Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79065461
setunits_3.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
Sat, Aug 24, 14:04
Size
1004 B
Mime Type
text/x-python
Expires
Mon, Aug 26, 14:04 (2 d)
Engine
blob
Format
Raw Data
Handle
20145308
Attached To
rPNBODY pNbody
setunits_3.py
View Options
#!/usr/bin/env python
from
pNbody
import
*
# define a new system of units : kpc,Msol,Myr
system_of_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_kpc
,
10
**
10
*
units
.
Unit_Ms
,
units
.
Unit_Myr
])
# get info
system_of_units
.
info
()
# trivial conversion factor into kpc,10**10Msol,Myr
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_kpc
)
print
system_of_units
.
convertionFactorTo
(
10
**
10
*
units
.
Unit_Ms
)
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_Myr
)
# length
#
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_cm
)
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_m
)
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_km
)
# velocity
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_km
/
units
.
Unit_s
)
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_kms
)
# energy
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_kg
*
units
.
Unit_ms
**
2
)
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_J
)
# density
print
system_of_units
.
convertionFactorTo
(
units
.
Unit_g
/
units
.
Unit_cm
**
3
)
Event Timeline
Log In to Comment