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

vector equations in @mtkmodel #2318

Open
baggepinnen opened this issue Oct 16, 2023 · 3 comments
Open

vector equations in @mtkmodel #2318

baggepinnen opened this issue Oct 16, 2023 · 3 comments
Assignees

Comments

@baggepinnen
Copy link
Contributor

The @mtkmodel macro appears to assume that all equations are scalars:

ERROR: MethodError: Cannot `convert` an object of type Vector{Equation} to an object of type Equation
...
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/oIgbi/src/systems/model_parsing.jl:25 [inlined]

would it be possible to let the macro instead use vcat so that a statement inside the @equations block would work no matter whether it results in a scalar or a vector?

@ChrisRackauckas
Copy link
Member

That would probably need to come after #2282.

would it be possible to let the macro instead use vcat so that a statement inside the @equations block would work no matter whether it results in a scalar or a vector?

We should be careful about accidentally flattening though.

@baggepinnen
Copy link
Contributor Author

I see, yes we don't want to destroy proper "array equations". In my usecase, I tried to call a helper function which returned an array of scalar equations. For now, I just had to revert to the old way of manually calling ODESystem

@GHE-HS
Copy link

GHE-HS commented Jun 26, 2024

I bumped into the same issues as @baggepinnen when trying to use a vector of equations in the macro

@mtkmodel
    (...)
    @equation begin
        var_arrayA .~ var_arrayB
    end
end

I see that now that #2282 has been merged.
Is there a workaround you could suggest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants