Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

change initial start Values from file

change initial start Values from file

Hi,

I am trying to set my initial start values using a .txt or .mos-file because it is a big model with many variables. I found this threat https://www.openmodelica.org/index.php/ … pic?id=715 where they seem to have found a solution but the way they do it won't work.

I was using OMShell and these functions

buildModel(WasteWater.ASM1.Examples.SmallPlant);
setInitXmlStartValue("WasteWater.ASM1.Examples.SmallPlant_init.xml", InitialComponents, InitialValues, "WasteWater.ASM1.Examples.SmallPlant_init.xml");
system("WasteWater.ASM1.Examples.ComplexPlant.exe");

Instead of InitialComponents and Initial Values i also tried to use specific variables and instead of system() i also tried simulate().
I also tried

buildModel(WasteWater.ASM1.Examples.SmallPlant);
system("WasteWater.ASM1.Examples.SmallPlant.exe -overrideFile small_asm1.txt");

But I always geht the same message: "Warning: Assuming fixed start value for the following 54 variables"


I had a look into the file_init.xml file and noticed something for each variable that said "useStart = false" so i was wondering if that is causing the problem since for the fixed variables it says "useStart = true".

Maybe something else is wrong. I hope you can help.
Regards

Pliskin

Re: change initial start Values from file

Only start-values of fixed variables are actually used. If you want to set a particular start-value, you need to set fixed=true.
The overrides only change given start-values. They cannot change the warning you get since this is a warning from buildModel, which will not consider values you try to set later on. At simulation-time, the start-values to use have been chosen - you can change the values but not which variables are used for the initial system.

Consider for example:

Code:

model M

  Real x(start=3.0),y(start=4.0);
equation
  x = y;
  der(x) = 1.0;
end M;

It gives the following output:

Code:

$ ./M -output x,y -override stopTime=0

time=0,x=4,y=4
$ ./M -output x,y -override stopTime=0,x=5
time=0,x=5,y=5
$ ./M -output x,y -override stopTime=0,y=7
time=0,x=4,y=4

And the following warnings:

Code:

Warning: Alias set with several free start values

* candidate: x(start = 3.0)
* candidate: y(start = 4.0)
=> select value from y(start = 4.0)
   because its component reference (or its binding component reference) is closer to the top level scope with depth: 1.
   If we have equal component reference depth for several components choose the one with non zero binding.
Warning: Assuming fixed start value for the following 1 variables:
         x:VARIABLE(start = 4.0 ) .M, .Real type: Real

Re: change initial start Values from file

So you are saying the 54 variables which have the startvalue 0.0 while building the model need to be set and no other variables?! -That is what i was trying.

"If you want to set a particular start-value, you need to set fixed=true. "
So if I set all the 54 variables in my model to fixed = true I can change them using the setInitStartXml oder override function? But doesn't that make them to constants?

Thanks already for your fast reply!

Re: change initial start Values from file

Setting the override only sets their start-values; it does not make them into constants.

Re: change initial start Values from file

Yes I know that override does not make them constants. Thanks I will try it!

Re: change initial start Values from file

Could you tell me what useStart="false" means? I changed the variables to fixed=true but it still seems not to be working. Maybe I am missing something out here.

Here is an Example of a variable from the  Model_init.xml file:
<ScalarVariable
  name = "Settler.hs"
  valueReference = "1001"
  description = "height of sludge layer"
  variability = "continuous" isDiscrete = "false"
  causality = "internal" isValueChangeable = "true"
  alias = "noAlias"
  classIndex = "1" classType = "rSta"
  isProtected = "false"
  fileName = "C:\OpenModelica1.9.1Nightly\lib\omlibrary\WasteWater.mo" startLine = "1671" startColumn = "11" endLine = "1671" endColumn = "48" fileWritable = "true">
  <Real useStart="false" fixed="false" useNominal="false" unit="m" displayUnit="m" />
  </ScalarVariable>
  alias = "noAlias"
  classIndex = "52" classType = "rDer"
  isProtected = "false"
  fileName = "C:\OpenModelica1.9.1Nightly\lib\omlibrary\WasteWater.mo" startLine = "783" startColumn = "9" endLine = "783" endColumn = "82" fileWritable = "true">
  <Real useStart="false" fixed="true" useNominal="false" min="0.0" unit="mg/l" displayUnit="mg/l" />


And is there a way to see if "system("WasteWater.ASM1.Examples.SmallPlant.exe -overrideFile small_asm1.txt");" is working proberly because I don't get any message at all after using it.

Edited by: Pliskin - Mar-04-14 18:35:56
There are 0 guests and 0 other users also viewing this topic
You are here: