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

numerical constant and spaces in equation #118

Open
johhell opened this issue Aug 31, 2021 · 1 comment
Open

numerical constant and spaces in equation #118

johhell opened this issue Aug 31, 2021 · 1 comment

Comments

@johhell
Copy link
Contributor

johhell commented Aug 31, 2021

issue with spaces in equations

correct results

two spaces

ConstantTest = Model(
    AA=1.3,
    equations = :[ der(X) = -1.0*X + 2.0*AA    ]  
)
ct = @instantiateModel(ConstantTest, log=true)
simulate!(ct, stopTime=10)
plot(ct, ("X"))

Equations after alias reduction:
   1: der(X) = -1.0X + 2.0AA

no spaces

    equations = :[ der(X) = -1.0*X+2.0*AA    ]

Equations after alias reduction:
   1: der(X) = -1.0X + 2.0AA

error message

one space

    equations = :[ der(X) = -1.0*X +2.0*AA    ]

Equations after alias reduction:
   1: der(X) = -1.0X
   2: 2.0AA
@HildingElmqvist
Copy link
Contributor

Thank you for highlighting this. It is a general property of the Julia parser.

`julia> e = [1 + 2]
1-element Vector{Int64}:
3

julia> e = [1 +2]
1×2 Matrix{Int64}:
1 2`

So your Modia model gives either one or two equations:

`julia> :[ der(X) = -1.0X + 2.0AA ]
:([der(X) = begin
#= REPL[28]:1 =#
-1.0X + 2.0AA
end])

julia> :[ der(X) = -1.0X +2.0AA ]
:([der(X) = begin
#= REPL[29]:1 =#
-1.0X
end 2.0AA])`

I will leave the ticket open in order to remember to improve the diagnostics.

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

No branches or pull requests

2 participants