Skip to content

Commit 08633e9

Browse files
feat: add ZeroCrossing and EventClock from zero crossing
1 parent acd2e1f commit 08633e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/discretedomain.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,14 @@ function input_timedomain(x)
365365
throw(ArgumentError("$x of type $(typeof(x)) is not an operator expression"))
366366
end
367367
end
368+
369+
function ZeroCrossing(expr; name = gensym(), up = true, down = true, kwargs...)
370+
return SymbolicContinuousCallback(
371+
[expr ~ 0], up ? ImperativeAffect(Returns(nothing)) : nothing;
372+
affect_neg = down ? ImperativeAffect(Returns(nothing)) : nothing,
373+
kwargs..., zero_crossing_id = name)
374+
end
375+
376+
function SciMLBase.Clocks.EventClock(cb::SymbolicContinuousCallback)
377+
return SciMLBase.Clocks.EventClock(cb.zero_crossing_id)
378+
end

0 commit comments

Comments
 (0)