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
1291fec3
Commit
1291fec3
authored
Mar 08, 2017
by
Bert Vandenbroucke
Browse files
Made all python scripts numpy 1.8.2 compatible, and fixed some bugs while doing it.
parent
26ecd35b
Changes
12
Hide whitespace changes
Inline
Side-by-side
examples/BigCosmoVolume/makeIC.py
View file @
1291fec3
...
...
@@ -107,7 +107,7 @@ if n_copy > 1:
for
i
in
range
(
n_copy
):
for
j
in
range
(
n_copy
):
for
k
in
range
(
n_copy
):
coords
=
np
.
append
(
coords
,
coords_tile
+
np
.
array
([
i
*
boxSize
,
j
*
boxSize
,
k
*
boxSize
]),
axis
=
0
)
coords
=
np
.
append
(
coords
,
coords_tile
+
np
.
array
([
i
*
boxSize
[
0
]
,
j
*
boxSize
[
1
]
,
k
*
boxSize
[
2
]
]),
axis
=
0
)
v
=
np
.
append
(
v
,
v_tile
,
axis
=
0
)
m
=
np
.
append
(
m
,
m_tile
)
h
=
np
.
append
(
h
,
h_tile
)
...
...
examples/CoolingHalo/makeIC.py
View file @
1291fec3
...
...
@@ -227,7 +227,7 @@ ds[()] = u
u
=
np
.
zeros
(
1
)
# Particle IDs
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
)
ds
=
grp
.
create_dataset
(
'ParticleIDs'
,
(
N
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/CoolingHaloWithSpin/makeIC.py
View file @
1291fec3
...
...
@@ -233,7 +233,7 @@ ds[()] = u
u
=
np
.
zeros
(
1
)
# Particle IDs
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
)
ds
=
grp
.
create_dataset
(
'ParticleIDs'
,
(
N
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/DiscPatch/GravityOnly/makeIC.py
View file @
1291fec3
...
...
@@ -150,7 +150,7 @@ ds[()] = m
m
=
numpy
.
zeros
(
1
)
ids
=
1
+
numpy
.
linspace
(
0
,
numPart
,
numPart
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
numpy
.
linspace
(
0
,
numPart
,
numPart
,
endpoint
=
False
)
ds
=
grp1
.
create_dataset
(
'ParticleIDs'
,
(
numPart
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/DiscPatch/HydroStatic/makeIC.py
View file @
1291fec3
...
...
@@ -205,7 +205,7 @@ if (entropy_flag == 1):
else
:
ds
[()]
=
u
ids
=
1
+
numpy
.
linspace
(
0
,
numGas
,
numGas
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
numpy
.
linspace
(
0
,
numGas
,
numGas
,
endpoint
=
False
)
ds
=
grp0
.
create_dataset
(
'ParticleIDs'
,
(
numGas
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/HydrostaticHalo/density_profile.py
View file @
1291fec3
...
...
@@ -28,7 +28,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitLength_in_cgs"
])
unit_velocity_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitVelocity_in_cgs"
])
unit_time_cgs
=
unit_length_cgs
/
unit_velocity_cgs
v_c
=
float
(
params
.
attrs
[
"
Softened
IsothermalPotential:vrot"
])
v_c
=
float
(
params
.
attrs
[
"IsothermalPotential:vrot"
])
v_c_cgs
=
v_c
*
unit_velocity_cgs
#lambda_cgs = float(params.attrs["LambdaCooling:lambda_cgs"])
#X_H = float(params.attrs["LambdaCooling:hydrogen_mass_abundance"])
...
...
examples/HydrostaticHalo/internal_energy_profile.py
View file @
1291fec3
...
...
@@ -46,7 +46,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitLength_in_cgs"
])
unit_velocity_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitVelocity_in_cgs"
])
unit_time_cgs
=
unit_length_cgs
/
unit_velocity_cgs
v_c
=
float
(
params
.
attrs
[
"
Softened
IsothermalPotential:vrot"
])
v_c
=
float
(
params
.
attrs
[
"IsothermalPotential:vrot"
])
v_c_cgs
=
v_c
*
unit_velocity_cgs
#lambda_cgs = float(params.attrs["LambdaCooling:lambda_cgs"])
#X_H = float(params.attrs["LambdaCooling:hydrogen_mass_abundance"])
...
...
examples/HydrostaticHalo/makeIC.py
View file @
1291fec3
...
...
@@ -227,7 +227,7 @@ ds[()] = u
u
=
np
.
zeros
(
1
)
# Particle IDs
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
np
.
linspace
(
0
,
N
,
N
,
endpoint
=
False
)
ds
=
grp
.
create_dataset
(
'ParticleIDs'
,
(
N
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/HydrostaticHalo/velocity_profile.py
View file @
1291fec3
...
...
@@ -46,7 +46,7 @@ unit_mass_cgs = float(params.attrs["InternalUnitSystem:UnitMass_in_cgs"])
unit_length_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitLength_in_cgs"
])
unit_velocity_cgs
=
float
(
params
.
attrs
[
"InternalUnitSystem:UnitVelocity_in_cgs"
])
unit_time_cgs
=
unit_length_cgs
/
unit_velocity_cgs
v_c
=
float
(
params
.
attrs
[
"
Softened
IsothermalPotential:vrot"
])
v_c
=
float
(
params
.
attrs
[
"IsothermalPotential:vrot"
])
v_c_cgs
=
v_c
*
unit_velocity_cgs
header
=
f
[
"Header"
]
N
=
header
.
attrs
[
"NumPart_Total"
][
0
]
...
...
examples/IsothermalPotential/makeIC.py
View file @
1291fec3
...
...
@@ -138,7 +138,7 @@ ds = grp1.create_dataset('Masses', (numPart,), 'f')
ds
[()]
=
m
m
=
numpy
.
zeros
(
1
)
ids
=
1
+
numpy
.
linspace
(
0
,
numPart
,
numPart
,
endpoint
=
False
,
dtype
=
'L'
)
ids
=
1
+
numpy
.
linspace
(
0
,
numPart
,
numPart
,
endpoint
=
False
)
ds
=
grp1
.
create_dataset
(
'ParticleIDs'
,
(
numPart
,
),
'L'
)
ds
[()]
=
ids
...
...
examples/Noh_3D/makeIC.py
View file @
1291fec3
...
...
@@ -35,8 +35,8 @@ glass = h5py.File("glassCube_64.hdf5", "r")
vol
=
8.
pos
=
glass
[
"/PartType0/Coordinates"
][:,:]
*
cbrt
(
vol
)
h
=
glass
[
"/PartType0/SmoothingLength"
][:]
*
cbrt
(
vol
)
pos
=
glass
[
"/PartType0/Coordinates"
][:,:]
*
vol
**
(
1.
/
3.
)
h
=
glass
[
"/PartType0/SmoothingLength"
][:]
*
vol
**
(
1.
/
3.
)
numPart
=
size
(
h
)
# Generate extra arrays
...
...
@@ -65,7 +65,7 @@ file = h5py.File(fileName, 'w')
# Header
grp
=
file
.
create_group
(
"/Header"
)
grp
.
attrs
[
"BoxSize"
]
=
[
cbrt
(
vol
),
cbrt
(
vol
),
cbrt
(
vol
)]
grp
.
attrs
[
"BoxSize"
]
=
[
vol
**
(
1.
/
3.
),
vol
**
(
1.
/
3.
),
vol
**
(
1.
/
3.
)]
grp
.
attrs
[
"NumPart_Total"
]
=
[
numPart
,
0
,
0
,
0
,
0
,
0
]
grp
.
attrs
[
"NumPart_Total_HighWord"
]
=
[
0
,
0
,
0
,
0
,
0
,
0
]
grp
.
attrs
[
"NumPart_ThisFile"
]
=
[
numPart
,
0
,
0
,
0
,
0
,
0
]
...
...
examples/SineWavePotential_3D/plotSolution.py
View file @
1291fec3
...
...
@@ -55,7 +55,7 @@ rho_x = 1000.*np.exp(-0.5*A/np.pi/cs2*np.cos(2.*np.pi*x))
P
=
cs2
*
rho
n1D
=
int
(
np
.
c
brt
(
len
(
P
)))
n1D
=
np
.
c
eil
(
len
(
P
)
**
(
1.
/
3.
))
gradP
=
np
.
zeros
(
P
.
shape
)
for
i
in
range
(
len
(
P
)):
iself
=
int
(
ids
[
i
]
/
n1D
/
n1D
)
...
...
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