Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyTurbulence
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bilocq Amaury
pyTurbulence
Commits
4a9300b8
Verified
Commit
4a9300b8
authored
2 months ago
by
Bilocq Amaury
Browse files
Options
Downloads
Patches
Plain Diff
Merge the dilatational/spectrum/total spectrum together
parent
13f33727
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#53307
passed
2 months ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyTurbulence/solver.py
+12
-8
12 additions, 8 deletions
pyTurbulence/solver.py
pyTurbulence/spectrum.py
+8
-9
8 additions, 9 deletions
pyTurbulence/spectrum.py
pyTurbulence/syntheticTurbulence.py
+7
-7
7 additions, 7 deletions
pyTurbulence/syntheticTurbulence.py
with
27 additions
and
24 deletions
pyTurbulence/solver.py
+
12
−
8
View file @
4a9300b8
...
@@ -101,20 +101,25 @@ def solve(user_params)->dict:
...
@@ -101,20 +101,25 @@ def solve(user_params)->dict:
domain_size
[
0
],
domain_size
[
0
],
domain_size
[
1
],
domain_size
[
2
])
domain_size
[
1
],
domain_size
[
2
])
_
,
_
,
tke_spectrum_dilatational
=
compute_tke_spectrum
(
ud
,
vd
,
wd
,
_
,
_
,
tke_spectrum_dilatational
=
compute_tke_spectrum
(
u
-
us
,
v
-
vs
,
w
-
ws
,
domain_size
[
0
],
domain_size
[
1
],
domain_size
[
2
])
_
,
_
,
tke_spectrum_total
=
compute_tke_spectrum
(
u
,
v
,
w
,
domain_size
[
0
],
domain_size
[
0
],
domain_size
[
1
],
domain_size
[
2
])
domain_size
[
1
],
domain_size
[
2
])
real_spectrum
=
energy_spectrum
(
spectrum
,
wave_numbers
,
urms
,
k0
)
real_spectrum
=
energy_spectrum
(
spectrum
,
wave_numbers
,
urms
,
k0
)
solenoidal_spectrum_path
=
os
.
path
.
join
(
results_dir
,
"
spectrum_solenoidal.pdf
"
)
spectrum_path
=
os
.
path
.
join
(
results_dir
,
"
spectrum.pdf
"
)
dilatational_spectrum_path
=
os
.
path
.
join
(
results_dir
,
"
spectrum_dilatational.pdf
"
)
tke_spectrum
=
[
tke_spectrum_solenoidal
,
tke_spectrum_dilatational
,
tke_spectrum_total
,
real_spectrum
]
plot_spectrum
(
wmax
,
wave_numbers
,
tke_spectrum_solenoidal
,
real_spectrum
=
real_spectrum
,
save_path
=
solenoidal_spectrum_path
)
plot_spectrum
(
wmax
,
wave_numbers
,
tke_spectrum
,
save_path
=
spectrum_path
)
plot_spectrum
(
wmax
,
wave_numbers
,
tke_spectrum_dilatational
,
real_spectrum
=
real_spectrum
,
save_path
=
dilatational_spectrum_path
)
end
=
time
.
time
()
end
=
time
.
time
()
spectrum_time
=
end
-
start
spectrum_time
=
end
-
start
# Save the spectrum data
# Save the spectrum data
spectrum_data_path
=
os
.
path
.
join
(
results_dir
,
"
spectrum.dat
"
)
spectrum_data_path
=
os
.
path
.
join
(
results_dir
,
"
spectrum.dat
"
)
np
.
savetxt
(
spectrum_data_path
,
np
.
column_stack
((
wave_numbers
,
tke_spectrum_solenoidal
)),
header
=
"
wave_numbers tke_spectrum
"
)
np
.
savetxt
(
spectrum_data_path
,
np
.
column_stack
((
wave_numbers
,
tke_spectrum_solenoidal
,
tke_spectrum_dilatational
,
tke_spectrum_total
)),
header
=
"
wave_numbers solenoidal dilatational total
"
)
# Save the data
# Save the data
start
=
time
.
time
()
start
=
time
.
time
()
...
@@ -148,8 +153,7 @@ def solve(user_params)->dict:
...
@@ -148,8 +153,7 @@ def solve(user_params)->dict:
"
pressure
"
:
pressure
,
"
pressure
"
:
pressure
,
"
temperature
"
:
temperature
,
"
temperature
"
:
temperature
,
"
wave_numbers
"
:
wave_numbers
,
"
wave_numbers
"
:
wave_numbers
,
"
tke_spectrum_solenoidal
"
:
tke_spectrum_solenoidal
,
"
tke_spectrum
"
:
tke_spectrum
,
"
tke_spectrum_dilatational
"
:
tke_spectrum_dilatational
,
"
real_spectrum
"
:
real_spectrum
"
real_spectrum
"
:
real_spectrum
}
}
...
...
This diff is collapsed.
Click to expand it.
pyTurbulence/spectrum.py
+
8
−
9
View file @
4a9300b8
...
@@ -96,16 +96,15 @@ def compute_tke_spectrum(u : np.ndarray,v : np.ndarray,w : np.ndarray,
...
@@ -96,16 +96,15 @@ def compute_tke_spectrum(u : np.ndarray,v : np.ndarray,w : np.ndarray,
return
knyquist
,
kvals
,
tke_spectrum
return
knyquist
,
kvals
,
tke_spectrum
def
plot_spectrum
(
wmax
,
wave_numbers
,
tke_spectrum
,
real_spectrum
=
None
,
save_path
=
None
):
def
plot_spectrum
(
wmax
,
wave_numbers
,
tke_spectrum
,
save_path
=
None
):
plt
.
figure
()
plt
.
figure
()
plt
.
loglog
(
wave_numbers
,
tke_spectrum
,
'
o-
'
,
label
=
'
Computed Spectrum
'
)
plt
.
loglog
(
wave_numbers
,
tke_spectrum
[
0
],
'
o-
'
,
label
=
'
Solenoidal spectrum
'
)
plt
.
axvline
(
x
=
wmax
,
color
=
'
r
'
,
linestyle
=
'
--
'
,
label
=
'
Cut-off Wavenumber
'
)
plt
.
loglog
(
wave_numbers
,
tke_spectrum
[
1
],
'
o-
'
,
label
=
'
Dilatational spectrum
'
)
plt
.
loglog
(
wave_numbers
,
tke_spectrum
[
2
],
'
o-
'
,
label
=
'
Total spectrum
'
)
if
real_spectrum
is
not
None
:
plt
.
loglog
(
wave_numbers
,
tke_spectrum
[
3
],
'
k
'
,
label
=
'
Real Spectrum
'
)
plt
.
loglog
(
wave_numbers
,
real_spectrum
,
'
k
'
,
label
=
'
Real Spectrum
'
)
plt
.
axvline
(
x
=
wmax
,
color
=
'
r
'
,
linestyle
=
'
--
'
,
label
=
'
Cut-off Wavenumber
'
)
plt
.
xlabel
(
'
k
'
)
plt
.
xlabel
(
'
Wavenumber (k)
'
)
plt
.
ylabel
(
'
E(k)
'
)
plt
.
ylabel
(
'
Energy Spectrum (E(k))
'
)
# plt.ylim(np.min(tke_spectrum), 1.5*np.max(tke_spectrum))
# plt.ylim(np.min(tke_spectrum), 1.5*np.max(tke_spectrum))
plt
.
ylim
(
1e-6
,
1.5
*
np
.
max
(
tke_spectrum
))
plt
.
ylim
(
1e-6
,
1.5
*
np
.
max
(
tke_spectrum
))
plt
.
legend
()
plt
.
legend
()
...
...
This diff is collapsed.
Click to expand it.
pyTurbulence/syntheticTurbulence.py
+
7
−
7
View file @
4a9300b8
...
@@ -168,7 +168,7 @@ def compute_solenoidal_pressure(u: np.ndarray,v: np.ndarray,w: np.ndarray,
...
@@ -168,7 +168,7 @@ def compute_solenoidal_pressure(u: np.ndarray,v: np.ndarray,w: np.ndarray,
return
pressure
return
pressure
def
compute_thermodynamic_fields
(
mean_density
:
float
,
mean_pressure
:
float
,
mean_temperature
:
float
,
def
compute_thermodynamic_fields
(
mean_density
:
float
,
mean_pressure
:
float
,
mean_temperature
:
float
,
u
:
np
.
ndarray
,
v
:
np
.
ndarray
,
w
:
np
.
ndarray
,
u
s
:
np
.
ndarray
,
v
s
:
np
.
ndarray
,
w
s
:
np
.
ndarray
,
ud
:
np
.
ndarray
,
vd
:
np
.
ndarray
,
wd
:
np
.
ndarray
,
ud
:
np
.
ndarray
,
vd
:
np
.
ndarray
,
wd
:
np
.
ndarray
,
incompressible_pressure_fluctuations
:
np
.
ndarray
,
incompressible_pressure_fluctuations
:
np
.
ndarray
,
gamma
:
float
,
Mt
:
float
,
case
:
int
)
->
Tuple
[
np
.
ndarray
,
np
.
ndarray
,
np
.
ndarray
,
gamma
:
float
,
Mt
:
float
,
case
:
int
)
->
Tuple
[
np
.
ndarray
,
np
.
ndarray
,
np
.
ndarray
,
...
@@ -186,11 +186,11 @@ def compute_thermodynamic_fields(mean_density : float, mean_pressure : float, me
...
@@ -186,11 +186,11 @@ def compute_thermodynamic_fields(mean_density : float, mean_pressure : float, me
Mean pressure.
Mean pressure.
mean_temperature : float
mean_temperature : float
Mean temperature.
Mean temperature.
u : np.ndarray
u
s
: np.ndarray
Solenoidal velocity component in the x-direction.
Solenoidal velocity component in the x-direction.
v : np.ndarray
v
s
: np.ndarray
Solenoidal velocity component in the y-direction.
Solenoidal velocity component in the y-direction.
w : np.ndarray
w
s
: np.ndarray
Solenoidal velocity component in the z-direction.
Solenoidal velocity component in the z-direction.
ud : np.ndarray
ud : np.ndarray
Dilatational velocity component in the x-direction.
Dilatational velocity component in the x-direction.
...
@@ -227,9 +227,9 @@ def compute_thermodynamic_fields(mean_density : float, mean_pressure : float, me
...
@@ -227,9 +227,9 @@ def compute_thermodynamic_fields(mean_density : float, mean_pressure : float, me
if
case
==
0
:
Mt
=
0.0
# no fluctuations case
if
case
==
0
:
Mt
=
0.0
# no fluctuations case
compressible_pressure_fluctuations
=
incompressible_pressure_fluctuations
*
gamma
*
Mt
**
2
compressible_pressure_fluctuations
=
incompressible_pressure_fluctuations
*
gamma
*
Mt
**
2
u
+
=
ud
*
gamma
*
Mt
**
2
u
=
us
+
ud
*
gamma
*
Mt
**
2
v
+
=
vd
*
gamma
*
Mt
**
2
v
=
vs
+
vd
*
gamma
*
Mt
**
2
w
+
=
wd
*
gamma
*
Mt
**
2
w
=
ws
+
wd
*
gamma
*
Mt
**
2
# Assuming R = 1 and rho' = overGamma*p'
# Assuming R = 1 and rho' = overGamma*p'
compressible_density_fluctuations
=
overGamma
*
compressible_pressure_fluctuations
compressible_density_fluctuations
=
overGamma
*
compressible_pressure_fluctuations
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment