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

SDEs with brownian motions requires structural_simplify #2831

Closed
TorkelE opened this issue Jun 30, 2024 · 1 comment · Fixed by #3316
Closed

SDEs with brownian motions requires structural_simplify #2831

TorkelE opened this issue Jun 30, 2024 · 1 comment · Fixed by #3316
Assignees
Labels
bug Something isn't working

Comments

@TorkelE
Copy link
Member

TorkelE commented Jun 30, 2024

In this example: https://docs.sciml.ai/ModelingToolkit/stable/tutorials/stochastic_diffeq/, if I change

@mtkbuild de = System(eqs, t)

to

@named de = System(eqs, t)
de = complete(de)

then I receive a

ERROR: No methods were found for the model function passed to the equation solver.
The function `f` needs to have dispatches, for example, for an ODEProblem
`f` must define either `f(u,p,t)` or `f(du,u,p,t)`. For more information
on how the model function `f` should be defined, consult the docstring for
the appropriate `AbstractSciMLFunction`.

Offending function: f
Stacktrace:
 [1] 
   @ SciMLBase ~/.julia/packages/SciMLBase/sakPO/src/utils.jl:250
 [2] isinplace (repeats 2 times)
   @ ~/.julia/packages/SciMLBase/sakPO/src/utils.jl:243 [inlined]
 [3] SDEProblem(f::ODESystem, g::Vector{…}, u0::Tuple{…}, tspan::Vector{…}, p::SciMLBase.NullParameters; kwargs::@Kwargs{})
   @ SciMLBase ~/.julia/packages/SciMLBase/sakPO/src/problems/sde_problems.jl:124
 [4] SDEProblem
   @ ~/.julia/packages/SciMLBase/sakPO/src/problems/sde_problems.jl:123 [inlined]
 [5] SDEProblem(f::ODESystem, g::Vector{Pair{Num, Float64}}, u0::Tuple{Float64, Float64}, tspan::Vector{Pair{Num, Float64}})
   @ SciMLBase ~/.julia/packages/SciMLBase/sakPO/src/problems/sde_problems.jl:123
 [6] top-level scope
   @ ~/Desktop/Julia Playground/Environment - Catalyst test/test_playground.jl:108
Some type information was truncated. Use `show(err)` to see complete types.

when I run

prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)

Full code:

using ModelingToolkit, StochasticDiffEq
using ModelingToolkit: t_nounits as t, D_nounits as D

# Define some variables
@parameters σ ρ β
@variables x(t) y(t) z(t)
@brownian a
eqs = [D(x) ~ σ * (y - x) + 0.1a * x,
    D(y) ~ x *- z) - y + 0.1a * y,
    D(z) ~ x * y - β * z + 0.1a * z]

@named de = System(eqs, t)
de = complete(de)

u0map = [
    x => 1.0,
    y => 0.0,
    z => 0.0
]

parammap = [
    σ => 10.0,
    β => 26.0,
    ρ => 2.33
]

prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)
sol = solve(prob, LambaEulerHeun())
@TorkelE TorkelE added the bug Something isn't working label Jun 30, 2024
@ChrisRackauckas
Copy link
Member

Yes it does require a structural simplify. We should throw a better error about that.

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

Successfully merging a pull request may close this issue.

3 participants