Skip to content

Commit

Permalink
Test capytaine lids (#363)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
7 people authored Oct 29, 2024
1 parent 2c0ef7b commit 71c826a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
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",
"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",
"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
32 changes: 19 additions & 13 deletions examples/tutorial_3_LUPA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"\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",
Expand Down Expand Up @@ -103,9 +104,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 +123,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 +150,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 +223,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

0 comments on commit 71c826a

Please sign in to comment.