예제 #1
0
def check_star_convergence(QL_, QR_, MPL, MPR):

    PL_ = State(QL_, MPL)

    if MPR.EOS > -1:  # not a vacuum
        PR_ = State(QR_, MPR)

        ρ0 = min(MPL.ρ0, MPR.ρ0)
        b02 = min(MPL.b02, MPR.b02)

        cond = amax(abs(PL_.Σ()[0] - PR_.Σ()[0])) / (b02 * ρ0) < STAR_TOL
        cond &= abs(PL_.v[0] - PR_.v[0]) / sqrt(b02) < STAR_TOL
    else:
        ρ0 = MPL.ρ0
        b02 = MPL.b02

        cond = amax(abs(PL_.Σ()[0])) / (b02 * ρ0) < STAR_TOL

    if THERMAL:
        if MPR.EOS > -1:
            q0 = min(q_dims(MPL), q_dims(MPR))
            T0 = min(MPL.T0, MPR.T0)

            cond &= abs(PL_.q()[0] - PR_.q()[0]) / q0 < STAR_TOL
            cond &= abs(PL_.T() - PR_.T()) / T0 < STAR_TOL
        else:
            q0 = q_dims(MPL)

            cond &= abs(PL_.q()[0]) / q0 < STAR_TOL

    return cond
예제 #2
0
def star_stepper_obj(x, QL, QR, dt, MPL, MPR):

    X = x.reshape([2, 21])
    ret = zeros([2, 21])

    QL_ = X[0, :17]
    QR_ = X[1, :17]

    PL = State(QL, MPL)
    PR = State(QR, MPR)
    PL_ = State(QL_, MPL)
    PR_ = State(QR_, MPR)

    pL = Cvec_to_Pvec(QL, MPL)
    pR = Cvec_to_Pvec(QR, MPR)
    pL_ = Cvec_to_Pvec(QL_, MPL)
    pR_ = Cvec_to_Pvec(QR_, MPR)

    ML = riemann_constraints2(PL, 'L', MPL)[:17, :17]
    MR = riemann_constraints2(PR, 'R', MPR)[:17, :17]

    xL_ = X[0, 17:]
    xR_ = X[1, 17:]

    xL = zeros(4)
    xR = zeros(4)

    xL[:3] = PL.Σ()[0]
    xR[:3] = PR.Σ()[0]
    xL[3] = PL.q()[0]
    xR[3] = PR.q()[0]

    ret[0, :4] = dot(ML[:4], pL_ - pL) - (xL_ - xL)
    ret[1, :4] = dot(MR[:4], pR_ - pR) - (xR_ - xR)

    SL = source_prim(QL, MPL)[:17]
    SR = source_prim(QR, MPR)[:17]
    SL_ = source_prim(QL_, MPL)[:17]
    SR_ = source_prim(QR_, MPR)[:17]

    ret[0, 4:17] = dot(ML[4:], (pL_ - pL) - dt / 2 * (SL + SL_))
    ret[1, 4:17] = dot(MR[4:], (pR_ - pR) - dt / 2 * (SR + SR_))

    bR = zeros(4)
    bL = zeros(4)
    bL[:3] = PL_.v
    bR[:3] = PR_.v
    bL[3] = PL_.T()
    bR[3] = PR_.T()

    ret[0, 17:] = xL_ - xR_
    ret[1, 17:] = bL - bR

    return ret.ravel()
예제 #3
0
def star_states_stiff(QL, QR, dt, MPL, MPR):

    PL = State(QL, MPL)
    PR = State(QR, MPR)

    x0 = zeros(42)
    x0[:21] = concatenate([QL, PL.Σ()[0], [PL.q()[0]]])
    x0[21:] = concatenate([QR, PR.Σ()[0], [PR.q()[0]]])

    def obj(x):
        return star_stepper_obj(x, QL, QR, dt, MPL, MPR)

    ret = newton_krylov(obj, x0).reshape([2, 21])

    return ret[0, :17], ret[1, :17]
예제 #4
0
def F_cons(Q, d, MP):

    ret = zeros(NV)

    P = State(Q, MP)

    ρ = P.ρ
    p = P.p()
    E = P.E
    v = P.v

    vd = v[d]
    ρvd = ρ * vd

    ret[0] = ρvd

    ret[1] = ρvd * E + p * vd
    ret[2:5] = ρvd * v
    ret[2 + d] += p

    if VISCOUS:

        A = P.A
        σ = P.σ()

        σd = σ[d]
        ret[1] -= dot(σd, v)
        ret[2:5] -= σd

        Av = dot(A, v)
        ret[5 + d] = Av[0]
        ret[8 + d] = Av[1]
        ret[11 + d] = Av[2]

    if THERMAL:

        J = P.J
        T = P.T()
        q = P.q()

        ret[1] += q[d]
        ret[14:17] = ρvd * J
        ret[14 + d] += T

    if MULTI:
        λ = P.λ
        ret[17] = ρvd * λ

    return ret