Skip to content

Commit 71c826a

Browse files
jtgrasbcmichelenstroferrgcoedtgaebemichaelcdevin
authored
Test capytaine lids (#363)
* Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch * Update RELEASING.md to reflect new workflow with the `dev` branch * Set Default uniform_shift to False (#313) * Make uniform shift default false and fix test_core * Allow for non-uniform shift for impedance * update docstrings (#326) * damping naming and consistently change radiation damping (#328) * run CI + codeQL on dev PRs/pushses * Fix test failures (#330) * fix tests * fix pioneer * actually test power solution for irregular wave (#327) * Update test_integration with new scaling (#333) * Phase Realizations Demo and Docs (#315) * Pioneer tutorial realizations demo Add frequency array and realization study to beginning of pioneer tutorial * Update pioneer * Clean pioneer and update docs * remove print * Units * Update pioneer plots * Waves before frequencies * Explain less frequencies * Minor updates * Update pioneer * Merge branch 'dev' of https://github.com/sandialabs/WecOptTool into phases_demo * issue 321 fd_to_td() bug (#329) * bug bix : DC and Nyquist frequency should not be devided by two before ifft * Changed td_to_fd to scale single sided frequency components rather than TD signal * minor bug fix from issue332 #332 * nodf -> ndof (#334) * add DOI for Daniel's paper (#336) * Tutorial cleanup (#339) * run CI on PRs against dev branch * revamped tutorial 1, including fix for #293 * more tutorial cleanup and editorial changes * more cleanup and incorporated changes in #315 * fixed tutorial 2 colormaps * finishing touches * reverted a few accidental changes * fixes as per Jeff's review comments --------- Co-authored-by: Ryan Coe <[email protected]> * Utils dev - replaces old utilities PR (#343) * run CI on PRs against dev branch * coppied fundamental utility files * import utilities module * added utilities funtions to tut1 * added bem plot from utils * added bem plot from utils * updated sankey plot * updated check_radiation_damping * cleared outputs * corrected bug * changed Zi to hydro_impedance to be consistent with our variables name python convention * PR review edits * add grid to plots * removed draft functions in utilities.py * typo * Fixed one more typo I found while reviewing Daniel's changes --------- Co-authored-by: Ryan Coe <[email protected]> Co-authored-by: Michael Devin <[email protected]> * Post process docstrings; use loops for multiple realizations (#337) * post_processing docstrings - examples - parameters (order) * handle multiple phase realizations internally * Update wecopttool/core.py * making outputs lists * Update implementation to function with tutorial 1 for now * Update tutorials * Update LUPA * Make sure same WEC is passed in * Add test_utilities Revert "Add test_utilities" This reverts commit 27399f0. * Update utilities module * Update utilities * Update test_utilities * Update tutorial 1 utilities call --------- Co-authored-by: Carlos A. Michelén Ströfer <[email protected]> Co-authored-by: Carlos A. Michelén Ströfer <[email protected]> Co-authored-by: jtgrasb <[email protected]> Co-authored-by: jtgrasb <[email protected]> * v3.0.0 * Lower tolerance for new test to fix CI failing occasionally * hyperlinks no longer have formatting, plus other small adjustments (#348) * Merge to dev, not main (#349) * Dev version of documentation site (#347) * added initial file changes based on sphinx_multiversion docs and WEC-Sim implementation * removed sphinx-multiversion since it is no longer supported and made manual multiversion * now uses absolute paths, commented out linkcheck for debugging * fixed docstring errors in utilities module * updating files again that somehow got reverted * fixing path in conf.py * don't run tutorials (will revert later) * handle file moves correctly, fixed if statement to make other versions appear * fixed two bugs in versions template * reverted temp changes, changes latest to main * switched latest to main * main branch now in root directory of pages * fixed URLs with change from last commit * make other branches visible before building * switched main branch tag for more testing * fixed typo * switched dev branch to an existing branch * renamed main to latest, changed version.html file name to avoid confusion * added prints about moving files so Sphinx output isn't misleading * fixed typo with quotations * changed versions.html name back because that broke things I guess * modified contributing documentation to reflect changes * add logic to remove duplicate 'latest' branch * Fixed pathing when already on latest * remove typo * Troubleshooting complete, switching back to correct branches for deployment * Removed extra word in docstring * removed redundant function * fixed pathing so returns to same file (and fixes tutorial/API docs) * changed latest branch for demonstration * switched back latest branch for deployment * updated with new Capytaine docs URL * Add warnings when adding inertia and hydrostatic stiffness automatically (#346) * CI workflow cleanup (#352) * removed conda environment from workflows since newer capytaine/wavespectra work with Windows * fixed unnecessary capitalization * still create CI conda environment to fix Mac environment failures * added conda env fully back in, push workflow deploys docs, split PR workflow * conda environment activates again * mambaforge instead of miniforge * manual cache reset * reset to older version of setup-miniconda to troubleshoot * Specify NumPy version <2.0 since it breaks autograd * v3.0.1 (#360) * Revert "v3.0.1 (#360)" (#361) This reverts commit f79ff8b. * Update pyproject.toml * Test out lid feature * Add lid to pioneer and remove extra files * Revert LUPA and add lid comment * Revert LUPA bem data * Fix pioneer * Test lid LUPA * Update LUPA with lid * LUPA lid * Revert LUPA unnecessary changes * Resolve Daniel's suggestions --------- Co-authored-by: Carlos A. Michelén Ströfer <[email protected]> Co-authored-by: Ryan Coe <[email protected]> Co-authored-by: Daniel Gaebele <[email protected]> Co-authored-by: Michael Devin <[email protected]> Co-authored-by: Carlos A. Michelén Ströfer <[email protected]> Co-authored-by: mcdevin <[email protected]>
1 parent 2c0ef7b commit 71c826a

File tree

5 files changed

+45
-20
lines changed

5 files changed

+45
-20
lines changed

examples/data/bem.nc

5.02 KB
Binary file not shown.

examples/tutorial_1_WaveBot.ipynb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"source": [
3333
"import autograd.numpy as np\n",
3434
"import capytaine as cpy\n",
35+
"from capytaine.io.meshio import load_from_meshio\n",
3536
"import matplotlib.pyplot as plt\n",
3637
"from scipy.optimize import brute\n",
3738
"\n",
@@ -135,7 +136,11 @@
135136
"#### WEC geometry mesh\n",
136137
"Now we will create a surface mesh for the WEC hull and store it using the `FloatingBody` object from Capytaine.\n",
137138
"The WaveBot mesh is pre-defined in the `wecopttool.geom` module, so we will call it directly from there.\n",
138-
"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."
139+
"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",
140+
"\n",
141+
"We also apply an internal lid which helps eliminate irregular frequency spikes. \n",
142+
"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",
143+
"See the `capytaine` documentation [here](https://capytaine.github.io/stable/index.html#) for more details. "
139144
]
140145
},
141146
{
@@ -145,9 +150,14 @@
145150
"outputs": [],
146151
"source": [
147152
"wb = wot.geom.WaveBot() # use standard dimensions\n",
148-
"mesh_size_factor = 0.5 # 1.0 for default, smaller to refine mesh\n",
153+
"mesh_size_factor = 0.2 # 1.0 for default, smaller to refine mesh\n",
149154
"mesh = wb.mesh(mesh_size_factor)\n",
150-
"fb = cpy.FloatingBody.from_meshio(mesh, name=\"WaveBot\")"
155+
"\n",
156+
"# create mesh object for WaveBot and add internal lid\n",
157+
"mesh_obj = load_from_meshio(mesh, 'WaveBot')\n",
158+
"lid_mesh = mesh_obj.generate_lid(-2e-2)\n",
159+
"\n",
160+
"fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"WaveBot\")"
151161
]
152162
},
153163
{

examples/tutorial_2_AquaHarmonics.ipynb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"outputs": [],
2424
"source": [
2525
"import capytaine as cpy\n",
26+
"from capytaine.io.meshio import load_from_meshio\n",
2627
"import autograd.numpy as np\n",
2728
"import matplotlib.pyplot as plt\n",
2829
"from matplotlib import cm\n",
@@ -68,6 +69,7 @@
6869
"metadata": {},
6970
"source": [
7071
"Next we create a `FloatingBody` object from the mesh in Capytaine, which we will use to calculate the hydrodynamics.\n",
72+
"We add a lid mesh to remove irregular frequency spikes, similar to [Tutorial 1](https://github.com/sandialabs/WecOptTool/blob/main/examples/tutorial_1_WaveBot.ipynb).\n",
7173
"We can visualize a 3D rendering of the mesh now as well."
7274
]
7375
},
@@ -77,7 +79,10 @@
7779
"metadata": {},
7880
"outputs": [],
7981
"source": [
80-
"fb = cpy.FloatingBody.from_meshio(mesh, name=\"AquaHarmonics\")\n",
82+
"mesh_obj = load_from_meshio(mesh, 'WaveBot')\n",
83+
"lid_mesh = mesh_obj.generate_lid(-5e-2)\n",
84+
"\n",
85+
"fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"AquaHarmonics\")\n",
8186
"fb.add_translation_dof(name=\"Heave\")\n",
8287
"ndof = fb.nb_dofs\n",
8388
"fb.show_matplotlib()"
@@ -125,7 +130,7 @@
125130
"outputs": [],
126131
"source": [
127132
"amplitude = 0.5\n",
128-
"wavefreq = 0.24/2 \n",
133+
"wavefreq = 0.24/2 \n",
129134
"phase = 30\n",
130135
"wavedir = 0\n",
131136
"\n",

examples/tutorial_3_LUPA.ipynb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"\n",
4040
"import gmsh, pygmsh\n",
4141
"import capytaine as cpy\n",
42+
"from capytaine.io.meshio import load_from_meshio\n",
4243
"import autograd.numpy as np\n",
4344
"import matplotlib.pyplot as plt\n",
4445
"import xarray as xr\n",
@@ -103,9 +104,10 @@
103104
"Here we create the mesh based on the dimensions provided by Oregon State University using `pygmsh`, available [here](https://pypi.org/project/pygmsh/).\n",
104105
"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",
105106
"\n",
106-
"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",
107-
"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",
108-
"If you would like to remove this spike and create smoother BEM results, set `hole = False` in the cell below."
107+
"The float has a hole where the spar passes through it. \n",
108+
"In previous versions of this tutorial, the hole was larger than the spar and led to a large spike in the BEM results. \n",
109+
"The spike has been resolved by making the hole smaller so that the float is flush with the spar.\n",
110+
"Like the other tutorials, a lid is added to remove any irregular frequency spikes. "
109111
]
110112
},
111113
{
@@ -121,20 +123,16 @@
121123
"h1 = 0.5 \n",
122124
"h2 = 0.21\n",
123125
"freeboard = 0.3\n",
124-
"r3 = 0.10/2 + 0.05 # hole radius\n",
125-
"hole = True # set to False to remove spike in BEM results\n",
126+
"r3 = 0.05 # hole radius\n",
126127
"with pygmsh.occ.Geometry() as geom:\n",
127128
" gmsh.option.setNumber('Mesh.MeshSizeFactor', mesh_size_factor)\n",
128129
" cyl = geom.add_cylinder([0, 0, 0], [0, 0, -h1], r1)\n",
129130
" cone = geom.add_cone([0, 0, -h1], [0, 0, -h2], r1, r2)\n",
130131
" geom.translate(cyl, [0, 0, freeboard])\n",
131132
" geom.translate(cone, [0, 0, freeboard]) \n",
132-
" if hole:\n",
133-
" tmp = geom.boolean_union([cyl, cone])\n",
134-
" bar = geom.add_cylinder([0, 0, 10], [0,0,-20], r3)\n",
135-
" geom.boolean_difference(tmp, bar)\n",
136-
" else:\n",
137-
" geom.boolean_union([cyl, cone])\n",
133+
" tmp = geom.boolean_union([cyl, cone])\n",
134+
" bar = geom.add_cylinder([0, 0, 10], [0,0,-20], r3)\n",
135+
" geom.boolean_difference(tmp, bar)\n",
138136
" mesh_float = geom.generate_mesh()"
139137
]
140138
},
@@ -152,8 +150,12 @@
152150
"metadata": {},
153151
"outputs": [],
154152
"source": [
153+
"# lid\n",
154+
"mesh_obj = load_from_meshio(mesh_float, 'float')\n",
155+
"lid_mesh = mesh_obj.generate_lid(z=-1e-2)\n",
156+
"\n",
155157
"# floating body\n",
156-
"float_fb = cpy.FloatingBody.from_meshio(mesh_float, name='float')\n",
158+
"float_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"float\")\n",
157159
"float_fb.add_translation_dof(name='Heave')"
158160
]
159161
},
@@ -221,8 +223,12 @@
221223
"metadata": {},
222224
"outputs": [],
223225
"source": [
226+
"# lid\n",
227+
"mesh_obj = load_from_meshio(mesh_spar, 'float')\n",
228+
"lid_mesh = mesh_obj.generate_lid(z=-1e-2)\n",
229+
"\n",
224230
"# floating body\n",
225-
"spar_fb = cpy.FloatingBody.from_meshio(mesh_spar, name='spar')\n",
231+
"spar_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"spar\")\n",
226232
"spar_fb.add_translation_dof(name='Heave')"
227233
]
228234
},

examples/tutorial_4_Pioneer.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"outputs": [],
3636
"source": [
3737
"import capytaine as cpy\n",
38+
"from capytaine.io.meshio import load_from_meshio\n",
3839
"import autograd.numpy as np\n",
3940
"import matplotlib.pyplot as plt\n",
4041
"from scipy.linalg import block_diag\n",
@@ -148,7 +149,7 @@
148149
" h2=17.321 * in2m,\n",
149150
" scale_factor=1,\n",
150151
" freeboard=freeboard)\n",
151-
"mesh = hull_geom.mesh(mesh_size_factor=0.5)\n",
152+
"mesh = hull_geom.mesh(mesh_size_factor=0.3)\n",
152153
"_ = hull_geom.plot_cross_section()"
153154
]
154155
},
@@ -253,7 +254,10 @@
253254
"metadata": {},
254255
"outputs": [],
255256
"source": [
256-
"pnr_fb = cpy.FloatingBody.from_meshio(mesh, name=\"Pioneer\")\n",
257+
"mesh_obj = load_from_meshio(mesh, 'Pioneer')\n",
258+
"lid_mesh = mesh_obj.generate_lid(-4e-2)\n",
259+
"\n",
260+
"pnr_fb = cpy.FloatingBody(mesh=mesh_obj, lid_mesh=lid_mesh, name=\"WaveBot\")\n",
257261
"pnr_fb.add_rotation_dof(name='Pitch')\n",
258262
"pnr_fb.center_of_mass = np.array([0., 0., buoy_props['CG']])\n",
259263
"pnr_fb.rotation_center = pnr_fb.center_of_mass\n",

0 commit comments

Comments
 (0)