Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
5e2482a0
Commit
5e2482a0
authored
Jul 11, 2017
by
Loikki
Browse files
Check if snapshot directory exists and add a digit to the output
#321
parent
81269f6a
Changes
33
Hide whitespace changes
Inline
Side-by-side
examples/CoolingBox/energy_plot.py
View file @
5e2482a0
...
...
@@ -34,7 +34,7 @@ import sys
stats_filename
=
"./energy.txt"
# First snapshot
snap_filename
=
"coolingBox_000.hdf5"
snap_filename
=
"coolingBox_000
0
.hdf5"
# Some constants in cgs units
k_b
=
1.38E-16
#boltzmann
...
...
@@ -104,7 +104,7 @@ print "Cooling time:", cooling_time_cgs, "[s]"
u_snapshots_cgs
=
zeros
(
25
)
t_snapshots_cgs
=
zeros
(
25
)
for
i
in
range
(
25
):
snap
=
h5
.
File
(
"coolingBox_%0.
3
d.hdf5"
%
i
,
'r'
)
snap
=
h5
.
File
(
"coolingBox_%0.
4
d.hdf5"
%
i
,
'r'
)
u_snapshots_cgs
[
i
]
=
sum
(
snap
[
"/PartType0/InternalEnergy"
][:]
*
snap
[
"/PartType0/Masses"
][:])
/
total_mass
[
0
]
*
unit_length
**
2
/
(
unit_time
)
**
2
t_snapshots_cgs
[
i
]
=
snap
[
"/Header"
].
attrs
[
"Time"
]
*
unit_time
...
...
examples/CoolingHalo/density_profile.py
View file @
5e2482a0
...
...
@@ -20,7 +20,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -39,7 +39,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHalo/internal_energy_profile.py
View file @
5e2482a0
...
...
@@ -38,7 +38,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -57,7 +57,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHalo/test_energy_conservation.py
View file @
5e2482a0
...
...
@@ -17,7 +17,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -41,7 +41,7 @@ time_array_cgs = []
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHalo/velocity_profile.py
View file @
5e2482a0
...
...
@@ -39,7 +39,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -58,7 +58,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHaloWithSpin/density_profile.py
View file @
5e2482a0
...
...
@@ -21,7 +21,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -42,7 +42,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHaloWithSpin/internal_energy_profile.py
View file @
5e2482a0
...
...
@@ -39,7 +39,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -60,7 +60,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHaloWithSpin/test_energy_conservation.py
View file @
5e2482a0
...
...
@@ -20,7 +20,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -44,7 +44,7 @@ time_array_cgs = []
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/CoolingHaloWithSpin/velocity_profile.py
View file @
5e2482a0
...
...
@@ -39,7 +39,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"CoolingHalo_000.hdf5"
filename
=
"CoolingHalo_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -58,7 +58,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"CoolingHalo_%0
3
d.hdf5"
%
i
filename
=
"CoolingHalo_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/ExternalPointMass/energy_plot.py
View file @
5e2482a0
...
...
@@ -34,7 +34,7 @@ import sys
stats_filename
=
"./energy.txt"
# First snapshot
snap_filename
=
"pointMass_000.hdf5"
snap_filename
=
"pointMass_000
0
.hdf5"
f
=
h5
.
File
(
snap_filename
,
'r'
)
# Read the units parameters from the snapshot
...
...
@@ -71,7 +71,7 @@ Lz_snap = np.zeros(402)
# Read all the particles from the snapshots
for
i
in
range
(
402
):
snap_filename
=
"pointMass_%0.
3
d.hdf5"
%
i
snap_filename
=
"pointMass_%0.
4
d.hdf5"
%
i
f
=
h5
.
File
(
snap_filename
,
'r'
)
pos_x
=
f
[
"PartType1/Coordinates"
][:,
0
]
...
...
examples/Gradients/run.sh
View file @
5e2482a0
...
...
@@ -2,12 +2,12 @@
python makeICs.py stretched
../swift
-s
-t
2 gradientsStretched.yml
python plot.py gradients_stretched_001.hdf5 stretched
python plot.py gradients_stretched_00
0
1.hdf5 stretched
python makeICs.py cartesian
../swift
-s
-t
2 gradientsCartesian.yml
python plot.py gradients_cartesian_001.hdf5 cartesian
python plot.py gradients_cartesian_00
0
1.hdf5 cartesian
python makeICs.py random
../swift
-s
-t
2 gradientsRandom.yml
python plot.py gradients_random_001.hdf5 random
python plot.py gradients_random_00
0
1.hdf5 random
examples/GreshoVortex_2D/plotSolution.py
View file @
5e2482a0
...
...
@@ -83,7 +83,7 @@ solution_s = solution_P / solution_rho**gas_gamma
solution_u
=
solution_P
/
((
gas_gamma
-
1.
)
*
solution_rho
)
# Read the simulation data
sim
=
h5py
.
File
(
"gresho_%0
3
d.hdf5"
%
snap
,
"r"
)
sim
=
h5py
.
File
(
"gresho_%0
4
d.hdf5"
%
snap
,
"r"
)
boxSize
=
sim
[
"/Header"
].
attrs
[
"BoxSize"
][
0
]
time
=
sim
[
"/Header"
].
attrs
[
"Time"
][
0
]
scheme
=
sim
[
"/HydroScheme"
].
attrs
[
"Scheme"
]
...
...
examples/HydrostaticHalo/density_profile.py
View file @
5e2482a0
...
...
@@ -42,7 +42,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -63,7 +63,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/HydrostaticHalo/internal_energy_profile.py
View file @
5e2482a0
...
...
@@ -60,7 +60,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -79,7 +79,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/HydrostaticHalo/test_energy_conservation.py
View file @
5e2482a0
...
...
@@ -38,7 +38,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -62,7 +62,7 @@ time_array_cgs = []
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/HydrostaticHalo/velocity_profile.py
View file @
5e2482a0
...
...
@@ -60,7 +60,7 @@ H_0_cgs = 100. * h * KM_PER_SEC_IN_CGS / (1.0e6 * PARSEC_IN_CGS)
#read some header/parameter information from the first snapshot
filename
=
"Hydrostatic_000.hdf5"
filename
=
"Hydrostatic_000
0
.hdf5"
f
=
h5
.
File
(
filename
,
'r'
)
params
=
f
[
"Parameters"
]
unit_mass_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitMass_in_cgs"
])
...
...
@@ -79,7 +79,7 @@ M_vir_cgs = r_vir_cgs * v_c_cgs**2 / CONST_G_CGS
for
i
in
range
(
n_snaps
):
filename
=
"Hydrostatic_%0
3
d.hdf5"
%
i
filename
=
"Hydrostatic_%0
4
d.hdf5"
%
i
f
=
h5
.
File
(
filename
,
'r'
)
coords_dset
=
f
[
"PartType0/Coordinates"
]
coords
=
np
.
array
(
coords_dset
)
...
...
examples/IsothermalPotential/energy_plot.py
View file @
5e2482a0
...
...
@@ -34,7 +34,7 @@ import sys
stats_filename
=
"./energy.txt"
# First snapshot
snap_filename
=
"Isothermal_000.hdf5"
snap_filename
=
"Isothermal_000
0
.hdf5"
f
=
h5
.
File
(
snap_filename
,
'r'
)
# Read the units parameters from the snapshot
...
...
@@ -70,7 +70,7 @@ Lz_snap = np.zeros(402)
# Read all the particles from the snapshots
for
i
in
range
(
402
):
snap_filename
=
"Isothermal_%0.
3
d.hdf5"
%
i
snap_filename
=
"Isothermal_%0.
4
d.hdf5"
%
i
f
=
h5
.
File
(
snap_filename
,
'r'
)
pos_x
=
f
[
"PartType1/Coordinates"
][:,
0
]
...
...
examples/KelvinHelmholtz_2D/plotSolution.py
View file @
5e2482a0
...
...
@@ -63,7 +63,7 @@ rc('font',**{'family':'sans-serif','sans-serif':['Times']})
snap
=
int
(
sys
.
argv
[
1
])
# Read the simulation data
sim
=
h5py
.
File
(
"kelvinHelmholtz_%0
3
d.hdf5"
%
snap
,
"r"
)
sim
=
h5py
.
File
(
"kelvinHelmholtz_%0
4
d.hdf5"
%
snap
,
"r"
)
boxSize
=
sim
[
"/Header"
].
attrs
[
"BoxSize"
][
0
]
time
=
sim
[
"/Header"
].
attrs
[
"Time"
][
0
]
scheme
=
sim
[
"/HydroScheme"
].
attrs
[
"Scheme"
]
...
...
examples/Noh_1D/plotSolution.py
View file @
5e2482a0
...
...
@@ -58,7 +58,7 @@ snap = int(sys.argv[1])
# Read the simulation data
sim
=
h5py
.
File
(
"noh_%0
3
d.hdf5"
%
snap
,
"r"
)
sim
=
h5py
.
File
(
"noh_%0
4
d.hdf5"
%
snap
,
"r"
)
boxSize
=
sim
[
"/Header"
].
attrs
[
"BoxSize"
][
0
]
time
=
sim
[
"/Header"
].
attrs
[
"Time"
][
0
]
scheme
=
sim
[
"/HydroScheme"
].
attrs
[
"Scheme"
]
...
...
examples/Noh_2D/plotSolution.py
View file @
5e2482a0
...
...
@@ -58,7 +58,7 @@ rc('font',**{'family':'sans-serif','sans-serif':['Times']})
snap
=
int
(
sys
.
argv
[
1
])
# Read the simulation data
sim
=
h5py
.
File
(
"noh_%0
3
d.hdf5"
%
snap
,
"r"
)
sim
=
h5py
.
File
(
"noh_%0
4
d.hdf5"
%
snap
,
"r"
)
boxSize
=
sim
[
"/Header"
].
attrs
[
"BoxSize"
][
0
]
time
=
sim
[
"/Header"
].
attrs
[
"Time"
][
0
]
scheme
=
sim
[
"/HydroScheme"
].
attrs
[
"Scheme"
]
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment