Skip to content

@mtkmodel macro for discrete-time systems #3498

Open
@baggepinnen

Description

@baggepinnen

It would be nice to have some way of constructing discrete-time systems using a model macro. @mtkmodel currently only creates ODESystems.

It could be either a new macro, or a kwarg to the existing one.

Example (not working)

using ModelingToolkit
t = ModelingToolkit.t_nounits
k = ShiftIndex(t)

@mtkmodel Float2Bool begin
    @variables begin
        u(t)::Float64
        y(t)::Bool
    end
    @equations begin
        y ~ u != 0
    end
end

@mtkmodel Model begin
    @variables begin
        x(t) = 0
    end
    @components begin
        conversion = Float2Bool()
    end
    @equations begin
        x(k) ~ 0.99x(k-1)
        conversion.u ~ x
    end
end

@named model = Model()

prob = DiscreteProblem(sys, [], (0,10))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions