diff --git a/CHANGELOG.md b/CHANGELOG.md index 737fc926f3..27b39d9534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Updated to casadi 3.6, which required some changes to the casadi integrator. ([#2859](https://github.com/pybamm-team/PyBaMM/pull/2859)) +## Bug fixes + +- Fixed a bug in the discretisation of initial conditions of a scaled variable ([#2856](https://github.com/pybamm-team/PyBaMM/pull/2856)) + # Breaking changes - Made `Jupyter` a development only dependency. Now `Jupyter` would not be a required dependency for users while installing `PyBaMM`. ([#2846](https://github.com/pybamm-team/PyBaMM/pull/2846)) diff --git a/pybamm/spatial_methods/spatial_method.py b/pybamm/spatial_methods/spatial_method.py index a7e5dfc164..acb0227bc2 100644 --- a/pybamm/spatial_methods/spatial_method.py +++ b/pybamm/spatial_methods/spatial_method.py @@ -134,7 +134,7 @@ def broadcast(self, symbol, domains, broadcast_type): matrix = vstack([identity for _ in range(tertiary_domain_size)]) out = pybamm.Matrix(matrix) @ symbol elif broadcast_type.startswith("full"): - out = symbol * pybamm.Vector(np.ones(full_domain_size)) + out = symbol * pybamm.Vector(np.ones(full_domain_size), domains=domains) out.domains = domains.copy() return out diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py index 29d6eedd77..90bbc29055 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py @@ -529,6 +529,27 @@ def test_neg_pos_bcs(self): self.assertEqual(disc.bcs[var]["right"][0], pybamm.Scalar(0)) self.assertEqual(disc.bcs[var]["right"][1], "Neumann") + def test_full_broadcast_domains(self): + model = pybamm.BaseModel() + var = pybamm.Variable( + "var", domain=["negative electrode", "separator"], scale=100 + ) + model.rhs = {var: 0} + a = pybamm.InputParameter("a") + ic = pybamm.concatenation( + pybamm.FullBroadcast(a * 100, "negative electrode"), + pybamm.FullBroadcast(100, "separator"), + ) + model.initial_conditions = {var: ic} + + mesh = get_mesh_for_testing() + spatial_methods = { + "negative electrode": pybamm.FiniteVolume(), + "separator": pybamm.FiniteVolume(), + } + disc = pybamm.Discretisation(mesh, spatial_methods) + disc.process_model(model) + if __name__ == "__main__": print("Add -v for more debug output")