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 riemann_constraints(P, sgn, MP): """ K=R: sgn = -1 K=L: sgn = 1 NOTE: Uses atypical ordering Extra constraints are: dΣ = dΣ/dρ * dρ + dΣ/dp * dp + dΣ/dA * dA dT = dT/dρ * dρ + dT/dp * dp v*L = v*R J*L = J*R """ _, Lhat, Rhat = eigen(P, 0, MP, False) Lhat = reorder(Lhat.T, order='atypical').T Rhat = reorder(Rhat, order='atypical') σA = P.dσdA() σρ = P.dσdρ() Tρ = P.dTdρ() Tp = P.dTdp() Lhat[:3, 0] = -σρ[0] Lhat[:3, 1] = array([1, 0, 0]) for i in range(3): Lhat[:3, 2 + 3 * i:5 + 3 * i] = -σA[0, :, :, i] Lhat[:3, 11:] = 0 if MP.THERMAL: Lhat[3, 0] = Tρ Lhat[3, 1] = Tp Lhat[3, 2:] = 0 Lhat[4:8, 11:15] *= -sgn Ξ1 = Xi1(P, 0, MP) Ξ2 = Xi2(P, 0, MP) O = dot(Ξ1, Ξ2) w, vl, vr = eig(O, left=1) D_1 = diag(1 / sqrt(w.real)) Q = vl.T Q_1 = vr I = dot(Q, Q_1) Q = solve(I, Q) tmp = zeros([5, 5]) tmp[:4] = Lhat[:4, :5] tmp[4] = Lhat[8, :5] b = zeros([5, 4]) b[:4, :4] = eye(4) X = solve(tmp, b) Rhat[:5, :4] = X Y0 = dot(Q_1, dot(D_1, Q)) Y = -sgn * dot(Y0, dot(Ξ1, X)) Rhat[11:15, :4] = Y Rhat[:, 4:8] = 0 Rhat[11:15, 4:8] = sgn * Q_1 return Lhat, Rhat
def Y_matrix(P, MP, sgn): ρ = P.ρ A = P.A σρ = P.dσdρ() σA = P.dσdA() e0 = array([1, 0, 0]) Π1 = σA[0, :, :, 0] tmp = zeros([5, 5]) tmp[:3, 0] = -σρ[0] tmp[0, 1] = 1 tmp[:3, 2:5] = -Π1 if THERMAL: tmp[3, 0] = P.dTdρ() tmp[3, 1] = P.dTdp() tmp[4, 0] = -1 / ρ tmp[4, 2:5] = inv(A)[0] else: p = P.p() σ = P.σ() c0 = c_0(ρ, p, A, MP) B = zeros([2, 3]) B[0, 0] = ρ B[1] = σ[0] - ρ * σρ[0] B[1, 0] += ρ * c0**2 rhs = column_stack((-σρ[0], e0)) C = solve(Π1, rhs) BA_1 = dot(B, inv(A)) Z = eye(2) - dot(BA_1, C) W = concatenate([eye(2), -BA_1], axis=1) tmp[3:5] = solve(Z, W) b = zeros([5, n1]) b[:n1, :n1] = eye(n1) X = solve(tmp, b) Ξ1 = Xi1(P, 0, MP) Ξ2 = Xi2(P, 0, MP) Ξ = dot(Ξ1, Ξ2) w, vr = eig(Ξ) D_1 = diag(1 / sqrt(w.real)) Q_1 = vr Q = inv(Q_1) Y0 = dot(Q_1, dot(D_1, Q)) return sgn * dot(Y0, dot(Ξ1, X))
def TAT_test(d, MP): Q = generate_vector(MP) P = State(Q, MP) Ξ1 = Xi1(P, d, MP) Ξ2 = Xi2(P, d, MP) TAT_py = dot(Ξ1, Ξ2) TAT_cp = GPRpy.system.thermo_acoustic_tensor(Q, d, MP) print("TAT ", check(TAT_cp, TAT_py)) return TAT_cp, TAT_py
def eigenvalues(P, d, MP): v = P.v vd = v[d] n1, n2, n3, n4, n5, n6 = get_indexes() Ξ1 = Xi1(P, d, MP) Ξ2 = Xi2(P, d, MP) Ξ = dot(Ξ1, Ξ2) w, vl, vr = eig(Ξ, left=1) sw = sqrt(w.real) D = diag(sw) l = array([vd + λ for λ in diag(D)] + [vd - λ for λ in diag(D)] + [vd] * n3) return l
def riemann_constraints(P, sgn, MP, left=False): """ K=R: sgn = -1 K=L: sgn = 1 NOTE: Uses atypical ordering Extra constraints are: dΣ = dΣ/dρ * dρ + dΣ/dp * dp + dΣ/dA * dA dT = dT/dρ * dρ + dT/dp * dp v*L = v*R J*L = J*R """ _, Lhat, Rhat = eigen(P, 0, False, MP, values=False, right=True, left=left, typical_order=False) if left: Lhat = left_riemann_constraints(P, Lhat, sgn) ρ = P.ρ A = P.A σρ = P.dσdρ() σA = P.dσdA() e0 = array([1, 0, 0]) Π1 = σA[0, :, :, 0] tmp = zeros([5, 5]) tmp[:3, 0] = -σρ[0] tmp[0, 1] = 1 tmp[:3, 2:5] = -Π1 if THERMAL: tmp[3, 0] = P.dTdρ() tmp[3, 1] = P.dTdp() tmp[4, 0] = -1 / ρ tmp[4, 2:5] = inv(A)[0] else: p = P.p() σ = P.σ() c0 = c_0(ρ, p, A, MP) B = zeros([2, 3]) B[0, 0] = ρ B[1] = σ[0] - ρ * σρ[0] B[1, 0] += ρ * c0**2 rhs = column_stack((-σρ[0], e0)) C = solve(Π1, rhs) BA_1 = dot(B, inv(A)) Z = eye(2) - dot(BA_1, C) W = concatenate([eye(2), -BA_1], axis=1) tmp[3:5] = solve(Z, W) b = zeros([5, n1]) b[:n1, :n1] = eye(n1) X = solve(tmp, b) Rhat[:5, :n1] = X Ξ1 = Xi1(P, 0, MP) Ξ2 = Xi2(P, 0, MP) Q, Q_1, _, D_1 = decompose_Ξ(Ξ1, Ξ2) Y0 = dot(Q_1, dot(D_1, Q)) Rhat[11:n5, :n1] = -sgn * dot(Y0, dot(Ξ1, X)) Rhat[:11, n1:n2] = 0 Rhat[11:n5, n1:n2] = sgn * dot(Q_1, D_1) return Lhat, Rhat
def right_eigenvectors(P, d, MP, typical_order): σA = P.dσdA() σρ = P.dσdρ() Π1 = σA[d, :, :, 0] Π2 = σA[d, :, :, 1] Π3 = σA[d, :, :, 2] Ξ1 = Xi1(P, d, MP) Ξ2 = Xi2(P, d, MP) Q, Q_1, D, D_1 = decompose_Ξ(Ξ1, Ξ2) n1, n2, n3, n4, n5, n6 = get_indexes() e0 = array([1, 0, 0]) R = zeros([17, 17]) tmp1 = 0.5 * dot(Ξ2, dot(Q_1, D_1**2)) tmp2 = 0.5 * dot(Q_1, D_1) R[:5, :n1] = tmp1 R[:5, n1:n2] = tmp1 R[11:n5, :n1] = tmp2 R[11:n5, n1:n2] = -tmp2 if THERMAL: ρ = P.ρ A = P.A Tρ = P.dTdρ() Tp = P.dTdp() b = Tp * σρ[d] + Tρ * e0 c = 1 / (solve(dot(Π1, A), b)[d] + Tp / ρ) R[0, 8] = -c * Tp R[1, 8] = c * Tρ R[2:5, 8] = c * solve(Π1, b) R[15, 15] = 1 R[16, 16] = 1 else: R[0, 6] = 1 R[1, 7] = 1 R[2:5, 6] = -solve(Π1, σρ[0]) R[2:5, 7] = solve(Π1, e0) R[2:5, n3:n4] = -solve(Π1, Π2) R[2:5, n4:n5] = -solve(Π1, Π3) for i in range(6): R[5 + i, n3 + i] = 1 if typical_order: R = reorder(R) if not THERMAL: R = R[:14, :14] return R
def left_eigenvectors(P, d, MP, typical_order): ρ = P.ρ A = P.A σA = P.dσdA() σρ = P.dσdρ() Π1 = σA[d, :, :, 0] Π2 = σA[d, :, :, 1] Π3 = σA[d, :, :, 2] Ξ1 = Xi1(P, d, MP) Ξ2 = Xi2(P, d, MP) Q, Q_1, D, D_1 = decompose_Ξ(Ξ1, Ξ2) n1, n2, n3, n4, n5, n6 = get_indexes() e0 = array([1, 0, 0]) L = zeros([17, 17]) tmp1 = dot(Q, Ξ1) tmp2 = -dot(Q[:, :3], Π2) / ρ tmp3 = -dot(Q[:, :3], Π3) / ρ tmp4 = dot(D, Q) L[:n1, :5] = tmp1 L[n1:n2, :5] = tmp1 L[:n1, 5:8] = tmp2 L[n1:n2, 5:8] = tmp2 L[:n1, 8:11] = tmp3 L[n1:n2, 8:11] = tmp3 L[:n1, 11:n5] = tmp4 L[n1:n2, 11:n5] = -tmp4 if THERMAL: tmp = inv(A)[0] L[8, 0] = -1 / ρ L[8, 2:5] = tmp L[8, 5:8] = dot(tmp, solve(Π1, Π2)) L[8, 8:11] = dot(tmp, solve(Π1, Π3)) L[15, 15] = 1 L[16, 16] = 1 else: σ = P.σ() p = P.p() c0 = c_0(ρ, p, A, MP) B = zeros([2, 3]) B[0, 0] = ρ B[1] = σ[0] - ρ * σρ[0] B[1, 0] += ρ * c0**2 C = zeros([3, 2]) C[:, 0] = -solve(Π1, σρ[0]) C[:, 1] = solve(Π1, e0) BA_1 = dot(B, inv(A)) Z = eye(2) - dot(BA_1, C) X = zeros([2, 14]) X[:, :2] = eye(2) X[:, 2:5] = -BA_1 X[:, 5:8] = -dot(BA_1, solve(Π1, Π2)) X[:, 8:11] = -dot(BA_1, solve(Π1, Π3)) L[6:8, :14] = solve(Z, X) for i in range(6): L[n3 + i, 5 + i] = 1 if typical_order: L = reorder(L.T).T if not THERMAL: L = L[:14, :14] return L