Skip to content

Commit ca8ef00

Browse files
committed
this is final version
1 parent 475d596 commit ca8ef00

File tree

2 files changed

+182
-35
lines changed

2 files changed

+182
-35
lines changed

riemann_exact.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# solve the Riemann problem for a gamma-law gas
1+
"""An exact Riemann solver for the Euler equations with a gamma-law
2+
gas. The left and right states are stored as State objects. We then
3+
create a RiemannProblem object with the left and right state:
4+
5+
> rp = RiemannProblem(left_state, right_state)
6+
7+
Next we solve for the star state:
8+
9+
> rp.find_star_state()
10+
11+
Finally, we sample the solution to find the interface state, which
12+
is returned as a State object:
13+
14+
> q_int = rp.sample_solution()
15+
"""
216

317
import numpy as np
418
import scipy.optimize as optimize
@@ -95,6 +109,8 @@ def rarefaction_solution(self, sgn, state):
95109
lambda_head = state.u + sgn*c
96110
lambda_tail = self.ustar + sgn*cstar
97111

112+
gam_fac = (self.gamma - 1.0)/(self.gamma + 1.0)
113+
98114
if (sgn > 0 and lambda_head < 0) or (sgn < 0 and lambda_head > 0):
99115
# R/L region
100116
solution = state
@@ -118,8 +134,6 @@ def rarefaction_solution(self, sgn, state):
118134
def sample_solution(self):
119135
"""given the star state (ustar, pstar), find the state on the interface"""
120136

121-
gam_fac = (self.gamma - 1.0)/(self.gamma + 1.0)
122-
123137
if self.ustar < 0:
124138
# we are in the R* or R region
125139
state = self.right
@@ -150,6 +164,7 @@ def cons_flux(state, v):
150164
state.p/(v.gamma - 1.0) + state.p) * state.u
151165
return flux
152166

167+
153168
if __name__ == "__main__":
154169

155170
q_l = State(rho=1.0, u=0.0, p=1.0)

0 commit comments

Comments
 (0)