Opened 9 years ago

Last modified 7 years ago

#3638 assigned defect

Parameters based on externally read parameters are not calculated correctly

Reported by: Christian Kral <dr.christian.kral@…> Owned by: Willi Braun
Priority: high Milestone: Future
Component: Run-time Version:
Keywords: Cc:

Description

Please consider the following example:

model ReadingParameters
  parameter String inputFile = Modelica.Utilities.Files.loadResource("modelica://ReadingParameters/input.dat") "Input data file";
  parameter Modelica.SIunits.Voltage V1 = KeyWordIO.readRealParameter(inputFile, "V1");
  parameter Modelica.SIunits.Voltage V2 = KeyWordIO.readRealParameter(inputFile, "V2");
  final parameter Real n12 = V1 / V2;
end ReadingParameters;

This example relies on the same library to read parameters from external files, as included in #3625.

Please run the attached example. It reads the data file "input.dat" from which the values V1 = 1000 and V2 = 100 are obtained. In this case the ratio n12 = V1/V2 is calculated correctly: n12 = 10

Now, in the data file change the second lint to V2 = 1000, make a right click on the result file in the Variable Browser and "re-simulate" (not re-compile). Then, the new parameters are read correctly, i.e., V1 = 1000 and V2 = 1000. However, the original parameter n12 = 10 remains unchanged, even though n12 should be equal to 1.

Attachments (3)

ReadingParameters.mo (419 bytes ) - added by Christian Kral <dr.christian.kral@…> 9 years ago.
Test example
KeyWordIO.mo (15.7 KB ) - added by Christian Kral <dr.christian.kral@…> 9 years ago.
Library to read parameters from external file
input.dat (19 bytes ) - added by Christian Kral <dr.christian.kral@…> 9 years ago.
Input data file containing parameter values V1 and V2

Download all attachments as: .zip

Change History (11)

by Christian Kral <dr.christian.kral@…>, 9 years ago

Attachment: ReadingParameters.mo added

Test example

by Christian Kral <dr.christian.kral@…>, 9 years ago

Attachment: KeyWordIO.mo added

Library to read parameters from external file

by Christian Kral <dr.christian.kral@…>, 9 years ago

Attachment: input.dat added

Input data file containing parameter values V1 and V2

comment:1 by Christian Kral <dr.christian.kral@…>, 9 years ago

Neither removing the attribute final of the parameter n12 nor adding annotation(Evaluate=true) change the model behavior.

comment:2 by Adeel Asghar, 9 years ago

Component: OMEditRun-time
Owner: changed from Adeel Asghar to wbraun, lochel
Status: newassigned

comment:3 by anonymous, 9 years ago

Owner: changed from wbraun, lochel to Willi Braun

comment:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:5 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:6 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:7 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:8 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

Note: See TracTickets for help on using tickets.