Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e15146e
Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch
cmichelenstrofer Apr 1, 2024
b5bddd6
Update RELEASING.md to reflect new workflow with the `dev` branch
cmichelenstrofer Apr 1, 2024
513ee2e
update docstrings (#326)
rgcoe Apr 2, 2024
ff2da60
damping naming and consistently change radiation damping (#328)
cmichelenstrofer Apr 2, 2024
615c091
issue 321 fd_to_td() bug (#329)
dtgaebe Apr 3, 2024
1fd12fa
nodf -> ndof (#334)
rgcoe Apr 3, 2024
84771f1
add DOI for Daniel's paper (#336)
rgcoe Apr 3, 2024
23a1f57
Lower tolerance for new test to fix CI failing occasionally
michaelcdevin May 7, 2024
ffeefbd
hyperlinks no longer have formatting, plus other small adjustments (#…
michaelcdevin May 8, 2024
6d2e5d0
Merge to dev, not main (#349)
michaelcdevin May 9, 2024
1f18073
Dev version of documentation site (#347)
michaelcdevin May 15, 2024
622b6d6
updated with new Capytaine docs URL
michaelcdevin May 15, 2024
16d95c8
Add warnings when adding inertia and hydrostatic stiffness automatica…
jtgrasb May 15, 2024
4100047
CI workflow cleanup (#352)
michaelcdevin Jun 13, 2024
474b63f
Updated workflows to newest Python version and changed references to …
michaelcdevin Jan 28, 2025
d5f8866
Revert to Python 3.12 (#394)
jtgrasb Jan 29, 2025
49c93e3
use dev for docs and restrict sphinx (#396)
jtgrasb Feb 20, 2025
4f30935
Remove Sphinx version requirement (#409)
jtgrasb Apr 16, 2025
f91b91e
v3.0.3
cmichelenstrofer Jun 18, 2025
c77911c
v3.1
cmichelenstrofer Jun 18, 2025
68c9a73
Trying to convert tutorial 1
jtgrasb Jul 31, 2025
14824f3
Convert to jax progress
jtgrasb Aug 11, 2025
27e7daa
post-processing
jtgrasb Aug 11, 2025
4fbbebc
clear outputs
jtgrasb Aug 11, 2025
ab42034
wavebot tutorial running
jtgrasb Aug 11, 2025
9ebf62a
wavebot tutorial running
jtgrasb Aug 11, 2025
43ead9c
Update to jax and numpy
jtgrasb Aug 20, 2025
0a7e2eb
Revert wavebot execution count
jtgrasb Aug 20, 2025
7ecc18d
update pyproject.toml
jtgrasb Aug 20, 2025
ea331ae
Merge branch 'dev' into jax_conversion
jtgrasb Aug 20, 2025
dfee887
Specify jax version for mac
jtgrasb Aug 20, 2025
50d4e2d
try jaxlib
jtgrasb Aug 20, 2025
a51e2f3
no jaxlib
jtgrasb Aug 20, 2025
d7143c3
add jax to environment manually
jtgrasb Sep 5, 2025
a30c1dd
add jaxlib to env
jtgrasb Sep 5, 2025
25f6eb1
ad jaxlib to pyproject
jtgrasb Sep 5, 2025
1ceebd7
install jax manually for macos
jtgrasb Sep 5, 2025
1da6b46
conda init
jtgrasb Sep 5, 2025
4658fb5
install jax and jaxlib on macos
jtgrasb Sep 5, 2025
a80fd73
try arm64
jtgrasb Sep 5, 2025
a477324
remove arm
jtgrasb Sep 5, 2025
2654c8c
make core optimization jittable
jtgrasb Sep 11, 2025
0cb3910
try pinning jax version
rgcoe Sep 29, 2025
8b9029e
revert previous
rgcoe Sep 29, 2025
f1e6e51
install entirely w. pip
rgcoe Sep 29, 2025
e69c59b
Add verbose outputs to testing
jtgrasb Oct 1, 2025
782f9c7
editable mode
jtgrasb Oct 2, 2025
3001c39
no mamba
jtgrasb Oct 2, 2025
3eba423
editable mode
jtgrasb Oct 2, 2025
4bc820e
update random inputs
jtgrasb Oct 9, 2025
f91425f
remove cache environment
jtgrasb Oct 14, 2025
aac9081
use pytest-cov
jtgrasb Oct 20, 2025
650b09c
remove cache clear
jtgrasb Oct 20, 2025
6275433
Fix push.yml
jtgrasb Oct 21, 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
45 changes: 3 additions & 42 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,13 @@ jobs:
# Checkout the WecOptTool repo
- uses: actions/checkout@v3

# Cache the conda environment >>>
# The cache key includes the OS, the date, the hash of the pyproject.toml file, and the cache number.
# A new cache is created if:
# - this is the first time today that this file is run (date changes)
# - the content of pyproject.toml changes
# - you manually change the value of the CACHE_NUMBER below
# Else the existing cache is used.
# Caching of environment has been removed for simplicity
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: test-env
use-mamba: true

# save the date to include in the cache key
- name: Get Date
id: get-date
run: echo "DATE=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_ENV
shell: bash

# create a conda yaml file
- name: Create environment.yml file
run: |
echo "name: test-env" >> environment.yml;
echo " " >> environment.yml
echo "dependencies:" >> environment.yml
echo " - python=${{ matrix.python-version }}" >> environment.yml
echo " - capytaine" >> environment.yml
echo " - wavespectra" >> environment.yml
cat environment.yml

# use the cache if it exists
- uses: actions/cache@v3
env:
CACHE_NUMBER: 0 # increase to reset cache manually
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.DATE }}-${{ hashFiles('pyproject.toml') }}-${{ env.CACHE_NUMBER }}
id: cache

# if cache key has changed, create new cache
- name: Update environment
run: mamba env update -n test-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
# <<< Cache the conda environment

# install libglu on ubuntu.
- name: Install libglu
Expand All @@ -81,13 +42,13 @@ jobs:
run: |
conda activate test-env
python3 -m pip install --upgrade pip
pip3 install gmsh pygmsh coveralls pytest
pip3 install gmsh pygmsh coveralls pytest pytest-cov
pip3 install .

# run all tests & coverage
- name: Run Test
shell: bash -l {0}
run: coverage run -m pytest
run: pytest --cov=wecopttool --cov-report=xml

# upload coverage data
- name: Upload coverage data to coveralls.io
Expand Down
44 changes: 2 additions & 42 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,12 @@ jobs:
# Checkout the WecOptTool repo
- uses: actions/checkout@v3

# Cache the conda environment >>>
# The cache key includes the OS, the date, the hash of the pyproject.toml file, and the cache number.
# A new cache is created if:
# - this is the first time today that this file is run (date changes)
# - the content of pyproject.toml changes
# - you manually change the value of the CACHE_NUMBER below
# Else the existing cache is used.
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: test-env
use-mamba: true

# save the date to include in the cache key
- name: Get Date
id: get-date
run: echo "DATE=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_ENV
shell: bash

# create a conda yaml file
- name: Create environment.yml file
run: |
echo "name: test-env" >> environment.yml;
echo " " >> environment.yml
echo "dependencies:" >> environment.yml
echo " - python=${{ matrix.python-version }}" >> environment.yml
echo " - capytaine" >> environment.yml
echo " - wavespectra" >> environment.yml
cat environment.yml

# use the cache if it exists
- uses: actions/cache@v3
env:
CACHE_NUMBER: 0 # increase to reset cache manually
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.DATE }}-${{ hashFiles('pyproject.toml') }}-${{ env.CACHE_NUMBER }}
id: cache

# if cache key has changed, create new cache
- name: Update environment
run: mamba env update -n test-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
# <<< Cache the conda environment

# install libglu on ubuntu.
- name: Install libglu
Expand All @@ -81,13 +41,13 @@ jobs:
run: |
conda activate test-env
python3 -m pip install --upgrade pip
pip3 install gmsh pygmsh coveralls pytest
pip3 install gmsh pygmsh coveralls pytest pytest-cov
pip3 install .

# run all tests & coverage
- name: Run Test
shell: bash -l {0}
run: coverage run -m pytest
run: pytest --cov=wecopttool --cov-report=xml

# upload coverage data
- name: Upload coverage data to coveralls.io
Expand Down
9 changes: 5 additions & 4 deletions examples/tutorial_1_WaveBot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"metadata": {},
"outputs": [],
"source": [
"import autograd.numpy as np\n",
"import numpy as np\n",
"import jax.numpy as jnp\n",
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -372,7 +373,7 @@
"\n",
"def const_f_pto(wec, x_wec, x_opt, wave): # Format for scipy.optimize.minimize\n",
" f = pto.force(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return f_max - np.abs(f.flatten())\n",
" return f_max - jnp.abs(f.flatten())\n",
"\n",
"ineq_cons = {'type': 'ineq',\n",
" 'fun': const_f_pto,\n",
Expand Down Expand Up @@ -706,7 +707,7 @@
"## Update PTO constraints and forcing\n",
"def const_f_pto_2(wec, x_wec, x_opt, wave):\n",
" f = pto_2.force_on_wec(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return f_max - np.abs(f.flatten())\n",
" return f_max - jnp.abs(f.flatten())\n",
"ineq_cons_2 = {'type': 'ineq', 'fun': const_f_pto_2}\n",
"constraints_2 = [ineq_cons_2]\n",
"f_add_2 = {'PTO': pto_2.force_on_wec}"
Expand Down Expand Up @@ -989,7 +990,7 @@
"\n",
" def const_f_pto(wec, x_wec, x_opt, wave):\n",
" f = pto.force(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return f_max - np.abs(f.flatten())\n",
" return f_max - jnp.abs(f.flatten())\n",
"\n",
" ineq_cons = {'type': 'ineq', 'fun': const_f_pto}\n",
" constraints = [ineq_cons]\n",
Expand Down
23 changes: 12 additions & 11 deletions examples/tutorial_2_AquaHarmonics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"source": [
"import capytaine as cpy\n",
"from capytaine.io.meshio import load_from_meshio\n",
"import autograd.numpy as np\n",
"import numpy as np\n",
"import jax.numpy as jnp\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import cm\n",
"from scipy.optimize import brute\n",
Expand Down Expand Up @@ -376,10 +377,10 @@
"source": [
"def f_buoyancy(wec, x_wec, x_opt, wave, nsubsteps=1):\n",
" \"\"\"Only the zeroth order component (doesn't include linear stiffness)\"\"\"\n",
" return displacement * rho * g * np.ones([wec.ncomponents*nsubsteps, wec.ndof])\n",
" return displacement * rho * g * jnp.ones([wec.ncomponents*nsubsteps, wec.ndof])\n",
"\n",
"def f_gravity(wec, x_wec, x_opt, wave, nsubsteps=1):\n",
" return -1 * wec.inertia_matrix.item() * g * np.ones([wec.ncomponents*nsubsteps, wec.ndof])\n",
" return -1 * wec.inertia_matrix.item() * g * jnp.ones([wec.ncomponents*nsubsteps, wec.ndof])\n",
"\n",
"def f_pretension_wec(wec, x_wec, x_opt, wave, nsubsteps=1):\n",
" \"\"\"Pretension force as it acts on the WEC\"\"\"\n",
Expand All @@ -389,18 +390,18 @@
"\n",
"def f_pto_passive(wec, x_wec, x_opt, wave, nsubsteps=1):\n",
" pos = wec.vec_to_dofmat(x_wec)\n",
" vel = np.dot(wec.derivative_mat,pos)\n",
" acc = np.dot(wec.derivative_mat, vel)\n",
" vel = jnp.dot(wec.derivative_mat,pos)\n",
" acc = jnp.dot(wec.derivative_mat, vel)\n",
" time_matrix = wec.time_mat_nsubsteps(nsubsteps)\n",
" spring = -(gear_ratios['spring']*airspring['gamma']*airspring['area']*\n",
" airspring['press_init']/airspring['vol_init']) * pos\n",
" f_spring = np.dot(time_matrix,spring)\n",
" f_spring = jnp.dot(time_matrix,spring)\n",
" fric = -(friction_pto + \n",
" friction['Bpneumatic_spring_static1']*\n",
" gear_ratios['spring']) * vel\n",
" f_fric = np.dot(time_matrix,fric)\n",
" f_fric = jnp.dot(time_matrix,fric)\n",
" inertia = inertia_pto * acc\n",
" f_inertia = np.dot(time_matrix,inertia)\n",
" f_inertia = jnp.dot(time_matrix,inertia)\n",
" return f_spring + f_fric + f_inertia\n",
"\n",
"def f_pto_line(wec, x_wec, x_opt, wave, nsubsteps=1):\n",
Expand Down Expand Up @@ -452,18 +453,18 @@
"\n",
"def const_peak_torque_pto(wec, x_wec, x_opt, wave):\n",
" torque = pto.force(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return torque_peak_max - np.abs(torque.flatten())\n",
" return torque_peak_max - jnp.abs(torque.flatten())\n",
"\n",
"def const_speed_pto(wec, x_wec, x_opt, wave):\n",
" rot_vel = pto.velocity(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return rot_speed_max - np.abs(rot_vel.flatten())\n",
" return rot_speed_max - jnp.abs(rot_vel.flatten())\n",
"\n",
"def const_power_pto(wec, x_wec, x_opt, wave):\n",
" power_mech = (\n",
" pto.velocity(wec, x_wec, x_opt, wave, nsubsteps) *\n",
" pto.force(wec, x_wec, x_opt, wave, nsubsteps)\n",
" )\n",
" return power_max - np.abs(power_mech.flatten())\n",
" return power_max - jnp.abs(power_mech.flatten())\n",
"\n",
"def constrain_min_tension(wec, x_wec, x_opt, wave):\n",
" total_tension = -1*f_pto_line(wec, x_wec, x_opt, wave, nsubsteps)\n",
Expand Down
21 changes: 11 additions & 10 deletions examples/tutorial_3_LUPA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"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 numpy as np\n",
"import jax.numpy as jnp\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"from scipy.optimize import brute\n",
Expand Down Expand Up @@ -766,8 +767,8 @@
"# maximum stroke\n",
"stroke_max = 0.5 # m\n",
"def const_stroke_pto(wec, x_wec, x_opt, wave): \n",
" pos = pto.position(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return stroke_max - np.abs(pos.flatten())\n",
" pos = pto.position(wec, x_wec, x_opt, waves, nsubsteps)\n",
" return stroke_max - jnp.abs(pos.flatten())\n",
"\n",
"## GENERATOR\n",
"# peak torque\n",
Expand All @@ -776,20 +777,20 @@
" \"\"\"Instantaneous torque must not exceed max torque Tmax - |T| >=0 \n",
" \"\"\"\n",
" torque = pto.force(wec, x_wec, x_opt, wave, nsubsteps) / gear_ratio(radius)\n",
" return generator['max_torque'] - np.abs(torque.flatten())\n",
" return generator['max_torque'] - jnp.abs(torque.flatten())\n",
"\n",
"# continuous torque\n",
"def const_torque_pto(wec, x_wec, x_opt, wave, radius=default_radius): \n",
" \"\"\"RMS torque must not exceed max continous torque \n",
" Tmax_conti - Trms >=0 \"\"\"\n",
" torque = pto.force(wec, x_wec, x_opt, wave, nsubsteps) / gear_ratio(radius)\n",
" torque_rms = np.sqrt(np.mean(torque.flatten()**2))\n",
" torque_rms = jnp.sqrt(jnp.mean(torque.flatten()**2))\n",
" return generator['continuous_torque'] - torque_rms\n",
"\n",
"# max speed\n",
"def const_speed_pto(wec, x_wec, x_opt, wave, radius=default_radius): \n",
" rot_vel = pto.velocity(wec, x_wec, x_opt, wave, nsubsteps) * gear_ratio(radius)\n",
" return generator['max_speed'] - np.abs(rot_vel.flatten())\n",
" return generator['max_speed'] - jnp.abs(rot_vel.flatten())\n",
"\n",
"## Constraints\n",
"constraints = [\n",
Expand Down Expand Up @@ -1263,7 +1264,7 @@
" stroke_max = 0.5 # m\n",
" def const_stroke_pto(wec, x_wec, x_opt, wave): \n",
" pos = pto.position(wec, x_wec, x_opt, wave, nsubsteps)\n",
" return stroke_max - np.abs(pos.flatten())\n",
" return stroke_max - jnp.abs(pos.flatten())\n",
"\n",
" ## GENERATOR\n",
" # peak torque\n",
Expand All @@ -1272,20 +1273,20 @@
" \"\"\"Instantaneous torque must not exceed max torque Tmax - |T| >=0 \n",
" \"\"\"\n",
" torque = pto.force(wec, x_wec, x_opt, wave, nsubsteps) / gear_ratio(radius)\n",
" return generator['max_torque'] - np.abs(torque.flatten())\n",
" return generator['max_torque'] - jnp.abs(torque.flatten())\n",
"\n",
" # continuous torque\n",
" def const_torque_pto(wec, x_wec, x_opt, wave): \n",
" \"\"\"RMS torque must not exceed max continous torque \n",
" Tmax_conti - Trms >=0 \"\"\"\n",
" torque = pto.force(wec, x_wec, x_opt, wave, nsubsteps) / gear_ratio(radius)\n",
" torque_rms = np.sqrt(np.mean(torque.flatten()**2))\n",
" torque_rms = jnp.sqrt(jnp.mean(torque.flatten()**2))\n",
" return generator['continuous_torque'] - torque_rms\n",
"\n",
" # max speed\n",
" def const_speed_pto(wec, x_wec, x_opt, wave): \n",
" rot_vel = pto.velocity(wec, x_wec, x_opt, wave, nsubsteps) * gear_ratio(radius)\n",
" return generator['max_speed'] - np.abs(rot_vel.flatten())\n",
" return generator['max_speed'] - jnp.abs(rot_vel.flatten())\n",
"\n",
" ## Constraints\n",
" constraints = [\n",
Expand Down
Loading
Loading