@@ -160,7 +160,7 @@ const Affect = Union{AffectSystem, FunctionalAffect, ImperativeAffect}
160160
161161"""
162162 SymbolicContinuousCallback(eqs::Vector{Equation}, affect = nothing, iv = nothing;
163- affect_neg = affect, initialize = nothing, finalize = nothing, rootfind = SciMLBase.LeftRootFind, algeeqs = Equation[])
163+ affect_neg = affect, initialize = nothing, finalize = nothing, rootfind = SciMLBase.LeftRootFind, alg_eqs = Equation[])
164164
165165A [`ContinuousCallback`](@ref SciMLBase.ContinuousCallback) specified symbolically. Takes a vector of equations `eq`
166166as well as the positive-edge `affect` and negative-edge `affect_neg` that apply when *any* of `eq` are satisfied.
@@ -226,7 +226,7 @@ struct SymbolicContinuousCallback <: AbstractCallback
226226 rootfind = SciMLBase. LeftRootFind,
227227 reinitializealg = nothing ,
228228 iv = nothing ,
229- algeeqs = Equation[])
229+ alg_eqs = Equation[])
230230 conditions = (conditions isa AbstractVector) ? conditions : [conditions]
231231
232232 if isnothing (reinitializealg)
@@ -236,29 +236,30 @@ struct SymbolicContinuousCallback <: AbstractCallback
236236 reinitializealg = SciMLBase. NoInit ()
237237 end
238238
239- new (conditions, make_affect (affect; iv, algeeqs , discrete_parameters),
240- make_affect (affect_neg; iv, algeeqs , discrete_parameters),
241- make_affect (initialize; iv, algeeqs , discrete_parameters), make_affect (
242- finalize; iv, algeeqs , discrete_parameters),
239+ new (conditions, make_affect (affect; iv, alg_eqs , discrete_parameters),
240+ make_affect (affect_neg; iv, alg_eqs , discrete_parameters),
241+ make_affect (initialize; iv, alg_eqs , discrete_parameters), make_affect (
242+ finalize; iv, alg_eqs , discrete_parameters),
243243 rootfind, reinitializealg)
244244 end # Default affect to nothing
245245end
246246
247- function SymbolicContinuousCallback (p:: Pair , args... ; kwargs... )
248- SymbolicContinuousCallback (p[1 ], p[2 ], args... ; kwargs... )
247+ SymbolicContinuousCallback (p:: Pair , args... ; kwargs... ) = SymbolicContinuousCallback (p[1 ], p[2 ], args... ; kwargs... )
248+
249+ function SymbolicContinuousCallback (cb:: SymbolicContinuousCallback , args... ; iv = nothing , alg_eqs = Equation[], kwargs... )
250+ cb
249251end
250- SymbolicContinuousCallback (cb:: SymbolicContinuousCallback , args... ; kwargs... ) = cb
251252
252253make_affect (affect:: Nothing ; kwargs... ) = nothing
253254make_affect (affect:: Tuple ; kwargs... ) = FunctionalAffect (affect... )
254255make_affect (affect:: NamedTuple ; kwargs... ) = FunctionalAffect (; affect... )
255256make_affect (affect:: Affect ; kwargs... ) = affect
256257
257258function make_affect (affect:: Vector{Equation} ; discrete_parameters:: AbstractVector = Any[],
258- iv = nothing , algeeqs :: Vector{Equation} = Equation[])
259+ iv = nothing , alg_eqs :: Vector{Equation} = Equation[])
259260 isempty (affect) && return nothing
260- isempty (algeeqs ) &&
261- @warn " No algebraic equations were found for the callback defined by $(join (affect, " , " )) . If the system has no algebraic equations, this can be disregarded. Otherwise pass in `algeeqs ` to the SymbolicContinuousCallback constructor."
261+ isempty (alg_eqs ) &&
262+ @warn " No algebraic equations were found for the callback defined by $(join (affect, " , " )) . If the system has no algebraic equations, this can be disregarded. Otherwise pass in `alg_eqs ` to the SymbolicContinuousCallback constructor."
262263 if isnothing (iv)
263264 iv = t_nounits
264265 @warn " No independent variable specified. Defaulting to t_nounits."
@@ -280,7 +281,7 @@ function make_affect(affect::Vector{Equation}; discrete_parameters::AbstractVect
280281 diffvs = collect_applied_operators (eq, Differential)
281282 union! (dvs, diffvs)
282283 end
283- for eq in algeeqs
284+ for eq in alg_eqs
284285 collect_vars! (dvs, params, eq, iv)
285286 end
286287
@@ -294,10 +295,10 @@ function make_affect(affect::Vector{Equation}; discrete_parameters::AbstractVect
294295 rev_map = Dict (zip (discrete_parameters, discretes))
295296 subs = merge (rev_map, Dict (zip (dvs, _dvs)))
296297 affect = Symbolics. fast_substitute (affect, subs)
297- algeeqs = Symbolics. fast_substitute (algeeqs , subs)
298+ alg_eqs = Symbolics. fast_substitute (alg_eqs , subs)
298299
299300 @named affectsys = ImplicitDiscreteSystem (
300- vcat (affect, algeeqs ), iv, collect (union (_dvs, discretes)),
301+ vcat (affect, alg_eqs ), iv, collect (union (_dvs, discretes)),
301302 collect (union (pre_params, sys_params)))
302303 affectsys = structural_simplify (affectsys; fully_determined = false )
303304 # get accessed parameters p from Pre(p) in the callback parameters
322323Generate continuous callbacks.
323324"""
324325function SymbolicContinuousCallbacks (events; discrete_parameters = Any[],
325- algeeqs :: Vector{Equation} = Equation[], iv = nothing )
326+ alg_eqs :: Vector{Equation} = Equation[], iv = nothing )
326327 callbacks = SymbolicContinuousCallback[]
327328 isnothing (events) && return callbacks
328329
@@ -332,7 +333,7 @@ function SymbolicContinuousCallbacks(events; discrete_parameters = Any[],
332333 for event in events
333334 cond, affs = event isa Pair ? (event[1 ], event[2 ]) : (event, nothing )
334335 push! (callbacks,
335- SymbolicContinuousCallback (cond, affs; iv, algeeqs , discrete_parameters))
336+ SymbolicContinuousCallback (cond, affs; iv, alg_eqs , discrete_parameters))
336337 end
337338 callbacks
338339end
421422# TODO : Iterative callbacks
422423"""
423424 SymbolicDiscreteCallback(conditions::Vector{Equation}, affect = nothing, iv = nothing;
424- initialize = nothing, finalize = nothing, algeeqs = Equation[])
425+ initialize = nothing, finalize = nothing, alg_eqs = Equation[])
425426
426427A callback that triggers at the first timestep that the conditions are satisfied.
427428
@@ -432,7 +433,7 @@ The condition can be one of:
432433
433434Arguments:
434435- iv: The independent variable of the system. This must be specified if the independent variable appaers in one of the equations explicitly, as in x ~ t + 1.
435- - algeeqs : Algebraic equations of the system that must be satisfied after the callback occurs.
436+ - alg_eqs : Algebraic equations of the system that must be satisfied after the callback occurs.
436437"""
437438struct SymbolicDiscreteCallback <: AbstractCallback
438439 conditions:: Any
@@ -444,7 +445,7 @@ struct SymbolicDiscreteCallback <: AbstractCallback
444445 function SymbolicDiscreteCallback (
445446 condition, affect = nothing ;
446447 initialize = nothing , finalize = nothing , iv = nothing ,
447- algeeqs = Equation[], discrete_parameters = Any[], reinitializealg = nothing )
448+ alg_eqs = Equation[], discrete_parameters = Any[], reinitializealg = nothing )
448449 c = is_timed_condition (condition) ? condition : value (scalarize (condition))
449450
450451 if isnothing (reinitializealg)
@@ -453,9 +454,9 @@ struct SymbolicDiscreteCallback <: AbstractCallback
453454 reinitializealg = SciMLBase. CheckInit () :
454455 reinitializealg = SciMLBase. NoInit ()
455456 end
456- new (c, make_affect (affect; iv, algeeqs , discrete_parameters),
457- make_affect (initialize; iv, algeeqs , discrete_parameters),
458- make_affect (finalize; iv, algeeqs , discrete_parameters), reinitializealg)
457+ new (c, make_affect (affect; iv, alg_eqs , discrete_parameters),
458+ make_affect (initialize; iv, alg_eqs , discrete_parameters),
459+ make_affect (finalize; iv, alg_eqs , discrete_parameters), reinitializealg)
459460 end # Default affect to nothing
460461end
461462
@@ -468,7 +469,7 @@ SymbolicDiscreteCallback(cb::SymbolicDiscreteCallback, args...; kwargs...) = cb
468469Generate discrete callbacks.
469470"""
470471function SymbolicDiscreteCallbacks (events; discrete_parameters:: Vector = Any[],
471- algeeqs :: Vector{Equation} = Equation[], iv = nothing )
472+ alg_eqs :: Vector{Equation} = Equation[], iv = nothing )
472473 callbacks = SymbolicDiscreteCallback[]
473474
474475 isnothing (events) && return callbacks
@@ -478,7 +479,7 @@ function SymbolicDiscreteCallbacks(events; discrete_parameters::Vector = Any[],
478479 for event in events
479480 cond, affs = event isa Pair ? (event[1 ], event[2 ]) : (event, nothing )
480481 push! (callbacks,
481- SymbolicDiscreteCallback (cond, affs; iv, algeeqs , discrete_parameters))
482+ SymbolicDiscreteCallback (cond, affs; iv, alg_eqs , discrete_parameters))
482483 end
483484 callbacks
484485end
0 commit comments