@@ -144,7 +144,6 @@ function generate_function(sys::AbstractODESystem, dvs = unknowns(sys), ps = par
144
144
ddvs = implicit_dae ? map (Differential (get_iv (sys)), dvs) :
145
145
nothing ,
146
146
isdde = false ,
147
- has_difference = false ,
148
147
kwargs... )
149
148
if isdde
150
149
eqs = delay_to_function (sys)
@@ -167,8 +166,7 @@ function generate_function(sys::AbstractODESystem, dvs = unknowns(sys), ps = par
167
166
if isdde
168
167
build_function (rhss, u, DDE_HISTORY_FUN, p, t; kwargs... )
169
168
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)
172
170
173
171
if implicit_dae
174
172
build_function (rhss, ddvs, u, p, t; postprocess_fbody = pre,
@@ -226,52 +224,6 @@ function delay_to_function(expr, iv, sts, ps, h)
226
224
end
227
225
end
228
226
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
-
275
227
function calculate_massmatrix (sys:: AbstractODESystem ; simplify = false )
276
228
eqs = [eq for eq in equations (sys) if ! isdifferenceeq (eq)]
277
229
dvs = unknowns (sys)
@@ -940,11 +892,11 @@ function DiffEqBase.ODEProblem{iip, specialize}(sys::AbstractODESystem, u0map =
940
892
check_length = true ,
941
893
kwargs... ) where {iip, specialize}
942
894
has_difference = any (isdifferenceeq, equations (sys))
895
+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
943
896
f, u0, p = process_DEProblem (ODEFunction{iip, specialize}, sys, u0map, parammap;
944
897
t = tspan != = nothing ? tspan[1 ] : tspan,
945
- has_difference = has_difference,
946
898
check_length, kwargs... )
947
- cbs = process_events (sys; callback, has_difference, kwargs... )
899
+ cbs = process_events (sys; callback, kwargs... )
948
900
inits = []
949
901
if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
950
902
affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
@@ -1010,23 +962,17 @@ function DiffEqBase.DAEProblem{iip}(sys::AbstractODESystem, du0map, u0map, tspan
1010
962
parammap = DiffEqBase. NullParameters ();
1011
963
check_length = true , kwargs... ) where {iip}
1012
964
has_difference = any (isdifferenceeq, equations (sys))
965
+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
1013
966
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,
1016
968
kwargs... )
1017
969
diffvars = collect_differential_variables (sys)
1018
970
sts = unknowns (sys)
1019
971
differential_vars = map (Base. Fix2 (in, diffvars), sts)
1020
972
kwargs = filter_kwargs (kwargs)
1021
973
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,
1028
975
kwargs... )
1029
- end
1030
976
end
1031
977
1032
978
function generate_history (sys:: AbstractODESystem , u0; kwargs... )
@@ -1043,15 +989,15 @@ function DiffEqBase.DDEProblem{iip}(sys::AbstractODESystem, u0map = [],
1043
989
check_length = true ,
1044
990
kwargs... ) where {iip}
1045
991
has_difference = any (isdifferenceeq, equations (sys))
992
+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
1046
993
f, u0, p = process_DEProblem (DDEFunction{iip}, sys, u0map, parammap;
1047
994
t = tspan != = nothing ? tspan[1 ] : tspan,
1048
- has_difference = has_difference,
1049
995
symbolic_u0 = true ,
1050
996
check_length, kwargs... )
1051
997
h_oop, h_iip = generate_history (sys, u0)
1052
998
h = h_oop
1053
999
u0 = h (p, tspan[1 ])
1054
- cbs = process_events (sys; callback, has_difference, kwargs... )
1000
+ cbs = process_events (sys; callback, kwargs... )
1055
1001
inits = []
1056
1002
if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
1057
1003
affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
@@ -1103,16 +1049,16 @@ function DiffEqBase.SDDEProblem{iip}(sys::AbstractODESystem, u0map = [],
1103
1049
sparsenoise = nothing ,
1104
1050
kwargs... ) where {iip}
1105
1051
has_difference = any (isdifferenceeq, equations (sys))
1052
+ has_difference && error (" The operators Difference and DiscreteUpdate are deprecated. Use ShiftIndex instead." )
1106
1053
f, u0, p = process_DEProblem (SDDEFunction{iip}, sys, u0map, parammap;
1107
1054
t = tspan != = nothing ? tspan[1 ] : tspan,
1108
- has_difference = has_difference,
1109
1055
symbolic_u0 = true ,
1110
1056
check_length, kwargs... )
1111
1057
h_oop, h_iip = generate_history (sys, u0)
1112
1058
h (out, p, t) = h_iip (out, p, t)
1113
1059
h (p, t) = h_oop (p, t)
1114
1060
u0 = h (p, tspan[1 ])
1115
- cbs = process_events (sys; callback, has_difference, kwargs... )
1061
+ cbs = process_events (sys; callback, kwargs... )
1116
1062
inits = []
1117
1063
if has_discrete_subsystems (sys) && (dss = get_discrete_subsystems (sys)) != = nothing
1118
1064
affects, inits, clocks, svs = ModelingToolkit. generate_discrete_affect (dss... )
0 commit comments