Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fluiddyn
fluidsim
Commits
a71817c534b3
Commit
f0ac7161
authored
May 27, 2021
by
Pierre Augier
Browse files
spatiotemporal_spectra: different things and better coverage
parent
fbd833f008e7
Pipeline
#22469
passed with stage
in 14 minutes and 39 seconds
Changes
6
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
doc/examples/milestone/run_simul.py
View file @
a71817c5
...
...
@@ -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
...
...
fluidsim/base/output/spatiotemporal_spectra.py
View file @
a71817c5
...
...
@@ -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
...
...
fluidsim/solvers/ns2d/output/spatiotemporal_spectra.py
View file @
a71817c5
...
...
@@ -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
:]
=
(
...
...
fluidsim/solvers/ns3d/output/spatiotemporal_spectra.py
View file @
a71817c5
...
...
@@ -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
:]
=
(
...
...
fluidsim/solvers/ns3d/strat/test_solver.py
View file @
a71817c5
...
...
@@ -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"
)
...
...
fluidsim/solvers/ns3d/test_solver.py
View file @
a71817c5
...
...
@@ -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"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment