@@ -248,6 +248,61 @@ def test_check_well_posedness_variables(self):
248
248
):
249
249
model .check_well_posedness (post_discretisation = True )
250
250
251
+ # model must be in semi-explicit form
252
+ model = pybamm .BaseModel ()
253
+ model .rhs = {c : d .diff (pybamm .t ), d : - 1 }
254
+ model .initial_conditions = {c : 1 , d : 1 }
255
+ with self .assertRaisesRegex (
256
+ pybamm .ModelError ,
257
+ "time derivative of variable found" ,
258
+ ):
259
+ model .check_well_posedness ()
260
+
261
+ # model must be in semi-explicit form
262
+ model = pybamm .BaseModel ()
263
+ model .algebraic = {
264
+ c : 2 * d - c ,
265
+ d : c * d .diff (pybamm .t ) - d ,
266
+ }
267
+ model .initial_conditions = {c : 1 , d : 1 }
268
+ with self .assertRaisesRegex (
269
+ pybamm .ModelError ,
270
+ "time derivative of variable found" ,
271
+ ):
272
+ model .check_well_posedness ()
273
+
274
+ # model must be in semi-explicit form
275
+ model = pybamm .BaseModel ()
276
+ model .rhs = {c : d .diff (pybamm .t ), d : - 1 }
277
+ model .initial_conditions = {c : 1 , d : 1 }
278
+ with self .assertRaisesRegex (
279
+ pybamm .ModelError ,
280
+ "time derivative of variable found" ,
281
+ ):
282
+ model .check_well_posedness ()
283
+
284
+ # model must be in semi-explicit form
285
+ model = pybamm .BaseModel ()
286
+ model .algebraic = {
287
+ d : 5 * pybamm .StateVector (slice (0 , 15 )) - 1 ,
288
+ c : 5 * pybamm .StateVectorDot (slice (0 , 15 )) - 1
289
+ }
290
+ with self .assertRaisesRegex (
291
+ pybamm .ModelError ,
292
+ "time derivative of state vector found" ,
293
+ ):
294
+ model .check_well_posedness (post_discretisation = True )
295
+
296
+ # model must be in semi-explicit form
297
+ model = pybamm .BaseModel ()
298
+ model .rhs = {c : 5 * pybamm .StateVectorDot (slice (0 , 15 )) - 1 }
299
+ model .initial_conditions = {c : 1 }
300
+ with self .assertRaisesRegex (
301
+ pybamm .ModelError ,
302
+ "time derivative of state vector found" ,
303
+ ):
304
+ model .check_well_posedness (post_discretisation = True )
305
+
251
306
def test_check_well_posedness_initial_boundary_conditions (self ):
252
307
# Well-posed model - Dirichlet
253
308
whole_cell = ["negative electrode" , "separator" , "positive electrode" ]
0 commit comments