Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5f63820
Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch
cmichelenstrofer Apr 1, 2024
dfd63ab
Update RELEASING.md to reflect new workflow with the `dev` branch
cmichelenstrofer Apr 1, 2024
51d85a9
update docstrings (#326)
rgcoe Apr 2, 2024
44cb872
damping naming and consistently change radiation damping (#328)
cmichelenstrofer Apr 2, 2024
7fc6902
actually test power solution for irregular wave (#327)
rgcoe Apr 3, 2024
7f03d9b
issue 321 fd_to_td() bug (#329)
dtgaebe Apr 3, 2024
92d5710
nodf -> ndof (#334)
rgcoe Apr 3, 2024
a5920e8
add DOI for Daniel's paper (#336)
rgcoe Apr 3, 2024
35ad528
Lower tolerance for new test to fix CI failing occasionally
michaelcdevin May 7, 2024
aa128ea
hyperlinks no longer have formatting, plus other small adjustments (#…
michaelcdevin May 8, 2024
d1e7af1
Merge to dev, not main (#349)
michaelcdevin May 9, 2024
dc69497
Dev version of documentation site (#347)
michaelcdevin May 15, 2024
a5c26dc
updated with new Capytaine docs URL
michaelcdevin May 15, 2024
0f2000c
Add warnings when adding inertia and hydrostatic stiffness automatica…
jtgrasb May 15, 2024
5988d9f
CI workflow cleanup (#352)
michaelcdevin Jun 13, 2024
ab6ad78
Specify NumPy version <2.0 since it breaks autograd
michaelcdevin Jun 21, 2024
0b93045
remove realization dimension if it exists (#365)
michaelcdevin Aug 2, 2024
9e55214
Update pyproject.toml
michaelcdevin Aug 2, 2024
362b78c
Pioneer tutorial updates (empirical impedance model and nonlinear spr…
jtgrasb Aug 13, 2024
fa0b584
Fix PTO force attribute and tutorial 1 constraint (#369)
jtgrasb Oct 8, 2024
0ed4704
Add debug option for building documentation locally (#374)
michaelcdevin Oct 10, 2024
2c3c9ab
Adding Pioneer journal paper to reference list (#372)
michaelcdevin Oct 11, 2024
8e7a325
Fix pioneer tutorial bug (define omega_data) (#379)
jtgrasb Oct 17, 2024
2c0ef7b
Fixing typo from #374 (#375)
michaelcdevin Oct 17, 2024
71c826a
Test capytaine lids (#363)
jtgrasb Oct 29, 2024
69b9c84
updated to allow NumPy v2.0+, updated a few functions that had been r…
michaelcdevin Jan 14, 2025
07b9666
Use Miniforge distribution in CI (#392)
michaelcdevin Jan 27, 2025
1bb535c
Merge branch 'dev' of https://github.com/jtgrasb/WecOptTool into pr/391
jtgrasb Jan 27, 2025
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
8 changes: 3 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
# - the content of pyproject.toml changes
# - you manually change the value of the CACHE_NUMBER below
# Else the existing cache is used.
- name: Setup Mambaforge
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: test-env
use-mamba: true
Expand All @@ -45,8 +45,6 @@ jobs:
shell: bash

# create a conda yaml file
# for some reason Windows installs capytaine 1.4 instead of latest.
# CHANGE: Capytaine version
- name: Create environment.yml file
run: |
echo "name: test-env" >> environment.yml;
Expand Down Expand Up @@ -139,4 +137,4 @@ jobs:
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
python3 docs/build_docs.py --build production
8 changes: 3 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
# - the content of pyproject.toml changes
# - you manually change the value of the CACHE_NUMBER below
# Else the existing cache is used.
- name: Setup Mambaforge
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: test-env
use-mamba: true
Expand All @@ -45,8 +45,6 @@ jobs:
shell: bash

# create a conda yaml file
# for some reason Windows installs capytaine 1.4 instead of latest.
# CHANGE: Capytaine version
- name: Create environment.yml file
run: |
echo "name: test-env" >> environment.yml;
Expand Down Expand Up @@ -138,7 +136,7 @@ jobs:
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
python3 docs/build_docs.py --build production

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
python3 docs/build_docs.py --build production

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
75 changes: 50 additions & 25 deletions docs/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import re
import yaml
import argparse

from sphinx.application import Sphinx

Expand All @@ -17,6 +18,10 @@
html_dir = os.path.join(build_dir, 'html')
doctree_dir = os.path.join(build_dir, 'doctrees')

parser = argparse.ArgumentParser()
parser.add_argument('-b', '--build', nargs=1, type=str,
choices=['debug', 'production'],
default='debug')

def linkcheck():
app = Sphinx(source_dir,
Expand Down Expand Up @@ -51,36 +56,56 @@ def cleanup():
f.write(data2)


def build_doc(version, tag, home_branch):
os.environ['current_version'] = version
subprocess.run(f'git checkout {tag}', shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, 'conf.py')}", shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(docs_dir, 'versions.yaml')}", shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, '_templates/versions.html')}", shell=True)
def build_doc(version, tag, home_branch, build):
if build != 'debug':
os.environ['current_version'] = version
subprocess.run(f'git checkout {tag}', shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, 'conf.py')}",
shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(docs_dir, 'versions.yaml')}",
shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, '_templates/versions.html')}",
shell=True)
source.make_theory_animations
linkcheck()
html()
cleanup()
subprocess.run(
f"git checkout {home_branch}", shell=True)
if build != 'debug':
subprocess.run(
f"git checkout {home_branch}", shell=True)


if __name__ == '__main__':
home_name = 'latest'
with open(os.path.join(docs_dir, 'versions.yaml'), 'r') as v_file:
versions = yaml.safe_load(v_file)
home_branch = versions[home_name]
build_doc(home_name, home_branch, home_branch)
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages')}...")
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages'))
def move_pages(dest_dir=None):
if dest_dir is None:
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages')}...")
shutil.copytree(
html_dir, os.path.join(docs_dir, 'pages'))
else:
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages', dest_dir)}...")
shutil.copytree(
html_dir, os.path.join(docs_dir, 'pages', dest_dir))
print('Done.')
for name, tag in versions.items():
if name != home_name:
build_doc(name, tag, home_branch)
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages', name)}...")
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages', name))
print('Done.')


if __name__ == '__main__':
args = parser.parse_args()
build = args.build
if build == 'debug':
print(f'Building docs in current branch...')
build_doc('latest', '', '', build)
move_pages()
else:
home_name = 'latest'
with open(os.path.join(docs_dir, 'versions.yaml'), 'r') as v_file:
versions = yaml.safe_load(v_file)
home_branch = versions[home_name]
build_doc(home_name, home_branch, home_branch, build)
move_pages()
for name, tag in versions.items():
if name != home_name:
build_doc(name, tag, home_branch, build)
move_pages(dest_dir=name)
shutil.rmtree(html_dir)
1 change: 1 addition & 0 deletions docs/source/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Bibliography
Grasberger:2023aa
Strofer:2023vw
Coe2020Initial
DEVIN2024119124
10 changes: 10 additions & 0 deletions docs/source/wecopttool_refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ @article{Bacelli2014Numerical
title = {Numerical optimal control of wave energy converters},
volume = {6},
year = {2014}}

@article{DEVIN2024119124,
title = {High-dimensional control co-design of a wave energy converter with a novel pitch resonator power takeoff system},
author = {Michael C. Devin and Daniel T. Gaebele and Carlos A. Michelén Ströfer and Jeff T. Grasberger and Jantzen Lee and Ryan G. Coe and Giorgio Bacelli},
journal = {Ocean Engineering},
volume = {312},
pages = {119124},
year = {2024},
issn = {0029-8018},
doi = {10.1016/j.oceaneng.2024.119124}}
Binary file modified examples/data/bem.nc
Binary file not shown.
Binary file added examples/data/pioneer_empirical_data.nc
Binary file not shown.
20 changes: 15 additions & 5 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 Expand Up @@ -359,7 +369,7 @@
"nsubsteps = 4\n",
"\n",
"def const_f_pto(wec, x_wec, x_opt, waves): # Format for scipy.optimize.minimize\n",
" f = pto.force_on_wec(wec, x_wec, x_opt, waves, nsubsteps)\n",
" f = pto.force(wec, x_wec, x_opt, waves, nsubsteps)\n",
" return f_max - np.abs(f.flatten())\n",
"\n",
"ineq_cons = {'type': 'ineq',\n",
Expand Down Expand Up @@ -974,7 +984,7 @@
" f_max = 750.0\n",
"\n",
" def const_f_pto(wec, x_wec, x_opt, waves):\n",
" f = pto.force_on_wec(wec, x_wec, x_opt, waves, nsubsteps)\n",
" f = pto.force(wec, x_wec, x_opt, waves, nsubsteps)\n",
" return f_max - np.abs(f.flatten())\n",
"\n",
" ineq_cons = {'type': 'ineq', 'fun': const_f_pto}\n",
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
Loading
Loading