@@ -144,7 +144,6 @@ function generate_function(sys::AbstractODESystem, dvs = unknowns(sys), ps = par
144144 ddvs = implicit_dae ? map (Differential (get_iv (sys)), dvs) :
145145 nothing ,
146146 isdde = false ,
147- has_difference = false ,
148147 kwargs... )
149148 if isdde
150149 eqs = delay_to_function (sys)
@@ -167,8 +166,7 @@ function generate_function(sys::AbstractODESystem, dvs = unknowns(sys), ps = par
167166 if isdde
168167 build_function (rhss, u, DDE_HISTORY_FUN, p, t; kwargs... )
169168 else
170- pre, sol_states = get_substitutions_and_solved_unknowns (sys,
171- no_postprocess = has_difference)
169+ pre, sol_states = get_substitutions_and_solved_unknowns (sys)
172170
173171 if implicit_dae
174172 build_function (rhss, ddvs, u, p, t; postprocess_fbody = pre,
@@ -226,52 +224,6 @@ function delay_to_function(expr, iv, sts, ps, h)
226224 end
227225end
228226
229- function generate_difference_cb (sys:: ODESystem , dvs = unknowns (sys), ps = parameters (sys);
230- kwargs... )
231- eqs = equations (sys)
232- check_operator_variables (eqs, Difference)
233-
234- var2eq = Dict (arguments (eq. lhs)[1 ] => eq for eq in eqs if isdifference (eq. lhs))
235-
236- u = map (x -> time_varying_as_func (value (x), sys), dvs)
237- p = map (x -> time_varying_as_func (value (x), sys), ps)
238- t = get_iv (sys)
239-
240- body = map (dvs) do v
241- eq = get (var2eq, v, nothing )
242- eq === nothing && return v
243- d = operation (eq. lhs)
244- d. update ? eq. rhs : eq. rhs + v
245- end
246-
247- pre = get_postprocess_fbody (sys)
248- cpre = get_preprocess_constants (body)
249- pre2 = x -> pre (cpre (x))
250- f_oop, f_iip = build_function (body, u, p, t; expression = Val{false },
251- postprocess_fbody = pre2, kwargs... )
252-
253- cb_affect! = let f_oop = f_oop, f_iip = f_iip
254- function cb_affect! (integ)
255- if DiffEqBase. isinplace (integ. sol. prob)
256- tmp, = DiffEqBase. get_tmp_cache (integ)
257- f_iip (tmp, integ. u, integ. p, integ. t) # aliasing `integ.u` would be bad.
258- copyto! (integ. u, tmp)
259- else
260- integ. u = f_oop (integ. u, integ. p, integ. t)
261- end
262- return nothing
263- end
264- end
265-
266- getdt (eq) = operation (eq. lhs). dt
267- deqs = values (var2eq)
268- dt = getdt (first (deqs))
269- all (dt == getdt (eq) for eq in deqs) ||
270- error (" All difference variables should have same time steps." )
271-
272- PeriodicCallback (cb_affect!, first (dt))
273- end
274-
275227function calculate_massmatrix (sys:: AbstractODESystem ; simplify = false )
276228 eqs = [eq for eq in equations (sys) if ! isdifferenceeq (eq)]
277229 dvs = unknowns (sys)
@@ -940,11 +892,11 @@ function DiffEqBase.ODEProblem{iip, specialize}(sys::AbstractODESystem, u0map =
940892 check_length = true ,
941893 kwargs... ) where {iip, specialize}
942894 has_difference = any (isdifferenceeq, equations (sys))
895+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
943896 f, u0, p = process_DEProblem (ODEFunction{iip, specialize}, sys, u0map, parammap;
944897 t = tspan != = nothing ? tspan[1 ] : tspan,
945- has_difference = has_difference,
946898 check_length, kwargs... )
947- cbs = process_events (sys; callback, has_difference, kwargs... )
899+ cbs = process_events (sys; callback, kwargs... )
948900 inits = []
949901 if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
950902 affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
@@ -1010,23 +962,17 @@ function DiffEqBase.DAEProblem{iip}(sys::AbstractODESystem, du0map, u0map, tspan
1010962 parammap = DiffEqBase. NullParameters ();
1011963 check_length = true , kwargs... ) where {iip}
1012964 has_difference = any (isdifferenceeq, equations (sys))
965+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
1013966 f, du0, u0, p = process_DEProblem (DAEFunction{iip}, sys, u0map, parammap;
1014- implicit_dae = true , du0map = du0map,
1015- has_difference = has_difference, check_length,
967+ implicit_dae = true , du0map = du0map, check_length,
1016968 kwargs... )
1017969 diffvars = collect_differential_variables (sys)
1018970 sts = unknowns (sys)
1019971 differential_vars = map (Base. Fix2 (in, diffvars), sts)
1020972 kwargs = filter_kwargs (kwargs)
1021973
1022- if has_difference
1023- DAEProblem {iip} (f, du0, u0, tspan, p;
1024- difference_cb = generate_difference_cb (sys; kwargs... ),
1025- differential_vars = differential_vars, kwargs... )
1026- else
1027- DAEProblem {iip} (f, du0, u0, tspan, p; differential_vars = differential_vars,
974+ DAEProblem {iip} (f, du0, u0, tspan, p; differential_vars = differential_vars,
1028975 kwargs... )
1029- end
1030976end
1031977
1032978function generate_history (sys:: AbstractODESystem , u0; kwargs... )
@@ -1043,15 +989,15 @@ function DiffEqBase.DDEProblem{iip}(sys::AbstractODESystem, u0map = [],
1043989 check_length = true ,
1044990 kwargs... ) where {iip}
1045991 has_difference = any (isdifferenceeq, equations (sys))
992+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
1046993 f, u0, p = process_DEProblem (DDEFunction{iip}, sys, u0map, parammap;
1047994 t = tspan != = nothing ? tspan[1 ] : tspan,
1048- has_difference = has_difference,
1049995 symbolic_u0 = true ,
1050996 check_length, kwargs... )
1051997 h_oop, h_iip = generate_history (sys, u0)
1052998 h = h_oop
1053999 u0 = h (p, tspan[1 ])
1054- cbs = process_events (sys; callback, has_difference, kwargs... )
1000+ cbs = process_events (sys; callback, kwargs... )
10551001 inits = []
10561002 if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
10571003 affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
@@ -1103,16 +1049,16 @@ function DiffEqBase.SDDEProblem{iip}(sys::AbstractODESystem, u0map = [],
11031049 sparsenoise = nothing ,
11041050 kwargs... ) where {iip}
11051051 has_difference = any (isdifferenceeq, equations (sys))
1052+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
11061053 f, u0, p = process_DEProblem (SDDEFunction{iip}, sys, u0map, parammap;
11071054 t = tspan != = nothing ? tspan[1 ] : tspan,
1108- has_difference = has_difference,
11091055 symbolic_u0 = true ,
11101056 check_length, kwargs... )
11111057 h_oop, h_iip = generate_history (sys, u0)
11121058 h (out, p, t) = h_iip (out, p, t)
11131059 h (p, t) = h_oop (p, t)
11141060 u0 = h (p, tspan[1 ])
1115- cbs = process_events (sys; callback, has_difference, kwargs... )
1061+ cbs = process_events (sys; callback, kwargs... )
11161062 inits = []
11171063 if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
11181064 affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
0 commit comments