def test_geometry_keys(self): geometry = pybamm.Geometry3DMacro() for prim_sec_vars in geometry.values(): for spatial_vars in prim_sec_vars.values(): all( self.assertIsInstance(spatial_var, pybamm.SpatialVariable) for spatial_var in spatial_vars.keys())
def test_add_custom_geometry(self): geometry = pybamm.Geometry3DMacro() whole_cell = ["negative electrode", "separator", "positive electrode"] x = pybamm.SpatialVariable("x", whole_cell) custom_geometry = { "negative electrode": { "primary": {x: {"min": pybamm.Scalar(1), "max": pybamm.Scalar(2)}} } } geometry.update(custom_geometry) self.assertEqual( geometry["negative electrode"], custom_geometry["negative electrode"] )
def test_combine_geometries_3D(self): geometry3Dmacro = pybamm.Geometry3DMacro() geometry1Dmicro = pybamm.Geometry1DMicro() geometry = pybamm.Geometry(geometry3Dmacro, geometry1Dmicro) self.assertEqual( set(geometry.keys()), set([ "negative electrode", "separator", "positive electrode", "negative particle", "positive particle", "current collector", ]), ) with self.assertRaises(ValueError): geometry1Dmacro = pybamm.Geometry1DMacro() geometry = pybamm.Geometry(geometry3Dmacro, geometry1Dmacro)