Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78350332
gget_ctes
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
Mon, Aug 19, 23:49
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Aug 21, 23:49 (2 d)
Engine
blob
Format
Raw Data
Handle
20031686
Attached To
rGTOOLS Gtools
gget_ctes
View Options
#!/usr/bin/env python
'''
Get some constantes in user units (from a user units defined unity system)
Yves Revaz
Thu Feb 16 15:06:07 CET 2006
'''
from
numarray
import
*
try
:
from
optparse
import
OptionParser
except
ImportError
:
from
optik
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"--UnitLength_in_cm"
,
action
=
"store"
,
dest
=
"UnitLength_in_cm"
,
type
=
"float"
,
default
=
0
,
help
=
"UnitLength in cm"
)
parser
.
add_option
(
"--UnitMass_in_g"
,
action
=
"store"
,
dest
=
"UnitMass_in_g"
,
type
=
"float"
,
default
=
0
,
help
=
"UnitMass in g"
)
parser
.
add_option
(
"--UnitVelocity_in_cm_per_s"
,
action
=
"store"
,
dest
=
"UnitVelocity_in_cm_per_s"
,
type
=
"float"
,
default
=
0
,
help
=
"UnitVelocity in cm per s"
)
parser
.
add_option
(
"--HydrogenMassFraction"
,
action
=
"store"
,
dest
=
"HydrogenMassFraction"
,
type
=
"float"
,
default
=
0.76
,
help
=
"Hydrogen Mass Fraction"
)
(
options
,
args
)
=
parser
.
parse_args
()
if
options
.
UnitLength_in_cm
==
0
:
print
"you must specify UnitLength_in_cm"
sys
.
exit
(
0
)
if
options
.
UnitMass_in_g
==
0
:
print
"you must specify UnitMass_in_g"
sys
.
exit
(
0
)
if
options
.
UnitVelocity_in_cm_per_s
==
0
:
print
"you must specify UnitVelocity_in_cm_per_s"
sys
.
exit
(
0
)
return
options
#############################
# main
#############################
BOLTZMANN
=
1.3806e-16
PROTONMASS
=
1.6726e-24
# get options
options
=
parse_options
()
UnitLength_in_cm
=
options
.
UnitLength_in_cm
UnitMass_in_g
=
options
.
UnitMass_in_g
UnitVelocity_in_cm_per_s
=
options
.
UnitVelocity_in_cm_per_s
HydrogenMassFraction
=
options
.
HydrogenMassFraction
UnitTime_in_s
=
UnitLength_in_cm
/
UnitVelocity_in_cm_per_s
;
UnitDensity_in_cgs
=
UnitMass_in_g
/
pow
(
UnitLength_in_cm
,
3
);
UnitPressure_in_cgs
=
UnitMass_in_g
/
UnitLength_in_cm
/
pow
(
UnitTime_in_s
,
2
);
UnitCoolingRate_in_cgs
=
UnitPressure_in_cgs
/
UnitTime_in_s
;
UnitEnergy_in_cgs
=
UnitMass_in_g
*
pow
(
UnitLength_in_cm
,
2
)
/
pow
(
UnitTime_in_s
,
2
);
meanweight
=
4.0
/
(
1
+
3
*
HydrogenMassFraction
)
Boltzmann
=
BOLTZMANN
/
UnitEnergy_in_cgs
ProtonMass
=
PROTONMASS
/
UnitMass_in_g
mumh
=
ProtonMass
*
meanweight
print
"Boltzmann =
%g
"
%
Boltzmann
print
"mumh =
%g
"
%
mumh
print
"X =
%4.2f
"
%
HydrogenMassFraction
Event Timeline
Log In to Comment