Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
743713e3
Commit
743713e3
authored
7 years ago
by
lhausamm
Browse files
Options
Downloads
Patches
Plain Diff
Read config.h in makeInput.py
parent
ba230049
No related branches found
No related tags found
1 merge request
!486
Add chemistry in part
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/makeInput.py
+21
-5
21 additions, 5 deletions
tests/makeInput.py
tests/testReading.c
+2
-3
2 additions, 3 deletions
tests/testReading.c
with
23 additions
and
8 deletions
tests/makeInput.py
+
21
−
5
View file @
743713e3
...
...
@@ -19,6 +19,7 @@
import
h5py
from
numpy
import
*
import
re
as
regex
# Generates a swift IC file containing a cartesian distribution of particles
# at a constant density and pressure in a cubic box
...
...
@@ -32,12 +33,24 @@ P = 1. # Pressure
gamma
=
5.
/
3.
# Gas adiabatic index
fileName
=
"
input.hdf5
"
# read flags from config.h
flags
=
{}
config_file
=
"
../config.h
"
with
open
(
config_file
,
"
r
"
)
as
f
:
reg
=
"
#define (\w*) (.*)
\n
"
for
line
in
f
:
m
=
regex
.
match
(
reg
,
line
)
if
m
:
flags
[
m
.
group
(
1
)]
=
m
.
group
(
2
)
cooling_grackle
=
"
COOLING_GRACKLE
"
in
flags
#---------------------------------------------------
numPart
=
L
**
3
mass
=
boxSize
**
3
*
rho
/
numPart
internalEnergy
=
P
/
((
gamma
-
1.
)
*
rho
)
he_density
=
rho
*
0.24
if
cooling_grackle
:
he_density
=
rho
*
0.24
#Generate particles
coords
=
zeros
((
numPart
,
3
))
...
...
@@ -46,7 +59,8 @@ m = zeros((numPart, 1))
h
=
zeros
((
numPart
,
1
))
u
=
zeros
((
numPart
,
1
))
ids
=
zeros
((
numPart
,
1
),
dtype
=
'
L
'
)
he
=
zeros
((
numPart
,
1
))
if
cooling_grackle
:
he
=
zeros
((
numPart
,
1
))
for
i
in
range
(
L
):
for
j
in
range
(
L
):
...
...
@@ -65,7 +79,8 @@ for i in range(L):
h
[
index
]
=
2.251
*
boxSize
/
L
u
[
index
]
=
internalEnergy
ids
[
index
]
=
index
he
[
index
]
=
he_density
if
cooling_grackle
:
he
[
index
]
=
he_density
#--------------------------------------------------
...
...
@@ -112,7 +127,8 @@ ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f')
ds
[()]
=
u
ds
=
grp
.
create_dataset
(
'
ParticleIDs
'
,
(
numPart
,
1
),
'
L
'
)
ds
[()]
=
ids
ds
=
grp
.
create_dataset
(
'
HeDensity
'
,
(
numPart
,
1
),
'
f
'
)
ds
[()]
=
he
if
cooling_grackle
:
ds
=
grp
.
create_dataset
(
'
HeDensity
'
,
(
numPart
,
1
),
'
f
'
)
ds
[()]
=
he
file
.
close
()
This diff is collapsed.
Click to expand it.
tests/testReading.c
+
2
−
3
View file @
743713e3
...
...
@@ -42,7 +42,9 @@ int main() {
const
double
boxSize
=
1
.;
const
size_t
L
=
4
;
const
double
rho
=
2
.;
#ifdef COOLING_GRACKLE
const
float
He_density
=
rho
*
0
.
24
;
#endif
/* Read data */
read_ic_single
(
"input.hdf5"
,
&
us
,
dim
,
&
parts
,
&
gparts
,
&
sparts
,
&
Ngas
,
...
...
@@ -95,9 +97,6 @@ int main() {
assert
(
parts
[
n
].
a_hydro
[
2
]
==
0
.);
#ifdef COOLING_GRACKLE
printf
(
"Test %g, %g, %g
\n
"
,
parts
[
n
].
cooling_data
.
He_density
,
He_density
,
parts
[
n
].
cooling_data
.
He_density
-
He_density
);
assert
(
parts
[
n
].
cooling_data
.
He_density
==
He_density
);
#endif
}
...
...
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