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

Capytaine v2 Hydrostatics #284

Merged
merged 22 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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.
46 changes: 13 additions & 33 deletions examples/tutorial_1_WaveBot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we will add the mass and hydrostatic stiffness properties. \n",
"If these values are known they can be added directly.\n",
"Here we will use the fact that the WaveBot is free floating and assume constant density to calculate these properties, which Capytaine can natively perform with the `FloatingBody` created above. For convenience, this functionality has been wrapped in `wecopttool.hydrostatics`."
"At this point we can visualize the mesh for inspection.\n",
"Capytaine has built-in methods for visualizing meshes (`fb.show`, and `fb.show_matplotlib`). \n",
"When running outside a Notebook, these are interactive. \n",
"The included WaveBot example also has a method for plotting the cross-section of the device. "
]
},
{
Expand All @@ -112,18 +113,8 @@
"metadata": {},
"outputs": [],
"source": [
"stiffness = wot.hydrostatics.stiffness_matrix(fb).values\n",
"mass = wot.hydrostatics.inertia_matrix(fb).values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At this point we can visualize the mesh for inspection.\n",
"Capytaine has built-in methods for visualizing meshes (`fb.show`, and `fb.show_matplotlib`). \n",
"When running outside a Notebook, these are interactive. \n",
"The included WaveBot example also has a method for plotting the cross-section of the device. "
"fb.show_matplotlib()\n",
"_ = wb.plot_cross_section(show=True) # specific to WaveBot"
]
},
{
Expand All @@ -132,8 +123,7 @@
"metadata": {},
"outputs": [],
"source": [
"fb.show_matplotlib()\n",
"_ = wb.plot_cross_section(show=True) # specific to WaveBot"
"bem_data['inertia_matrix'].values"
]
},
{
Expand All @@ -145,7 +135,9 @@
"\n",
"We will analyze 50 frequencies with a spacing of 0.05 Hz. These frequencies will be used for the Fourier representation of both the wave and the desired PTO force in the pseudo-spectral problem. See the Theory section of the Documentation for more details on the pseudo-spectral problem formulation.\n",
"\n",
"If you would like to save our BEM data to a NetCDF file for future use, see the `wecopttool.write_netcdf` function."
"If you would like to save our BEM data to a NetCDF file for future use, see the `wecopttool.write_netcdf` function.\n",
"\n",
"The run_bem() function now calculates the hydrostatics and stores them as part of bem_data. The inertia and stiffness can still be defined manually as part of the `FloatingBody` if desired."
]
},
{
Expand Down Expand Up @@ -236,8 +228,6 @@
"source": [
"wec = wot.WEC.from_bem(\n",
" bem_data,\n",
" inertia_matrix=mass,\n",
" hydrostatic_stiffness=stiffness,\n",
" constraints=constraints,\n",
" friction=None,\n",
" f_add=f_add,\n",
Expand Down Expand Up @@ -512,8 +502,6 @@
"# Update WEC\n",
"\n",
"wec_2 = wot.WEC.from_bem(bem_data,\n",
" inertia_matrix=mass,\n",
" hydrostatic_stiffness=stiffness,\n",
" constraints=constraints_2,\n",
" friction=None,\n",
" f_add=f_add_2\n",
Expand Down Expand Up @@ -558,8 +546,6 @@
"source": [
"wec_2_nocon = wot.WEC.from_bem(\n",
" bem_data,\n",
" inertia_matrix=mass,\n",
" hydrostatic_stiffness=stiffness,\n",
" constraints=None,\n",
" friction=None,\n",
" f_add=f_add_2)\n",
Expand Down Expand Up @@ -712,10 +698,6 @@
" nfreq = 50\n",
" bem_data = wot.run_bem(fb, freq)\n",
"\n",
" # Mass & hydrostatic stiffness\n",
" stiffness_3 = wot.hydrostatics.stiffness_matrix(fb).values\n",
" mass_3 = wot.hydrostatics.inertia_matrix(fb).values\n",
"\n",
" # Impedance definition\n",
" omega = bem_data.omega.values\n",
" gear_ratio = 12.0\n",
Expand Down Expand Up @@ -764,8 +746,6 @@
"\n",
" # Create WEC\n",
" wec = wot.WEC.from_bem(bem_data,\n",
" inertia_matrix=mass_3,\n",
" hydrostatic_stiffness=stiffness_3,\n",
" constraints=constraints,\n",
" friction=None, \n",
" f_add=f_add,\n",
Expand Down Expand Up @@ -860,9 +840,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "wot_dev",
"display_name": "wecopttool2_0_0",
"language": "python",
"name": "python3"
"name": "wecopttool2_0_0"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -874,7 +854,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.10.9"
},
"vscode": {
"interpreter": {
Expand Down
Loading
Loading