-
Notifications
You must be signed in to change notification settings - Fork 13
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
OMJulia api docu: sample code should work right away #85
Comments
We could switch from the Sphinx documentation from OpenModelica to Documenter.jl and only refer to that documentation from the OpenModelica User's Guide. It's possible to make all examples inside the documentation test, so we can ensure they are always working as intended and also test them on different OS (Windows and Linux). Regarding your issue: The Readme.md provides an example using the MSL. using OMJulia
mod = OMJulia.OMCSession()
sendExpression(mod, "loadFile(getInstallationDirectoryPath() + \"/share/doc/omc/testmodels/BouncingBall.mo\")")
ModelicaSystem(mod,"BouncingBall.mo","BouncingBall") It's probably best, to just add the source code of bouncingBall.mo into the documentation. model BouncingBall
parameter Real e=0.7 "coefficient of restitution";
parameter Real g=9.81 "gravity acceleration";
Real h(fixed=true, start=1) "height of ball";
Real v(fixed=true) "velocity of ball";
Boolean flying(fixed=true, start=true) "true, if ball is flying";
Boolean impact;
Real v_new(fixed=true);
Integer foo;
equation
impact = h <= 0.0;
foo = if impact then 1 else 2;
der(v) = if flying then -g else 0;
der(h) = v;
when {h <= 0.0 and v <= 0.0,impact} then
v_new = if edge(impact) then -e*pre(v) else 0;
flying = v_new > 0;
reinit(v, v_new);
end when;
end BouncingBall; |
The parameter sensitivity is using the lottka voltera example, which is very compact. |
100% move to Documenter.jl |
We decided in today's dev-meeting to switch to Documenter.jl. I'll create a PR with the initial setup and CI to build and upload the documentation to a GitHub page. If that is up and running we can add more and more stuff to it. |
@olivleno is https://openmodelica.github.io/OMJulia.jl/dev/quickstart/#ModelicaSystem a better documentation or is there any information missing? |
@AnHeuermann thanks for your efforts. I like the enhancement of the example code showing how to manage result file. Very nice. Also the note where to find the BouncingBall.mo is very helpful. All this can be considered very very basic stuff that everybody should know, but the path handling can always be a stumbling block if you are using a new environment without knowing how path information is handled, e.g. , the |
I tested the Scripting API example code in a julia script. The line: throws the error: |
You'll need to update OMJulia to v0.2.2 |
The introduction to OMJulia is nice but still not straight forward with stumbling blocks for new users.
For instance the example code:
doesn't work unless you have the mo file in the proper place.
A new user should be able to run the code just like that.
I'd suggest to provide the required models for download or use a model from the MSL and document all prerequisites, like path to the MSL and so on, such that everybody is able to reproduce the results without being confronted with error messages after executing the code examples and having to trouble shoot all kind of things (e.g. figure out the path to the MSL) that could be easily documented or integrated in the code.
The text was updated successfully, but these errors were encountered: