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
fab7b536
Commit
fab7b536
authored
5 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
adds stat computation for Gaussian field test
parent
e0bf5553
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TurTLE/TEST.py
+38
-0
38 additions, 0 deletions
TurTLE/TEST.py
TurTLE/test/test_Gaussian_field.py
+50
-0
50 additions, 0 deletions
TurTLE/test/test_Gaussian_field.py
cpp/full_code/Gauss_field_test.cpp
+42
-9
42 additions, 9 deletions
cpp/full_code/Gauss_field_test.cpp
with
130 additions
and
9 deletions
TurTLE/TEST.py
+
38
−
0
View file @
fab7b536
...
@@ -129,6 +129,12 @@ class TEST(_code):
...
@@ -129,6 +129,12 @@ class TEST(_code):
pars
[
'
tracers0_integration_steps
'
]
=
int
(
4
)
pars
[
'
tracers0_integration_steps
'
]
=
int
(
4
)
pars
[
'
tracers0_neighbours
'
]
=
int
(
1
)
pars
[
'
tracers0_neighbours
'
]
=
int
(
1
)
pars
[
'
tracers0_smoothness
'
]
=
int
(
1
)
pars
[
'
tracers0_smoothness
'
]
=
int
(
1
)
if
dns_type
==
'
Gauss_field_test
'
:
pars
[
'
histogram_bins
'
]
=
129
pars
[
'
max_velocity_estimate
'
]
=
8.
pars
[
'
spectrum_slope
'
]
=
1.
pars
[
'
spectrum_k_cutoff
'
]
=
16.
pars
[
'
spectrum_coefficient
'
]
=
1.
return
pars
return
pars
def
get_kspace
(
self
):
def
get_kspace
(
self
):
kspace
=
{}
kspace
=
{}
...
@@ -175,6 +181,38 @@ class TEST(_code):
...
@@ -175,6 +181,38 @@ class TEST(_code):
kspace
=
self
.
get_kspace
()
kspace
=
self
.
get_kspace
()
nshells
=
kspace
[
'
nshell
'
].
shape
[
0
]
nshells
=
kspace
[
'
nshell
'
].
shape
[
0
]
ofile
[
'
checkpoint
'
]
=
int
(
0
)
ofile
[
'
checkpoint
'
]
=
int
(
0
)
vec_stat_datasets
=
[]
scal_stat_datasets
=
[]
if
self
.
dns_type
in
[
'
Gauss_field_test
'
]:
vec_stat_datasets
.
append
(
'
velocity
'
)
for
k
in
vec_stat_datasets
:
time_chunk
=
2
**
20
//
(
8
*
3
*
3
*
nshells
)
time_chunk
=
max
(
time_chunk
,
1
)
ofile
.
create_dataset
(
'
statistics/spectra/
'
+
k
+
'
_
'
+
k
,
(
1
,
nshells
,
3
,
3
),
chunks
=
(
time_chunk
,
nshells
,
3
,
3
),
maxshape
=
(
None
,
nshells
,
3
,
3
),
dtype
=
np
.
float64
)
time_chunk
=
2
**
20
//
(
8
*
4
*
10
)
time_chunk
=
max
(
time_chunk
,
1
)
a
=
ofile
.
create_dataset
(
'
statistics/moments/
'
+
k
,
(
1
,
10
,
4
),
chunks
=
(
time_chunk
,
10
,
4
),
maxshape
=
(
None
,
10
,
4
),
dtype
=
np
.
float64
)
time_chunk
=
2
**
20
//
(
8
*
4
*
self
.
parameters
[
'
histogram_bins
'
])
time_chunk
=
max
(
time_chunk
,
1
)
ofile
.
create_dataset
(
'
statistics/histograms/
'
+
k
,
(
1
,
self
.
parameters
[
'
histogram_bins
'
],
4
),
chunks
=
(
time_chunk
,
self
.
parameters
[
'
histogram_bins
'
],
4
),
maxshape
=
(
None
,
self
.
parameters
[
'
histogram_bins
'
],
4
),
dtype
=
np
.
int64
)
return
None
return
None
def
job_parser_arguments
(
def
job_parser_arguments
(
self
,
self
,
...
...
This diff is collapsed.
Click to expand it.
TurTLE/test/test_Gaussian_field.py
0 → 100644
+
50
−
0
View file @
fab7b536
#! /usr/bin/env python
import
numpy
as
np
import
h5py
import
sys
import
TurTLE
from
TurTLE
import
TEST
try
:
import
matplotlib.pyplot
as
plt
except
:
plt
=
None
def
main
():
c
=
TEST
()
# size of grid
n
=
64
c
.
launch
(
[
'
Gauss_field_test
'
,
'
--nx
'
,
str
(
n
),
'
--ny
'
,
str
(
n
),
'
--nz
'
,
str
(
n
),
'
--simname
'
,
'
Gaussianity_test
'
,
'
--np
'
,
'
4
'
,
'
--ntpp
'
,
'
1
'
,
'
--wd
'
,
'
./
'
]
+
sys
.
argv
[
1
:])
df
=
h5py
.
File
(
c
.
simname
+
'
.h5
'
,
'
r
'
)
f
=
plt
.
figure
()
# test spectrum
a
=
f
.
add_subplot
(
121
)
kk
=
df
[
'
kspace/kshell
'
][...]
phi_ij
=
df
[
'
statistics/spectra/velocity_velocity
'
][
0
]
energy
=
(
phi_ij
[...,
0
,
0
]
+
phi_ij
[...,
1
,
1
]
+
phi_ij
[...,
2
,
2
])
/
2
a
.
plot
(
kk
,
energy
)
a
.
set_xscale
(
'
log
'
)
a
.
set_yscale
(
'
log
'
)
# test isotropy
a
=
f
.
add_subplot
(
122
)
a
.
plot
(
df
[
'
statistics/histograms/velocity
'
][
0
,
:,
:
3
])
f
.
tight_layout
()
f
.
savefig
(
'
spectrum_isotropy_test.pdf
'
)
df
.
close
()
return
None
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
cpp/full_code/Gauss_field_test.cpp
+
42
−
9
View file @
fab7b536
...
@@ -160,17 +160,50 @@ template <typename rnumber>
...
@@ -160,17 +160,50 @@ template <typename rnumber>
int
Gauss_field_test
<
rnumber
>::
do_work
(
void
)
int
Gauss_field_test
<
rnumber
>::
do_work
(
void
)
{
{
TIMEZONE
(
"Gauss_field_test::do_work"
);
TIMEZONE
(
"Gauss_field_test::do_work"
);
make_gaussian_random_field
(
this
->
kk
,
this
->
scalar_field
);
/// initialize vector Gaussian random field
make_gaussian_random_field
(
this
->
kk
,
this
->
vector_field
,
3
);
make_gaussian_random_field
(
this
->
kk
,
this
->
vector_field
,
3
);
DEBUG_MSG
(
"L2norm = %g
\n
"
,
this
->
vector_field
->
L2norm
(
this
->
kk
));
/// impose divergence free condition while maintaining the energy of the field
this
->
kk
->
template
project_divfree
<
rnumber
>(
this
->
vector_field
->
get_cdata
(),
true
);
this
->
kk
->
template
project_divfree
<
rnumber
>(
this
->
vector_field
->
get_cdata
(),
true
);
DEBUG_MSG
(
"L2norm = %g
\n
"
,
this
->
vector_field
->
L2norm
(
this
->
kk
));
this
->
kk
->
template
project_divfree
<
rnumber
>(
this
->
vector_field
->
get_cdata
());
/// initialize statistics file.
DEBUG_MSG
(
"L2norm = %g
\n
"
,
this
->
vector_field
->
L2norm
(
this
->
kk
));
hid_t
stat_group
,
stat_file
;
make_gaussian_random_field
(
this
->
kk
,
this
->
vector_field
,
3
);
if
(
this
->
myrank
==
0
)
DEBUG_MSG
(
"L2norm = %g
\n
"
,
this
->
vector_field
->
L2norm
(
this
->
kk
));
{
this
->
kk
->
template
project_divfree
<
rnumber
>(
this
->
vector_field
->
get_cdata
());
// set caching parameters
DEBUG_MSG
(
"L2norm = %g
\n
"
,
this
->
vector_field
->
L2norm
(
this
->
kk
));
hid_t
fapl
=
H5Pcreate
(
H5P_FILE_ACCESS
);
herr_t
cache_err
=
H5Pset_cache
(
fapl
,
0
,
521
,
134217728
,
1.0
);
DEBUG_MSG
(
"when setting stat_file cache I got %d
\n
"
,
cache_err
);
stat_file
=
H5Fopen
(
(
this
->
simname
+
".h5"
).
c_str
(),
H5F_ACC_RDWR
,
fapl
);
stat_group
=
H5Gopen
(
stat_file
,
"statistics"
,
H5P_DEFAULT
);
}
else
{
stat_file
=
0
;
stat_group
=
0
;
}
/// compute basic statistics of Gaussian field
this
->
vector_field
->
compute_stats
(
this
->
kk
,
stat_group
,
"velocity"
,
0
,
8.
);
/// close stat file
if
(
this
->
myrank
==
0
)
{
H5Gclose
(
stat_group
);
H5Fclose
(
stat_file
);
}
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
...
...
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