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

Allow to apply Domain callbacks to specified equations only

Open BeastyBlacksmith opened this issue 7 years ago • 2 comments

Currently Domain callbacks apply to all equations simultaneously. In many use cases you only want to apply them for some equations ( think of a position that should always stay positive but the velocity still should be able to become negative ).

BeastyBlacksmith avatar Feb 01 '18 14:02 BeastyBlacksmith

This can be done with an idxs argument for which indices to apply to, and using views in the actual callback. Should be a pretty easy addition.

ChrisRackauckas avatar Feb 01 '18 14:02 ChrisRackauckas

This should be possible with GeneralDomainCallback. You can e.g. define the residual function such that the residuals for unconstrained states are always 0, that residuals of negative states are 0 if they are negative (u < 0) and u if u > 0, and that residuals of positive states are 0 if they are positive and -u if u < 0.

devmotion avatar Mar 01 '22 23:03 devmotion