Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Features

- [1038](https://github.com/pybop-team/PyBOP/pull/1038) - Stores the `reason` for a `FailedSolution` and updates the `pybamm.RecommendedSolver` to return the error on failure.
- [#1038](https://github.com/pybop-team/PyBOP/pull/1038) - Stores the `reason` for a `FailedSolution` and updates the `pybamm.RecommendedSolver` to return the error on failure.
- [#975](https://github.com/pybop-team/PyBOP/pull/975) - Adds coupled GITT-EIS parameterisation: `pybop.pybamm.EISSimulator` accepts a `protocol` and computes an impedance spectrum about the state reached at each acquisition time. Adds the example script `gitt_eis.py`, updates `pybop.plot.nyquist` for subplots, and adds `equal_aspect` to the plotting backends.
- [#1007](https://github.com/pybop-team/PyBOP/pull/1007) - Adds example script for discharge rate parameterisation.

Expand Down
4 changes: 0 additions & 4 deletions pybop/pybamm/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ def _simulate_with_rebuild(
self._parameter_values = unmodified_parameter_values
return solutions

@property
def built_model(self):
return None if self._simulation is None else self._simulation._built_model # noqa: SLF001

@property
def input_parameter_names(self):
return self._input_parameter_names
Expand Down
21 changes: 16 additions & 5 deletions tests/unit/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def test_parameter_errors_constructor(self):
):
BaseSimulator(params)

out = simulator.set_output_variables(None)
assert (
out is NotImplementedError
) # raising an error in BaseSimulator breaks Problem.set_target

with pytest.raises(NotImplementedError):
simulator.get_failed_solution("error")

Expand Down Expand Up @@ -133,6 +138,9 @@ def test_set_output_variables(self):
for var in simulator.default_variables:
assert var in solution.variable_names

simulator.set_output_variables(["Voltage [V]"])
assert simulator.default_variables == ["Voltage [V]"]

def test_remove_voltage_events(self, model):
simulator = pybop.pybamm.Simulator(model, remove_voltage_events=False)
assert "Maximum voltage [V]" in [e.name for e in simulator.model.events]
Expand Down Expand Up @@ -251,21 +259,22 @@ def test_input_parameters_are_not_swapped(
"Negative particle diffusivity [m2.s-1]": 3.0e-14,
}

def solve(values, **kwargs):
def simulator(values):
protocol = dataset if coupled else None
acquisition_indices = acquisitions if coupled else None
simulator = pybop.pybamm.EISSimulator(
return pybop.pybamm.EISSimulator(
model,
parameter_values=values,
protocol=protocol,
acquisition_indices=acquisition_indices,
f_eval=frequencies,
)
return simulator.solve(**kwargs)

fixed = copy(parameter_values)
fixed.update(inputs)
expected = solve(fixed)
simulator1 = simulator(fixed)
assert simulator1.input_parameter_names == []
expected = simulator1.solve()

fitted = copy(parameter_values)
fitted.update(
Expand All @@ -274,7 +283,9 @@ def solve(values, **kwargs):
for name, value in inputs.items()
}
)
solution = solve(fitted, inputs=inputs)
simulator2 = simulator(fitted)
assert set(simulator2.input_parameter_names) == set(inputs.keys())
solution = simulator2.solve(inputs=inputs)

if coupled:
for name in solution.variable_names:
Expand Down
Loading