diff --git a/pyro/compressible/riemann.py b/pyro/compressible/riemann.py index f2db89446..f878bffb5 100644 --- a/pyro/compressible/riemann.py +++ b/pyro/compressible/riemann.py @@ -1130,15 +1130,19 @@ def consFlux(idir, coord_type, gamma, F = np.zeros_like(U_state) - u = np.zeros_like(U_state[..., ixmom]) - v = np.zeros_like(U_state[..., iymom]) - - for i in range(U_state.shape[0]): - for j in range(U_state.shape[1]): - if U_state[i, j, idens] != 0.0: - u[i, j] = U_state[i, j, ixmom] / U_state[i, j, idens] - if U_state[i, j, idens] != 0.0: - v[i, j] = U_state[i, j, iymom] / U_state[i, j, idens] + if U_state.ndim == 1: + if U_state[idens] != 0.0: + u = U_state[ixmom] / U_state[idens] + v = U_state[iymom] / U_state[idens] + + else: + u = np.zeros_like(U_state[..., ixmom]) + v = np.zeros_like(U_state[..., iymom]) + for i in range(U_state.shape[0]): + for j in range(U_state.shape[1]): + if U_state[i, j, idens] != 0.0: + u[i, j] = U_state[i, j, ixmom] / U_state[i, j, idens] + v[i, j] = U_state[i, j, iymom] / U_state[i, j, idens] p = (U_state[..., iener] - 0.5 * U_state[..., idens] * (u * u + v * v)) * (gamma - 1.0) diff --git a/pyro/compressible/simulation.py b/pyro/compressible/simulation.py index 5ce6b83a6..af152d319 100644 --- a/pyro/compressible/simulation.py +++ b/pyro/compressible/simulation.py @@ -59,7 +59,7 @@ def cons_to_prim(U, gamma, ivars, myg): out=np.zeros_like(U[:, :, ivars.iymom]), where=(U[:, :, ivars.idens] != 0.0)) - e = np.divide(U[:, :, ivars.iener] - 0.5*q[:, :, ivars.irho]* + e = np.divide(U[:, :, ivars.iener] - 0.5 * q[:, :, ivars.irho] * (q[:, :, ivars.iu]**2 + q[:, :, ivars.iv]**2), q[:, :, ivars.irho], out=np.zeros_like(U[:, :, ivars.iener]),