Opened 6 years ago
Last modified 6 years ago
#5344 assigned defect
Duplicate of model causes incomplete code
Reported by: | Christian Kral <dr.christian.kral@…> | Owned by: | perost |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | Interactive Environment | Version: | v1.14.0-dev-nightly |
Keywords: | Cc: |
Description
Consider the following package:
package Source import Modelica.Constants.pi; import SI = Modelica.SIunits; package Components model Component parameter SI.Radius r = 1 "Radius"; parameter SI.Area area = r^2*pi; end Component; end Components; model Example Components.Component component; parameter SI.Length l = 1; annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)); end Example; end Source;
If I make a right click on the model Example and select duplicate with the following settings,
Name: Example Path: (blank)
the duplicated example
model Example Components.Component component; parameter SI.Length l = 1; annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)); end Example;
cannot be simulated for the following reasons:
- In the duplicate model the class name is just copied and pasted, but not replaced by the fully qualified class name which is required when copying the model the outside of the package Source. This means that
Components.Component component;
has to be replaced by
Source.Components.Component component;
- The import of SI is missing in the duplicate. So after adding
import SI = Modelica.SIunits;
the model is finally complete:
model Example import SI = Modelica.SIunits; Source.Components.Component component; parameter SI.Length l = 1; annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)); end Example;
Conclusions and proposal
- When creating a duplicate of a model into a package on the same hierarchy level the actual implementation is OK
- When creating a duplicate of a model into a package on a different hierarchy level, but still inside the package where the inherited import statements are located, only the class names have to be replaced by the fully qualified class names
- When creating a duplicate of a model into a package on a different hierarchy level outside the package where the inherited import statements are located, then the "missing" import statements have to be inserted, in addition to replacing the class names by the fully qualified class names
For a productive development of models it were extremely helpful to improve the duplicate in the proposed way. Otherwise, it is particularly for beginners extremely difficult to implement the required manual changes. But even experienced user usually suffer from a long list of adaptations to be made when duplicating a model.
Attachments (1)
Change History (3)
Changed 6 years ago by adeas31
comment:1 Changed 6 years ago by adeas31
- Component changed from OMEdit to Interactive Environment
- Owner changed from adeas31 to perost
- Status changed from new to assigned
comment:2 Changed 6 years ago by casella
- Milestone changed from Future to 2.0.0
Per can you fix the copyClass to handle such cases. See the attached script.