Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68653065
setunits_7.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, Jun 28, 08:34
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Jun 30, 08:34 (2 d)
Engine
blob
Format
Raw Data
Handle
18615634
Attached To
rPNBODY pNbody
setunits_7.py
View Options
#!/usr/bin/env python
from
pNbody
import
*
##############################
# define some system of units
##############################
# output system of units (cgs)
cgs_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_cm
,
units
.
Unit_g
,
units
.
Unit_s
,
units
.
Unit_K
])
# gear system of units
params
=
{}
params
[
'UnitVelocity_in_cm_per_s'
]
=
20725573.785998672
params
[
'UnitMass_in_g'
]
=
1.989e+43
params
[
'UnitLength_in_cm'
]
=
3.085678e+21
gear_units
=
units
.
Set_SystemUnits_From_Params
(
params
)
##############################
# compute constants
##############################
# compute mu
Xi
=
0.76
mu
=
4.
/
(
8.
-
5.
*
(
1.
-
Xi
))
# get k (boltzmann) in cgs_units
k
=
ctes
.
BOLTZMANN
.
into
(
cgs_units
)
# get mh (hydrogen mass) in cgs_units
mh
=
ctes
.
PROTONMASS
.
into
(
cgs_units
)
##############################
# specific thermal energy
##############################
T
=
1e4
ui
=
3
/
2.
*
k
/
(
mu
*
mh
)
*
T
##############################
# mass
##############################
mi
=
5e-08
# gear_units (500Msol)
mi
=
mi
*
gear_units
.
convertionFactorTo
(
cgs_units
.
UnitMass
)
##############################
# energy
##############################
Nsn
=
5
Nngb
=
10.
Esn
=
Nsn
*
1e51
*
0.03
# already in cgs
Esni
=
Esn
/
Nngb
# already in cgs
##############################
# now compute, all in cgs
##############################
ei
=
mi
*
ui
eip
=
ei
+
Esni
print
"ratio"
,
eip
/
ei
##############################
# now compute, all in gear
##############################
ui
=
ui
*
cgs_units
.
convertionFactorTo
(
gear_units
.
UnitSpecEnergy
)
mi
=
mi
*
cgs_units
.
convertionFactorTo
(
gear_units
.
UnitMass
)
Esni
=
Esni
*
cgs_units
.
convertionFactorTo
(
gear_units
.
UnitEnergy
)
print
"------------"
print
ui
print
mi
print
Esni
Event Timeline
Log In to Comment