@@ -885,7 +885,8 @@ Compile an affect defined by a set of equations. Systems with algebraic equation
885885function compile_equational_affect (
886886 aff:: Union{AffectSystem, Vector{Equation}} , sys; reset_jumps = false , kwargs... )
887887 if aff isa AbstractVector
888- aff = make_affect (aff; iv = get_iv (sys), warn_no_algebraic = false )
888+ aff = make_affect (
889+ aff; iv = get_iv (sys), alg_eqs = alg_equations (sys), warn_no_algebraic = false )
889890 end
890891 affsys = system (aff)
891892 ps_to_update = discretes (aff)
@@ -923,7 +924,9 @@ function compile_equational_affect(
923924 wrap_code = add_integrator_header (sys, integ, :p ),
924925 expression = Val{false }, outputidxs = p_idxs, wrap_mtkparameters, cse = false )
925926
926- return let dvs_to_update = dvs_to_update, ps_to_update = ps_to_update, reset_jump = reset_jump, u_up! = u_up!, p_up! = p_up!
927+ return let dvs_to_update = dvs_to_update, ps_to_update = ps_to_update,
928+ reset_jumps = reset_jumps, u_up! = u_up!, p_up! = p_up!
929+
927930 function explicit_affect! (integ)
928931 isempty (dvs_to_update) || u_up! (integ)
929932 isempty (ps_to_update) || p_up! (integ)
@@ -941,24 +944,26 @@ function compile_equational_affect(
941944 p_getters = [getsym (sys, unPre (p)) for p in ps_to_access]
942945 u_setters = [setsym (sys, u) for u in dvs_to_update]
943946 p_setters = [setsym (sys, p) for p in ps_to_update]
944- solu_getters = [getsym (affsys, sys_map[u]) for u in dvs_to_update]
945- solp_getters = [getsym (affsys, sys_map[p]) for p in ps_to_update]
947+ affu_getters = [getsym (affsys, sys_map[u]) for u in dvs_to_update]
948+ affp_getters = [getsym (affsys, sys_map[p]) for p in ps_to_update]
946949
947- affprob = ImplicitDiscreteProblem (affsys, u0map, (integ. t, integ. t), pmap;
950+ affprob = ImplicitDiscreteProblem (affsys, [dv => 0 for dv in dvs_to_access],
951+ (0 , 0 ), [p => 0 for p in ps_to_access];
948952 build_initializeprob = false , check_length = false )
949953
950954 function implicit_affect! (integ)
951- pmap = [p => getp (integ) for (p, getp) in zip (parameters (affsys), p_getters)]
952- u0map = [u => getu (integ) for (u, getu) in zip (unknowns (affsys), u_getters)]
953- affprob = remake (affprob, u0 = u0map, p = pmap)
955+ pmap = Pair[p => getp (integ) for (p, getp) in zip (ps_to_access, p_getters)]
956+ u0map = Pair[u => getu (integ)
957+ for (u, getu) in zip (dvs_to_access, u_getters)]
958+ affprob = remake (affprob, u0 = u0map, p = pmap, tspan = (integ. t, integ. t))
954959 affsol = init (affprob, IDSolve ())
955960 (check_error (affsol) === ReturnCode. InitialFailure) &&
956961 throw (UnsolvableCallbackError (all_equations (aff)))
957962
958- for (setu!, getu) in zip (u_setters, solu_getters )
963+ for (setu!, getu) in zip (u_setters, affu_getters )
959964 setu! (integ, getu (affsol))
960965 end
961- for (setp!, getp) in zip (p_setters, solp_getters )
966+ for (setp!, getp) in zip (p_setters, affp_getters )
962967 setp! (integ, getp (affsol))
963968 end
964969 end
0 commit comments