Skip to content

Commit

Permalink
Merge pull request #2856 from pybamm-team/issue-2855-domains
Browse files Browse the repository at this point in the history
fix domains bug
  • Loading branch information
valentinsulzer committed Apr 6, 2023
2 parents 5475a4e + b6d2645 commit c81afee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pybamm/spatial_methods/spatial_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c81afee

Please sign in to comment.