@@ -238,8 +238,6 @@ function ImplicitDiscreteSystem(eqs, iv; kwargs...)
238238 return ImplicitDiscreteSystem (eqs, iv,
239239 collect (allunknowns), collect (new_ps); kwargs... )
240240end
241- # basically at every timestep it should build a nonlinear solve
242- # Previous timesteps should be treated as parameters? is this right?
243241
244242function flatten (sys:: ImplicitDiscreteSystem , noeqs = false )
245243 systems = get_systems (sys)
@@ -263,25 +261,10 @@ end
263261
264262function generate_function (
265263 sys:: ImplicitDiscreteSystem , dvs = unknowns (sys), ps = parameters (sys); wrap_code = identity, kwargs... )
266- if ! iscomplete (sys)
267- error (" A completed system is required. Call `complete` or `structural_simplify` on the system." )
268- end
269- p = (reorder_parameters (sys, unwrap .(ps))... , cachesyms... )
270- isscalar = ! (exprs isa AbstractArray)
271- pre, sol_states = get_substitutions_and_solved_unknowns (sys, isscalar ? [exprs] : exprs)
272- if postprocess_fbody === nothing
273- postprocess_fbody = pre
274- end
275- if states === nothing
276- states = sol_states
277- end
278264 exprs = [eq. lhs - eq. rhs for eq in equations (sys)]
279- u = map (Shift (iv, - 1 ), dvs)
280- u_next = dvs
281-
282- wrap_code = wrap_code .∘ wrap_array_vars (sys, exprs) .∘ wrap_parameter_dependencies (sys, false )
283-
284- build_function (exprs, u_next, u, p... , get_iv (sys))
265+ u = dvs
266+ u_next = map (Shift (iv, 1 ), u)
267+ generate_custom_function (sys, exprs, u_next, u, ps... , get_iv (sys); kwargs... )
285268end
286269
287270function shift_u0map_forward (sys:: ImplicitDiscreteSystem , u0map, defs)
0 commit comments