Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
QuickSched
Commits
f8422742
Commit
f8422742
authored
10 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added a script to generate Gadget-2 HDF5 initial conditions from the BH particle dump.
parent
3dff5bf5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/make_gadget_ic.py
+48
-0
48 additions, 0 deletions
examples/make_gadget_ic.py
with
48 additions
and
0 deletions
examples/make_gadget_ic.py
0 → 100644
+
48
−
0
View file @
f8422742
import
h5py
import
numpy
as
np
import
sys
inputName
=
"
particle_dump.dat
"
outputName
=
"
particle_dump.hdf5
"
boxSize
=
1.
if
len
(
sys
.
argv
)
>
1
:
inputName
=
sys
.
argv
[
1
]
outputName
=
sys
.
argv
[
2
]
print
"
Reading
"
,
inputName
data
=
np
.
loadtxt
(
inputName
)
IDs
=
data
[:,
0
]
mass
=
data
[:,
1
]
pos
=
data
[:,
2
:
5
]
numPart
=
np
.
size
(
IDs
)
print
"
Found
"
,
numPart
,
"
particles
"
# Create file
print
"
Writing
"
,
outputName
f
=
h5py
.
File
(
"
particle_dump.hdf5
"
,
"
w
"
)
# Write particles
grp
=
f
.
create_group
(
"
PartType1
"
)
grp
.
create_dataset
(
"
Coordinates
"
,
(
numPart
,
3
),
data
=
pos
)
grp
.
create_dataset
(
"
Velocities
"
,
(
numPart
,
3
),
data
=
np
.
zeros
(
np
.
shape
(
pos
)))
grp
.
create_dataset
(
"
Masses
"
,
(
numPart
,
1
),
data
=
mass
)
grp
.
create_dataset
(
"
ParticleIDs
"
,
(
numPart
,
1
),
data
=
IDs
,
dtype
=
'
i
'
)
#Write header
grp
=
f
.
create_group
(
"
Header
"
)
grp
.
attrs
.
create
(
"
BoxSize
"
,
boxSize
,
dtype
=
'
d
'
)
grp
.
attrs
.
create
(
"
Flag_Entropy_ICs
"
,
np
.
array
([
0
,
0
,
0
,
0
,
0
,
0
]),
dtype
=
'
i
'
)
grp
.
attrs
.
create
(
"
MassTable
"
,
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
]),
dtype
=
'
d
'
)
grp
.
attrs
.
create
(
"
NumFilesPerSnapshot
"
,
1.
,
dtype
=
'
i
'
)
grp
.
attrs
.
create
(
"
NumPart_ThisFile
"
,
np
.
array
([
0
,
numPart
,
0
,
0
,
0
,
0
]),
dtype
=
'
i
'
)
grp
.
attrs
.
create
(
"
NumPart_Total
"
,
np
.
array
([
0
,
numPart
,
0
,
0
,
0
,
0
]),
dtype
=
'
i
'
)
grp
.
attrs
.
create
(
"
NumPart_HighWord
"
,
np
.
array
([
0
,
0
,
0
,
0
,
0
,
0
]),
dtype
=
'
i
'
)
grp
.
attrs
.
create
(
"
Time
"
,
0.
,
dtype
=
'
d
'
)
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