- Index
- » Programming
- » Modelica Language
- » Parameter strings in initial algorithm
Parameter strings in initial algorithm
Parameter strings in initial algorithm
Hey everyone, new modelica user here.
I've been trying to initialise a String parameter within an initial algorithm section, for example:
Code:
model Fail
parameter String x(fixed=false);
initial algorithm
x := "please work";
end Fail;
But it won't simulate. I get errors:
Code:
"Simulation execution failed for model: Fail
LOG_INIT | error | The initialization problem is inconsistent due to the following equation: 0 != 1 = not x == $TMP_x_1
stdout | warning | Error in initialization. Storing results and exiting.
| | | | Use -lv=LOG_INIT -w for more information.
"
and
Code:
Warning: Parameter x has no value, and is fixed during initialization (fixed=true), using available start value (start="") as default value.
Warning: The initial conditions are over specified. Use +d=initialization for more information.
It is as if 'fixed' gets forced to true for some reason. However if I instead try the same thing with a Real it works:
Code:
model Pass
parameter Real x(fixed=false);
initial algorithm
x := 10;
end Pass;
Does anyone know why this is the case? I would like to do this because I would like to conditionally set the string parameter. If anyone has an alternative approach that would be welcome also.
Thanks
Re: Parameter strings in initial algorithm
That is because there is no fixed attribute for string type. See section 4.8.4 in Modelica specification:
Code:
4.8.4 String Type
The following is the predefined String type:
type String // Note: Defined with Modelica syntax although predefined
StringType value; // Accessed without dot-notation
parameter StringType quantity = "";
parameter StringType start = ""; // Initial value
end String;
- lochel
- 45 Posts
Re: Parameter strings in initial algorithm
I think your model shouldn’t have passed the front end. So we should probably add a ticket about it anyway.
- lochel
- 45 Posts
- Index
- » Programming
- » Modelica Language
- » Parameter strings in initial algorithm