def riemann_constraints(Q, sgn, MP): M = M_prim(Q, 0, MP) λ, L = eig(M, left=True, right=False) λ = λ.real L = L.T Lhat = L[λ.argsort()] Lhat[:n1] *= 0 P = State(Q, MP) σρ = P.dσdρ() σA = P.dσdA() Lhat[:3, 0] = -σρ[0] Lhat[0, 1] = 1 for i in range(3): Lhat[:3, 5 + 3 * i:8 + 3 * i] = -σA[0, :, i] if THERMAL: Lhat[3, 0] = P.dTdρ() Lhat[3, 1] = P.dTdp() Lhat[-n1:, 2:5] *= -sgn if THERMAL: Lhat[-n1:, 14] *= -sgn return Lhat
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