ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Event trigger directionality

Open paulflang opened this issue 2 years ago • 4 comments

I am trying to introduce directionality in an event trigger (i.e. only fire as either up or downpass). IIUC this correctly it should be possible in principle with affect_neg!=nothing in the ContinuousVectorCallback . But in MTK, I am using a Pair{Vector{Equation}, Vector{Equation}}[] that is passed to continuous_events in the ODESystem constructor. Is there a good way to introduce directionality in a trigger using the ODESystem constructor/continuous_events keyword? My current code is here. Perhaps rather than using ~ in the trigger equation < or > could be used?

paulflang avatar Aug 01 '22 11:08 paulflang

SymbolicContinuousCallbacks could be modified to accept an affect_neg! function too:

https://github.com/SciML/ModelingToolkit.jl/blob/01186a4b41c0100dfd65f84dd188d0739f238976/src/systems/callbacks.jl#L73

isaacsas avatar Aug 01 '22 12:08 isaacsas

@paulflang I can add that for you, but might not be till later in the week.

isaacsas avatar Aug 01 '22 12:08 isaacsas

@isaacsas : that would be great. But not urgent rn.

paulflang avatar Aug 01 '22 15:08 paulflang

I'm trying to finish off getting normal events into SDEs and jump processes first: https://github.com/SciML/ModelingToolkit.jl/pull/1714

isaacsas avatar Aug 01 '22 15:08 isaacsas

Hi, is there any progress or a workaround for this issue yet?

SLiemann avatar Oct 06 '22 11:10 SLiemann

I have the same need for a directional callback. Currently using ifelse but thinking a directional callback can be more efficient.

cuihantao avatar Jan 01 '23 02:01 cuihantao

We were discussing this more recently in https://github.com/SciML/SBMLToolkit.jl/issues/101. I close it there, let's continue discussing here.

paulflang avatar Jan 02 '23 15:01 paulflang