Python:raschii库计算任意阶数Stokes波
Stokes五阶波
最近发现一个很有用的Stokes波计算Python库,raschii官方说明,可以计算任意阶数,不同水深下的Stokes波,简单做了下测试,测试结果与脚本如下
Python 脚本
import raschii
import matplotlib.pyplot as plt
import numpy as np
order=5
wavelength=3
waveheight=0.1
h0=1.5
h1=0.5
h2=10
fwave0 = raschii.FentonWave(height=waveheight, depth=h0, length=wavelength, N=order)
fwave1 = raschii.FentonWave(height=waveheight, depth=h1, length=wavelength, N=order)
fwave2 = raschii.FentonWave(height=waveheight, depth=h2, length=wavelength, N=order)
Y0=[]
Y1=[]
Y2=[]
X=np.linspace(0,30,1000)
for each in X:
Y0.append(float(fwave0.surface_elevation(x=each)))
Y1.append(float(fwave1.surface_elevation(x=each)))
Y2.append(float(fwave2.surface_elevation(x=each)))
YY0=np.array(Y0)
YY1=np.array(Y1)
YY2=np.array(Y2)
plt.figure()
plt.grid()
plt.plot(X, YY0-h0)
plt.plot(X, YY2-h2)#
plt.plot(X, YY1-h1)
plt.legend(['h = %3.2f m'%h0,'h = %3.2f m'%h2,'h = %3.2f m'%h1], loc = 'upper right')
plt.title('lambda = %3.2f m | stokes order = %d | Height = %4.3f m '%(wavelength,order,waveheight))
plt.xlabel('x/m')
plt.ylabel('eta/m')