Ejemplo n.º 1
0
#===============================================================================
# User defined parameters
#===============================================================================
composition_request = {'X': 0.9, 'Y': 0.02, 'dXc': 0.001}
logT_bounds = [3.8, 8]
logRho_bounds = [-11, -3]

#===============================================================================
# Loading OPAL table
#===============================================================================
# 1. requires: pystellar and AstroObject python modules see: https://github.com/alexrudy
# 2. add requiered opal table to pystellar/data/
# 3. edit pystellar/OPAL.yml and add a new entry for the table
# 4. make a symbolic link or copy pystellar/data/ to ./
op = OpacityTable(fkey='Gz020', filename='/home/rth/src/pystellar/OPAL.yml')

op.composition(**composition_request)

composition_match = {
    key: getattr(op, key)
    for key in ['X', 'Y', 'Z', 'dXc', 'dXo']
}
print 'Requested composition :', pretty_print_composition(composition_request)
print 'Found composition     :', pretty_print_composition(composition_match)

#===============================================================================
# Grid definition
#===============================================================================
print 'Density bounds [g/cm3]:', logRho_bounds
print 'Temperature bounds [K]:', logT_bounds
Ejemplo n.º 2
0
Xs = [0, 0.70]
Ys = [0.98, 0.28]
logTs = [7.55, 6.91]
logPs = [16.85, 16.87]

for X, Y, logT, logP in zip(Xs, Ys, logTs, logPs):
    mu = mmw(X=X, Y=Y)
    beta = lbeta(logT=logT, logP=logP, mu=mu)
    dens = ldensity(logT=logT, logP=logP, mu=mu)
    print u"For X=%5.3f, Y=%5.3f, log(T)=%5.3f, log(P)=%5.3f\n → μ=%5.3f → ρ=%5.3f, β=%5.3f" % (
        X, Y, logT, logP, mu, dens, beta)

# Problem #6
print "\nProblem #6:"

logTs = [6.3, 5.0]
logrhos = [0.3, -4.0]
X = 0.700
Y = 0.280
opacity = OpacityTable("GN93hz", load=True)
opacity.composition(X=X, Y=Y)
print u"Fixed composition at X=%.3g,Y=%.3g,Z=%.3g" % (opacity.X, opacity.Y,
                                                      opacity.Z)
print u"Using table %d" % (opacity.n + 1)

for logT, logrho in zip(logTs, logrhos):
    kappa = opacity.lookup(logrho=logrho, logT=logT)
    print u"log(T)=%5.3f, log(ρ)=%6.3f\n → log(κ)=%5.3f" % (logT, logrho,
                                                            kappa)
Ejemplo n.º 3
0
# 

from pystellar.opacity import OpacityTable

print "\nProblem #6:"

print "1: OP17"
print "2: GN93hz"
print "3: cunha06"
logTs   = [6.3, 5.0]
logrhos = [0.3,-4.0]
logTsmall = [3.05,3.95]
logrhosmall = [-8.0,-4.0]
X = 0.700
Y = 0.280
opacity1 = OpacityTable("OP17",load=False)
opacity2 = OpacityTable("GN93hz",load=False,X=X,Y=Y,efkey="cunha06")
opacity3 = OpacityTable("cunha06",load=False,X=X,Y=Y)
opacity1.composition(X=X,Y=Y)
opacity2.composition(X=X,Y=Y)
opacity3.composition(X=X,Y=Y)
print u"1: Fixed composition at X=%.3g,Y=%.3g,Z=%.3g" % (opacity1.X,opacity1.Y,opacity1.Z)
print u"2: Fixed composition at X=%.3g,Y=%.3g,Z=%.3g" % (opacity2.X,opacity2.Y,opacity2.Z)
print u"3: Fixed composition at X=%.3g,Y=%.3g,Z=%.3g" % (opacity3.X,opacity3.Y,opacity3.Z)
print u"1: Using table %d" % opacity1.n
print u"2: Using table %d" % opacity2.n
print u"3: Using table %d" % opacity3.n

for i,(logT,logrho) in enumerate(zip(logTs,logrhos)):
    kappa = opacity1.lookup(logrho=logrho,logT=logT)
    print u"1: log(T)=%5.3f, log(ρ)=%6.3f → κ=%5.3f" % (logT,logrho,kappa)
Ejemplo n.º 4
0
#

from __future__ import division

from pystellar.density import density
from pystellar.opacity import OpacityTable
from pystellar.threading import ObjectsManager, EngineManager

import numpy as np
import time
import logging

X = 0.70
Y = 0.28

log = logging.getLogger('pystellar.opacity')
log.setLevel(logging.DEBUG)
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
log.addHandler(console)

OP = OpacityTable(fkey='OP17', X=0.70, Y=0.28, efkey='cunha06')
P, T = [8.726086186677213013e+07, 4.576702504411734481e+03]

rho = density(P=P, T=T, X=X, Y=Y)

print OP.kappa(rho=rho, T=T)
print OP.make_points(logT=np.log10(T), logrho=np.log10(rho))
T = 11264.2381423
rho = 0.0044603404639
print OP.kappa(T=T, rho=rho)
Ejemplo n.º 5
0
 def setup(self):
     """Set up this test suite"""
     self.o = OpacityTable("GN93hz", load=False)
Ejemplo n.º 6
0
from pystellar.threading import ObjectsManager, EngineManager

import numpy as np
import time

print "--Launching Thread"
start = time.clock()
OT = ObjectsManager(OpacityTable,nprocs=1,ikwargs=dict(fkey='OP17',X=0.70,Y=0.28))
OT.start()
finish = time.clock()
print "--Threads Launched: %g" % (finish-start)


print "++Launching Object"
start = time.clock()
OO = OpacityTable(fkey='GN93hz',X=0.70,Y=0.28)
finish = time.clock()
print "++Object Launched: %g" % (finish-start)


print "--Get Composition"
start = time.clock()
OT.properties()
n,X,Y,Z,dXc,dXo = OT.retrieve()
print u"Fixed composition at X=%.3g,Y=%.3g,Z=%.3g" % (X,Y,Z)
print u"Using table %d" % (n + 1)
finish = time.clock()
print "--Got Composition: %g" % (finish-start)


print "++Get Composition"