Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: rename BEM.jl to MarineHydro.jl everywhere." #5

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "MarineHydro"
name = "BEM"
uuid = "8d7a907f-d253-4c14-a318-41dd3f310a02"
authors = ["KapilKhanal <[email protected]>"]
version = "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Fully-differentiable boundary element solver for marine hydrodynamics. This new
Includes plots and data generated for the paper.

- **📜 src**
Source code files for the `MarineHydro.jl` package, including the main functionality.
Source code files for the `BEM.jl` package, including the main functionality.

- **🧪 test**
Contains test files and resources to verify the functionality of the source code.
Expand Down Expand Up @@ -74,10 +74,10 @@ Fully-differentiable boundary element solver for marine hydrodynamics. This new
ENV["PYTHON"] = "/path/to/capytaine_env/bin/python" # run 'which python' in your terminal for this
```

6. **Using the MarineHydro Module**
6. **Using the BEM Module**
Load the module in your Julia session:
```julia
using MarineHydro
using BEM
using PyCall
# import your capytaine mesh
cpt = pyimport("capytaine")
Expand Down
6 changes: 3 additions & 3 deletions paper/ArraySensitivities.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Plots
using CSV
using DataFrames
using MarineHydro
using BEM
include("/home/cornell/BEMJulia/BEM.jl/paper/meshGradients_pair.jl")
#takes a while depending on this - some faces_max_radius gives weird answer
#check meshes.jl to change faces_max_radius.
Expand All @@ -23,7 +23,7 @@ function added_mass_off_diagonal(radius,omega ,dx1)
sphere_2_heave_normal = [element_is_in_sphere_2(j) ? mesh.normals[j,:]' * [0.0, 0.0, 1.0] : 0.0 for j in 1:total_nfaces]
k = omega^2 / 9.81 # Wave number
S, D = assemble_matrices((Rankine(), RankineReflected(), GFWu()), mesh, k)
potential = MarineHydro.solve(D, S, -1im * omega * sphere_1_heave_normal)
potential = BEM.solve(D, S, -1im * omega * sphere_1_heave_normal)
pressure = 1im * 1000 * omega * potential
# force = -sum(pressure .* sphere_2_heave_normal .* mesh.areas)
# A12 = real(force) / omega^2
Expand All @@ -41,7 +41,7 @@ function damping_off_diagonal(radius,omega ,dx1)
sphere_2_heave_normal = [element_is_in_sphere_2(j) ? mesh.normals[j,:]' * [0.0, 0.0, 1.0] : 0.0 for j in 1:total_nfaces]
k = omega^2 / 9.81 # Wave number
S, D = assemble_matrices((Rankine(), RankineReflected(), GFWu()), mesh, k) # Assemble matrices tuple error -- use default
potential = MarineHydro.solve(D, S, -1im * omega * sphere_1_heave_normal)
potential = BEM.solve(D, S, -1im * omega * sphere_1_heave_normal)
pressure = 1im * 1000 * omega * potential
force = -sum(pressure .* sphere_1_heave_normal .* mesh.areas)
B11 = imag(force) / omega
Expand Down
2 changes: 1 addition & 1 deletion paper/CoeficientsGradients.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using Zygote
using FiniteDifferences
using Test
Expand Down
4 changes: 2 additions & 2 deletions paper/ComparisonPlots.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## COEFFICIENTS CHECKS - DO NOT DELETE even if commented out; MAKE TEST
using LinearAlgebra,Statistics,Plots
using MarineHydro
using BEM
using ColorTypes
include("MeshGradients_singlebody.jl")
include("HulmeData.jl")
Expand Down Expand Up @@ -184,4 +184,4 @@ _grad_fine = [6552.7934287808785, 26211.17371512438, 58975.14085905893, 104844.
#plot(radii, _grad_coarse, xlabel="r [m]", ylabel="∂A_∂ω", label="AD (coarse mesh)",marker = "*")
plot(radii, _gradients , xlabel="r [m]", ylabel="∂A_∂r", label="AD",marker = "*",color = vermillion)
plot!(radii,analy_grady , xlabel="r [m]", label="analytical",marker = "*" , color = bluishgreen)
savefig("/home/cornell/BEMJulia/MarineHydro.jl/paper/Plots/analy_ad_AMass_surge.pdf")
savefig("/home/cornell/BEMJulia/MarineHydro.jl/paper/Plots/analy_ad_AMass_surge.pdf")
6 changes: 3 additions & 3 deletions paper/DelhommeauVsWu.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PyCall, MarineHydro, Zygote, Plots, ColorTypes
using PyCall, BEM, Zygote, Plots, ColorTypes

orange = RGB(230/255,159/255,0/255)
vermillion = RGB(213/255, 94/255, 0/255)
Expand Down Expand Up @@ -63,12 +63,12 @@ xlabel!("k")
ylabel!("Gradient")
title!("Comparison of Gradients: Wu vs Delhommeau")
legend()
savefig("/home/cornell/BEMJulia/MarineHydro.jl/paper/Plots/added_mass_del_wu.pdf")
savefig("/home/cornell/BEMJulia/BEM.jl/paper/Plots/added_mass_del_wu.pdf")

plot(k_range, A_w_gradwu, label="A_w_gradwu", lw=2, linestyle=:dash, color=vermillion)
plot!(k_range, A_w_graddel, label="A_w_graddel", lw=2, linestyle=:solid, color=bluishgreen)
xlabel!("k")
ylabel!("Gradient")
title!("Comparison of Gradients: Wu vs Delhommeau")
legend()
savefig("/home/cornell/BEMJulia/MarineHydro.jl/paper/Plots/gradw_added_mass_del_wu.pdf")
savefig("/home/cornell/BEMJulia/BEM.jl/paper/Plots/gradw_added_mass_del_wu.pdf")
2 changes: 1 addition & 1 deletion paper/HydrostaticsRule.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Zygote
using ChainRulesCore
using MarineHydro
using BEM
cpt = pyimport("capytaine")

∂J_r_fd_hs(f,r; h=1e-5) = (f(r+h) .- f(r-h)) ./ (2*h)
Expand Down
6 changes: 3 additions & 3 deletions paper/Multibody.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using PyCall
using LinearAlgebra

Expand Down Expand Up @@ -33,7 +33,7 @@ Am = zeros((2, 2))
Bm = zeros((2, 2))

# radiation of first sphere
potential = MarineHydro.solve(D, S, -1im * omega * sphere_1_heave_normal)
potential = BEM.solve(D, S, -1im * omega * sphere_1_heave_normal)
pressure = 1im * 1000 * omega * potential
force_on_sphere_1 = -sum(pressure .* sphere_1_heave_normal .* mesh.areas)
A11 = real(force_on_sphere_1)/omega^2
Expand All @@ -44,7 +44,7 @@ B12 = imag(force_on_sphere_2)/omega
Am = [A11 A12; A12 A11]
Bm = [B11 B12; B12 B11]
# # radiation of second sphere (very symmetric here, but that is just for demonstration)
# potential = MarineHydro.solve(D, S, -1im * omega * sphere_2_heave_normal)
# potential = BEM.solve(D, S, -1im * omega * sphere_2_heave_normal)
# pressure = 1im * 1000 * omega * potential
# force_on_sphere_1 = -sum(pressure .* sphere_1_heave_normal .* mesh.areas)
# Am[2, 1] = real(force_on_sphere_1)/omega^2
Expand Down
4 changes: 2 additions & 2 deletions paper/Power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using ForwardDiff
using Zygote, ChainRulesCore
ForwardDiff.can_dual(::Type{Any}) = true
using LinearAlgebra
using MarineHydro
using BEM
using ImplicitAD
include("/home/cornell/BEMJulia/MarineHydro.jl/paper/meshGradients_pair.jl")
include("/home/cornell/BEMJulia/MarineHydro.jl/paper/HydrostaticsRule.jl")
Expand Down Expand Up @@ -38,7 +38,7 @@ function power(r1,dx1)
# sphere_2_center = hcat(sphere_2_center'...)

# radiation of first sphere
potential = MarineHydro.solve(D, S, -1im * omega * sphere_1_heave_normal)
potential = BEM.solve(D, S, -1im * omega * sphere_1_heave_normal)
pressure = 1im * 1000 * omega * potential
force_on_sphere_1 = -sum(pressure .* sphere_1_heave_normal .* mesh.areas)
A11 = real(force_on_sphere_1)/omega^2
Expand Down
2 changes: 1 addition & 1 deletion paper/direct_vs_indirect.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using Zygote
using FiniteDifferences
using Test
Expand Down
2 changes: 1 addition & 1 deletion paper/meshGradients_pair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function ChainRulesCore.rrule(::typeof(sphere_faces), r,dx1)
return Mesh(vertices,faces,centers,normals,areas,radii,nvertices,nfaces) #
end

using MarineHydro
using BEM
#test differentiability
function func(r1,dx1)
mesh = differentiableMeshPairs(r1,dx1)
Expand Down
16 changes: 8 additions & 8 deletions paper/profileBEM.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using BenchmarkTools
include("BemProgram.jl")
include("MeshGradients_singlebody.jl")
Expand All @@ -24,21 +24,21 @@ element_2 = (

function integral_and_gradient(GF, element_1, element_2, wavenumber=nothing)
return (
MarineHydro.integral(GF, element_1, element_2, wavenumber),
MarineHydro.integral_gradient(GF, element_1, element_2, wavenumber)
BEM.integral(GF, element_1, element_2, wavenumber),
BEM.integral_gradient(GF, element_1, element_2, wavenumber)
)
end
omega = 1.03

println("Rankine")
@btime MarineHydro.integral($(Rankine()), $element_1, $element_2)
@btime MarineHydro.integral_gradient($(Rankine()), $element_1, $element_2)
@btime BEM.integral($(Rankine()), $element_1, $element_2)
@btime BEM.integral_gradient($(Rankine()), $element_1, $element_2)
@btime integral_and_gradient($(Rankine()), $element_1, $element_2)

wavenumber = 1.0
println("GFWu")
@btime MarineHydro.integral($(GFWu()), $element_1, $element_2, $wavenumber)
@btime MarineHydro.integral_gradient($(GFWu()), $element_1, $element_2, $wavenumber)
@btime BEM.integral($(GFWu()), $element_1, $element_2, $wavenumber)
@btime BEM.integral_gradient($(GFWu()), $element_1, $element_2, $wavenumber)
@btime integral_and_gradient($(GFWu()), $element_1, $element_2, $wavenumber)


Expand All @@ -52,4 +52,4 @@ B(radius) = damping_program(radius,omega,dof)
@show A(1.0)
@btime Zygote.gradient(A, 1.0)

nothing
nothing
2 changes: 1 addition & 1 deletion src/MarineHydro.jl → src/BEM.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module MarineHydro
module BEM

export greens, gradient_greens, integral, integral_gradient, solve,calculate_radiation_forces
export Mesh, element, integrate_pressure, DiffractionForce,assemble_matrix_wu
Expand Down
2 changes: 1 addition & 1 deletion test/analytical.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using Test
using PyCall

Expand Down
4 changes: 2 additions & 2 deletions test/benchmarks_test.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BenchmarkTools
using MarineHydro
using BEM
using PyCall
using Zygote

Expand All @@ -8,7 +8,7 @@ radius = 1.0
resolution = (6, 6) #smaller data just to test
cptmesh = cpt.mesh_sphere(name="sphere", radius=radius, center=(0, 0, 0), resolution=resolution)
cptmesh.keep_immersed_part(inplace=true)
mesh = MarineHydro.Mesh(cptmesh)
mesh = BEM.Mesh(cptmesh)
npanels = mesh.nfaces
println( "Mesh information $resolution with panels $npanels")
omega = 1.12
Expand Down
2 changes: 1 addition & 1 deletion test/coeff_gradient_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Test
using Zygote
using MarineHydro
using BEM
using PyCall
using LinearAlgebra
using ImplicitAD
Expand Down
2 changes: 1 addition & 1 deletion test/differentiability_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Test
using Zygote
using MarineHydro
using BEM
using PyCall
using LinearAlgebra
using ImplicitAD
Expand Down
6 changes: 3 additions & 3 deletions test/green_function.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Test
using MarineHydro
using BEM

@testset "Green function" begin

Expand Down Expand Up @@ -31,7 +31,7 @@ using MarineHydro
end

@testset "Alternative definitions of the reflected Rankine" begin
import MarineHydro.free_surface_symmetry
import BEM.free_surface_symmetry

@test greens(Rankine(), free_surface_symmetry(e1), e2) ≈ greens(Rankine(), e1, free_surface_symmetry(e2))
@test gradient_greens(Rankine(), free_surface_symmetry(e1), e2, with_respect_to_first_variable=true) ≈ vertical_reflection(gradient_greens(Rankine(), e1, free_surface_symmetry(e2), with_respect_to_first_variable=true))
Expand All @@ -54,7 +54,7 @@ using MarineHydro

@testset "Guével-Delhommeau" begin

import MarineHydro._dimless_wave_term, MarineHydro._d_dimless_wave_term_dr
import BEM._dimless_wave_term, BEM._d_dimless_wave_term_dr
# From cpt.Delhommeau().fortran_core.delhommeau_integrals.numerical_integration(1.0, -1.0, 1000)
capy_ref = [-1.84003542, 1.76871985, -0.59117747, -1.01715699]
@test _dimless_wave_term(1.0, -1.0) ≈ capy_ref[1] + im*capy_ref[2] atol=1e-4
Expand Down
2 changes: 1 addition & 1 deletion test/with_capytaine.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MarineHydro
using BEM
using Test
using PyCall

Expand Down
Loading