This instance will be upgraded to Heptapod 0.23.2 on 2021-08-05 at 11:00 UTC+2 (a few minutes of down time)

Commit f0ac7161 authored by Pierre Augier's avatar Pierre Augier
Browse files

spatiotemporal_spectra: different things and better coverage

parent fbd833f008e7
Pipeline #22469 passed with stage
in 14 minutes and 39 seconds
......@@ -101,7 +101,9 @@ def main(args):
lz = params.oper.Lz = mesh
params.oper.nz = round(lz / dx)
params.oper.coef_dealiasing = 0.8
params.oper.NO_SHEAR_MODES = True
params.no_vz_kz0 = True
params.forcing.enable = True
params.forcing.type = "milestone"
......@@ -166,7 +168,7 @@ def main(args):
spatiotemporal_spectra = params.output.spatiotemporal_spectra
spatiotemporal_spectra.file_max_size = 20.0
spatiotemporal_spectra.probes_region = (10, 10, 10)
spatiotemporal_spectra.probes_region = (10 * lx / ly, 10, 10)
sim = Simul(params)
......@@ -175,9 +177,10 @@ def main(args):
mpi.printby0(
"For a video, run something like:\n\n"
f"cd {sim.output.path_run}; "
'ipython -i -c "from fluidsim import load_sim_for_plot as load; '
"sim=load(); sim.output.phys_fields.animate('vx')\""
f"cd {sim.output.path_run}\n"
'ipython -i -c "from fluidsim import load_sim_for_plot as load; sim=load()"\n'
"Then, in IPython:\n"
"sim.output.phys_fields.animate('vx')"
)
return params, sim
......
......@@ -707,10 +707,12 @@ class SpatioTemporalSpectraNS:
if self.nb_dim == 3:
deltaky = 2 * pi / params_oper.Ly
deltakz = 2 * pi / params_oper.Lz
_deltakhs = [deltakx, deltaky]
_ideltakh = np.argmax(_deltakhs)
deltakh = _deltakhs[_ideltakh]
KY = deltaky * spectra[f"K{order[1]}_adim"]
KH = np.sqrt(KX ** 2 + KY ** 2)
deltakh = max(deltakx, deltaky)
khmax_spectra = max(KX.max(), KY.max())
khmax_spectra = [KX, KY][_ideltakh].max()
del KY
else:
# in 2d, vertical (here "z") is y
......
......@@ -64,7 +64,7 @@ def compute_spectrum_kzkhomega(
spectrum_kzkhomega[ikz, ikh + 1, i] += coef_share * value
# get one-sided spectrum in the omega dimension
nomega = nomega // 2 + 1
nomega = (nomega + 1) // 2
spectrum_onesided = np.zeros((nkz, nkh, nomega))
spectrum_onesided[:, :, 0] = spectrum_kzkhomega[:, :, 0]
spectrum_onesided[:, :, 1:] = (
......
......@@ -71,7 +71,7 @@ def compute_spectrum_kzkhomega(
spectrum_kzkhomega[ikz, ikh + 1, i] += coef_share * value
# get one-sided spectrum in the omega dimension
nomega = nomega // 2 + 1
nomega = (nomega + 1) // 2
spectrum_onesided = np.zeros((nkz, nkh, nomega))
spectrum_onesided[:, :, 0] = spectrum_kzkhomega[:, :, 0]
spectrum_onesided[:, :, 1:] = (
......
......@@ -74,7 +74,7 @@ class TestOutput(TestSimulBase):
@classmethod
def init_params(self):
params = super().init_params()
params.time_stepping.t_end = 0.3
params.init_fields.type = "noise"
params.forcing.enable = True
......@@ -85,6 +85,8 @@ class TestOutput(TestSimulBase):
for key in periods._key_attribs:
periods[key] = 0.2
periods.spatiotemporal_spectra = 0.01
periods.spatial_means = 0.05
periods.spatial_means_regions = 0.05
......@@ -97,6 +99,12 @@ class TestOutput(TestSimulBase):
params.output.spectra.kzkh_periodicity = 2
params.output.spatiotemporal_spectra.probes_region = (
params.oper.nx // 2,
params.oper.ny // 2,
params.oper.nz // 2,
)
@pytest.mark.filterwarnings("ignore:divide by zero encountered in log10")
def test_output(self):
......@@ -174,6 +182,11 @@ class TestOutput(TestSimulBase):
sim2.output.phys_fields.animate("vx")
sim2.output.phys_fields.plot(field="vx", time=10)
sim2.output.spatiotemporal_spectra.plot_kzkhomega(
key_field="Kp", equation="omega=200 * N"
)
sim2.output.spatiotemporal_spectra.plot_temporal_spectra()
plt.close("all")
......
......@@ -356,10 +356,10 @@ class TestOutput(TestSimulBase):
# `1:` because the energy in the mode kx=ky=kz=0 is not zero.
assert np.allclose(spectrum_vz[1:, 0, :].sum(), 0.0)
sim3.output.spatiotemporal_spectra.plot_temporal_spectra()
sim3.output.spatiotemporal_spectra.plot_kzkhomega(
key_field="Khr", equation="kh=1"
)
sim3.output.spatiotemporal_spectra.plot_temporal_spectra()
plt.close("all")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment