Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F105182296
pychem_IMF_properties
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, Mar 15, 06:16
Size
5 KB
Mime Type
text/x-python
Expires
Mon, Mar 17, 06:16 (2 d)
Engine
blob
Format
Raw Data
Handle
24939631
Attached To
rGEAR Gear
pychem_IMF_properties
View Options
#!/usr/bin/env python
import
Ptools
as
pt
from
optparse
import
OptionParser
from
pNbody
import
*
from
pNbody
import
units
import
string
from
scipy
import
optimize
from
PyChem
import
chemistry
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
=
pt
.
add_limits_options
(
parser
)
parser
=
pt
.
add_log_options
(
parser
)
parser
=
pt
.
add_postscript_options
(
parser
)
parser
.
add_option
(
"--x"
,
action
=
"store"
,
dest
=
"x"
,
type
=
"string"
,
default
=
'Fe'
,
help
=
"x value to plot"
,
metavar
=
" STRING"
)
parser
.
add_option
(
"--y"
,
action
=
"store"
,
dest
=
"y"
,
type
=
"string"
,
default
=
'Mg'
,
help
=
"y value to plot"
,
metavar
=
" STRING"
)
parser
.
add_option
(
"--dt"
,
action
=
"store"
,
dest
=
"dt"
,
type
=
"float"
,
default
=
0.1
,
help
=
"dt"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--mstar"
,
action
=
"store"
,
dest
=
"mstar"
,
type
=
"float"
,
default
=
1e5
,
help
=
"initial mass of the SSP in solar mass"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--tstar"
,
action
=
"store"
,
dest
=
"tstar"
,
type
=
"float"
,
default
=
0
,
help
=
"formation time of the SSP"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"-o"
,
action
=
"store"
,
dest
=
"obs"
,
type
=
"string"
,
default
=
'Y'
,
help
=
"observable to plot"
,
metavar
=
" STRING"
)
parser
.
add_option
(
"--timeunit"
,
action
=
"store"
,
dest
=
"timeunit"
,
type
=
"string"
,
default
=
None
,
help
=
"unit of time"
,
metavar
=
" STRING"
)
parser
.
add_option
(
"--NumberOfTables"
,
action
=
"store"
,
dest
=
"NumberOfTables"
,
type
=
"int"
,
default
=
1
,
help
=
"NumberOfTables"
,
metavar
=
" INT"
)
parser
.
add_option
(
"--DefaultTable"
,
action
=
"store"
,
dest
=
"DefaultTable"
,
type
=
"int"
,
default
=
0
,
help
=
"DefaultTable"
,
metavar
=
" INT"
)
(
options
,
args
)
=
parser
.
parse_args
()
pt
.
check_files_number
(
args
)
files
=
args
return
files
,
options
########################################################################
# M A I N
########################################################################
SOLAR_MASS
=
1.989e33
UnitLength_in_cm
=
3.085e+21
UnitMass_in_g
=
1.989e+43
UnitVelocity_in_cm_per_s
=
20725573.785998672
UnitTime_in_s
=
148849920000000.0
files
,
opt
=
parse_options
()
file
=
files
[
0
]
# some parameters
M0
=
opt
.
mstar
*
SOLAR_MASS
/
UnitMass_in_g
# gas mass of the SSP (in code unit)
# init
chemistry
.
init_chimie
(
file
,
opt
.
NumberOfTables
,
opt
.
DefaultTable
)
mmax
=
chemistry
.
get_Mmax
()
mmin
=
chemistry
.
get_Mmin
()
##################
# theoretical imf
##################
'''
here, the imf is normed in order that
the integral of it, i.e, the mass fraction
of stars is equal to 1.
'''
bins_th
=
arange
(
mmin
,
mmax
,
1e-12
)
.
astype
(
float32
)
hx_th
=
chemistry
.
get_imf
(
bins_th
)
.
astype
(
float32
)
bins_th
=
bins_th
.
astype
(
float
)
*
UnitMass_in_g
/
SOLAR_MASS
toMsol
=
chemistry
.
CodeUnits_to_SolarMass_Factor
()
toMcodeUnit
=
1
/
toMsol
print
print
"-----------------------------------------------------"
print
print
"M0 =
%8.1e
Msol"
%
(
M0
*
toMsol
)
SNII_Mmin
=
chemistry
.
get_SNII_Mmin
()
SNII_Mmax
=
chemistry
.
get_SNII_Mmax
()
SNIa_Mmin
=
chemistry
.
get_Mmin
()
SNIa_Mmax
=
chemistry
.
get_Mmax
()
DYIN_Mmin
=
1
*
toMcodeUnit
DYIN_Mmax
=
chemistry
.
get_DYIN_Mmax
()
print
print
"SNII_Mmin =
%8.1e
Msol"
%
(
SNII_Mmin
*
toMsol
)
print
"SNII_Mmax =
%8.1e
Msol"
%
(
SNII_Mmax
*
toMsol
)
print
print
"SNIa_Mmin =
%8.1e
Msol"
%
(
SNIa_Mmin
*
toMsol
)
print
"SNIa_Mmax =
%8.1e
Msol"
%
(
SNIa_Mmax
*
toMsol
)
print
print
"DYIN_Mmin =
%8.1e
Msol"
%
(
DYIN_Mmin
*
toMsol
)
print
"DYIN_Mmax =
%8.1e
Msol"
%
(
DYIN_Mmax
*
toMsol
)
print
# compute the number of stars per mass between m1 and m2 (dep on M0)
# N this is thus the number of stars in a particle of mass M0
N_SNII
=
chemistry
.
SNII_rate
(
SNII_Mmin
,
SNII_Mmax
)
*
M0
#N_SNII = chemistry.get_imf_N(array([SNII_Mmin]),array([SNII_Mmax]))[0]*M0
print
"# of SNII =
%f
"
%
(
N_SNII
)
N_SNIa
=
chemistry
.
SNIa_rate
(
DYIN_Mmin
,
DYIN_Mmax
)
*
M0
print
"# of SNIa =
%f
"
%
(
N_SNIa
)
N_DYIN
=
chemistry
.
DYIN_rate
(
DYIN_Mmin
,
DYIN_Mmax
)
*
M0
#N_DYIN = chemistry.get_imf_N(array([DYIN_Mmin]),array([DYIN_Mmax]))[0]*M0
print
"# of DYIN =
%f
"
%
(
N_DYIN
)
Event Timeline
Log In to Comment