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

Test capytaine lids #363

Open
wants to merge 39 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9e35f0a
Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch
cmichelenstrofer Apr 1, 2024
db731fe
Update RELEASING.md to reflect new workflow with the `dev` branch
cmichelenstrofer Apr 1, 2024
eed5f7d
Set Default uniform_shift to False (#313)
jtgrasb Apr 1, 2024
b466e6f
update docstrings (#326)
ryancoe Apr 2, 2024
d4f9fc7
damping naming and consistently change radiation damping (#328)
cmichelenstrofer Apr 2, 2024
b4d802f
run CI + codeQL on dev PRs/pushses
ryancoe Apr 2, 2024
775d273
Fix test failures (#330)
jtgrasb Apr 3, 2024
a7bef5f
actually test power solution for irregular wave (#327)
ryancoe Apr 3, 2024
83de96f
Update test_integration with new scaling (#333)
jtgrasb Apr 3, 2024
2abb4fb
Phase Realizations Demo and Docs (#315)
jtgrasb Apr 3, 2024
6fdd660
issue 321 fd_to_td() bug (#329)
dtgaebe Apr 3, 2024
c6f858a
nodf -> ndof (#334)
ryancoe Apr 3, 2024
0b6cd08
add DOI for Daniel's paper (#336)
ryancoe Apr 3, 2024
ea039c5
Tutorial cleanup (#339)
michaelcdevin Apr 23, 2024
b8506d8
Utils dev - replaces old utilities PR (#343)
dtgaebe May 2, 2024
9f2e6ba
Post process docstrings; use loops for multiple realizations (#337)
ryancoe May 3, 2024
98a1feb
v3.0.0
michaelcdevin May 6, 2024
bc38e2e
Lower tolerance for new test to fix CI failing occasionally
michaelcdevin May 7, 2024
ecd7727
hyperlinks no longer have formatting, plus other small adjustments (#…
michaelcdevin May 8, 2024
4792bea
Merge to dev, not main (#349)
michaelcdevin May 9, 2024
ca15bd9
Dev version of documentation site (#347)
michaelcdevin May 15, 2024
d9f8907
updated with new Capytaine docs URL
michaelcdevin May 15, 2024
c218780
Add warnings when adding inertia and hydrostatic stiffness automatica…
jtgrasb May 15, 2024
de6e448
CI workflow cleanup (#352)
michaelcdevin Jun 13, 2024
a8485d2
Merge remote-tracking branch 'origin' into dev
michaelcdevin Jun 21, 2024
902c17b
Specify NumPy version <2.0 since it breaks autograd
michaelcdevin Jun 21, 2024
f79ff8b
v3.0.1 (#360)
cmichelenstrofer Jul 11, 2024
f316682
Revert "v3.0.1 (#360)" (#361)
cmichelenstrofer Jul 11, 2024
39c20ef
Update pyproject.toml
cmichelenstrofer Jul 11, 2024
e020dff
Test out lid feature
jtgrasb Jul 31, 2024
764b0c0
Add lid to pioneer and remove extra files
jtgrasb Aug 1, 2024
961f7dd
Revert LUPA and add lid comment
jtgrasb Aug 1, 2024
1125740
Revert LUPA bem data
jtgrasb Aug 1, 2024
71da814
Fix pioneer
jtgrasb Aug 1, 2024
31e755b
Merge branch 'dev' of https://github.com/sandialabs/WecOptTool into t…
jtgrasb Aug 20, 2024
486ef4e
Test lid LUPA
jtgrasb Aug 20, 2024
53da35a
Update LUPA with lid
jtgrasb Aug 20, 2024
7df0b70
LUPA lid
jtgrasb Aug 20, 2024
8be17ab
Revert LUPA unnecessary changes
jtgrasb Aug 20, 2024
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
Binary file modified examples/data/bem.nc
Binary file not shown.
16 changes: 13 additions & 3 deletions examples/tutorial_1_WaveBot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"source": [
"import autograd.numpy as np\n",
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import matplotlib.pyplot as plt\n",
"from scipy.optimize import brute\n",
"\n",
Expand Down Expand Up @@ -135,7 +136,11 @@
"#### WEC geometry mesh\n",
"Now we will create a surface mesh for the WEC hull and store it using the `FloatingBody` object from Capytaine.\n",
"The WaveBot mesh is pre-defined in the `wecopttool.geom` module, so we will call it directly from there.\n",
"Note that the Capytaine `from_meshio` method can also import from other file types (STL, VTK, MSH, etc.), click [here](https://pypi.org/project/meshio/) for the full list of compatible mesh file types."
"Note that the Capytaine `from_meshio` method can also import from other file types (STL, VTK, MSH, etc.), click [here](https://pypi.org/project/meshio/) for the full list of compatible mesh file types.\n",
"\n",
"We also apply an internal lid which helps eliminate irregular frequency spikes. \n",
"The lid position was chosen by iterating through a series of mesh size factors and lid positions to move the frequency spikes above the range of interest. \n",
"See the `capytaine` documentation [here](https://capytaine.github.io/stable/index.html#) for more details. "
]
},
{
Expand All @@ -145,9 +150,14 @@
"outputs": [],
"source": [
"wb = wot.geom.WaveBot() # use standard dimensions\n",
"mesh_size_factor = 0.5 # 1.0 for default, smaller to refine mesh\n",
"mesh_size_factor = 0.2 # 1.0 for default, smaller to refine mesh\n",
"mesh = wb.mesh(mesh_size_factor)\n",
"fb = cpy.FloatingBody.from_meshio(mesh, name=\"WaveBot\")"
"\n",
"# create mesh object for WaveBot and add internal lid\n",
"mesh_obj = load_from_meshio(mesh, 'WaveBot')\n",
"lid_mesh = mesh_obj.generate_lid(-2e-2)\n",
"\n",
"fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"WaveBot\")"
]
},
{
Expand Down
9 changes: 7 additions & 2 deletions examples/tutorial_2_AquaHarmonics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"outputs": [],
"source": [
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import autograd.numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import cm\n",
Expand Down Expand Up @@ -68,6 +69,7 @@
"metadata": {},
"source": [
"Next we create a `FloatingBody` object from the mesh in Capytaine, which we will use to calculate the hydrodynamics.\n",
"Again, we add a lid mesh to remove irregular frequency spikes.\n",
"We can visualize a 3D rendering of the mesh now as well."
]
},
Expand All @@ -77,7 +79,10 @@
"metadata": {},
"outputs": [],
"source": [
"fb = cpy.FloatingBody.from_meshio(mesh, name=\"AquaHarmonics\")\n",
"mesh_obj = load_from_meshio(mesh, 'WaveBot')\n",
"lid_mesh = mesh_obj.generate_lid(-5e-2)\n",
"\n",
"fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"AquaHarmonics\")\n",
"fb.add_translation_dof(name=\"Heave\")\n",
"ndof = fb.nb_dofs\n",
"fb.show_matplotlib()"
Expand Down Expand Up @@ -125,7 +130,7 @@
"outputs": [],
"source": [
"amplitude = 0.5\n",
"wavefreq = 0.24/2 \n",
"wavefreq = 0.24/2 \n",
"phase = 30\n",
"wavedir = 0\n",
"\n",
Expand Down
33 changes: 20 additions & 13 deletions examples/tutorial_3_LUPA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
"\n",
"import gmsh, pygmsh\n",
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import autograd.numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"from scipy.optimize import brute\n",
"\n",
"\n",
"import wecopttool as wot\n",
"\n",
"## set colorblind-friendly colormap for plots\n",
Expand Down Expand Up @@ -103,9 +105,10 @@
"Here we create the mesh based on the dimensions provided by Oregon State University using `pygmsh`, available [here](https://pypi.org/project/pygmsh/).\n",
"This is the same package used by `geom.py` (click [here](https://sandialabs.github.io/WecOptTool/api_docs/wecopttool.geom.html) for API documentation) containing the predefined WaveBot and AquaHarmonics meshes used in the previous tutorials.\n",
"\n",
"The float has a hole where the spar passes through it, though OSU has found that this hole creates a large spike in the BEM results at about 4.5 rad/s.\n",
"There is not much energy in the waves at this frequency in the wave spectrum we will be using, so this spike should not significantly affect our results.\n",
"If you would like to remove this spike and create smoother BEM results, set `hole = False` in the cell below."
"The float has a hole where the spar passes through it. \n",
"In previous versions of this tutorial, the hole was larger than the spar and led to a large spike in the BEM results. \n",
"The spike has been resolved by making the hole smaller so that the float is flush with the spar.\n",
"Like the other tutorials, a lid is added to remove any irregular frequency spikes. "
]
},
{
Expand All @@ -121,20 +124,16 @@
"h1 = 0.5 \n",
"h2 = 0.21\n",
"freeboard = 0.3\n",
"r3 = 0.10/2 + 0.05 # hole radius\n",
"hole = True # set to False to remove spike in BEM results\n",
"r3 = 0.05 # hole radius\n",
"with pygmsh.occ.Geometry() as geom:\n",
" gmsh.option.setNumber('Mesh.MeshSizeFactor', mesh_size_factor)\n",
" cyl = geom.add_cylinder([0, 0, 0], [0, 0, -h1], r1)\n",
" cone = geom.add_cone([0, 0, -h1], [0, 0, -h2], r1, r2)\n",
" geom.translate(cyl, [0, 0, freeboard])\n",
" geom.translate(cone, [0, 0, freeboard]) \n",
" if hole:\n",
" tmp = geom.boolean_union([cyl, cone])\n",
" bar = geom.add_cylinder([0, 0, 10], [0,0,-20], r3)\n",
" geom.boolean_difference(tmp, bar)\n",
" else:\n",
" geom.boolean_union([cyl, cone])\n",
" tmp = geom.boolean_union([cyl, cone])\n",
" bar = geom.add_cylinder([0, 0, 10], [0,0,-20], r3)\n",
" geom.boolean_difference(tmp, bar)\n",
" mesh_float = geom.generate_mesh()"
]
},
Expand All @@ -152,8 +151,12 @@
"metadata": {},
"outputs": [],
"source": [
"# lid\n",
"mesh_obj = load_from_meshio(mesh_float, 'float')\n",
"lid_mesh = mesh_obj.generate_lid(z=-1e-2)\n",
"\n",
"# floating body\n",
"float_fb = cpy.FloatingBody.from_meshio(mesh_float, name='float')\n",
"float_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"float\")\n",
"float_fb.add_translation_dof(name='Heave')"
]
},
Expand Down Expand Up @@ -221,8 +224,12 @@
"metadata": {},
"outputs": [],
"source": [
"# lid\n",
"mesh_obj = load_from_meshio(mesh_spar, 'float')\n",
"lid_mesh = mesh_obj.generate_lid(z=-1e-2)\n",
"\n",
"# floating body\n",
"spar_fb = cpy.FloatingBody.from_meshio(mesh_spar, name='spar')\n",
"spar_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"spar\")\n",
"spar_fb.add_translation_dof(name='Heave')"
]
},
Expand Down
8 changes: 6 additions & 2 deletions examples/tutorial_4_Pioneer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"outputs": [],
"source": [
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import autograd.numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.linalg import block_diag\n",
Expand Down Expand Up @@ -148,7 +149,7 @@
" h2=17.321 * in2m,\n",
" scale_factor=1,\n",
" freeboard=freeboard)\n",
"mesh = hull_geom.mesh(mesh_size_factor=0.5)\n",
"mesh = hull_geom.mesh(mesh_size_factor=0.3)\n",
"_ = hull_geom.plot_cross_section()"
]
},
Expand Down Expand Up @@ -253,7 +254,10 @@
"metadata": {},
"outputs": [],
"source": [
"pnr_fb = cpy.FloatingBody.from_meshio(mesh, name=\"Pioneer\")\n",
"mesh_obj = load_from_meshio(mesh, 'Pioneer')\n",
"lid_mesh = mesh_obj.generate_lid(-4e-2)\n",
"\n",
"pnr_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"WaveBot\")\n",
"pnr_fb.add_rotation_dof(name='Pitch')\n",
"pnr_fb.center_of_mass = np.array([0., 0., buoy_props['CG']])\n",
"pnr_fb.rotation_center = pnr_fb.center_of_mass\n",
Expand Down
Loading