예제 #1
0
파일: helmholtz.py 프로젝트: frivasa/flashy
def wrapVector(rho, var, xmass, species):
    """
    Wrapper for J.Schwab's Helmholtz python module, which is
    itself also one for Timmes' Helmholtz EoS.
    Checks rho for length and comparison so that it can be
    used for single points.

    Args:
        rho(float): query density.
        var(float): auxilliary thermodynamic variable (T, P, S or E(int)).
        xmass(float): query mass fractions.
        species(str): query nuclide list.

    Returns:
        (trojan): [[rho/s], [var/s], [abar/s], [zbar/s]]

    """
    try:
        pnts = len(rho)
    except TypeError:
        _, abar, zbar = convXmass2Abun(species, xmass)
        return [[rho], [var], [abar], [zbar]]
    allp = []
    for p in range(pnts):
        _, abar, zbar = convXmass2Abun(species, xmass[p])
        allp.append((rho[p], var[p], abar, zbar))
    vr, vv, va, vz = zip(*allp)
    return [vr, vv, va, vz]
예제 #2
0
파일: helmholtz.py 프로젝트: frivasa/flashy
def buildHelmTrojan(fname, offset=1, geom='spherical'):
    """Frankensteinian bridge between flash checkpoints and
    J.Schwab's Helmholtz python module.
    Joined inward/outward and spewing cj data to avoid
    calling yt more than once.

    Args:
        fname(str): filename.
        offset(int): zone offset from shock.

    """
    props = ['dens', 'temp', 'pres', 'eint']
    nprops = len(props)
    data, species = hdf5yt.getLineout(fname,
                                      fields=props,
                                      species=True,
                                      geom=geom)
    nspecs = len(species)
    xin, xout, cjin, cjout, time, xmatch = getRayleighVelocities(fname)
    # get fuel and ash for outward shock
    # xin/xout == ray @ len([x for x in ray['r'][rsort] if x<xout])
    inw = len([x for x in data[0] if x < xout]) + offset
    ouw = inw - 2 * offset
    inv, ouv = [], []
    for i in range(1, nprops + 1):
        inv.append(data[i][inw])
        ouv.append(data[i][ouw])
    xmin, xmou = [], []
    for i in range(nprops + 1, nprops + 1 + nspecs):
        xmin.append(data[i][inw])
        xmou.append(data[i][ouw])
    _, abar, zbar = convXmass2Abun(species, xmin)
    # [pressure, eint], [rho], [temp], [abar], [zbar]]
    fuelo = [[inv[-2], inv[-1]], [inv[0]], [inv[1]], [abar], [zbar]]
    _, abar, zbar = convXmass2Abun(species, xmou)
    asho = [[ouv[-2], ouv[-1]], [ouv[0]], [ouv[1]], [abar], [zbar]]

    # get fuel and ash for inward shock
    inw = len([x for x in data[0] if x < xin]) - offset
    ouw = inw + 2 * offset
    inv, ouv = [], []
    for i in range(1, nprops + 1):
        inv.append(data[i][inw])
        ouv.append(data[i][ouw])
    xmin, xmou = [], []
    for i in range(nprops + 1, nprops + 1 + nspecs):
        xmin.append(data[i][inw])
        xmou.append(data[i][ouw])
    _, abar, zbar = convXmass2Abun(species, xmin)
    fueli = [[inv[-2], inv[-1]], [inv[0]], [inv[1]], [abar], [zbar]]
    _, abar, zbar = convXmass2Abun(species, xmou)
    ashi = [[ouv[-2], ouv[-1]], [ouv[0]], [ouv[1]], [abar], [zbar]]
    return fueli, ashi, fuelo, asho, [xin, xout, cjin, cjout, time, xmatch]
예제 #3
0
파일: dmatTools.py 프로젝트: frivasa/flashy
def getMassEnergy(prof, trueA=False):
    """calculate total binding energy per cell
    for a dmat(lineout) in erg/g.
    """
    # molar in mol/g
    factors = nuc.getBinding(prof.species, trueA=trueA)
    binding = []
    sumy = []
    for cell in range(len(prof.density)):
        # for each cell get all the mass fractions and convert to molar
        xis = prof.data[cell, len(prof.bulkprops)-1:]
        molar, abar, zbar = nuc.convXmass2Abun(prof.species, xis)
        sumy.append(np.sum(molar))
        binding.append(np.dot(factors, molar)*nuc.Avogadro)
    return sumy, binding  # binding in erg/g