@@ -242,14 +242,23 @@ def integrate_casadi(self, rhs, algebraic, y0, t_eval, inputs=None):
242
242
# set up and solve
243
243
t = casadi .MX .sym ("t" )
244
244
u = casadi .vertcat (* [x for x in inputs .values ()])
245
- y_diff = casadi . MX . sym ( " y_diff" , rhs ( 0 , y0 , u ). shape [ 0 ])
245
+ y_diff = self . y_diff
246
246
problem = {"t" : t , "x" : y_diff }
247
247
if algebraic is None :
248
- problem .update ({"ode" : rhs (t , y_diff , u )})
248
+ y_casadi_w_ext = casadi .vertcat (y_diff , self .y_ext [y_diff .shape [0 ] :])
249
+ problem .update ({"ode" : rhs (t , y_casadi_w_ext , u )})
249
250
else :
250
- y_alg = casadi .MX .sym ("y_alg" , algebraic (0 , y0 , u ).shape [0 ])
251
- y = casadi .vertcat (y_diff , y_alg )
252
- problem .update ({"z" : y_alg , "ode" : rhs (t , y , u ), "alg" : algebraic (t , y , u )})
251
+ y_alg = self .y_alg
252
+ y_casadi_w_ext = casadi .vertcat (
253
+ y_diff , y_alg , self .y_ext [y_diff .shape [0 ] + y_alg .shape [0 ] :]
254
+ )
255
+ problem .update (
256
+ {
257
+ "z" : y_alg ,
258
+ "ode" : rhs (t , y_casadi_w_ext , u ),
259
+ "alg" : algebraic (t , y_casadi_w_ext , u ),
260
+ }
261
+ )
253
262
integrator = casadi .integrator ("F" , self .method , problem , options )
254
263
try :
255
264
# Try solving
0 commit comments