Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TurTLE
TurTLE
Commits
60d3ba85
Commit
60d3ba85
authored
Jan 21, 2020
by
Lukas Bentkamp
Committed by
Cristian Lalescu
Jan 30, 2020
Browse files
testing Gaussian field on cluster
parent
9953edec
Changes
1
Hide whitespace changes
Inline
Side-by-side
TurTLE/test/test_Gaussian_field.py
View file @
60d3ba85
...
...
@@ -5,7 +5,7 @@ from scipy import trapz
from
scipy.stats
import
norm
from
scipy.integrate
import
quad
import
h5py
import
sys
import
sys
,
os
import
time
import
TurTLE
...
...
@@ -17,7 +17,6 @@ except:
plt
=
None
def
main
():
c
=
TEST
()
# size of grid
n
=
1024
slope
=
-
5.
/
3.
...
...
@@ -29,23 +28,27 @@ def main():
rseed
=
int
(
time
.
time
())
simname
=
'Gaussianity_test'
opt
=
c
.
launch
(
[
'Gauss_field_test'
,
'--nx'
,
str
(
n
),
'--ny'
,
str
(
n
),
'--nz'
,
str
(
n
),
'--simname'
,
simname
,
'--np'
,
'4'
,
'--ntpp'
,
'1'
,
'--wd'
,
'./'
,
'--histogram_bins'
,
str
(
bin_no
),
'--max_velocity_estimate'
,
'8.'
,
'--spectrum_slope'
,
str
(
slope
),
'--spectrum_k_cutoff'
,
str
(
k_cutoff
),
'--spectrum_coefficient'
,
str
(
coeff
),
'--field_random_seed'
,
str
(
rseed
)]
+
sys
.
argv
[
1
:])
plot_stuff
(
c
.
simname
,
total_energy
=
total_energy
)
if
not
os
.
path
.
exists
(
simname
+
'.h5'
):
c
=
TEST
()
opt
=
c
.
launch
(
[
'Gauss_field_test'
,
'--nx'
,
str
(
n
),
'--ny'
,
str
(
n
),
'--nz'
,
str
(
n
),
'--simname'
,
simname
,
'--np'
,
'4'
,
'--environment'
,
'short'
,
'--minutes'
,
'60'
,
'--ntpp'
,
'1'
,
'--wd'
,
'./'
,
'--histogram_bins'
,
str
(
bin_no
),
'--max_velocity_estimate'
,
'8.'
,
'--spectrum_slope'
,
str
(
slope
),
'--spectrum_k_cutoff'
,
str
(
k_cutoff
),
'--spectrum_coefficient'
,
str
(
coeff
),
'--field_random_seed'
,
str
(
rseed
)]
+
sys
.
argv
[
1
:])
plot_stuff
(
simname
,
total_energy
=
total_energy
)
return
None
def
plot_stuff
(
simname
,
total_energy
=
1.
):
...
...
@@ -107,12 +110,12 @@ def plot_stuff(simname, total_energy = 1.):
print
(
'----------- k2-premultiplied spectrum -----------'
)
k2func
=
lambda
k
,
k_c
=
k_cutoff
,
s
=
slope
:
k
**
(
2
+
s
)
*
np
.
exp
(
-
k
/
k_c
)
k2sum_analytic
=
quad
(
k2func
,
0
,
k_cutoff
*
20
)[
0
]
print
(
'Analytically: {}'
.
format
(
k2sum_analytic
))
print
(
'Analytically: {}'
.
format
(
coeff
*
k2sum_analytic
))
k2spec_trace
=
(
df
[
'statistics/spectra/k*velocity_k*velocity'
][...,
0
,
0
]
+
df
[
'statistics/spectra/k*velocity_k*velocity'
][...,
1
,
1
]
+
df
[
'statistics/spectra/k*velocity_k*velocity'
][...,
2
,
2
])
print
(
'Energy sum: {}'
.
format
(
np
.
sum
(
k2spec_trace
*
df
[
'kspace/dk'
][()])))
print
(
'Energy sum: {}'
.
format
(
np
.
sum
(
k2spec_trace
*
df
[
'kspace/dk'
][()])
/
2.
))
df
.
close
()
return
None
...
...
Write
Preview
Markdown
is supported
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