Skip to content

Commit 396de9e

Browse files
committed
#738 add check model option to simulation
1 parent e5e67c0 commit 396de9e

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

input/parameters/lithium-ion/cells/kokam_Marquis2019/parameters.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ Negative current collector thermal conductivity [W.m-1.K-1],401,,
3333
Positive current collector thermal conductivity [W.m-1.K-1],237,,
3434
,,,
3535
# Electrical,,,
36-
Cell capacity [A.h],0.68,,24 Ah/m2 * 0.137m * 0.207m
36+
Cell capacity [A.h],0.680616,,24 Ah/m2 * 0.137m * 0.207m

pybamm/simulation.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,19 @@ def set_parameters(self):
9898
)
9999
self._parameter_values.process_geometry(self._geometry)
100100

101-
def build(self):
101+
def build(self, check_model=True):
102102
"""
103103
A method to build the model into a system of matrices and vectors suitable for
104104
performing numerical computations. If the model has already been built or
105105
solved then this function will have no effect. If you want to rebuild,
106106
first use "reset()". This method will automatically set the parameters
107107
if they have not already been set.
108+
109+
Parameters
110+
----------
111+
check_model : bool, optional
112+
If True, model checks are performed after discretisation (see
113+
:meth:`pybamm.Discretisation.process_model`). Default is True.
108114
"""
109115

110116
if self.built_model:
@@ -113,9 +119,11 @@ def build(self):
113119
self.set_parameters()
114120
self._mesh = pybamm.Mesh(self._geometry, self._submesh_types, self._var_pts)
115121
self._disc = pybamm.Discretisation(self._mesh, self._spatial_methods)
116-
self._built_model = self._disc.process_model(self._model, inplace=False)
122+
self._built_model = self._disc.process_model(
123+
self._model, inplace=False, check_model=check_model
124+
)
117125

118-
def solve(self, t_eval=None, solver=None):
126+
def solve(self, t_eval=None, solver=None, check_model=True):
119127
"""
120128
A method to solve the model. This method will automatically build
121129
and set the model parameters if not already done so.
@@ -129,8 +137,11 @@ def solve(self, t_eval=None, solver=None):
129137
non-dimensional time of 1.
130138
solver : :class:`pybamm.BaseSolver`
131139
The solver to use to solve the model.
140+
check_model : bool, optional
141+
If True, model checks are performed after discretisation (see
142+
:meth:`pybamm.Discretisation.process_model`). Default is True.
132143
"""
133-
self.build()
144+
self.build(check_model=check_model)
134145

135146
if t_eval is None:
136147
try:

tests/unit/test_simulation.py

+7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def test_solve(self):
7171

7272
self.assertEqual(sim._solution, None)
7373

74+
# test solve without check
75+
sim.reset()
76+
sim.solve(check_model=False)
77+
for val in list(sim.built_model.rhs.values()):
78+
self.assertFalse(val.has_symbol_of_classes(pybamm.Parameter))
79+
self.assertTrue(val.has_symbol_of_classes(pybamm.Matrix))
80+
7481
def test_reuse_commands(self):
7582

7683
sim = pybamm.Simulation(pybamm.lithium_ion.SPM())

0 commit comments

Comments
 (0)