Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121789537
gSetCosmoBox
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
Sun, Jul 13, 22:19
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Jul 15, 22:19 (2 d)
Engine
blob
Format
Raw Data
Handle
27371999
Attached To
rGTOOLS Gtools
gSetCosmoBox
View Options
#!/usr/bin/env python
from
pNbody
import
units
,
io
,
ctes
,
cosmo
from
numpy
import
*
import
sys
from
optparse
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"--Omega0"
,
action
=
"store"
,
dest
=
"Omega0"
,
type
=
"float"
,
default
=
0.315
,
help
=
"Omega0"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--OmegaLambda"
,
action
=
"store"
,
dest
=
"OmegaLambda"
,
type
=
"float"
,
default
=
0.685
,
help
=
"OmegaLambda"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--OmegaBaryon"
,
action
=
"store"
,
dest
=
"OmegaBaryon"
,
type
=
"float"
,
default
=
0.0486
,
help
=
"OmegaBaryon"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--HubbleParam"
,
action
=
"store"
,
dest
=
"HubbleParam"
,
type
=
"float"
,
default
=
0.673
,
help
=
"HubbleParam"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--UnitLength_in_cm"
,
action
=
"store"
,
dest
=
"UnitLength_in_cm"
,
type
=
"float"
,
default
=
3.085678e21
,
help
=
"UnitLength_in_cm"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--UnitVelocity_in_cm_per_s"
,
action
=
"store"
,
dest
=
"UnitVelocity_in_cm_per_s"
,
type
=
"float"
,
default
=
1e5
,
help
=
"UnitVelocity_in_cm_per_s"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--UnitMass_in_g"
,
action
=
"store"
,
dest
=
"UnitMass_in_g"
,
type
=
"float"
,
default
=
1.989e43
,
help
=
"UnitMass_in_g"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--BoxSize"
,
action
=
"store"
,
dest
=
"BoxSize"
,
type
=
"float"
,
default
=
100
,
help
=
"boxsize in Mpc"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--level"
,
action
=
"store"
,
dest
=
"level"
,
type
=
"int"
,
default
=
9
,
help
=
"resolution level"
,
metavar
=
" INT"
)
(
options
,
args
)
=
parser
.
parse_args
()
return
options
opt
=
parse_options
()
Omega0
=
opt
.
Omega0
OmegaLambda
=
opt
.
OmegaLambda
OmegaBaryon
=
opt
.
OmegaBaryon
HubbleParam
=
opt
.
HubbleParam
params
=
{}
params
[
'UnitLength_in_cm'
]
=
opt
.
UnitLength_in_cm
params
[
'UnitVelocity_in_cm_per_s'
]
=
opt
.
UnitVelocity_in_cm_per_s
params
[
'UnitMass_in_g'
]
=
opt
.
UnitMass_in_g
system_of_units
=
units
.
Set_SystemUnits_From_Params
(
params
)
G
=
ctes
.
GRAVITY
.
into
(
system_of_units
)
H
=
ctes
.
HUBBLE
.
into
(
system_of_units
)
rhoc
=
pow
(
H
,
2
)
*
3
/
(
8
*
pi
*
G
)
#print rhoc,"in code units, h not used"
out_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_kpc
,
units
.
Unit_Msol
,
units
.
Unit_s
,
units
.
Unit_K
])
L
=
opt
.
BoxSize
*
1000
V
=
L
**
3
M
=
V
*
rhoc
*
Omega0
n
=
2
**
opt
.
level
N
=
n
**
3
MDM0
=
M
/
N
*
system_of_units
.
convertionFactorTo
(
out_units
.
UnitMass
)
print
"
%d
particules in one side"
%
n
print
"
%d
particules"
%
N
print
"
%g
Msol"
%
MDM0
Event Timeline
Log In to Comment