Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93074548
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, Nov 26, 00:33
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Nov 28, 00:33 (2 d)
Engine
blob
Format
Raw Data
Handle
22568023
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")
(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]"
########################################################################
# MAIN
########################################################################
if __name__ == '__main__':
files,opt = parse_options()
MakePlot(files,opt)
Event Timeline
Log In to Comment