Skip to content

making SDESystem without using @mtkbuild #3174

@Sush1090

Description

@Sush1090

Is your feature request related to a problem? Please describe.

I like to make my "acausal" components using the following format

function MyComp(;name,...)
    @named inport = ...connector..
    @named outport = ...connector..
    para = @parameters begin
        MyParas ...
    end
    vars = @variables begin
        MyVars ...
     end
   eqs = [  outport.mdot ~ abs(inport.mdot) 
            outport.p ~ eq1 ...
            outport.h ~ eq2 ...
            ..
   ]
   compose(ODESystem(eqs, t, vars, para;name), inport, outport)
end

This works very well for ODESystems
I would like to know if I can have the same possibility of doing the same with SDESystem
Describe the solution you’d like
So it should look something like this:

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


function sto(;name)
    para = @parameters begin
        σ=10.0 
        ρ=28
        β=8/3
    end
    vars = @variables begin
        x(t)
        y(t)
        z(t)
    end 
    br = @brownian begin
        B
    end
    eqs = [D(x) ~ σ * (y - x) + B,
        D(y) ~ x *- z) - y ,
        D(z) ~ x * y - β * z ]
    System(eqs,t,vars,para,br;name)
end
@named de = sto()
sys = structural_simplify(de)
typeof(sys)

The current example of SDESystem works well as described in here but uses @mtkbuild which does not allow me to make my function.
Describe alternatives you’ve considered
The example in the tutorial is the only alternative I know but the "low-level" interface allows for more flexibility as I have mentioned in the example of ODESystem and SDESystem.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions