Skip to content

Commit ef4ca69

Browse files
committed
Doc update
1 parent dd74158 commit ef4ca69

File tree

3 files changed

+64
-37
lines changed

3 files changed

+64
-37
lines changed

README.rst

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,64 @@
11
Raschii
22
=======
33

4-
Raschii is a Python library for constructing non-linear regular waves and is
5-
named after `Thysanoessa raschii
6-
<https://en.wikipedia.org/wiki/Thysanoessa_raschii>`_, the Arctic Krill.
7-
8-
Supported wave models are currently:
4+
Raschii is a Python library for constructing non-linear regular waves.
5+
Supported wave models are:
96

107
- Stream function waves (M. M. Rienecker and J. D. Fenton, 1981)
118
- Stokes second- through fifth-order waves (based on J. D. Fenton, 1985)
129
- Airy waves, the standard linear wave theory
1310

14-
Raschii includes a command line program to plot regular waves from the supported
15-
wave models and C++ code generation for using the results in other programs,
16-
such as in `FEniCS <https://www.fenicsproject.org/>`_ expressions for initial
17-
and boundary conditions in a FEM solver. There is also a limited `Dart port
18-
<https://bitbucket.org/trlandet/raschiidart>`_ which is used in the `online demo
19-
<https://raschii.readthedocs.io/en/latest/raschii_dart.html>`_.
11+
Raschii directly computes the series expansion coefficients (for Stokes waves),
12+
or solves a minimization problem for the coefficients (for stream function
13+
waves). Once the expansion coefficients of the wave has been found you can
14+
15+
1) Compute the free-surface elevation
16+
2) Compute the particle velocities at any point in the wave field (and in the
17+
air phase by use of the potential-flow solution above the free-surface).
18+
3) Export the wave field to a file in the SWD_ file format (Spectral Wave Data, see
19+
more below). The SWD library can then be used to compute many other properties
20+
such as the velocity potential, the particle accelerations, the stream function,
21+
the Bernoulli pressure, `and several other properties
22+
<https://spectral-wave-data.readthedocs.io/en/latest/theory.html#spectral-kinematics>`_.
2023

2124
.. figure:: http://raschii.readthedocs.io/en/latest/_static/fenton_stokes.png
2225
:alt: A comparison of Stokes and Fenton waves of fifth order
2326

2427
A comparison of fifth-order Stokes waves and fifth-order Fenton stream
2528
function waves. Deep water, wave height 12 m, wave length 100 m.
2629

27-
As of version 1.0.3, Raschii can output waves in the SWD_ (spectral wave data)
28-
standard file format for use as the incoming incident waves in flow analysis
29-
programs such as boundary element and CFD (Euler and Navier-Stokes equation solvers).
30-
The SWD export functionality is in use in the Maritime and Offshore industries for
31-
3D-flow analyses of floating and fixed structures subjected to ocean surface waves.
30+
31+
Using the Raschii waves
32+
-----------------------
33+
34+
Raschii can output waves in the SWD_ (spectral wave data) standard file format for
35+
use as the incoming incident waves in flow analysis programs such as potential-flow
36+
or CFD (Euler and Navier-Stokes equations etc). The SWD file format is used by other
37+
linear and non-linear wave-generation tools, such as the non-linear irregular-wave
38+
HOSM solver DNV WAMOD. By supporting the SWD file format you avoid having to implement
39+
your own wave models for all types of waves, and you can instead use a uniform wave
40+
API for all types of linear and non-linear waves and let the SWD library handle the
41+
details of the wave kinematics.
42+
43+
Raschii also includes a command line program to plot regular waves from the supported
44+
wave models and C++ code generation for using the results in other programs, such as
45+
in `FEniCS <https://www.fenicsproject.org/>`_ expressions for initial and boundary
46+
conditions in a FEM solver (if you do not want to link to the SWD library for some
47+
reason).
3248

3349
.. _SWD: https://github.com/SpectralWaveData/spectral_wave_data
3450

3551

3652
Installation and running
3753
------------------------
3854

39-
Raschii can be installed by running
55+
Raschii can be installed using pip, uv, or any other Python package manager that
56+
supports the `Python Package Index (PyPI) <https://pypi.org/project/raschii>`_.
57+
Example:
4058

