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

Component X of var. parameter has binding X2 of higher var. continuous

Component X of var. parameter has binding X2 of higher var. continuous

I have `YY` as Realinput. How can I solve the below error? I only need YY at the initial?

parameter Real X1 = 200
final parameter Real R_ic = YY * 1 / X1;
Modelica.Blocks.Interfaces.RealInput YY
Modelica.Blocks.Continuous.FirstOrder firstOrder(T = 5, k = 1, y_start = R_ic)

Translation Error
Component R_ic of variability parameter has binding 'YY* 1 / X1' of higher variability continuous.


//Translation Error
//Component y_start of variability parameter has binding 'R_ic[<firstOrder, firstOrder>]' of higher variability continuous.


Edited by: Amro - Jan-14-22 19:41:14

Re: Component X of var. parameter has binding X2 of higher var. continuous

A final parameter can't be modified. Because `RealInput YY` is of higher variability (it is allowed to change at simulation time) the value of `R_ic` would need to change if `YY` would change and that contradicts the final keyword.

Make `Component R_ic` and `YY` parameters and let the compiler handle it. You can still change the parameter `YY` from outside.
If variable `YY` is only needed at initialication the compiler will figure that out,use it only at the initialization system and remove it from the simulation system.

Code:


  parameter Real X1 = 200;
  parameter Real R_ic = YY * 1 / X1;
  parameter Real YY;
  Modelica.Blocks.Continuous.FirstOrder firstOrder(T = 5, k = 1, y_start = R_ic);

Edited by: AnHeuermann - Jan-17-22 09:20:49

Re: Component X of var. parameter has binding X2 of higher var. continuous


Make `Component R_ic` and `YY` parameters and let the compiler handle it. You can still change the parameter `YY` from outside.

Code:


  parameter Real X1 = 200;
  parameter Real R_ic = YY * 1 / X1;
  parameter Real YY;
  Modelica.Blocks.Continuous.FirstOrder firstOrder(T = 5, k = 1, y_start = R_ic);

Thank you!
How can I still change the parameter `YY` from outside as it is no longer input? I am setting `YY` an input because my model here will be as a black box, in which `YY` will be connected to a previous block in the Diagram view. Eventually, I want to use this black block as FMU in another simulation tool.

Edited by: Amro - Jan-17-22 22:13:13

Re: Component X of var. parameter has binding X2 of higher var. continuous

If you use a "normal" FMU you can change parameters with some fmi2SetXXX function. I'm not sure what is changeable in a black-box fmu, I guess basically nothing besides inputs.

I think it is possible for parameters to be inputs as well. At least OpenModelica doesn't issue a warning about it.

Maybe that works for you:

Code:


  parameter Real X1 = 200;
  parameter input Real R_ic = YY * 1 / X1;
  parameter Real YY;
  Modelica.Blocks.Continuous.FirstOrder firstOrder(T = 5, k = 1, y_start = R_ic);

There are 0 guests and 0 other users also viewing this topic
You are here: