Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour for SDEs with continuous callbacks #2723

Open
TorkelE opened this issue May 17, 2024 · 0 comments
Open

Strange behaviour for SDEs with continuous callbacks #2723

TorkelE opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@TorkelE
Copy link
Member

TorkelE commented May 17, 2024

Here I create a continuous callback that should add 20 units of X whenever X hits the threshold at 50.0. Practically, the about of X added seems a bit random, and typically less that 20.0.

using ModelingToolkit
@variables t X(t)
@parameters p d
D = Differential(t)

eqs = [D(X) ~ p - d*X]
noiseeqs = [0.1*X]
continuous_events =[[X ~ 50.0] => [X ~ X + 20.0]]
@named ssys = SDESystem(eqs, noiseeqs, t, [X], [p, d]; continuous_events)
ssys = complete(ssys) # because @mtkbuild/structural_simplify are broken for SDE systems.

u0 = [X => 55.0]
tspan = (0.0, 100.0)
ps = [p => 10.0, d => 0.2]

oprob = SDEProblem(ssys, u0, tspan, ps)
sol = solve(oprob, ImplicitEM())
plot(sol)

image

@TorkelE TorkelE added the bug Something isn't working label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant