Olaflow waveDict generation with fft
This commit is contained in:
parent
8f902fb24d
commit
1506fd06a1
2 changed files with 33 additions and 19 deletions
|
@ -15,23 +15,30 @@ FoamFile
|
||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//waveType regular;
|
waveType irregular;
|
||||||
//waveTheory cnoidal;
|
genAbs 1;
|
||||||
//genAbs 1;
|
|
||||||
//absDir 0.0;
|
|
||||||
//nPaddles 1;
|
|
||||||
//wavePeriod 20.0;
|
|
||||||
//waveHeight 15.0;
|
|
||||||
//waveDir 0.0;
|
|
||||||
//wavePhase 0.;
|
|
||||||
//tSmooth 0.0;
|
|
||||||
|
|
||||||
waveType solitary;
|
|
||||||
waveTheory Boussinesq;
|
|
||||||
genAbs 0;
|
|
||||||
absDir 0.0;
|
absDir 0.0;
|
||||||
nPaddles 1;
|
nPaddles 1;
|
||||||
waveHeight 7.5;
|
secondOrder 1;
|
||||||
waveDir 0.0;
|
waveHeights
|
||||||
|
{n}
|
||||||
|
(
|
||||||
|
{wh}
|
||||||
|
);
|
||||||
|
wavePeriods
|
||||||
|
{n}
|
||||||
|
(
|
||||||
|
{wper}
|
||||||
|
);
|
||||||
|
wavePhases
|
||||||
|
{n}
|
||||||
|
(
|
||||||
|
{wph}
|
||||||
|
);
|
||||||
|
waveDirs
|
||||||
|
{n}
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
|
@ -34,13 +34,20 @@ t = data("t")
|
||||||
|
|
||||||
watl = data("watl")
|
watl = data("watl")
|
||||||
|
|
||||||
arg_x0 = np.argmin(np.abs(x+1250))
|
arg_x0 = np.argmin(np.abs(x + 1250))
|
||||||
|
|
||||||
wl = watl[:, arg_x0]
|
wl = watl[:, arg_x0]
|
||||||
|
|
||||||
f = fft.rfftfreq(t.size, np.diff(t).mean())
|
f = fft.rfftfreq(t.size, np.diff(t).mean())[1:]
|
||||||
w_fft = fft.rfft(wl)
|
w_fft = fft.rfft(wl)[1:]
|
||||||
amp = np.abs(w_fft)
|
amp = np.abs(w_fft)
|
||||||
phi = np.angle(w_fft)
|
phi = np.angle(w_fft)
|
||||||
|
|
||||||
|
olaflow_root = pathlib.Path(config.get("olaflow", "root"))
|
||||||
|
org = olaflow_root.joinpath("constant", "waveDict.org").read_text()
|
||||||
|
org = org.replace("{n}", str(t.size))
|
||||||
|
org = org.replace("{wh}", "\n".join(amp.astype(np.str_)))
|
||||||
|
org = org.replace("{wph}", "\n".join(phi.astype(np.str_)))
|
||||||
|
org = org.replace("{wper}", "\n".join((1 / f).astype(np.str_)))
|
||||||
|
olaflow_root.joinpath("constant", "waveDict").write_text(org)
|
||||||
print(f, amp, phi, sep="\n")
|
print(f, amp, phi, sep="\n")
|
||||||
|
|
Loading…
Reference in a new issue