-
Notifications
You must be signed in to change notification settings - Fork 58
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
imports loaded in package.mo not found when trying to load a model #199
Comments
This should work fine.
|
@martinscripts when i tried to load this model in OMEdit, i get the following error
And i cannot find the model TimeLineKeys.mo in the package, could you please make sure the model |
@adeas31 here the first part of the output:
|
@arun3688 copy the attached files into the folder dynawo\dynawo\sources\Models\Modelica\Dynawo\NonElectrical\Logs in your local dynawo repo, then it should work. |
Is there anything else I can supply in order to answer my question? :) |
I just talked with @arun3688 and he will try to investigate this further. In the meantime can you try the latest version of OpenModelica. The version 1.18 is almost 2-3 yrs old. Also try updating the OMPython to the latest version as well. |
Thank you. Unfortunately, the OM 1.18 is a dependency of Dynawo, the library I am using. |
@martinscripts I tested the library in OMPython after putting the missing files in
The Dynawo library works with recent OpenModelica version |
Thanks so much for your help. while it may work, the version it is a requirement for contributing to dynawo. Cheers! :) |
Updating OMPython got me a step further. The problem that I described doesn't happen anymore. Thank you! |
Hello again, I ran into a similar problem again once I tried to load my own model (outside of Dynawo) with Dynawo as a dependency:
Is this correct calling of ModelicaSystem()? Again, it does not find the following packages:
I want to try OMEdit 1.22.2, I installed it as a second instance alongside 1.18.0. (see here) Best regards, |
I think OMPython uses the |
Ok, it is set to 1.22.2. Any further ideas? |
@martinscripts I am not sure I understand what you mean here. The Dynawo software, which is a hybrid C++/Modelica thing, may have a dependency on a specific version of OpenModelica for quality assurance reasons. But if you just use the Dynawo Modelica library, which I understand is found here, the only dependency is on the Modelica Standard Library 3.2.3, which is automatically installed when you install OpenModelica. We understand's RTE's requirements, as they are using Dynawo in production they have to make sure all the dependencies are well tested and are a bit reluctant at updating the OpenModelica version. On the other hand, OpenModelica has been vastly improved since version 1.18.0, so we can't really offer assistance to you if you stick to a version of the software that lacks two an half years of bug fixes and developments. Unless there is a very specific reason for that. |
Hey @casella, at the moment I am working with and referring to OMEdit 1.22.2, which is the latest official release. While the update of OMPython helped with the problem I originally described, it did not work with an own package outside the dynawo library. |
OK. Can you please provide @arun3688 an updated libray with the keys, so he can try to reproduce you problem and fix it? |
I am guessing it fails to load the dynamo library. Is there any other error message besides this? |
@adeas31 no only those messages. @casella @arun3688 the dynawo library did not change, see above for where to put the timelineKeys files. Here is the model I am trying to load, which in turn uses dynawo. |
Can you post the output of the following script,
|
Can you please open a ticket on the dynawo project where you ask the developers to remove the timelineKeys files from .gitignore and manage them properly on the git repository? We will soon add Dynawo to the OMC package manager, and this is essential for the whole thing to work properly in all cases. Thanks! |
|
I suspected this could be the problem, and in fact here it is. Unfortunately, Dynawo is still using MSL 3.2.3, if OMC loads MSL 4.0.0, nothing will work. The question is, why isn't the uses annotation handled properly? |
Now it makes sense. You should get this error message from OMPython as well. @arun3688 can you fix OMPython so it shows the error messages properly.
The following script should work without error,
And the following OMPython code should also work,
|
Uses annotation is handled. The script explicitly loads Modelica 4.0.0 before loading the dynawo library. I updated the script. |
@martinscripts I found the issue, the dependency package are not loaded in OMPython and that is causing the issue in OMPython |
thanks people, That's a really promising lead! @adeas31 |
@martinscripts in general I would try to avoid explicitly loading installed libraries. Every library should have proper uses annotations, so that the package manager can figure this out automatically. |
okay, thanks for the help.
Would this look something like this, in the package.mo that I was loading? within ;
package KundurTwoArea "Kundur Two Area test system used for small signal stability studies"
// generic import commands
import Complex "Complex numbers foundation class";
import Modelica;
import Modelica.ComplexMath "Complex numbers operators (+, - , *, exp, abs...)";
import Modelica.Icons;
import Dynawo;
import Dynawo.AdditionalIcons;
import Dynawo.Electrical.SystemBase;
import Dynawo.Types "Standard Dynawo variable types";
extends Icons.Package;
annotation(
uses(Modelica(version = "3.2.3")),
preferredView = "info",
Documentation(info = "<html><head></head><body>This package contains the two-area test system described in Example 12.6 of Prabha Kundur's Power System Stability and Control.</body></html>"));
end KundurTwoArea;
|
Yes. Note that if you drag-and-drop a model from a library into another model, possibly contained in a package, OMEdit automatically adds the appropriate uses annotation, so that the library is automatically loaded when loading the model or package. As a matter of fact, I'm not sure why you add those import statements. If you build models graphically, there is no need for them. You just need to have the libraries loaded. This happens automatically if
Note that Modelica Standard Library is automatically installed when you install OpenModelica on Windows. Dynawo is currently not included in the package manager, so you need to download it somewhere and open it manually every time you start OMEdit - you can do that with one click in the Welcome page using the recent file list. Until we include Dynawo in the package manager, to get it automatically loaded you need to add a |
What I mean is that |
@martinscripts the issue is fixed with this commit 1fcbcac, i have published the package to pip, and you can do
|
@martinscripts please close the ticket if this now works for you. |
@casella I'm not fully sure where you would add used(Dynawo), until now it seems like I didn't need that (or I overlooked it). Thank you all for your help. The model builds now, seems to work fine :). |
Once we have put Dynawo in the package manager, you should put this annotation annotation(uses(Modelica(version = 3.2.3), Dynawo), ...); at the end of your KundurTwoArea package. This would ensure that as soon as you open KundurTwoArea, the right version of the Modelica Standard library and the latest installed version of Dynawo will be automatically loaded. |
Description
This may be connected to #133.
I am trying to load a model which uses the dynawo library
There are several packages loaded inside the package.mo of dynawo:
which can't be found when loading a model through ModelicaSystem() in OMPython.
Maybe I am just missing something?
Thank you in advance :)
Steps to reproduce
returns the error
Error: Function ComplexMath.'abs' not found in scope GeneratorSynchronous.
Expected behavior
It should be loaded properly because
ComplexMath
is loaded in dynawo's package.mo, as pasted above.And in OMEdit it runs.
writing
mod = ModelicaSystem(DYNAWO_PACKAGE_PATH, "Dynawo.Examples.SMIB.SMIBStepPm", ["Modelica", "Modelica.ComplexMath"])
did not change it.Version and OS
The text was updated successfully, but these errors were encountered: