Skip to content

Commit 601be89

Browse files
author
Michael Zingale
committed
Merge branch 'master' of https://github.com/zingale/pyro2
2 parents e88b95b + 40e1c2d commit 601be89

File tree

6 files changed

+36
-68
lines changed

6 files changed

+36
-68
lines changed

compressible/BC.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def user(bcName, bcEdge, variable, my_data):
1616
ymom = my_data.get_var("y-momentum")
1717
ener = my_data.get_var("energy")
1818

19-
grav = my_data.rp.get_param("compressible.grav")
19+
grav = my_data.get_aux("grav")
20+
gamma = my_data.get_aux("gamma")
2021

2122
myg = my_data.grid
2223

@@ -52,15 +53,15 @@ def user(bcName, bcEdge, variable, my_data):
5253
dens[:,myg.jlo]
5354

5455
eint_base = (ener[:,myg.jlo] - ke_base)/dens[:,myg.jlo]
55-
pres_base = eos.pres(dens_base, eint_base)
56+
pres_base = eos.pres(gamma, dens_base, eint_base)
5657

5758
# we are assuming that the density is constant in this
5859
# formulation of HSE, so the pressure comes simply from
5960
# differencing the HSE equation
6061
j = myg.jlo-1
6162
while (j >= 0):
6263
pres_below = pres_base - grav*dens_base*myg.dy
63-
rhoe = eos.rhoe(pres_below)
64+
rhoe = eos.rhoe(gamma, pres_below)
6465

6566
ener[:,j] = rhoe + ke_base
6667

@@ -102,15 +103,15 @@ def user(bcName, bcEdge, variable, my_data):
102103
dens[:,myg.jhi]
103104

104105
eint_base = (ener[:,myg.jhi] - ke_base)/dens[:,myg.jhi]
105-
pres_base = eos.pres(dens_base, eint_base)
106+
pres_base = eos.pres(gamma, dens_base, eint_base)
106107

107108
# we are assuming that the density is constant in this
108109
# formulation of HSE, so the pressure comes simply from
109110
# differencing the HSE equation
110111
j = myg.jhi+1
111112
while (j <= myg.jhi+myg.ng):
112113
pres_above = pres_base + grav*dens_base*myg.dy
113-
rhoe = eos.rhoe(pres_above)
114+
rhoe = eos.rhoe(gamma, pres_above)
114115

115116
ener[:,j] = rhoe + ke_base
116117

compressible/eos.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
1-
gamma = None
1+
"""
2+
This is a gamma-law equation of state.
3+
"""
24

3-
def init(gamma_constant):
4-
global gamma
5-
gamma = gamma_constant
6-
7-
8-
def pres(dens, eint):
5+
def pres(gamma, dens, eint):
96
""" given the density and the specific internal energy, return the
107
pressure """
11-
12-
global gamma
138
p = dens*eint*(gamma - 1.0)
14-
159
return p
1610

1711

18-
def dens(pres, eint):
12+
def dens(gamma, pres, eint):
1913
""" given the pressure and the specific internal energy, return
2014
the density """
21-
22-
global gamma
2315
dens = pres/(eint*(gamma - 1.0))
24-
2516
return dens
2617

2718

28-
def rhoe(pres):
19+
def rhoe(gamma, pres):
2920
""" given the pressure, return (rho * e) """
30-
31-
global gamma
3221
rhoe = pres/(gamma - 1.0)
33-
3422
return rhoe
3523

3624

compressible/simulation.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,10 @@ def initialize(self):
113113

114114

115115
# store the EOS gamma as an auxillary quantity so we can have a
116-
# self-contained object stored in output files to make plots
117-
gamma = self.rp.get_param("eos.gamma")
118-
my_data.set_aux("gamma", gamma)
119-
120-
# initialize the EOS gamma
121-
eos.init(gamma)
116+
# self-contained object stored in output files to make plots.
117+
# store grav because we'll need that in some BCs
118+
my_data.set_aux("gamma", self.rp.get_param("eos.gamma"))
119+
my_data.set_aux("grav", self.rp.get_param("compressible.grav"))
122120

123121
my_data.create()
124122

@@ -160,11 +158,11 @@ def timestep(self):
160158

161159
e = (ener - 0.5*dens*(u*u + v*v))/dens
162160

163-
p = eos.pres(dens, e)
164-
165-
# compute the sounds speed
166161
gamma = self.rp.get_param("eos.gamma")
167162

163+
p = eos.pres(gamma, dens, e)
164+
165+
# compute the sounds speed
168166
cs = numpy.sqrt(gamma*p/dens)
169167

170168

@@ -246,12 +244,13 @@ def dovis(self):
246244

247245
magvel = numpy.sqrt(magvel)
248246

249-
# access gamma from the object instead of using the EOS so we can
250-
# use dovis outside of a running simulation.
247+
e = rhoe/dens
248+
249+
# access gamma from the cc_data object so we can use dovis
250+
# outside of a running simulation.
251251
gamma = self.cc_data.get_aux("gamma")
252-
p = rhoe*(gamma - 1.0)
253252

