From 1506fd06a106f9ce30c0051f0a11f6a4299e9fc1 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Fri, 8 Apr 2022 13:41:14 +0200 Subject: [PATCH] Olaflow waveDict generation with fft --- .../of/constant/{waveDict => waveDict.org} | 39 +++++++++++-------- olaflow/processing/sws_wavedict.py | 13 +++++-- 2 files changed, 33 insertions(+), 19 deletions(-) rename olaflow/of/constant/{waveDict => waveDict.org} (73%) diff --git a/olaflow/of/constant/waveDict b/olaflow/of/constant/waveDict.org similarity index 73% rename from olaflow/of/constant/waveDict rename to olaflow/of/constant/waveDict.org index d274bbd..082a318 100644 --- a/olaflow/of/constant/waveDict +++ b/olaflow/of/constant/waveDict.org @@ -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 +}; // ************************************************************************* // diff --git a/olaflow/processing/sws_wavedict.py b/olaflow/processing/sws_wavedict.py index c3c758b..ebb7ef2 100644 --- a/olaflow/processing/sws_wavedict.py +++ b/olaflow/processing/sws_wavedict.py @@ -34,13 +34,20 @@ t = data("t") watl = data("watl") -arg_x0 = np.argmin(np.abs(x+1250)) +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")