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
c07ad0f4f2fc
Commit
8d14ac6c
authored
May 17, 2021
by
Pierre Augier
Browse files
spatiotemp-spectra-2d: refactoring and improve coverage
parent
32f61ea18a25
Pipeline
#22178
passed with stage
in 17 minutes and 47 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
fluidsim/base/output/spatiotemporal_spectra.py
View file @
c07ad0f4
...
...
@@ -853,6 +853,17 @@ class SpatioTemporalSpectraNS:
# slice along equation
if
equation
is
None
:
equation
=
f
"omega=0"
elif
equation
.
startswith
(
"kh="
):
kh
=
eval
(
equation
[
len
(
"kh="
)
:])
kh_spectra
=
spectra_kzkhomega
[
"kh_spectra"
]
ikh
=
abs
(
kh_spectra
-
kh
).
argmin
()
equation
=
f
"ikh=
{
ikh
}
"
elif
equation
.
startswith
(
"kz="
):
kz
=
eval
(
equation
[
len
(
"kz="
)
:])
kz_spectra
=
spectra_kzkhomega
[
"kz_spectra"
]
ikz
=
abs
(
kz_spectra
-
kz
).
argmin
()
equation
=
f
"ikz=
{
ikz
}
"
if
equation
.
startswith
(
"omega="
):
omega
=
eval
(
equation
[
len
(
"omega="
)
:])
omegas
=
spectra_kzkhomega
[
"omegas"
]
...
...
@@ -870,44 +881,6 @@ class SpatioTemporalSpectraNS:
equation
=
r
"$\omega/N=$"
+
f
"
{
omega
/
N
:
.
2
g
}
"
except
AttributeError
:
pass
elif
equation
.
startswith
(
"kh="
):
kh
=
eval
(
equation
[
len
(
"kh="
)
:])
kh_spectra
=
spectra_kzkhomega
[
"kh_spectra"
]
ikh
=
abs
(
kh_spectra
-
kh
).
argmin
()
spect
=
spectra_kzkhomega
[
key_spect
][:,
ikh
,
:].
transpose
()
xaxis
=
np
.
arange
(
spectra_kzkhomega
[
"kz_spectra"
].
size
)
yaxis
=
spectra_kzkhomega
[
"omegas"
]
# use reduced frequency for stratified fluids
try
:
N
=
self
.
sim
.
params
.
N
yaxis
/=
N
except
AttributeError
:
pass
xlabel
=
r
"$k_z/\delta k_z$"
ylabel
=
r
"$\omega/N$"
kh
=
kh_spectra
[
ikh
]
equation
=
f
"$k_h =
{
ikh
}
\\
delta k_h =
{
kh
:
.
2
g
}
$"
elif
equation
.
startswith
(
"kz="
):
kz
=
eval
(
equation
[
len
(
"kz="
)
:])
kz_spectra
=
spectra_kzkhomega
[
"kz_spectra"
]
ikz
=
abs
(
kz_spectra
-
kz
).
argmin
()
spect
=
spectra_kzkhomega
[
key_spect
][
ikz
,
:,
:].
transpose
()
xaxis
=
np
.
arange
(
spectra_kzkhomega
[
"kh_spectra"
].
size
)
yaxis
=
spectra_kzkhomega
[
"omegas"
]
# use reduced frequency for stratified fluids
try
:
N
=
self
.
sim
.
params
.
N
yaxis
/=
N
except
AttributeError
:
pass
xlabel
=
r
"$k_h/\delta k_h$"
ylabel
=
r
"$\omega/N$"
kz
=
kz_spectra
[
ikz
]
equation
=
f
"$k_z =
{
ikz
}
\\
delta k_z =
{
kz
:
.
2
g
}
$"
elif
equation
.
startswith
(
"ikh="
):
ikh
=
eval
(
equation
[
len
(
"ikh="
)
:])
kh_spectra
=
spectra_kzkhomega
[
"kh_spectra"
]
...
...
@@ -983,8 +956,9 @@ class SpatioTemporalSpectraNS:
/
spectra_kzkhomega
[
"kh_spectra"
][
1
]
)
if
equation
.
startswith
(
r
"$\omega"
):
ikz_disp
=
np
.
sqrt
(
N
**
2
/
omega
**
2
-
1
)
/
dkh_over_dkz
*
xaxis
ax
.
plot
(
xaxis
,
ikz_disp
,
"k+"
,
linewidth
=
2
)
if
omega
>
0
:
ikz_disp
=
np
.
sqrt
(
N
**
2
/
omega
**
2
-
1
)
/
dkh_over_dkz
*
xaxis
ax
.
plot
(
xaxis
,
ikz_disp
,
"k+"
,
linewidth
=
2
)
elif
equation
.
startswith
(
r
"$k_h"
):
omega_disp
=
ikh
/
np
.
sqrt
(
ikh
**
2
+
dkh_over_dkz
**
2
*
xaxis
**
2
)
ax
.
plot
(
xaxis
,
omega_disp
,
"k+"
,
linewidth
=
2
)
...
...
fluidsim/solvers/ns2d/strat/test_solver.py
View file @
c07ad0f4
...
...
@@ -334,9 +334,22 @@ class TestForcingOutput(TestSimulBase):
E_omega_from_spatiotemp
,
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
,
equation
=
"omega=1"
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
,
equation
=
"kh=1"
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
,
equation
=
"kz=1"
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
,
equation
=
"ikh=1"
)
sim2
.
output
.
spatiotemporal_spectra
.
plot_kzkhomega
(
key_field
=
"ux"
,
equation
=
"ikz=1"
)
sim2
.
output
.
increments
.
load
()
sim2
.
output
.
increments
.
plot
()
...
...
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