254-
e = rhoe/dens
253+
p = eos.pres(gamma, dens, e)
255254

256255
myg = self.cc_data.grid
257256

compressible/unsplitFluxes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
146146

147147
myg = my_data.grid
148148

149+
gamma = rp.get_param("eos.gamma")
150+
149151
#=========================================================================
150152
# compute the primitive variables
151153
#=========================================================================
@@ -165,7 +167,7 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
165167
# get the pressure
166168
e = (ener - 0.5*(xmom**2 + ymom**2)/dens)/dens
167169

168-
p = eos.pres(dens, e)
170+
p = eos.pres(gamma, dens, e)
169171

170172
smallp = 1.e-10
171173
p = p.clip(smallp) # apply a floor to the pressure
@@ -218,8 +220,6 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
218220
tm_states = tc.timer("interfaceStates")
219221
tm_states.begin()
220222

221-
gamma = rp.get_param("eos.gamma")
222-
223223
V_l = myg.scratch_array(vars.nvar)
224224
V_r = myg.scratch_array(vars.nvar)
225225

@@ -239,13 +239,13 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
239239
U_xl[:,:,vars.idens] = V_l[:,:,vars.irho]
240240
U_xl[:,:,vars.ixmom] = V_l[:,:,vars.irho]*V_l[:,:,vars.iu]
241241
U_xl[:,:,vars.iymom] = V_l[:,:,vars.irho]*V_l[:,:,vars.iv]
242-
U_xl[:,:,vars.iener] = eos.rhoe(V_l[:,:,vars.ip]) + \
242+
U_xl[:,:,vars.iener] = eos.rhoe(gamma, V_l[:,:,vars.ip]) + \
243243
0.5*V_l[:,:,vars.irho]*(V_l[:,:,vars.iu]**2 + V_l[:,:,vars.iv]**2)
244244

245245
U_xr[:,:,vars.idens] = V_r[:,:,vars.irho]
246246
U_xr[:,:,vars.ixmom] = V_r[:,:,vars.irho]*V_r[:,:,vars.iu]
247247
U_xr[:,:,vars.iymom] = V_r[:,:,vars.irho]*V_r[:,:,vars.iv]
248-
U_xr[:,:,vars.iener] = eos.rhoe(V_r[:,:,vars.ip]) + \
248+
U_xr[:,:,vars.iener] = eos.rhoe(gamma, V_r[:,:,vars.ip]) + \
249249
0.5*V_r[:,:,vars.irho]*(V_r[:,:,vars.iu]**2 + V_r[:,:,vars.iv]**2)
250250

251251

@@ -271,7 +271,7 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
271271
vars.nvar,
272272
gamma,
273273
r, u, v, p,
274-
ldelta_r, ldelta_u, ldelta_v, ldelta_p)
274+
ldelta_r, ldelta_u, ldelta_v, ldelta_p)
275275

276276
tm_states.end()
277277

@@ -283,13 +283,13 @@ def unsplitFluxes(my_data, rp, vars, tc, dt):
283283
U_yl[:,:,vars.idens] = V_l[:,:,vars.irho]
284284
U_yl[:,:,vars.ixmom] = V_l[:,:,vars.irho]*V_l[:,:,vars.iu]
285285
U_yl[:,:,vars.iymom] = V_l[:,:,vars.irho]*V_l[:,:,vars.iv]
286-
U_yl[:,:,vars.iener] = eos.rhoe(V_l[:,:,vars.ip]) + \
286+
U_yl[:,:,vars.iener] = eos.rhoe(gamma, V_l[:,:,vars.ip]) + \
287287
0.5*V_l[:,:,vars.irho]*(V_l[:,:,vars.iu]**2 + V_l[:,:,vars.iv]**2)
288288

289289
U_yr[:,:,vars.idens] = V_r[:,:,vars.irho]
290290
U_yr[:,:,vars.ixmom] = V_r[:,:,vars.irho]*V_r[:,:,vars.iu]
291291
U_yr[:,:,vars.iymom] = V_r[:,:,vars.irho]*V_r[:,:,vars.iv]
292-
U_yr[:,:,vars.iener] = eos.rhoe(V_r[:,:,vars.ip]) + \
292+
U_yr[:,:,vars.iener] = eos.rhoe(gamma, V_r[:,:,vars.ip]) + \
293293
0.5*V_r[:,:,vars.irho]*(V_r[:,:,vars.iu]**2 + V_r[:,:,vars.iv]**2)
294294

295295

diffusion/FLOW

Lines changed: 0 additions & 23 deletions
This file was deleted.

plot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ def makeplot(myd, solverName, outfile):
1313

1414
exec 'import ' + solverName + ' as solver'
1515

16+
sim = solver.Simulation(None, None)
17+
sim.cc_data = myd
18+
1619
pylab.figure(num=1, figsize=(8,4.5), dpi=100, facecolor='w')
1720

18-
solver.dovis(myd, 0)
21+
sim.dovis(0)
1922
pylab.savefig(outfile)
2023
pylab.show()
2124

0 commit comments

Comments
 (0)