diff --git a/pyro/mesh/patch.py b/pyro/mesh/patch.py index 721bfc9d1..8a7f97164 100644 --- a/pyro/mesh/patch.py +++ b/pyro/mesh/patch.py @@ -245,15 +245,15 @@ class SphericalPolar(Grid2d): def __init__(self, nx, ny, *, ng=1, xmin=0.2, xmax=1.0, ymin=0.0, ymax=1.0): + super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) + # Make sure theta is within [0, PI] assert ymin >= 0.0 and ymax <= np.pi, "y or \u03b8 should be within [0, \u03c0]." # Make sure the ghost cells doesn't extend out negative x(r) - assert xmin - ng*(xmax-xmin)/nx >= 0.0, \ + assert xmin - ng*self.dx >= 0.0, \ "xmin (r-direction), must be large enough so ghost cell doesn't have negative x." - super().__init__(nx, ny, ng=ng, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) - self.coord_type = 1 # Length of the side along r-direction, dr diff --git a/pyro/simulation_null.py b/pyro/simulation_null.py index c10fc75ce..0baaea658 100644 --- a/pyro/simulation_null.py +++ b/pyro/simulation_null.py @@ -1,4 +1,5 @@ import h5py +import numpy as np import pyro.mesh.boundary as bnd import pyro.util.profile_pyro as profile @@ -52,6 +53,19 @@ def grid_setup(rp, ng=1): ymin=ymin, ymax=ymax, ng=ng) + # Make sure y-boundary condition is reflect when + # ymin = 0 and ymax = pi + + if grid_type == "SphericalPolar": + if ymin <= 0.05: + rp.set_param("mesh.ylboundary", "reflect") + msg.warning("With SphericalPolar grid," + + " mesh.ylboundary auto set to reflect when ymin ~ 0") + if abs(np.pi - ymax) <= 0.05: + rp.set_param("mesh.yrboundary", "reflect") + msg.warning("With SphericalPolar grid," + + " mesh.yrboundary auto set to reflect when ymax ~ pi") + return my_grid