Пример #1
0
def massDensity(numDeps, temp, press, mmw, zScale):

    """Solves the equation of state (EOS) for the mass density (rho) given total
 * pressure from HSE solution, for a mixture of ideal gas particles and photons
 *
 * Need to assume a mean molecular weight structure, mu(Tau)
  """
    
    logE = math.log10(math.e) #// for debug output

    #//press is a 4 x numDeps array:
    #// rows 0 & 1 are linear and log *gas* pressure, respectively
    #// rows 2 & 3 are linear and log *radiation* pressure
    #// double c = 9.9989E+10; // light speed in vaccuum in cm/s
    #// double sigma = 5.670373E-5;   //Stefan-Boltzmann constant ergs/s/cm^2/K^4   
    #//Row 0 of mmwNe is Mean molecular weight in amu
    k = Useful.k()
    logK = Useful.logK()
    amu = Useful.amu()
    logAmu = Useful.logAmu()
    #double logMuAmu

#//System.out.println("STATE: logK " + logK + " logMuAmu " + logMuAmu);
    rho = [[0.0 for i in range(numDeps)] for j in range(2)]

    #// Declare scatch variables:
    #// double logPrad, pRad, pGas, logPgas;
    for i in range(numDeps):

        logMuAmu = math.log(mmw[i]) + logAmu

        #// Compute LTE bolometric radiation contribution to total HSE pressure
        #//logPrad = radFac + 4.0*temp[1][i] ;
        #//pRad = Math.exp(logPrad);
        #//pGas = press[0][i] - pRad;
        #//logPgas = Math.log(pGas);
        rho[1][i] = press[1][i] - temp[1][i] + (logMuAmu - logK)
        rho[0][i] = math.exp(rho[1][i])
        #//System.out.println("i " + i + " press[1] " + logE * press[1][i] + " mmw[i] " + mmw[i] + " rho " + logE * rho[1][i]);
        #//System.out.println("temp " + temp[0][i] + " rho " + rho[0][i]);
        

    return rho
Пример #2
0
def lineGridGauss(lam0In, massIn, xiTIn, numDeps, teff, numCore):

    c = Useful.c()
    logC = Useful.logC()
    #//double k = Useful.k;
    logK = Useful.logK()
    #//double e = Useful.e;
    #//double mE = Useful.mE;
    amu = Useful.amu()

    dln10 = math.log(10.0)
    ln2 = math.log(2.0)

    logE = math.log10(math.e)  #// for debug output

    #//Put input parameters into linear cgs units:
    #//double gammaCol = Math.pow(10.0, logGammaCol);
    logTeff = math.log(teff)

    xiT = xiTIn * 1.0E5  #//km/s to cm/s
    lam0 = lam0In  #// * 1.0E-7; //nm to cm
    logLam0 = math.log(lam0)
    logMass = math.log(massIn * amu)  #//amu to g

    #// Compute depth-independent Doppler width, Delta_lambda_D:
    #double doppler, logDopp;
    #double logHelp, help; //scratch

    logHelp = ln2 + logK + logTeff - logMass  #// M-B dist, square of v_mode
    help = math.exp(
        logHelp) + xiT * xiT  #// quadratic sum of thermal v and turbulent v
    logHelp = 0.5 * math.log(help)
    logDopp = logHelp + logLam0 - logC

    doppler = math.exp(logDopp)  #// cm

    #//System.out.println("LineGrid: doppler, logDopp: " + doppler + " " + logE*logDopp);
    #//Set up a half-profile Delta_lambda grid in Doppler width units
    #//from line centre to wing
    #//int numCore = 5;
    #//int numWing = 5;
    #//int numWing = 0;  //debug
    numPoints = numCore

    #// a 2D 2 X numPoints array of Delta Lambdas
    #// Row 0 : Delta lambdas in cm - will need to be in nm for Planck and Rad Trans?
    #// Row 1 : Delta lambdas in Doppler widths
    linePoints = [[0.0 for i in range(numPoints)] for j in range(2)]

    #// Line profiel points in Doppler widths - needed for Voigt function, H(a,v):
    v = [0.0 for i in range(numPoints)]

    maxCoreV = 3.5  #//core half-width ~ in Doppler widths
    #//double maxWingDeltaLogV = 1.5 * ln10; //maximum base e logarithmic shift from line centre in Doppler widths
    minWingDeltaLogV = math.log(maxCoreV + 1.5)
    maxWingDeltaLogV = 9.0 + minWingDeltaLogV

    #double logV, ii, jj;

    for il in range(numPoints):

        ii = float(il)

        #// In core, space v points linearly:
        #// Voigt "v" parameter
        #// v > 0 --> This is the *red* wing:
        v[il] = ii * maxCoreV / (numCore - 1)
        linePoints[0][il] = doppler * v[il]
        linePoints[1][il] = v[il]

        #//System.out.println("LineGrid: il, lam, v: " + il + " " +
        #//        linePoints[0][il] + " " + linePoints[1][il]);
    #} // il lambda loop

    #// Add the negative DeltaLambda half of the line:
    numPoints2 = (2 * numPoints) - 1
    #//System.out.println("LineGrid: numpoints2: " + numPoints2);

    #// Return a 2D 2 X (2xnumPoints-1) array of Delta Lambdas
    #// Row 0 : Delta lambdas in cm - will need to be in nm for Planck and Rad Trans?
    #// Row 1 : Delta lambdas in Doppler widths
    linePoints2 = [[0.0 for i in range(numPoints2)] for j in range(2)]

    #//wavelengths are depth-independent - just put them in the 0th depth slot:
    for il2 in range(numPoints2):

        if (il2 < numPoints - 1):

            il = (numPoints - 1) - il2
            linePoints2[0][il2] = -1.0 * linePoints[0][il]
            linePoints2[1][il2] = -1.0 * linePoints[1][il]

        else:

            #//Positive DelataLambda half:
            il = il2 - (numPoints - 1)
            linePoints2[0][il2] = linePoints[0][il]
            linePoints2[1][il2] = linePoints[1][il]

    #//System.out.println("LineGrid: il2, lam, v: " + il2 + " " +
    #//        linePoints2[0][il2] + " " + linePoints2[1][il2]);
    #} //il2 loop

    return linePoints2
