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

parameter unable to change through _ini.xml

parameter unable to change through _ini.xml

Hi,

my intention is to change a parameter of a component through the _init.xml:

The model is declared as:

Code:


model ModelA
  ...
  parameter Types.ActivePower PRefConst = 0
  ...
  Types.ActivePower PRef(nominal = SNom) =  PRefConst
   ...
end ModelA;

During the instantiation of ModelA, the PRefConst is assigned to a value:

Code:


  model_a ModelA(..., PRefConst = 14.9e6, ...);

In the compiled C code, it can be noticed that the PRefConst's value is assigned hard-coded:

Code:



/*
equation index: 6068
type: SIMPLE_ASSIGN
model_a .PRefConst = 14900000.0
*/
void modelName_eqFunction_6068(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,6068};
  data->simulationInfo->realParameter[1565] /* model_a .PRefConst PARAM */ = 14900000.0;
  TRACE_POP
}

/*
equation index: 6067
type: SIMPLE_ASSIGN
model_a .PRef = model_a .PRefConst
*/
void modelName_eqFunction_6067(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,6067};
  data->simulationInfo->realParameter[1564] /* model_a .PRef PARAM */ = data->simulationInfo->realParameter[1565] /* model_a .PRefConst PARAM */;
  TRACE_POP
}



So that in the end even I chang the value of PRefConst in the _init.xml file, the value of PRef is still 14900000.0, because it is already assigned by the original PRefConst's value in the C code. How can I avoid this? Maybe through some options in preOptModules or postOptModules
My current preOptModules is set to

Code:


setPreOptModules("normalInlineFunction,expandDerOperator,clockPartitioning,findStateOrder,inlineArrayEqn,encapsulateWhenConditions")

Edited by: jz95 - Nov-10-20 12:17:37
There are 0 guests and 0 other users also viewing this topic
You are here: