Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
run: pip install .

- name: Validate
run: pylint --errors-only pyro pyro/analysis pyro/**/tests/*.py
run: pylint --disable=fixme pyro pyro/analysis pyro/**/tests/*.py

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ disable = [
"missing-function-docstring",
"missing-module-docstring",
"pointless-string-statement",
"cyclic-import",
"duplicate-code",
]
enable = [
"useless-suppression",
Expand Down
7 changes: 1 addition & 6 deletions pyro/advection_fv4/fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pyro.advection_fv4 import interface


def fluxes(my_data, rp, dt):
def fluxes(my_data, rp):
r"""Construct the fluxes through the interfaces for the linear advection
equation:

Expand Down Expand Up @@ -41,11 +41,6 @@ def fluxes(my_data, rp, dt):
we are advecting.
rp : RuntimeParameters object
The runtime parameters for the simulation
dt : float
The timestep we are advancing through.
scalar_name : str
The name of the variable contained in my_data that we are
advecting

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion pyro/advection_fv4/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def substep(self, myd):

k = myg.scratch_array()

flux_x, flux_y = flx.fluxes(myd, self.rp, self.dt)
flux_x, flux_y = flx.fluxes(myd, self.rp)

F_x = ai.ArrayIndexer(d=flux_x, grid=myg)
F_y = ai.ArrayIndexer(d=flux_y, grid=myg)
Expand Down
7 changes: 1 addition & 6 deletions pyro/advection_rk/fluxes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyro.mesh import reconstruction


def fluxes(my_data, rp, dt):
def fluxes(my_data, rp):
"""
Construct the fluxes through the interfaces for the linear advection
equation:
Expand Down Expand Up @@ -42,11 +42,6 @@ def fluxes(my_data, rp, dt):
we are advecting.
rp : RuntimeParameters object
The runtime parameters for the simulation
dt : float
The timestep we are advancing through.
scalar_name : str
The name of the variable contained in my_data that we are
advecting

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion pyro/advection_rk/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def substep(self, myd):

k = myg.scratch_array()

flux_x, flux_y = flx.fluxes(myd, self.rp, self.dt)
flux_x, flux_y = flx.fluxes(myd, self.rp)

F_x = ai.ArrayIndexer(d=flux_x, grid=myg)
F_y = ai.ArrayIndexer(d=flux_y, grid=myg)
Expand Down
7 changes: 1 addition & 6 deletions pyro/advection_weno/fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fvs(q, order, u, alpha):
return flux


def fluxes(my_data, rp, dt):
def fluxes(my_data, rp):
r"""
Construct the fluxes through the interfaces for the linear advection
equation
Expand All @@ -62,11 +62,6 @@ def fluxes(my_data, rp, dt):
we are advecting.
rp : RuntimeParameters object
The runtime parameters for the simulation
dt : float
The timestep we are advancing through.
scalar_name : str
The name of the variable contained in my_data that we are
advecting

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion pyro/advection_weno/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def substep(self, myd):

k = myg.scratch_array()

flux_x, flux_y = flx.fluxes(myd, self.rp, self.dt)
flux_x, flux_y = flx.fluxes(myd, self.rp)

F_x = ai.ArrayIndexer(d=flux_x, grid=myg)
F_y = ai.ArrayIndexer(d=flux_y, grid=myg)
Expand Down
2 changes: 1 addition & 1 deletion pyro/burgers/advective_fluxes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pyro.incompressible.incomp_interface as interface
import pyro.mesh.reconstruction as reconstruction
from pyro.mesh import reconstruction


def unsplit_fluxes(my_data, rp, dt):
Expand Down
4 changes: 2 additions & 2 deletions pyro/burgers/problems/smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import numpy

import pyro.mesh.patch as patch
from pyro.mesh import patch
from pyro.util import msg


def init_data(my_data, rp):
""" initialize the smooth burgers problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the smooth burgers problem...")

Expand Down Expand Up @@ -41,4 +42,3 @@ def init_data(my_data, rp):

def finalize():
""" print out any information to the user at the end of the run """
pass
4 changes: 2 additions & 2 deletions pyro/burgers/problems/test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import sys

import pyro.mesh.patch as patch
from pyro.mesh import patch
from pyro.util import msg


def init_data(myd, rp):
""" initialize the burgers test problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the burgers test problem...")

Expand All @@ -31,4 +32,3 @@ def init_data(myd, rp):

def finalize():
""" print out any information to the user at the end of the run """
pass
4 changes: 2 additions & 2 deletions pyro/burgers/problems/tophat.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import sys

import pyro.mesh.patch as patch
from pyro.mesh import patch
from pyro.util import msg


def init_data(myd, rp):
""" initialize the tophat burgers problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the tophat burgers problem...")

Expand Down Expand Up @@ -40,4 +41,3 @@ def init_data(myd, rp):

def finalize():
""" print out any information to the user at the end of the run """
pass
6 changes: 3 additions & 3 deletions pyro/burgers/problems/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def verify(file1, file2):

if __name__ == "__main__":

file1 = sys.argv[1]
file2 = sys.argv[2]
file1_ = sys.argv[1]
file2_ = sys.argv[2]

verify(file1, file2)
verify(file1_, file2_)
8 changes: 4 additions & 4 deletions pyro/burgers/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import numpy as np

import pyro.burgers.advective_fluxes as flx
import pyro.mesh.patch as patch
import pyro.particles.particles as particles
import pyro.util.plot_tools as plot_tools
from pyro.mesh import patch
from pyro.particles import particles
from pyro.simulation_null import NullSimulation, bc_setup, grid_setup
from pyro.util import plot_tools


class Simulation(NullSimulation):
Expand Down Expand Up @@ -128,7 +128,7 @@ def dovis(self):
uv = myg.scratch_array()
uv.v()[:, :] = np.sqrt(u.v()*u.v() + v.v()*v.v())

_, axes, cbar_title = plot_tools.setup_axes(myg, 1)
_, axes, _ = plot_tools.setup_axes(myg, 1)

# plot x-y velocity magnitude
ax = axes[0]
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def riemann_prim(idir, ng,
@njit(cache=True)
def riemann_hllc(idir, ng,
idens, ixmom, iymom, iener, irhoX, nspec,
lower_solid, upper_solid,
lower_solid, upper_solid, # pylint: disable=unused-argument
gamma, U_l, U_r):
r"""
This is the HLLC Riemann solver. The implementation follows
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible_fv4/fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def flux_cons(ivars, idir, gamma, q):
return flux


def fluxes(myd, rp, ivars, solid, tc):
def fluxes(myd, rp, ivars):

alpha = 0.3
beta = 0.3
Expand Down
3 changes: 1 addition & 2 deletions pyro/compressible_fv4/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def substep(self, myd):

k = myg.scratch_array(nvar=self.ivars.nvar)

flux_x, flux_y = flx.fluxes(myd, self.rp,
self.ivars, self.solid, self.tc)
flux_x, flux_y = flx.fluxes(myd, self.rp, self.ivars)

for n in range(self.ivars.nvar):
k.v(n=n)[:, :] = \
Expand Down
15 changes: 7 additions & 8 deletions pyro/compressible_sr/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

@njit(cache=True)
def states(idir, ng, dx, dt,
irho, iu, iv, ip, iX,
idens, ixmom, iymom, iener, irhoX, nspec,
irho, iu, iv, ip, iX, nspec,
gamma, qv, Uv, dUv):
r"""
predict the cell-centered state to the edges in one-dimension
Expand Down Expand Up @@ -342,6 +341,7 @@ def riemann_cgf(idir, ng,
out : ndarray
Conserved flux
"""
_ = U_l, U_r # unused by this solver

qx, qy, nvar = q_l.shape

Expand Down Expand Up @@ -604,7 +604,7 @@ def riemann_cgf(idir, ng,
U[irhoX:irhoX+nspec] = xn * U[idens]

# compute the fluxes
F[i, j, :] = consFlux(idir, gamma, idens, ixmom, iymom, iener, irhoX, iu, iv, ip, nspec, U, q)
F[i, j, :] = consFlux(idir, idens, ixmom, iymom, iener, irhoX, iu, iv, ip, nspec, U, q)

return F

Expand Down Expand Up @@ -938,6 +938,7 @@ def riemann_hllc(idir, ng,
out : ndarray
Conserved flux
"""
_ = irho, iX, lower_solid, upper_solid, gamma # unused by this solver

qx, qy, nvar = U_l.shape

Expand Down Expand Up @@ -994,9 +995,9 @@ def riemann_hllc(idir, ng,
a_l = -1.0
a_r = 1.0

F_l = consFlux(idir, gamma, idens, ixmom, iymom, iener, irhoX,
F_l = consFlux(idir, idens, ixmom, iymom, iener, irhoX,
iu, iv, ip, nspec, U_l[i, j, :], q_l[i, j, :])
F_r = consFlux(idir, gamma, idens, ixmom, iymom, iener, irhoX,
F_r = consFlux(idir, idens, ixmom, iymom, iener, irhoX,
iu, iv, ip, nspec, U_r[i, j, :], q_r[i, j, :])

F_HLLE = (a_r*F_l - a_l*F_r + a_r*a_l*(U_r[i, j, :] - U_l[i, j, :])) / (a_r - a_l)
Expand Down Expand Up @@ -1103,16 +1104,14 @@ def riemann_hllc(idir, ng,


@njit(cache=True)
def consFlux(idir, gamma, idens, ixmom, iymom, iener, irhoX, iu, iv, ip, nspec, U_state, q_state):
def consFlux(idir, idens, ixmom, iymom, iener, irhoX, iu, iv, ip, nspec, U_state, q_state):
r"""
Calculate the conservative flux.

Parameters
----------
idir : int
Are we predicting to the edges in the x-direction (1) or y-direction (2)?
gamma : float
Adiabatic index
idens, ixmom, iymom, iener, irhoX : int
The indices of the density, x-momentum, y-momentum, internal energy density
and species partial densities in the conserved state vector.
Expand Down
8 changes: 2 additions & 6 deletions pyro/compressible_sr/unsplit_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ def unsplit_fluxes(my_data, my_aux, rp, ivars, solid, tc, dt):

_U_l, _U_r = ifc.states(1, myg.ng, myg.dx, dt,
ivars.irho, ivars.iu, ivars.iv, ivars.ip, ivars.ix,
ivars.idens, ivars.ixmom, ivars.iymom, ivars.iener,
ivars.irhox, ivars.naux,
gamma, q, my_data.data, ldx)
ivars.naux, gamma, q, my_data.data, ldx)

U_xl = ai.ArrayIndexer(d=_U_l, grid=myg)
U_xr = ai.ArrayIndexer(d=_U_r, grid=myg)
Expand All @@ -232,9 +230,7 @@ def unsplit_fluxes(my_data, my_aux, rp, ivars, solid, tc, dt):

_U_l, _U_r = ifc.states(2, myg.ng, myg.dy, dt,
ivars.irho, ivars.iu, ivars.iv, ivars.ip, ivars.ix,
ivars.idens, ivars.ixmom, ivars.iymom, ivars.iener,
ivars.irhox, ivars.naux,
gamma, q, my_data.data, ldy)
ivars.naux, gamma, q, my_data.data, ldy)

U_yl = ai.ArrayIndexer(d=_U_l, grid=myg)
U_yr = ai.ArrayIndexer(d=_U_r, grid=myg)
Expand Down
4 changes: 2 additions & 2 deletions pyro/swe/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def states(idir, ng, dx, dt,
@njit(cache=True)
def riemann_roe(idir, ng,
ih, ixmom, iymom, ihX, nspec,
lower_solid, upper_solid,
lower_solid, upper_solid, # pylint: disable=unused-argument
g, U_l, U_r):
r"""
This is the Roe Riemann solver with entropy fix. The implementation
Expand Down Expand Up @@ -358,7 +358,7 @@ def riemann_roe(idir, ng,
@njit(cache=True)
def riemann_hllc(idir, ng,
ih, ixmom, iymom, ihX, nspec,
lower_solid, upper_solid,
lower_solid, upper_solid, # pylint: disable=unused-argument
g, U_l, U_r):
r"""
this is the HLLC Riemann solver. The implementation follows
Expand Down
14 changes: 5 additions & 9 deletions pyro/swe/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, myd):
self.ix = -1


def cons_to_prim(U, g, ivars, myg):
def cons_to_prim(U, ivars, myg):
"""
Convert an input vector of conserved variables
:math:`U = (h, hu, hv, {hX})`
Expand All @@ -68,7 +68,7 @@ def cons_to_prim(U, g, ivars, myg):
return q


def prim_to_cons(q, g, ivars, myg):
def prim_to_cons(q, ivars, myg):
"""
Convert an input vector of primitive variables :math:`q = (h, u, v, {X})`
to conserved variables :math:`U = (h, hu, hv, {hX})`
Expand Down Expand Up @@ -186,8 +186,8 @@ def evolve(self):

myg = self.cc_data.grid

Flux_x, Flux_y = flx.unsplit_fluxes(self.cc_data, self.aux_data, self.rp,
self.ivars, self.solid, self.tc, self.dt)
Flux_x, Flux_y = flx.unsplit_fluxes(self.cc_data, self.rp, self.ivars,
self.solid, self.tc, self.dt)

# conservative update
dtdx = self.dt/myg.dx
Expand Down Expand Up @@ -222,11 +222,7 @@ def dovis(self):
# we are plotting from a file
ivars = Variables(self.cc_data)

# access g from the cc_data object so we can use dovis
# outside of a running simulation.
g = self.cc_data.get_aux("g")

q = cons_to_prim(self.cc_data.data, g, ivars, self.cc_data.grid)
q = cons_to_prim(self.cc_data.data, ivars, self.cc_data.grid)

h = q[:, :, ivars.ih]
u = q[:, :, ivars.iu]
Expand Down
5 changes: 2 additions & 3 deletions pyro/swe/tests/test_swe.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ def test_initializationst(self):
def test_prim(self):

# U -> q
g = self.sim.cc_data.get_aux("g")
q = sn.cons_to_prim(self.sim.cc_data.data, g, self.sim.ivars, self.sim.cc_data.grid)
q = sn.cons_to_prim(self.sim.cc_data.data, self.sim.ivars, self.sim.cc_data.grid)

# q -> U
U = sn.prim_to_cons(q, g, self.sim.ivars, self.sim.cc_data.grid)
U = sn.prim_to_cons(q, self.sim.ivars, self.sim.cc_data.grid)
assert_array_equal(U, self.sim.cc_data.data)

def test_derives(self):
Expand Down
Loading