From 4825ad53dfa1c29169912c680cdedee9c04319e4 Mon Sep 17 00:00:00 2001 From: jtgrasb Date: Thu, 26 Oct 2023 09:27:41 -0400 Subject: [PATCH] Check minimum computable mesh in tutorial 1 --- examples/tutorial_1_WaveBot.ipynb | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/examples/tutorial_1_WaveBot.ipynb b/examples/tutorial_1_WaveBot.ipynb index 34c0cd99..218ce3b6 100644 --- a/examples/tutorial_1_WaveBot.ipynb +++ b/examples/tutorial_1_WaveBot.ipynb @@ -140,12 +140,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### BEM\n", - "With our Capytaine floating body created, we can now run the Boundary Element Method solver in Capytaine to get the hydrostatic and hydrodynamic coefficients of our WEC object. This is wrapped into the `wecopttool.run_bem` function.\n", - "\n", + "#### Frequency and mesh check\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." + "The `fb.minimal_computable_wavelength` parameter checks the mesh to determine the minimum wavelength that can be reliably computed using Capytaine. This warning is ignored here because the BEM results have been validated, but can be used as a guide for mesh refinement to ensure accurate BEM results." ] }, { @@ -158,6 +156,32 @@ "nfreq = 50\n", "freq = wot.frequency(f1, nfreq, False) # False -> no zero frequency\n", "\n", + "min_computable_wavelength = fb.minimal_computable_wavelength\n", + "g = 9.81\n", + "min_period = 1/(f1*nfreq)\n", + "min_wavelength = (g*(min_period)**2)/(2*np.pi)\n", + "\n", + "if min_wavelength < min_computable_wavelength:\n", + " print(f'Warning: Minimum wavelength in frequency spectrum ({min_wavelength}) is smaller'\n", + " f' than the minimum computable wavelength ({min_computable_wavelength}).')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### BEM\n", + "With our Capytaine floating body created, we can now run the Boundary Element Method solver in Capytaine to get the hydrostatic and hydrodynamic coefficients of our WEC object. This is wrapped into the `wecopttool.run_bem` function.\n", + "\n", + "If you would like to save our BEM data to a NetCDF file for future use, see the `wecopttool.write_netcdf` function." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "bem_data = wot.run_bem(fb, freq)" ] }, @@ -862,7 +886,7 @@ "kernelspec": { "display_name": "wot_dev", "language": "python", - "name": "python3" + "name": "wecopttool2_0_0" }, "language_info": { "codemirror_mode": { @@ -874,7 +898,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.10" + "version": "3.10.9" }, "vscode": { "interpreter": {