Пример #3
0
def lineGridDelta(lam0In, massIn, xiTIn, numDeps, teff):

    c = Useful.c()
    logC = Useful.logC()
    #//double k = Useful.k;
    logK = Useful.logK()
    #//double e = Useful.e;
    #//double mE = Useful.mE;
    amu = Useful.amu()

    ln10 = math.log(10.0)
    ln2 = math.log(2.0)

    logE = math.log10(math.e)  #// for debug output

    #//Put input parameters into linear cgs units:
    #//double gammaCol = Math.pow(10.0, logGammaCol);
    logTeff = math.log(teff)

    xiT = xiTIn * 1.0E5  #//km/s to cm/s
    lam0 = lam0In  #// * 1.0E-7; //nm to cm
    logLam0 = math.log(lam0)
    logMass = math.log(massIn * amu)  #//amu to g

    #// Compute depth-independent Doppler width, Delta_lambda_D:
    #double doppler, logDopp;
    #double logHelp, help; //scratch

    logHelp = ln2 + logK + logTeff - logMass  #// M-B dist, square of v_mode
    help = math.exp(
        logHelp) + xiT * xiT  #// quadratic sum of thermal v and turbulent v
    logHelp = 0.5 * math.log(help)
    logDopp = logHelp + logLam0 - logC

    doppler = math.exp(logDopp)  #// cm

    #//System.out.println("LineGrid: doppler, logDopp: " + doppler + " " + logE*logDopp);
    #//Set up a half-profile Delta_lambda grid in Doppler width units
    #//from line centre to wing
    #//int numCore = 5;
    #//int numWing = 5;
    #//int numWing = 0;  //debug
    numPoints = 1

    #// a 2D 2 X numPoints array of Delta Lambdas
    #// Row 0 : Delta lambdas in cm - will need to be in nm for Planck and Rad Trans?
    #// Row 1 : Delta lambdas in Doppler widths
    linePoints = [[0.0 for i in range(numPoints)] for j in range(2)]

    #// Line profiel points in Doppler widths - needed for Voigt function, H(a,v):
    v = [0.0 for i in range(numPoints)]

    #double logV, ii, jj;

    il = 0
    ii = float(il)

    #// In core, space v points linearly:
    #// Voigt "v" parameter
    #// v > 0 --> This is the *red* wing:
    v[il] = ii
    linePoints[0][il] = doppler * v[il]
    linePoints[1][il] = v[il]

    #//System.out.println("LineGrid: il, lam, v: " + il + " " +
    #//        linePoints[0][il] + " " + linePoints[1][il]);

    return linePoints
