Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F103708785
gJeans
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
Tue, Mar 4, 04:36
Size
3 KB
Mime Type
text/x-python
Expires
Thu, Mar 6, 04:36 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24645262
Attached To
rGTOOLS Gtools
gJeans
View Options
#!/usr/bin/env python
from
optparse
import
OptionParser
import
Ptools
as
pt
from
pNbody
import
*
from
pNbody
import
units
from
pNbody
import
ctes
from
pNbody
import
thermodyn
import
string
from
scipy
import
optimize
# DlogA = da / a
#
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parse
=
pt
.
add_units_options
(
parser
)
parser
.
add_option
(
"--Temperature"
,
action
=
"store"
,
dest
=
"Temperature"
,
type
=
"float"
,
default
=
10
,
help
=
"Temperature [K]"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--Density"
,
action
=
"store"
,
dest
=
"Density"
,
type
=
"float"
,
default
=
1
,
help
=
"Density [a/cc]"
,
metavar
=
" FLOAT"
)
parser
.
add_option
(
"--NJ"
,
action
=
"store"
,
dest
=
"NJ"
,
type
=
"float"
,
default
=
10
,
help
=
"Number of particles desired to sample a Jeans Mass"
,
metavar
=
" FLOAT"
)
(
options
,
args
)
=
parser
.
parse_args
()
#pt.check_files_number(args)
files
=
args
return
files
,
options
#######################################
# MakePlot
#######################################
def
MakePlot
(
files
,
opt
):
gamma
=
5
/
3.
G
=
ctes
.
GRAVITY
.
value
PROTONMASS
=
ctes
.
PROTONMASS
.
value
BOLTZMANN
=
ctes
.
BOLTZMANN
.
value
# input units
Unit_atom
=
ctes
.
PROTONMASS
.
into
(
units
.
cgs
)
*
units
.
Unit_g
Unit_atom
.
set_symbol
(
'atom'
)
in_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_cm
,
Unit_atom
,
units
.
Unit_s
,
units
.
Unit_K
])
# cgs
cgs_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_cm
,
units
.
Unit_g
,
units
.
Unit_s
,
units
.
Unit_K
])
# astro
out_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_pc
,
units
.
Unit_Msol
,
units
.
Unit_s
,
units
.
Unit_K
])
# convert to cgs
Density
=
opt
.
Density
*
in_units
.
convertionFactorTo
(
cgs_units
.
UnitDensity
)
Temperature
=
opt
.
Temperature
# deflauts parameters in cgs
pars
=
{
"k"
:
BOLTZMANN
,
"mh"
:
PROTONMASS
,
"mu"
:
2
,
"gamma"
:
gamma
,
"G"
:
G
}
JeansLength
=
thermodyn
.
JeansLength_rt
(
Density
,
Temperature
,
pars
)
JeansMass
=
thermodyn
.
JeansMass_rt
(
Density
,
Temperature
,
pars
)
print
JeansLength
*
cgs_units
.
convertionFactorTo
(
out_units
.
UnitLength
)
,
"[pc]"
print
JeansMass
*
cgs_units
.
convertionFactorTo
(
out_units
.
UnitMass
)
,
"[Msol]"
#MassPart = JeansMass/opt.Nsph
print
print
"Resolution needed for NJ=
%d
"
%
opt
.
NJ
print
MassResolution
=
JeansMass
/
opt
.
NJ
SpatialResolution
=
(
JeansLength
/
2.
)
/
(
opt
.
NJ
)
**
(
1
/
3.
)
print
"Spatial Resolution =
%g
[pc]"
%
(
SpatialResolution
*
cgs_units
.
convertionFactorTo
(
out_units
.
UnitLength
)
)
print
"Mass Resolution =
%g
[Msol]"
%
(
MassResolution
*
cgs_units
.
convertionFactorTo
(
out_units
.
UnitMass
)
)
#print "Particule mass resolution : %g [Msol] (using %d neighbours)"%(MassPart *cgs_units.convertionFactorTo(out_units.UnitMass ) ,opt.NJ )
########################################################################
# MAIN
########################################################################
if
__name__
==
'__main__'
:
files
,
opt
=
parse_options
()
MakePlot
(
files
,
opt
)
Event Timeline
Log In to Comment