Skip to content

Commit

Permalink
fix regression error and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichen3 committed Nov 20, 2024
1 parent 3230eaa commit 3f47f53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions pyro/compressible/riemann.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down

0 comments on commit 3f47f53

Please sign in to comment.