Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
" parameter_values=parameter_values,\n",
" protocol=dataset,\n",
" solver=pybamm.CasadiSolver(mode=\"safe\", dt_max=40),\n",
" cache_esoh=False,\n",
")\n",
"cost = pybop.SumSquaredError(dataset)\n",
"problem = pybop.Problem(simulator, cost)"
Expand Down Expand Up @@ -539,7 +540,7 @@
"source": [
"parameter_values.update(result.best_inputs)\n",
"sol = pybamm.Simulation(\n",
" model, parameter_values=parameter_values, experiment=experiment\n",
" model, parameter_values=parameter_values, experiment=experiment, cache_esoh=False\n",
").solve(initial_soc=0.95)\n",
"# sol.plot();"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
"outputs": [],
"source": [
"simulator = pybop.pybamm.Simulator(\n",
" model, parameter_values=parameter_values, protocol=dataset\n",
" model, parameter_values=parameter_values, protocol=dataset, cache_esoh=False\n",
")\n",
"cost = pybop.SumSquaredError(dataset)\n",
"problem = pybop.Problem(simulator, cost)"
Expand Down Expand Up @@ -571,6 +571,7 @@
" parameter_values=parameter_values,\n",
" protocol=dataset_two_pulse,\n",
" initial_state={\"Initial SoC\": 0.8 - 0.0075},\n",
" cache_esoh=False,\n",
")\n",
"cost_two_pulse = pybop.SumSquaredError(dataset_two_pulse)\n",
"problem = pybop.Problem(simulator, cost_two_pulse)"
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/battery_parameterisation/thermal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
parameter_values = pybamm.ParameterValues("Chen2020")
model = pybamm.lithium_ion.SPM()
solution = pybamm.Simulation(
model, parameter_values=parameter_values, experiment=experiment
model, parameter_values=parameter_values, experiment=experiment, cache_esoh=False
).solve(initial_soc=init_soc)

# Add thermal parameters and the voltage data
Expand Down Expand Up @@ -61,6 +61,6 @@
# Run an example thermal simulation
thermal_model = pybop.lithium_ion.CellTemperature()
solution = pybamm.Simulation(
thermal_model, parameter_values=grouped_parameter_values
thermal_model, parameter_values=grouped_parameter_values, cache_esoh=False
).solve(initial_soc=init_soc, t_eval=solution.t)
solution.plot(["Current [A]", "SoC", "Voltage [V]", "Cell temperature [K]"])
2 changes: 1 addition & 1 deletion examples/scripts/comparison_examples/grouped_SPMe.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
strict=False,
):
solution = pybamm.Simulation(
model, parameter_values=param, experiment=experiment
model, parameter_values=param, experiment=experiment, cache_esoh=False
).solve(initial_soc=init_soc)
dataset = pybop.import_pybamm_solution(solution)
plot_dict.add_traces(
Expand Down
5 changes: 5 additions & 0 deletions pybop/pybamm/eis_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class EISSimulator(BaseSimulator):
discretisation_kwargs : dict, optional
Any keyword arguments to pass to the Discretisation class.
See :class:`pybamm.Discretisation` for details.
cache_esoh : bool, optional
If True, the electrode SOH computation is cached for repeated calls to `pybamm.Simulation.solve`
(default: True).
build_every_time : bool, optional
If True, the model will be rebuilt every evaluation. Otherwise, the need to rebuild will be
determined automatically.
Expand All @@ -72,6 +75,7 @@ def __init__(
var_pts: dict | None = None,
spatial_methods: dict | None = None,
discretisation_kwargs: dict | None = None,
cache_esoh: bool = True,
build_every_time: bool = False,
):
# Set-up model for EIS
Expand All @@ -93,6 +97,7 @@ def __init__(
var_pts=var_pts,
spatial_methods=spatial_methods,
discretisation_kwargs=discretisation_kwargs,
cache_esoh=cache_esoh,
build_every_time=build_every_time,
)
self.debug_mode = False
Expand Down
6 changes: 6 additions & 0 deletions pybop/pybamm/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Simulator(BaseSimulator):
discretisation_kwargs : dict, optional
Any keyword arguments to pass to the Discretisation class.
See :class:`pybamm.Discretisation` for details.
cache_esoh : bool, optional
If True, the electrode SOH computation is cached for repeated calls to `pybamm.Simulation.solve`
(default: True).
build_every_time : bool, optional
If True, the model will be rebuilt every evaluation. Otherwise, the need to rebuild will be
determined automatically.
Expand All @@ -71,6 +74,7 @@ def __init__(
var_pts: dict | None = None,
spatial_methods: dict | None = None,
discretisation_kwargs: dict | None = None,
cache_esoh: bool = True,
build_every_time: bool = False,
):
# Core
Expand Down Expand Up @@ -114,6 +118,7 @@ def __init__(
self._var_pts = var_pts or model.default_var_pts
self._spatial_methods = spatial_methods or model.default_spatial_methods
self._discretisation_kwargs = discretisation_kwargs or {"check_model": True}
self._cache_esoh = cache_esoh

# State
self._simulation = None
Expand Down Expand Up @@ -388,6 +393,7 @@ def create_simulation(self) -> pybamm.Simulation:
var_pts=self._var_pts,
spatial_methods=self._spatial_methods,
discretisation_kwargs=self._discretisation_kwargs,
cache_esoh=self._cache_esoh,
)

def _simulate_without_rebuild(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ classifiers = [
# versions in the tests in nightly_dependency_tests.yml as appropriate
requires-python = ">=3.10, <3.14"
dependencies = [
"pybamm>=25.12.0",
"pybamm @ git+https://github.com/pybamm-team/PyBaMM@main", # update after next PyBaMM release
"numpy>=1.26",
"scipy>=1.12",
"pints>=0.6.0",
Expand Down
Loading