This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

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

spatiotemp-spectra-2d: update example and improve a bit usability

parent 8723eb3ab980
......@@ -12,10 +12,9 @@ params = Simul.create_default_params()
gamma = 1.0
nb_wavelength = 2
nz = nb_wavelength * 30 * 2
nx = 6 * nz
params.time_stepping.t_end = 100.0
nz = nb_wavelength * 30
inv_aspect_ratio = 6
nx = inv_aspect_ratio * nz
params.short_name_type_run = "quasi1d"
......@@ -38,6 +37,9 @@ params.oper.coef_dealiasing = 0.65
# Brunt Vaisala frequency
params.N = gamma * omega_af / F
period_N = 2 * pi / params.N
params.time_stepping.t_end = 500 * period_N
k_max = params.oper.coef_dealiasing * pi * nx / Lx
omega_max = (forcing_rate * k_max ** 2) ** (1 / 3)
......@@ -74,6 +76,19 @@ params.output.periods_save.spect_energy_budg = 0.5
params.output.periods_save.spectra_multidim = 1.0
params.output.periods_save.increments = 1.0
params.output.periods_save.temporal_spectra = period_N / 4
params.output.periods_save.spatiotemporal_spectra = period_N / 4
temporal_spectra = params.output.temporal_spectra
temporal_spectra.file_max_size = 20.0
temporal_spectra.probes_deltax = temporal_spectra.probes_deltay = Lz / 10
spatiotemporal_spectra = params.output.spatiotemporal_spectra
spatiotemporal_spectra.file_max_size = 20.0
ikz_max = 16
ikx_max = inv_aspect_ratio * ikz_max
spatiotemporal_spectra.probes_region = (ikx_max, ikz_max)
sim = Simul(params)
sim.time_stepping.start()
......@@ -82,13 +97,10 @@ mpi.printby0(
"\nTo display a video of this simulation, you can do:\n"
f"cd {sim.output.path_run}"
+ """
ipython
# then in ipython (copy the 3 lines in the terminal):
ipython --matplotlib -i -c "from fluidsim import load_sim_for_plot as load; sim=load();"
from fluidsim import load_sim_for_plot
sim = load_sim_for_plot()
# then in ipython (copy the line in the terminal):
sim.output.phys_fields.animate('b', dt_frame_in_sec=0.1, dt_equations=0.1)
sim.output.phys_fields.animate('b', dt_frame_in_sec=0.1, dt_equations=0.25)
"""
)
......@@ -102,7 +102,6 @@ class SpatioTemporalSpectra3D(SpecificOutput):
params.output._set_child(
cls._tag,
attribs={
"HAS_TO_PLOT_SAVED": False,
"probes_region": None,
"file_max_size": 10.0, # MB
"SAVE_AS_COMPLEX64": True,
......@@ -154,7 +153,6 @@ class SpatioTemporalSpectra3D(SpecificOutput):
super().__init__(
output,
period_save=params.output.periods_save.spatiotemporal_spectra,
has_to_plot_saved=params_st_spec.HAS_TO_PLOT_SAVED,
)
oper = self.sim.oper
......@@ -797,7 +795,11 @@ class SpatioTemporalSpectraNS:
vmin=None,
vmax=None,
):
"""plot the spatiotemporal spectra, with a cylindrical average in k-space"""
"""plot the spatiotemporal spectra, with a cylindrical average in k-space
equation must start with 'omega=', 'kh=', 'kz=', 'ikh=' or 'ikz='.
"""
keys_plot = self.keys_fields
if self.nb_dim == 3:
keys_plot.extend(["Khd", "Khr", "Kp"])
......@@ -952,11 +954,6 @@ class SpatioTemporalSpectraNS:
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
if vmin is None:
vmin = np.log10(spect[np.isfinite(spect)].min())
if vmax is None:
vmax = np.log10(spect[np.isfinite(spect)].max())
# no log(0)
spect += 1e-15
......
......@@ -47,7 +47,6 @@ class TemporalSpectra3D(SpecificOutput):
params.output.periods_save._set_attrib(tag, 0)
attribs = {
"HAS_TO_PLOT_SAVED": False,
"probes_deltax": 0.1, # m
"probes_deltay": 0.1, # m
"probes_region": None, # m
......@@ -104,7 +103,6 @@ class TemporalSpectra3D(SpecificOutput):
super().__init__(
output,
period_save=params.output.periods_save.temporal_spectra,
has_to_plot_saved=params_tspec.HAS_TO_PLOT_SAVED,
)
oper = self.sim.oper
......
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