def pop_plot(): """ 10.1016/j.jcp.2018.03.037 5.3. C4 Pop-plot """ tf = 1e-7 nx = 2000 Lx = 6.4e-2 L0 = 0.04e-2 MP = C4_JWL_SI ρ = 1590 p = 1e5 pb = 30e9 v = zeros(3) A = eye(3) Q = Cvec(ρ, p, v, MP, A, λ=1) Qb = Cvec(ρ, pb, v, MP, A, λ=0) dX = [Lx / nx] u = zeros([nx, 15]) for i in range(nx): x = (i + 0.5) * dX[0] if x < L0: u[i] = Qb else: u[i] = Q return u, [MP], tf, dX, 'transitive'
def primitive_IC(nx, dX, ρL, pL, vL, ρR, pR, vR, MPs, x0=0.5, λL=None, λR=None): isMulti = len(MPs) > 1 MPL = MPs[0] MPR = MPs[1] if isMulti else MPL AL = (ρL / MPL.ρ0)**(1 / 3) * eye(3) JL = zeros(3) QL = Cvec(ρL, pL, vL, MPL, AL, JL, λL) AR = (ρR / MPR.ρ0)**(1 / 3) * eye(3) JR = zeros(3) QR = Cvec(ρR, pR, vR, MPR, AR, JR, λR) return riemann_IC(nx, dX, QL, QR, x0, isMulti)
def aluminium_plates(): """ N = 2 cfl = 0.8 SPLIT = True FLUX = 0 LSET = 2 RIEMANN_STICK = false RIEMANN_RELAXATION = true STAR_TOL = 1e-8 """ MP = Al_GRP_SI Lx = 0.03 Ly = 0.04 nx = 300 ny = 400 tf = 5e-6 ρ = MP.ρ0 p = 0 v0 = array([400., 0., 0.]) v1 = zeros(3) A = eye(3) MPs = [VAC, MP, MP] dX = [Lx / nx, Ly / ny] Q0 = pad(Cvec(ρ, p, v0, MP, A), (0, 2), 'constant') Q1 = pad(Cvec(ρ, p, v1, MP, A), (0, 2), 'constant') u = zeros([nx, ny, 16]) for i in range(nx): for j in range(ny): x = (i+0.5) * dX[0] y = (j+0.5) * dX[1] # projectile if 0.001 <= x <= 0.006 and 0.014 <= y <= 0.026: u[i, j] = Q0 u[i, j, -2] = 1 u[i, j, -1] = -1 # plate elif 0.006 <= x <= 0.028 and 0.003 <= y <= 0.037: u[i, j] = Q1 u[i, j, -2] = 1 u[i, j, -1] = 1 # vacuum else: u[i, j, -2] = -1 u[i, j, -1] = -1 u = u[:, int(ny/2):] return u, MPs, tf, dX, 'halfy'
def helium_bubble(): """ 10.1016/j.jcp.2003.10.010 5. Numerical experiments - Test B N = 3 cfl = 0.5 SPLIT = True SOLVER = 'rusanov' """ #tf = 7e-4 tf = 14e-4 nx = 200 Lx = 1 dX = [Lx / nx] dx = dX[0] ρL = 1.3333 pL = 1.5e5 vL = array([35.35 * sqrt(10), 0, 0]) AL = ρL**(1 / 3) * eye(3) ρM = 1 pM = 1e5 vM = zeros(3) AM = ρM**(1 / 3) * eye(3) ρR = 0.1379 pR = 1e5 vR = zeros(3) AR = ρR**(1 / 3) * eye(3) u = zeros([nx, 18]) Q1 = Cvec(ρL, pL, vL, Air_SG_SI, AL) Q2 = Cvec(ρM, pM, vM, Air_SG_SI, AM) Q3 = Cvec(ρR, pR, vR, He_SG_SI, AR) for i in range(nx): if i * dx < 0.05: u[i] = Q1 elif i * dx < 0.4: u[i] = Q2 elif i * dx < 0.6: u[i] = Q3 else: u[i] = Q2 if i * dx < 0.4 or i * dx >= 0.6: u[i, -1] = -1 else: u[i, -1] = 1 return u, [Air_SG_SI, He_SG_SI], tf, dX, 'transitive'
def pbx_copper(test): """ 10.1016/j.jcp.2011.07.008 6.1 Initial value problems N = 3 cfl = 0.5 SPLIT = True FLUX = 0 """ nx = 3000 Lx = 1 dX = [Lx / nx] if test == 1: pL = 18.9e9 vR = zeros(3) FR = eye(3) tf = 5e-5 elif test == 2: pL = 1e5 vR = array([2, 0, 0.1]) FR = array([[1, 0, 0], [-0.01, 0.95, 0.02], [-0.015, 0, 0.9]]) tf = 9e-5 vL = zeros(3) ρL = 1840 AL = eye(3) SR = 0 if test == 1: QL = Cvec(ρL, pL, vL, PBX_SG_SI, AL) QR = Cvec_hyp(FR, SR, vR, Cu_HYP_SI) MPs = [PBX_SG_SI, Cu_GR_SI] elif test == 2: QL = Cvec_hyp(FR, SR, vR, Cu_HYP_SI) QR = Cvec(ρL, pL, vL, PBX_SG_SI, AL) MPs = [Cu_GR_SI, PBX_SG_SI] QL = concatenate([QL, [0]]) QR = concatenate([QR, [0]]) u = riemann_IC(nx, dX, QL, QR, 0.5, True) return u, MPs, tf, dX, 'transitive'
def viscous_shock(center=0): """ 10.1016/j.jcp.2016.02.015 4.13 Viscous shock profile """ tf = 0.2 nx = 100 Lx = 1 Ms = 2 γ = 1.4 μ = 2e-2 MP = material_params(EOS='sg', ρ0=1, cv=2.5, γ=γ, b0=5, cα=5, μ=μ, Pr=0.75) dX = [Lx / nx] x = arange(-Lx / 2, Lx / 2, 1 / nx) ρ = zeros(nx) p = zeros(nx) v = zeros(nx) for i in range(nx): ρ[i], p[i], v[i] = viscous_shock_exact(x[i], Ms, MP, μ, center=center) v -= v[0] # Velocity in shock 0 u = zeros([nx, 17]) for i in range(nx): A = (ρ[i])**(1 / 3) * eye(3) J = zeros(3) u[i] = Cvec(ρ[i], p[i], array([v[i], 0, 0]), MP, A, J) return u, [MP], tf, dX, 'transitive'
def boundary_layer(): tf = 10 Lx = 1.5 Ly = 0.4 nx = 75 ny = 100 γ = 1.4 ρ = 1 p = 100 / γ v = array([1, 0, 0]) A = eye(3) MP = material_params(EOS='sg', ρ0=ρ, cv=1, γ=γ, b0=8, μ=1e-3) u = zeros([nx, ny, 14]) Q = Cvec(ρ, p, v, MP, A) for i in range(nx): for j in range(ny): u[i, j] = Q print("LAMINAR BOUNDARY LAYER") return u, [MP], tf, [Lx / nx, Ly / ny], ''
def piston(): """ http://arxiv.org/abs/1806.00706 6.1 Elasto-plastic piston N = 3 cfl = 0.5 SPLIT = True SOLVER = 'roe' """ tf = 1.5e-4 nx = 400 Lx = 1 dX = [Lx / nx] MP = Cu_SMGP_SI ρ = MP.ρ0 p = 0 v = zeros(3) A = eye(3) Q = Cvec(ρ, p, v, MP, A) u = zeros([nx, 14]) for i in range(nx): u[i] = Q return u, [MP], tf, dX, 'piston_bc'
def convected_vortex(μ=1e-6, κ=1e-6, t=0): tf = 1 Lx = 10 Ly = 10 nx = 10 ny = 10 ε = 5 γ = 1.4 ρ = 1 p = 1 v = array([1, 1, 0]) J = zeros(3) dX = [Lx / nx, Ly / ny] MP = material_params(EOS='sg', ρ0=ρ, cv=2.5, γ=γ, b0=0.5, cα=1, μ=μ, κ=κ) u = zeros([nx, ny, 17]) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] dv, dT, dρ, dp, A = vortex(x, y, Lx / 2 + t, Ly / 2 + t, ε, γ, ρ) u[i, j] = Cvec(ρ + dρ, p + dp, v + dv, MP, A, J) print("CONVECTED ISENTROPIC VORTEX") return u, [MP], tf, dX, 'periodic'
def taylor_green(): tf = 10 Lx = 2 * pi Ly = 2 * pi nx = 50 ny = 50 γ = 1.4 ρ = 1 p = 100 / γ A = eye(3) MP = material_params(EOS='sg', ρ0=ρ, cv=1, γ=γ, b0=10, μ=1e-2) dX = [Lx / nx, Ly / ny] u = zeros([nx, ny, 14]) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] v = array([sin(x) * cos(y), -cos(x) * sin(y)]) pi = p + (cos(2 * x) + cos(2 * y)) / 4 u[i, j] = Cvec(ρ, pi, v, MP, A) print("TAYLOR-GREEN VORTEX") return u, [MP], tf, dX
def double_shear_layer(): tf = 1.8 Lx = 1 Ly = 1 nx = 200 ny = 200 γ = 1.4 ρ = 1 p = 100 / γ A = eye(3) MP = material_params(EOS='sg', ρ0=ρ, cv=1, γ=γ, b0=8, μ=2e-4) dX = [Lx / nx, Ly / ny] ρ_ = 30 δ = 0.05 u = zeros([nx, ny, 14]) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] if y > 0.75: v1 = tanh(ρ_ * (0.75 - y)) else: v1 = tanh(ρ_ * (y - 0.25)) v2 = δ * sin(2 * pi * x) v = array([v1, v2, 0]) u[i, j] = Cvec(ρ, p, v, MP, A) print("DOUBLE SHEAR LAYER") return u, [MP], tf, dX
def cylindrical_shock(): """ 10.1002/nme.2695 6.2. Two-dimensional test case N = 4 cfl = 0.8 SPLIT = True SOLVER = 'roe' """ tf = 10e-6 nx = 500 ny = 500 Lx = 0.2 Ly = 0.2 dX = [Lx / nx, Ly / ny] MP = Cu_GRP_SI ρi = MP.ρ0 pi = 0 Ai = eye(3) ρo = 9375 po = 10e9 Ao = (ρo / MP.ρ0)**(1 / 3) * eye(3) v = zeros(3) Qi = Cvec(ρi, pi, v, MP, Ai) Qo = Cvec(ρo, po, v, MP, Ao) u = zeros([nx, ny, 14]) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] r = sqrt((x - Lx / 2)**2 + (y - Ly / 2)**2) if r > 0.02: u[i, j] = Qo else: u[i, j] = Qi return u[:, 250:], [MP], tf, dX, 'slip'
def steady_znd(): n = 100 MP = NM_JWL_SI L = 0.0062432 ρ = 1137 p = 23e9 tf = 1e-6 Q = Cvec(ρ, 0, zeros(3), MP, A=eye(3), λ=1) Qs = Cvec(ρ, p, zeros(3), MP, A=eye(3), λ=1) u = zeros([n, 15]) for i in range(n): u[i] = Q u[0] = Qs return u, [MP], tf, [L / n], 'transitive'
def generate_vector(MP): A = rand(3, 3) A *= sign(det(A)) ρ = det(A) * MP.ρ0 p = rand() v = rand(3) J = rand(3) E = total_energy(ρ, p, v, A, J, 0, MP) return Cvec(ρ, p, v, A, J, MP)
def generate_vecs(MP): A = rand(3, 3) A /= sign(det3(A)) ρ = det3(A) * MP.ρ0 p = rand() v = rand(3) J = rand(3) Q = Cvec(ρ, p, v, MP, A, J) P = State(Q, MP) return Q, P
def circular_explosion(): tf = 0.2 Lx = 2 Ly = 2 nx = 400 ny = 400 R = 0.25 * Lx MP = material_params(EOS='sg', ρ0=1, cv=2.5, γ=1.4, b0=0.5, cα=0.5, μ=1e-4, κ=1e-4) dX = [Lx / nx, Ly / ny] v = zeros([3]) J = zeros([3]) ρi = 1 pi = 1 Ai = eye(3) Qi = Cvec(ρi, pi, v, MP, Ai, J) ρo = 0.125 po = 0.1 Ao = 0.5 * eye(3) Qo = Cvec(ρo, po, v, MP, Ao, J) u = zeros([nx, ny, 17]) for i in range(nx): for j in range(ny): x = -Lx / 2 + (i + 0.5) * dX[0] y = -Ly / 2 + (j + 0.5) * dX[1] r = sqrt(x**2 + y**2) if r < R: u[i, j] = Qi else: u[i, j] = Qo print("CIRCULAR EXPLOSION") return u, [MP], tf, dX, 'transitive'
def shock_detonation(): tf = 0.5 L = 1 nx = 400 MP = material_params('sg', ρ0=1, γ=1.4, cv=2.5, b0=1e-8, μ=1e-4, Qc=1, Kc=250, Ti=0.25, REACTION='d') ρL = 1.4 pL = 1 vL = zeros(3) AL = ρL**(1 / 3) * eye(3) λL = 0 ρR = 0.887565 pR = 0.191709 vR = array([-0.57735, 0, 0]) AR = ρR**(1 / 3) * eye(3) λR = 1 QL = Cvec(ρL, pL, vL, MP, A=AL, λ=λL) QR = Cvec(ρR, pR, vR, MP, A=AR, λ=λR) u = zeros([nx, 15]) for i in range(nx): if i < nx / 4: u[i] = QL else: u[i] = QR return u, [MP], tf, [L / nx], 'transitive'
def Wfan(S, P, MP, a): r = P.ρ u = P.v[0] p = P.p() y = MP.γ pINF = MP.pINF temp = 2 / (y + 1) + (y - 1) * (u - S) / ((y + 1) * a) rf = r * pow(temp, 2 / (y - 1)) vf = array([2 * (a + (y - 1) * u / 2 + S) / (y + 1), 0, 0]) pf = (p + pINF) * pow(temp, 2 * y / (y - 1)) - pINF return Cvec(rf, pf, vf, MP)
def taylor_bar(): """ N = 2 cfl = 0.8 SPLIT = True FLUX = 0 LSET = 1 DESTRESS = false RIEMANN_STICK = false RIEMANN_RELAXATION = true STAR_TOL = 1e-8 """ Lx = 200 Ly = 550 tf = 5e3 nx = 200 ny = int(nx * Ly / Lx) dX = [Lx / nx, Ly / ny] p = 0 v = array([0, -0.015, 0]) A = eye(3) MP = Al_SMGP_CGS MPs = [VAC, MP] Q = pad(Cvec(MP.ρ0, p, v, MP, A), (0, 1), 'constant') u = zeros([nx, ny, 15]) for i in range(nx): for j in range(ny): x = (i+0.5) * dX[0] y = (j+0.5) * dX[1] # projectile if Lx / 4 <= x <= 3 * Lx / 4 and y <= 5.5 * Ly / 6: u[i, j] = Q u[i, j, -1] = 1 # vacuum else: u[i, j, -1] = -1 u = u[int(nx/2):] return u, MPs, tf, dX, 'halfx'
def rod_penetration(): """ N = 2 cfl = 0.8 SPLIT = True FLUX = 0 LSET = 2 RIEMANN_RELAXATION = true """ D = 0.029 V = -1250 # D = 0.0495 # V = -1700 o = 0.01 nx = 200 Lx = 0.06 Ly = 0.05 + 1.5 * D ny = int(nx * Ly / Lx) dX = [Lx / nx, Ly / ny] tf = 20e-6 # 80e-6 MP1 = W_SMGP_SI MP2 = Steel_SMGP_SI p = 0 v1 = array([0, V, 0]) v2 = zeros(3) A = eye(3) MPs = [VAC, MP1, MP2] dX = [Lx / nx, Ly / ny] Q1 = pad(Cvec(MP1.ρ0, p, v1, MP1, A), (0, 2), 'constant') Q2 = pad(Cvec(MP2.ρ0, p, v2, MP2, A), (0, 2), 'constant') u = zeros([nx, ny, 16]) for i in range(nx): for j in range(ny): x = (i+0.5) * dX[0] y = (j+0.5) * dX[1] # projectile if 0.028 <= x <= 0.032 and D + o <= y <= D + 0.05 + o: u[i, j] = Q1 u[i, j, -2] = 1 u[i, j, -1] = -1 # plate elif o <= y <= D + o: u[i, j] = Q2 u[i, j, -2] = 1 u[i, j, -1] = 1 # vacuum else: u[i, j, -2] = -1 u[i, j, -1] = -1 u = u[int(nx/2):] return u, MPs, tf, dX, 'halfx'
def exact_euler(n, t, x0, QL, QR, MPL, MPR): """ Returns the exact solution to the Euler equations at (x,t), given initial states PL for x<x0 and PR for x>x0 """ ret = zeros([n, len(QL)]) PL = State(QL, MPL) PR = State(QR, MPR) ρL = PL.ρ ρR = PR.ρ uL = PL.v[0] uR = PR.v[0] pL = PL.p() pR = PR.p() c0L = c_0(ρL, pL, eye(3), MPL) c0R = c_0(ρR, pR, eye(3), MPR) p_ = p_star(PL, PR, MPL, MPR) u_ = u_star(p_, PL, PR, MPL, MPR) print('Interface:', u_ * t + x0) for i in range(n): x = (i + 0.5) / n S = (x - x0) / t if (S < u_): if (p_ < pL): # Left fan if (S < uL - c0L): ret[i] = QL else: STL = u_ - c0_star(p_, PL, MPL) if (S < STL): ret[i] = Wfan(S, PL, MPL, c0L) else: r_ = r_star_fan(p_, PL, MPL) v_ = array([u_, 0, 0]) ret[i] = Cvec(r_, p_, v_, MPL) else: # Left shock SL = uL - Q(p_, PL, MPL) / ρL if (S < SL): ret[i] = QL else: r_ = r_star_shock(p_, PL, MPL) v_ = array([u_, 0, 0]) ret[i] = Cvec(r_, p_, v_, MPL) ret[i, -1] = -1 else: if (p_ < pR): # Right fan if (uR + c0R < S): ret[i] = QR else: STR = u_ + c0_star(p_, PR, MPR) if (STR < S): ret[i] = Wfan(S, PR, MPR, -c0R) else: r_ = r_star_fan(p_, PR, MPR) v_ = array([u_, 0, 0]) ret[i] = Cvec(r_, p_, v_, MPR) else: # Right shock SR = uR + Q(p_, PR, MPR) / ρR if (SR < S): ret[i] = QR else: r_ = r_star_shock(p_, PR, MPR) v_ = array([u_, 0, 0]) ret[i] = Cvec(r_, p_, v_, MPR) ret[i, -1] = 1 return ret
def rod_impact(): """ N = 2 cfl = 0.8 SPLIT = True FLUX = 0 LSET = 3 RIEMANN_STICK = false RIEMANN_RELAXATION = true STAR_TOL = 1e-8 PRIM_RECONSTRUCT = true """ Lx = 0.55 Ly = 0.18 nx = 2000 tf = 60e-6 nx = int(nx) ny = int(nx * Ly / Lx) dX = [Lx / nx, Ly / ny] MPa = Air_SG_SI MPm = Cu_GRP_SI2 MPe = NM_CC_SI pm = 1e5 pe = 1e5 pa = 1e5 v1 = array([2000, 0, 0]) v = zeros(3) A = eye(3) MPs = [MPa, MPe, MPm, MPm] dX = [Lx / nx, Ly / ny] Qm1 = pad(Cvec(MPm.ρ0, pm, v1, MPm, A, λ=0), (0, 3), 'constant') Qm2 = pad(Cvec(MPm.ρ0, pm, v, MPm, A, λ=0), (0, 3), 'constant') Qe = pad(Cvec(MPe.ρ0, pe, v, MPe, A, λ=1), (0, 3), 'constant') Qa = pad(Cvec(MPa.ρ0, pa, v, MPa, A, λ=0), (0, 3), 'constant') u = zeros([nx, ny, 18]) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] # projectile if x <= 0.06 and 0.04 <= y <= 0.14: u[i, j] = Qm1 u[i, j, -3] = 1 u[i, j, -2] = 1 u[i, j, -1] = 1 # casing elif ((0.06 <= x <= 0.08 or 0.53 <= x <= 0.55) and 0.02 <= y <= 0.16) or \ (0.08 <= x <= 0.53 and (0.02 <= y <= 0.04 or 0.14 <= y <= 0.16)): u[i, j] = Qm2 u[i, j, -3] = 1 u[i, j, -2] = 1 u[i, j, -1] = -1 # explosive elif 0.08 <= x <= 0.53 and 0.04 <= y <= 0.14: u[i, j] = Qe u[i, j, -3] = 1 u[i, j, -2] = -1 u[i, j, -1] = -1 # air else: u[i, j] = Qa u[i, j, -3] = -1 u[i, j, -2] = -1 u[i, j, -1] = -1 u = u[:, int(ny / 2):] return u, MPs, tf, dX, 'halfy'
wL = array([QL for i in range(N)]) wR = array([QR for i in range(N)]) """ wL = zeros([N, NV]) wR = zeros([N, NV]) v0 = zeros(3) J0 = zeros(3) for i in range(N): ρL = 3 - NODES[i] pL = ρL AL = ρL**(1 / 3) * eye(3) ρR = 2 - NODES[i] pR = ρR AR = ρR**(1 / 3) * eye(3) wL[i] = Cvec(ρL, pL, v0, AL, J0, MP) wR[i] = Cvec(ρR, pR, v0, AR, J0, MP) WwL = dot(W, wL) WwR = dot(W, wR) qL0 = array([wL for i in range(N)]) qR0 = array([wR for i in range(N)]) nX = NT * NV x0 = zeros(2 * nX + 6 * N) x0[0:nX] = qL0.ravel() x0[nX:2 * nX] = qR0.ravel() dt = 0.01 def f(x):
def confined_explosive(): """ N = 2 cfl = 0.8 SPLIT = True FLUX = 1 LSET = 3 / 4 RIEMANN_STICK = false RIEMANN_RELAXATION = true STAR_TOL = 1e-8 PRIM_RECONSTRUCT = true """ BACK_PLATE = False AIR_GAP = False NITRO = False Lx = 0.051 Ly = 0.09 nx = 200 tf = 4.9e-6 o = 0.0015 if AIR_GAP else 0 ny = int(nx * Ly / Lx) dX = [Lx / nx, Ly / ny] MPm = Steel_SMGP_SI MPa = Air_SG_SI if NITRO: MPe = NM_CC_SI else: MPe = C4_JWL_SI pm = 1e5 pe = 1e5 pa = 1e5 v1 = array([700, 0, 0]) v = zeros(3) A = eye(3) if AIR_GAP: MPs = [MPa, MPe, MPm, MPm, VAC] u = zeros([nx, ny, 19]) u[:, :, -4:] = 1 else: MPs = [MPe, MPm, MPm, VAC] u = zeros([nx, ny, 18]) u[:, :, -3:] = 1 dX = [Lx / nx, Ly / ny] Qm1 = Cvec(MPm.ρ0, pm, v1, MPm, A, λ=0) Qm2 = Cvec(MPm.ρ0, pm, v, MPm, A, λ=0) Qe = Cvec(MPe.ρ0, pe, v, MPe, A, λ=1) Qa = Cvec(MPa.ρ0, pa, v, MPa, A, λ=0) for i in range(nx): for j in range(ny): x = (i + 0.5) * dX[0] y = (j + 0.5) * dX[1] # air gap if 0.033 <= x <= 0.033 + o: u[i, j, :15] = Qa u[i, j, -4:] = -1 # projectile elif x <= 0.03 and 0.036 <= y <= 0.054: u[i, j, :15] = Qm1 u[i, j, -1] = -1 # front plate elif 0.03 <= x <= 0.033: u[i, j, :15] = Qm2 u[i, j, -2:] = -1 # explosive elif 0.033 + o <= x <= 0.039 + o: u[i, j, :15] = Qe u[i, j, -3:] = -1 # back plate elif 0.039 + o <= x: if BACK_PLATE: u[i, j, :15] = Qm2 u[i, j, -2:] = -1 else: u[i, j, :15] = Qe u[i, j, -3:] = -1 #u = u[:, int(ny/2):] return u, MPs, tf, dX, 'transitive'