Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
TurTLE
TurTLE
Commits
9953edec
Commit
9953edec
authored
5 years ago
by
Lukas Bentkamp
Committed by
Cristian Lalescu
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Testing the premultiplied spectrum
parent
946d44c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
TurTLE/TEST.py
+1
-0
1 addition, 0 deletions
TurTLE/TEST.py
TurTLE/test/test_Gaussian_field.py
+32
-19
32 additions, 19 deletions
TurTLE/test/test_Gaussian_field.py
cpp/full_code/Gauss_field_test.cpp
+8
-0
8 additions, 0 deletions
cpp/full_code/Gauss_field_test.cpp
cpp/kspace.cpp
+1
-0
1 addition, 0 deletions
cpp/kspace.cpp
with
42 additions
and
19 deletions
TurTLE/TEST.py
+
1
−
0
View file @
9953edec
...
...
@@ -188,6 +188,7 @@ class TEST(_code):
scal_rspace_stats
=
[]
if
self
.
dns_type
in
[
'
Gauss_field_test
'
]:
vec_spectra_stats
.
append
(
'
velocity
'
)
vec_spectra_stats
.
append
(
'
k*velocity
'
)
vec4_rspace_stats
.
append
(
'
velocity
'
)
tens_rspace_stats
.
append
(
'
velocity_gradient
'
)
scal_rspace_stats
.
append
(
'
velocity_divergence
'
)
...
...
This diff is collapsed.
Click to expand it.
TurTLE/test/test_Gaussian_field.py
+
32
−
19
View file @
9953edec
...
...
@@ -19,21 +19,22 @@ except:
def
main
():
c
=
TEST
()
# size of grid
n
=
256
n
=
1024
slope
=
-
5.
/
3.
k_cutoff
=
30
.
k_cutoff
=
64
.
func
=
lambda
k
,
k_c
=
k_cutoff
,
s
=
slope
:
k
**
s
*
np
.
exp
(
-
k
/
k_c
)
total_energy
=
quad
(
func
,
1
,
k_cutoff
*
4
)[
0
]
total_energy
=
quad
(
func
,
0.6
,
k_cutoff
*
8
)[
0
]
coeff
=
1.
/
total_energy
bin_no
=
100
rseed
=
int
(
time
.
time
())
simname
=
'
Gaussianity_test
'
c
.
launch
(
opt
=
c
.
launch
(
[
'
Gauss_field_test
'
,
'
--nx
'
,
str
(
n
),
'
--ny
'
,
str
(
n
),
'
--nz
'
,
str
(
n
),
'
--simname
'
,
'
Gaussianity_test
'
,
'
--simname
'
,
simname
,
'
--np
'
,
'
4
'
,
'
--ntpp
'
,
'
1
'
,
'
--wd
'
,
'
./
'
,
...
...
@@ -82,6 +83,7 @@ def plot_stuff(simname, total_energy = 1.):
f_vel
=
hist_vel
/
np
.
sum
(
hist_vel
,
axis
=
0
,
keepdims
=
True
).
astype
(
float
)
/
velbinsize
print
(
'
Energy analytically: {}
'
.
format
(
total_energy
))
print
(
np
.
sum
(
energy
*
np
.
arange
(
len
(
energy
))
**
2
))
print
(
'
Energy sum: {}
'
.
format
(
np
.
sum
(
energy
*
df
[
'
kspace/dk
'
][()])))
print
(
'
Moment sum: {}
'
.
format
(
df
[
'
statistics/moments/velocity
'
][
0
,
2
,
3
]
/
2
))
print
(
'
Velocity variances: {}
'
.
format
(
trapz
(
vel
[:,
None
]
**
2
*
f_vel
,
vel
[:,
None
],
axis
=
0
)))
...
...
@@ -101,6 +103,17 @@ def plot_stuff(simname, total_energy = 1.):
df
[
'
statistics/moments/velocity_divergence
'
][
0
,
2
]))
print
(
'
Gradient second moment is: {0}
'
.
format
(
df
[
'
statistics/moments/velocity_gradient
'
][
0
,
2
].
mean
()))
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
))
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
'
][()])))
df
.
close
()
return
None
...
...
This diff is collapsed.
Click to expand it.
cpp/full_code/Gauss_field_test.cpp
+
8
−
0
View file @
9953edec
...
...
@@ -144,6 +144,14 @@ int Gauss_field_test<rnumber>::do_work(void)
this
->
vector_field
,
this
->
scalar_field
);
/// compute integral of premultiplied energy spectrum
this
->
kk
->
cospectrum
<
rnumber
,
THREE
>
(
this
->
vector_field
->
get_cdata
(),
stat_group
,
"k*velocity_k*velocity"
,
0
,
2.
);
/// compute basic statistics of Gaussian field
this
->
vector_field
->
compute_stats
(
this
->
kk
,
...
...
This diff is collapsed.
Click to expand it.
cpp/kspace.cpp
+
1
−
0
View file @
9953edec
...
...
@@ -783,6 +783,7 @@ void kspace<be, dt>::cospectrum(
{
double
*
spec_local
=
spec_local_thread
.
getMine
();
int
tmp_int
=
int
(
sqrt
(
k2
)
/
this
->
dk
)
*
ncomp
(
fc
)
*
ncomp
(
fc
);
for
(
hsize_t
i
=
0
;
i
<
ncomp
(
fc
);
i
++
)
for
(
hsize_t
j
=
0
;
j
<
ncomp
(
fc
);
j
++
){
spec_local
[
tmp_int
+
i
*
ncomp
(
fc
)
+
j
]
+=
pow
(
k2
,
wavenumber_exp
/
2.
)
*
...
...
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