diff --git a/pybamm/meshes/zero_dimensional_submesh.py b/pybamm/meshes/zero_dimensional_submesh.py index 7adc4f2e72..970eb209c7 100644 --- a/pybamm/meshes/zero_dimensional_submesh.py +++ b/pybamm/meshes/zero_dimensional_submesh.py @@ -15,10 +15,11 @@ class SubMesh0D(SubMesh): Parameters ---------- position : dict - A dictionary that contains the position of the spatial variable + A dictionary that contains the position of the 0D submesh (a signle point) + in space npts : dict, optional - Number of points to be used. Included for compatibility with other meshes, but - ignored by this mesh class + Number of points to be used. Included for compatibility with other meshes, + but ignored by this mesh class tabs : dict A dictionary that contains information about the size and location of the tabs. Included for compatibility with other meshes, but diff --git a/pybamm/quick_plot.py b/pybamm/quick_plot.py index a24b9287d9..29caf2b8dd 100644 --- a/pybamm/quick_plot.py +++ b/pybamm/quick_plot.py @@ -82,7 +82,7 @@ def __init__( # If only one mesh is passed but there are multiple models, try to use # the same mesh for all of them meshes = [meshes] * len(models) - elif not isinstance(models, list): + elif not isinstance(meshes, list): raise TypeError("'meshes' must be 'pybamm.Mesh' or list") if isinstance(solutions, pybamm.Solution): solutions = [solutions] diff --git a/tests/unit/test_meshes/test_scikit_fem_submesh.py b/tests/unit/test_meshes/test_scikit_fem_submesh.py index 0bcdd8f2db..a5366f3bc1 100644 --- a/tests/unit/test_meshes/test_scikit_fem_submesh.py +++ b/tests/unit/test_meshes/test_scikit_fem_submesh.py @@ -340,6 +340,10 @@ def test_init_failure(self): with self.assertRaises(pybamm.DomainError): pybamm.ScikitExponential2DSubMesh(lims, None, None) + # side not top + with self.assertRaises(pybamm.GeometryError): + pybamm.ScikitExponential2DSubMesh(None, None, None, side="bottom") + class TestScikitUser2DSubMesh(unittest.TestCase): def test_mesh_creation(self): diff --git a/tests/unit/test_quick_plot.py b/tests/unit/test_quick_plot.py index 406291d95d..ca0907ce7a 100644 --- a/tests/unit/test_quick_plot.py +++ b/tests/unit/test_quick_plot.py @@ -111,8 +111,7 @@ def test_loqs_spm_base(self): t_eval = np.linspace(0, 0.01, 2) # SPM - options = {"thermal": "isothermal"} - for model in [pybamm.lithium_ion.SPM(options), pybamm.lead_acid.LOQS()]: + for model in [pybamm.lithium_ion.SPM(), pybamm.lead_acid.LOQS()]: geometry = model.default_geometry param = model.default_parameter_values param.process_model(model) @@ -126,15 +125,33 @@ def test_loqs_spm_base(self): solution = solver.solve(model, t_eval) pybamm.QuickPlot(model, mesh, solution) + # test quick plot of particle for spm + if model.name == "Single Particle Model": + output_variables = [ + "X-averaged negative particle concentration [mol.m-3]", + "X-averaged positive particle concentration [mol.m-3]", + ] + pybamm.QuickPlot(model, mesh, solution, output_variables) + def test_failure(self): with self.assertRaisesRegex(TypeError, "'models' must be"): pybamm.QuickPlot(1, None, None) + with self.assertRaisesRegex(TypeError, "'meshes' must be"): + model = pybamm.lithium_ion.SPM() + pybamm.QuickPlot(model, 1, None) with self.assertRaisesRegex(TypeError, "'solutions' must be"): - pybamm.QuickPlot(pybamm.BaseModel(), None, 1) + geometry = model.default_geometry + param = model.default_parameter_values + param.process_model(model) + param.process_geometry(geometry) + mesh = pybamm.Mesh( + geometry, model.default_submesh_types, model.default_var_pts + ) + pybamm.QuickPlot(model, mesh, 1) with self.assertRaisesRegex(ValueError, "must provide the same"): pybamm.QuickPlot( - pybamm.BaseModel(), - None, + model, + mesh, [pybamm.Solution(0, 0, 0, 0, ""), pybamm.Solution(0, 0, 0, 0, "")], )