1
Fork 0

Olaflow waveDict generation with fft

This commit is contained in:
Edgar P. Burkhart 2022-04-08 13:41:14 +02:00
parent 8f902fb24d
commit 1506fd06a1
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 33 additions and 19 deletions

View file

@ -15,23 +15,30 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//waveType regular;
//waveTheory cnoidal;
//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;
waveType irregular;
genAbs 1;
absDir 0.0;
nPaddles 1;
waveHeight 7.5;
waveDir 0.0;
secondOrder 1;
waveHeights
{n}
(
{wh}
);
wavePeriods
{n}
(
{wper}
);
wavePhases
{n}
(
{wph}
);
waveDirs
{n}
{
0
};
// ************************************************************************* //

View file

@ -38,9 +38,16 @@ arg_x0 = np.argmin(np.abs(x+1250))
wl = watl[:, arg_x0]
f = fft.rfftfreq(t.size, np.diff(t).mean())
w_fft = fft.rfft(wl)
f = fft.rfftfreq(t.size, np.diff(t).mean())[1:]
w_fft = fft.rfft(wl)[1:]
amp = np.abs(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")