Example #1
0
 def test_solar_mu(self):
     """Solar values work for mu(X,Y): X=0.70, Y=0.28, log(T)=6.91, log(P)=16.87"""
     X = 0.70
     Y = 0.28
     logT = 6.91
     logP = 16.87
     mu = mmw(X=X,Y=Y)
     mu_sol = 0.617283950617284
     assert mu - mu_sol < 1e-10, u"μ mismatch: %g, %g" % (mu,mu_sol)
Example #2
0
 def test_solar_mu(self):
     """Solar values work for mu(X,Y): X=0.70, Y=0.28, log(T)=6.91, log(P)=16.87"""
     X = 0.70
     Y = 0.28
     logT = 6.91
     logP = 16.87
     mu = mmw(X=X, Y=Y)
     mu_sol = 0.617283950617284
     assert mu - mu_sol < 1e-10, u"μ mismatch: %g, %g" % (mu, mu_sol)
Example #3
0
# P_Guess_Iteration = 2
P_Guess_Iteration = 0
Opacity = ObjectThread(OpacityTable,
                       ikwargs=dict(fkey='GN93hz', X=X, Y=Y),
                       locking=True)
Opacity.start()
star = Star(config=Config, optable_args=Opacity.duplicator)

print ""
print "Problem #4&5:"

print "Settings for the Sun"
print "M = %10.6g g" % Ms
print "X = %10.3f" % star.X
print "Y = %10.3f" % star.Y
print u"μ = %10.3f" % mmw(X=X, Y=Y)
print ""

print "Outer Boundary Conditions"
print "    Inital Guess:"
print "    R = %10.6e cm" % Rs
print "    L = %10.6e erg/s" % Lsun
r, l, P, T = outer_boundary(R=Rs,
                            L=Lsun,
                            M=Ms,
                            mu=mmw(X=X, Y=Y),
                            optable=Opacity,
                            Piter=P_Guess_Iteration)
print "At m=M:"
print "    r = %10.6e cm" % r
print "    l = %10.6e erg/s" % l
Example #4
0
from pystellar.density import ldensity, lbeta, mmw
from pystellar.opacity import OpacityTable
import numpy as np

print "Stellar Structure Problem Set 1"

# Problem #5
print "\nProblem #5:"

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,
Example #5
0
Config = DottedConfiguration()
Config.dn = DottedConfiguration
Config.load("Star.yml")
print Config["Data.Energy"].store
X = 0.700
Y = 0.280
Opacity = ObjectThread(OpacityTable,ikwargs=dict(fkey='GN93hz',X=X,Y=Y,snap=True),locking=True)
Opacity.start()

print ""

print "Settings for the Sun"
print "M = %10.6g g" % Ms
print "X = %10.3f" % X
print "Y = %10.3f" % Y
print u"μ = %10.3f" % mmw(X=X,Y=Y)
print ""

m = 1.9890999983295044e+33

print "Inner Boundary Conditions"
print "    Initial Step:"
print "    m = %10.6e g" % m
(r,l,P,T) = [  6.96000000e+10,   2.13492744e+33,   3.64246107e+27,  5.77489402e+03]
print "At m=m:"
print "    r = %10.6e cm" % r
print "    l = %10.6e erg/s" % l
print "    P = %10.6e Dyne/cm^2" % P
print "    T = %10.6e K" % T
print u"      = %10.6e " % density(P=P,T=T,X=X,Y=Y)
print "Derivatives"
from pystellar.threading import ObjectsManager,ObjectPassthrough,EngineManager,ObjectThread

X = 0.700
Y = 0.280
epsilon = 0.001
Opacity = ObjectThread(OpacityTable,ikwargs=dict(fkey='GN93hz',X=X,Y=Y),locking=True)
Opacity.start()

print "Stellar Model Photospheric Boundary Conditions"

print "Settings for the Sun"
print "M = %10.6g g" % Ms
print "X = %10.3f" % X
print "Y = %10.3f" % Y
print u"ε = %10.3f ergs/g" % epsilon
print u"μ = %10.3f" % mmw(X=X,Y=Y)

print "Outer Boundary Conditions"
print "Testing Outer Presure Conversion Mehtods"
print "    Inital Guess:"
print "    R = %10.6e cm" % Rs
print "    L = %10.6e erg/s" % Lsun
start = time.clock()
ri,li,Pi,Ti = outer_boundary(R=Rs,L=Lsun,M=Ms,mu=mmw(X=X,Y=Y),optable=Opacity,Piter=10)
print "Iterable time taken: %g" % (time.clock() - start)
start = time.clock()
r,l,P,T = outer_boundary(R=Rs,L=Lsun,M=Ms,mu=mmw(X=X,Y=Y),optable=Opacity,Piter=False)
print "Absolute time taken: %g" % (time.clock() - start)
print "At m=M:"
print "    -- Algebraic -------------- | -- Iterable -------------- | -- Delta --------| "
print u"    R = %10.6e cm,        | R = %10.6e cm        | ΔR = %11.4e |" % (r,ri,(r-ri)/r)