Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106615439
test_InitHsml.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Mar 28, 11:39
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Mar 30, 12:39 (2 d)
Engine
blob
Format
Raw Data
Handle
25234469
Attached To
rGEAR Gear
test_InitHsml.py
View Options
#!/usr/bin/env python
from
mpi4py
import
MPI
from
pNbody
import
ic
from
numpy
import
*
from
PyGear
import
gadget
import
Ptools
as
pt
import
sys
import
time
random
.
seed
(
MPI
.
COMM_WORLD
.
Get_rank
())
# 2 for two points
n
=
10000
rc
=
2
rmax
=
100
nb
=
ic
.
plummer
(
n
,
1
,
1
,
1
,
eps
=
rc
,
rmax
=
rmax
,
ftype
=
'gadget'
)
nb
.
rename
(
'plummer.dat'
)
nb
.
write
()
gadget
.
InitMPI
()
# init MPI
gadget
.
InitDefaultParameters
()
# init default parameters
gadget
.
Info
()
params
=
{}
params
[
'ErrTolTheta'
]
=
0.7
params
[
'DesNumNgb'
]
=
50
params
[
'MaxNumNgbDeviation'
]
=
1
params
[
'UnitLength_in_cm'
]
=
3.085e+21
params
[
'UnitMass_in_g'
]
=
4.435693e+44
params
[
'UnitVelocity_in_cm_per_s'
]
=
97824708.2699
params
[
'SofteningGas'
]
=
rc
/
100.
params
[
'SofteningHalo'
]
=
rc
/
100.
params
[
'SofteningDisk'
]
=
rc
/
100.
params
[
'SofteningBulge'
]
=
rc
/
100.
params
[
'SofteningStars'
]
=
rc
/
100.
params
[
'SofteningBndry'
]
=
rc
/
100.
params
[
'SofteningGasMaxPhys'
]
=
rc
/
100.
params
[
'SofteningHaloMaxPhys'
]
=
rc
/
100.
params
[
'SofteningDiskMaxPhys'
]
=
rc
/
100.
params
[
'SofteningBulgeMaxPhys'
]
=
rc
/
100.
params
[
'SofteningStarsMaxPhys'
]
=
rc
/
100.
params
[
'SofteningBndryMaxPhys'
]
=
rc
/
100.
gadget
.
SetParameters
(
params
)
params
=
gadget
.
GetParameters
()
gadget
.
LoadParticles
(
array
(
nb
.
npart
),
nb
.
pos
,
nb
.
vel
,
nb
.
mass
,
nb
.
num
,
nb
.
tpe
)
nb
.
rho
=
gadget
.
GetAllDensities
()
nb
.
hsml
=
gadget
.
GetAllHsml
()
nb
.
pos
=
gadget
.
GetAllPositions
()
x
=
arange
(
-
20
,
20
,
1
)
y
=
zeros
(
len
(
x
),
float32
)
z
=
zeros
(
len
(
x
),
float32
)
pos
=
transpose
(
array
([
x
,
y
,
z
]))
.
astype
(
float32
)
r
=
sqrt
(
x
**
2
+
y
**
2
+
z
**
2
)
hsml
=
ones
(
len
(
pos
))
.
astype
(
float32
)
*
nb
.
hsml
.
mean
()
rho
,
hsml
=
gadget
.
InitHsml
(
pos
,
hsml
)
###############################
# plot
###############################
pt
.
scatter
(
nb
.
rxyz
(),
nb
.
hsml
,
s
=
1
)
pt
.
scatter
(
r
,
hsml
,
s
=
10
,
color
=
'r'
)
pt
.
figure
()
pt
.
scatter
(
nb
.
rxyz
(),
nb
.
rho
,
s
=
1
)
pt
.
scatter
(
r
,
rho
,
s
=
10
,
color
=
'r'
)
#pt.semilogx()
#pt.semilogy()
pt
.
show
()
Event Timeline
Log In to Comment