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
def check_star_convergence(QL_, QR_, MPL, MPR, STAR_TOL=1e-6): PL_ = State(QL_, MPL) PR_ = State(QR_, MPR) cond1 = amax(abs(PL_.Σ()[0] - PR_.Σ()[0])) < STAR_TOL cond2 = abs(PL_.T() - PR_.T()) < STAR_TOL return cond1 and cond2
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()
def check_star_convergence(QL_, QR_, MPL, MPR): PL_ = State(QL_, MPL) PR_ = State(QR_, MPR) cond1 = amax(abs(PL_.Σ()[0] - PR_.Σ()[0])) < STAR_TOL if THERMAL: cond2 = abs(PL_.T() - PR_.T()) < STAR_TOL else: cond2 = True return cond1 and cond2
def star_stepper(QL_, QR_, MPL, MPR, interfaceType): """ Iterates to the next approximation of the star states. NOTE: the material on the right may be a vacuum. """ PL = State(QL_, MPL) _, RL = riemann_constraints(PL, 1, MPL) if THERMAL: xL = concatenate([PL.Σ()[0], [PL.T()]]) else: xL = PL.Σ()[0] cL = zeros(n6) if MPR.EOS > -1: # not a vacuum PR = State(QR_, MPR) _, RR = riemann_constraints(PR, -1, MPR) if THERMAL: xR = concatenate([PR.Σ()[0], [PR.T()]]) else: xR = PR.Σ()[0] cR = zeros(n6) if interfaceType == 'stick': x_ = stick_bcs(RL, RR, PL, PR, xL, xR) elif interfaceType == 'slip': x_ = slip_bcs(RL, RR, PL, PR, xL, xR) cL[:n1] = x_ - xL cR[:n1] = x_ - xR PRvec = Pvec(PR) PR_vec = dot(RR, cR) + PRvec QR_ = Pvec_to_Cvec(reorder(PR_vec), MPR) else: cL[:n1] = - xL if THERMAL: YL = RL[14, :4] cL[3] = (dot(YL[:3], PL.Σ()[0]) - PL.J[0]) / YL[3] QR_ = zeros(n6) PLvec = Pvec(PL) PL_vec = dot(RL, cL) + PLvec QL_ = Pvec_to_Cvec(reorder(PL_vec), MPL) return QL_, QR_
def star_stepper(QL, QR, dt, MPL, MPR, SL=None, SR=None): d = 0 PL = State(QL, MPL) PR = State(QR, MPR) LL, RL = riemann_constraints(PL, 1, MPL) LR, RR = riemann_constraints(PR, -1, MPR) YL = RL[11:15, :4] YR = RR[11:15, :4] xL = concatenate([PL.Σ()[d], [PL.T()]]) xR = concatenate([PR.Σ()[d], [PR.T()]]) Ξ1L = Xi1(PL, d, MPL) Ξ2L = Xi2(PL, d, MPL) OL = dot(Ξ1L, Ξ2L) Ξ1R = Xi1(PR, d, MPR) Ξ2R = Xi2(PR, d, MPR) OR = dot(Ξ1R, Ξ2R) _, QL_1 = eig(OL) _, QR_1 = eig(OR) if SL is not None: cL = dot(LL, reorder(SL, order='atypical')) cR = dot(LR, reorder(SR, order='atypical')) XL = dot(QL_1, cL[4:8]) XR = dot(QR_1, cR[4:8]) yL = concatenate([PL.v, [PL.J[d]]]) yR = concatenate([PR.v, [PR.J[d]]]) x_ = solve(YL - YR, yR - yL - dt * (XL + XR) + dot(YL, xL) - dot(YR, xR)) else: yL = concatenate([PL.v, [PL.J[d]]]) yR = concatenate([PR.v, [PR.J[d]]]) x_ = solve(YL - YR, yR - yL + dot(YL, xL) - dot(YR, xR)) cL[:4] = x_ - xL cR[:4] = x_ - xR PLvec = reorder(Pvec(PL, MPL.THERMAL), order='atypical') PRvec = reorder(Pvec(PR, MPR.THERMAL), order='atypical') PL_vec = dot(RL, cL) + PLvec PR_vec = dot(RR, cR) + PRvec QL_ = Pvec_to_Cvec(reorder(PL_vec), MPL) QR_ = Pvec_to_Cvec(reorder(PR_vec), MPR) return QL_, QR_
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
def M_prim(Q, d, MP): """ The system jacobian of the primitive system NOTE: Uses typical ordering """ P = State(Q, MP) ρ = P.ρ p = P.p() A = P.A v = P.v c0 = c_0(ρ, p, A, MP) ret = v[d] * eye(NV) ret[0, 2 + d] = ρ ret[1, 2 + d] = ρ * c0**2 ret[2 + d, 1] = 1 / ρ if VISCOUS: σ = P.σ() dσdρ = P.dσdρ() dσdA = P.dσdA() ret[1, 2:5] += σ[d] - ρ * dσdρ[d] ret[2:5, 0] = -1 / ρ * dσdρ[d] ret[2:5, 5:14] = -1 / ρ * dσdA[d].reshape([3, 9]) ret[5 + d, 2:5] = A[0] ret[8 + d, 2:5] = A[1] ret[11 + d, 2:5] = A[2] if THERMAL: dTdρ = P.dTdρ() dTdp = P.dTdp() T = P.T() ch = c_h(ρ, T, MP) ret[1, 14 + d] = ρ * ch**2 / dTdp ret[14 + d, 0] = dTdρ / ρ ret[14 + d, 1] = dTdp / ρ return ret
def star_stepper(QL, QR, MPL, MPR, NV=17): PL = State(QL, MPL) PR = State(QR, MPR) LhatL = riemann_constraints(QL, -1, MPL) LhatR = riemann_constraints(QR, 1, MPR) cL = zeros(NV) cR = zeros(NV) if STICK: YL = Y_matrix(PL, MPL, -1) YR = Y_matrix(PR, MPR, 1) if THERMAL: xL = concatenate([PL.Σ()[0], [PL.T()]]) xR = concatenate([PR.Σ()[0], [PR.T()]]) yL = concatenate([PL.v, PL.J[:1]]) yR = concatenate([PR.v, PR.J[:1]]) else: xL = PL.Σ()[0] xR = PR.Σ()[0] yL = PL.v yR = PR.v x_ = solve(YL - YR, yR - yL + dot(YL, xL) - dot(YR, xR)) else: # slip conditions - only implemented for non-thermal if THERMAL: YL = Y_matrix(PL, MPL, -1)[[0, 3]] YR = Y_matrix(PR, MPR, 1)[[0, 3]] xL = array([PL.Σ()[0], PL.T()]) xR = array([PR.Σ()[0], PR.T()]) yL = array([PL.v[0], PL.J[0]]) yR = array([PR.v[0], PR.J[0]]) M = YL[:, [0, -1]] - YR[:, [0, -1]] x_ = solve(M, yR - yL + dot(YL, xL) - dot(YR, xR)) x_ = array([x_[0], 0, 0, x_[1]]) else: YL = Y_matrix(PL, MPL, -1)[0] YR = Y_matrix(PR, MPR, 1)[0] xL = PL.Σ()[0] xR = PR.Σ()[0] yL = PL.v[0] yR = PR.v[0] x_ = (yR - yL + dot(YL, xL) - dot(YR, xR)) / (YL - YR)[0] x_ = array([x_, 0, 0]) cL[:n1] = x_ - xL cR[:n1] = x_ - xR PLvec = Pvec(QL, MPL) PRvec = Pvec(QR, MPR) PL_vec = solve(LhatL, cL) + PLvec PR_vec = solve(LhatR, cR) + PRvec QL_ = Pvec_to_Cvec(PL_vec, MPL) QR_ = Pvec_to_Cvec(PR_vec, MPR) return QL_, QR_