Пример #4
0
def delta(linePoints, lam0In, numDeps, tauRos, massIn, xiTIn, teff):

    """//delta function line profile for initiali check of line strength"""

    lam0 = lam0In #// * 1.0E-7; //nm to cm
    logLam0 = math.log(lam0)

    logE = math.log10(math.e) #// for debug output

    #//System.out.println("LineProf: doppler, logDopp: " + doppler + " " + logE*logDopp);

    #//Put input parameters into linear cgs units:

    #//System.out.println("LINEGRID: Tau1: " + tau1);
    #//logA = 2.0 * logLam0 + logGamma - ln4pi - logC - logDopp;
    #//a = Math.exp(logA);
    #//System.out.println("LINEGRID: logA: " + logE * logA);
    #//Set up a half-profile Delta_lambda grid in Doppler width units 
    #//from line centre to wing
    numPoints = 1
    #//System.out.println("LineProf: numPoints: " + numPoints);

    #// Return a 2D numPoints X numDeps array of normalized line profile points (phi)

    lineProf = [ [ 0.0 for i in range(numDeps) ] for j in range(1) ]
    c = Useful.c()
    logC = Useful.logC()
    logK = Useful.logK()
    amu = Useful.amu()
    ln10 = math.log(10.0)
    ln2 = math.log(2.0)
    lnSqRtPi = 0.5 * math.log(math.pi)
    logTeff = math.log(teff)
    xiT = xiTIn * 1.0E5 #//km/s to cm/s
    logMass = math.log(massIn * amu)  #//amu to g
    #// Compute depth-independent Doppler width, Delta_lambda_D:
    #double doppler, logDopp;
    #double logHelp, help; //scratch
    logHelp = ln2 + logK + logTeff - logMass #// M-B dist, square of v_mode
    help = math.exp(logHelp) + xiT * xiT #// quadratic sum of thermal v and turbulent v
    logHelp = 0.5 * math.log(help)
    logDopp = logHelp + logLam0 - logC
    doppler = math.exp(logDopp)  #// cm


    #// Line profile points in Doppler widths - needed for Voigt function, H(a,v):
    #double ii;

    #// lineProf[0][0] = 0.0; v[0] = 0.0; //Line centre - cannot do logaritmically!
    #double  delta, core, logDelta;
    #//int il0 = 36;
    #//System.out.println("il0 " + il0 + " temp[il] " + temp[0][il0] + " press[il] " + logE*press[1][il0]);
    for id in range(numDeps):

        #//if (il <= numCore) {

        #// - Gaussian ONLY - at line centre Lorentzian will diverge!
        delta = 1.0
        #//System.out.println("LINEGRID- CORE: core: " + core);

        #//System.out.println("LINEGRID: il, v[il]: " + il + " " + v[il] + " lineProf[0][il]: " + lineProf[0][il]);
        #//System.out.println("LINEGRID: il, Voigt, H(): " + il + " " + voigt);
        #//Convert from H(a,v) in dimensionless Voigt units to physical phi((Delta lambda) profile:
        logDelta = math.log(delta) + 2.0 * logLam0 - lnSqRtPi - logDopp - logC

        lineProf[0][id] = math.exp(logDelta)
        #//if (id == 36) {
        #//    System.out.println("il " + il + " linePoints " + 1.0e7 * linePoints[0][il] + " id " + id + " lineProf[il][id] " + lineProf[il][id]);
        #//}

        #//System.out.println("LineProf: il, id, lineProf[il][id]: " + il + " " + id + " " + lineProf[il][id]);

        #// if (id == 20) {
        #//     for (int il = 0; il < numPoints; il++) {
        #//        System.out.format("Voigt: %20.16f   %20.16f%n", linePoints[1][il], logE * Math.log(lineProf[il][id]));
        #//    }
        #// }
    #} //id loop

    return lineProf