Skip to content

@mtkmodel macro for discrete-time systems #3498

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

Open
baggepinnen opened this issue Mar 26, 2025 · 0 comments · May be fixed by #3526
Open

@mtkmodel macro for discrete-time systems #3498

baggepinnen opened this issue Mar 26, 2025 · 0 comments · May be fixed by #3526
Assignees

Comments

@baggepinnen
Copy link
Contributor

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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants