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

Variability of redeclared component changed

Variability of redeclared component changed

Hi,

my model (ModelReplacParamCont) contains two elements of type parameter record, one of them is replaceable. In my model tester, I change  the type of replaceable parameter, and perform an assignment between these two parameters.

When I call the translateModel in OMshell, I get the following error message:

------------------------------

translateModel(VerktorSizeNullPkg.RepacParam.ModelReplacParamContTester)
"There were errors during translation. Use getErrorString() to see them."
[C:/Users/erick/Desktop/TISC_OM_report/ProblemTester/vektorSizeNull/VerktorSizeNullPkg.mo:109:7-111:74:writable] Error: Component container.param2 of variability PARAM has binding container.param of higher variability VAR.
Error: Error occurred while flattening model VerktorSizeNullPkg.RepacParam.ModelReplacParamContTester

---------------------------------------

Should in this case the redeclared object keep the same variability (in ths case, parameter) ?

Here is my testcode:

package RepacParam "test for variability error in OMshell"
  record ModelReplacParamBasis
    constant Integer x;

  end ModelReplacParamBasis;

  record ModelReplacParam1
    extends VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis(final x=1);
  end ModelReplacParam1;

  record ModelReplacParam2
    extends VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis(final x=10);
  end ModelReplacParam2;

  model ModelReplacParamCont
    replaceable parameter VerktorSizeNullPkg.RepacParam.ModelReplacParam1
                                                               param
        constrainedby VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis;

    parameter VerktorSizeNullPkg.RepacParam.ModelReplacParamBasis param2 = param;

  end ModelReplacParamCont;

  model ModelReplacParamContTester
    VerktorSizeNullPkg.RepacParam.ModelReplacParamCont container(redeclare
        VerktorSizeNullPkg.RepacParam.ModelReplacParam2  param);           /*parameter*/

  end ModelReplacParamContTester;
end RepacParam;

--------------------------------------------

Thanks in advance,
Erick

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