4159
.. code:: bash
4260
43-
python -m pip install raschii
44-
45-
Substitute ``python`` with ``python3`` as appropriate to your installation.
46-
The command will also install any dependencies (numpy).
61+
pip install raschii
4762
4863
4964
Using Raschii from Python
@@ -56,6 +71,7 @@ An example of using Raschii from Python:
5671
import raschii
5772
5873
fwave = raschii.FentonWave(height=0.25, depth=0.5, length=2.0, N=20)
74+
5975
print(fwave.surface_elevation(x=0))
6076
print(fwave.surface_elevation(x=[0, 0.1, 0.2, 0.3]))
6177
print(fwave.velocity(x=0, z=0.2))
@@ -84,9 +100,8 @@ help for the command line programs to get detailed usage info.
84100
python -m raschii.cmd.plot -h
85101
python -m raschii.cmd.swd -h
86102
87-
Substitute ``python`` with ``python3`` as appropriate to your installation.
88-
You must install the ``matplotlib`` Python package to be able to use the
89-
plot command.
103+
Substitute ``python`` with ``python3`` or ``uv run`` as appropriate to your installation.
104+
You must install the ``matplotlib`` Python package to be able to use the plot command.
90105

91106
An example of using Raschii from the command line:
92107

documentation/usage.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ You can get the crest velocity by running
4848
4949
This will show that the crest velocity is approximately 7.6 m/s.
5050

51-
You can give period instead of wave length if you want (added in version 1.1.0).
52-
This is slightly slower, but still relatively instant unless you are generating
53-
a ton of waves. The period is used to iteratively try to find a wave length that
54-
results in the correct period, which is easy for deep-water Airy waves and not
55-
so easy for finite depth and higher-order waves.
51+
You can give the wave period instead of the wave length if this is more convenient.
52+
Specifying the period makes the calculations slightly slower, but the answer is still
53+
given almost instantly, so unless you are generating a lot of waves it should not be a
54+
problem. The wave length is computed from the wave period by an iterative procedure
55+
that finds the wave length that results in the requested non-linear wave period. This
56+
is easy for deep-water Airy waves and not so easy for finite depth and higher-order
57+
non-linear waves, hence the need for iteration.
5658

5759

5860
Most common parameters

raschii/cmd/plot.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import numpy
21
from math import pi, sinh, cosh, tanh
3-
from matplotlib import pyplot
2+
import sys
3+
4+
import numpy
5+
46
from raschii import get_wave_model, check_breaking_criteria
57

68

@@ -18,10 +20,16 @@ def plot_wave(
1820
plot_quiver=False,
1921
ymin=None,
2022
ymax=None,
21-
):
23+
) -> int:
2224
"""
2325
Plot waves with the given parameters
2426
"""
27+
try:
28+
from matplotlib import pyplot
29+
except ImportError:
30+
print("You need to install matplotlib to plot waves")
31+
return 10
32+
2533
# Figure for plot of wave with quiver
2634
fig1, ax1 = pyplot.subplots(1, 1)
2735

@@ -209,6 +217,7 @@ def plot_wave(
209217
fig1.tight_layout()
210218
fig2.tight_layout(rect=[0, 0.0, 1, 0.95])
211219
pyplot.show()
220+
return 0
212221

213222

214223
def makeXY(x, ymin, ymax, Ny):
@@ -226,13 +235,13 @@ def makeXY(x, ymin, ymax, Ny):
226235
return X, Y
227236

228237

229-
def main():
238+
def main() -> int:
230239
# Get command line arguments
231240
import argparse
232241

233242
parser = argparse.ArgumentParser(prog="raschii.cmd.plot", description="Plot a Raschii wave")
234243
parser.add_argument(
235-
"wave_type", help="Name of the wave model. " 'You can specify several, e.g., "Fenton,Airy"'
244+
"wave_type", help='Name of the wave model. You can specify several, e.g., "Fenton,Airy"'
236245
)
237246
parser.add_argument("wave_height", help="Wave height", type=float)
238247
parser.add_argument("water_depth", help="The still water depth", type=float)
@@ -275,10 +284,10 @@ def main():
275284
if warn:
276285
print(warn)
277286
if err and not args.force:
278-
exit(1)
287+
return 1
279288

280289
model_names = args.wave_type.split(",")
281-
plot_wave(
290+
return plot_wave(
282291
model_names=model_names,
283292
height=args.wave_height,
284293
depth=args.water_depth,
@@ -294,4 +303,5 @@ def main():
294303

295304

296305
if __name__ == "__main__":
297-
main()
306+
status = main()
307+
sys.exit(status if status is not None else 0)

0 commit comments

Comments
 (0)