Skip to content

Commit 2973bf9

Browse files
committed
exact solution
1 parent 3b4cc4f commit 2973bf9

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

compressible/riemann-slow-shock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
#right = riemann.State(p=1.0, u=-10.9636, rho=1.0)
2525

2626
# slow shock
27-
left = riemann.State(p=100.0, u=-1.5336, rho=5.6698)
28-
right = riemann.State(p=1.0, u=-10.5636, rho=1.0)
27+
left = riemann.State(p=100.0, u=-1.4701, rho=5.6698)
28+
right = riemann.State(p=1.0, u=-10.5, rho=1.0)
2929

3030
rp = riemann.RiemannProblem(left, right)
3131
rp.find_star_state()
3232

33-
x, rho, u, p = rp.sample_solution(0.2, 128)
33+
x, rho, u, p = rp.sample_solution(1.0, 128)
3434

3535
plt.subplot(311)
3636

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# plot the Hugoniot loci for a compressible Riemann problem
2+
3+
from __future__ import print_function
4+
5+
import numpy as np
6+
import riemann
7+
8+
9+
def store(left, right, time, gamma, outfile="riemann.out"):
10+
11+
rp = riemann.RiemannProblem(left, right, gamma=gamma)
12+
rp.find_star_state()
13+
14+
x, rho, u, p = rp.sample_solution(time, 128)
15+
16+
e = p/rho/(gamma - 1.0)
17+
18+
# output the solution
19+
with open(outfile, "w") as f:
20+
f.write("# left: {}\n".format(left))
21+
f.write("# right: {}\n".format(right))
22+
f.write("# gamma = {}\n".format(gamma))
23+
f.write("# time = {}\n".format(time))
24+
f.write("# {:^20} {:^20} {:^20} {:^20} {:^20}\n".format("x", "rho", "u", "p", "e"))
25+
for n in range(len(x)):
26+
f.write(" {:20.10g} {:20.10g} {:20.10g} {:20.10g} {:20.10g}\n".format(x[n], rho[n], u[n], p[n], e[n]))
27+
28+
29+
# Sod
30+
left = riemann.State(p=1.0, u=0.0, rho=1.0)
31+
right = riemann.State(p=0.1, u=0.0, rho=0.125)
32+
time = 0.2
33+
gamma = 1.4
34+
outfile = "sod_exact.out"
35+
36+
store(left, right, time, gamma, outfile=outfile)
37+
38+
# double rarefaction
39+
left = riemann.State(p=0.4, u=-2.0, rho=1.0)
40+
right = riemann.State(p=0.4, u=2.0, rho=1.0)
41+
time = 0.15
42+
gamma = 1.4
43+
outfile = "double_rarefaction_exact.out"
44+
45+
store(left, right, time, gamma, outfile=outfile)
46+
47+
# strong shock
48+
left = riemann.State(p=1000.0, u=0.0, rho=1.0)
49+
right = riemann.State(p=0.01, u=0.0, rho=1.0)
50+
time = 0.012
51+
gamma = 1.4
52+
outfile = "strong_shock_exact.out"
53+
54+
store(left, right, time, gamma, outfile=outfile)
55+
56+
# slow shock
57+
left = riemann.State(p=100.0, u=-1.4701, rho=5.6698)
58+
right = riemann.State(p=1.0, u=-10.5, rho=1.0)
59+
time = 1.0
60+
gamma = 1.4
61+
outfile = "slow_shock_exact.out"
62+
63+
store(left, right, time, gamma, outfile=outfile)

0 commit comments

Comments
 (0)