Search code examples
modelicaopenmodelica

Fixed value for a parameter in modelica


I have a parameter z for which I need the value to be 1, always.

model test
Real parameter z = 1;
end test;

When I drag and drop this model and double click on it, the parameters tab opens and I can change the value. How can i prevent that from happening?


Solution

  • Make the parameter final or protected. Final means you cannot modify it (and you can set the final modifier in a modification, like M m(final z=2) when instantiating a component). OpenModelica will also evaluate final parameters by default in order to produce a more efficient simulation (making them almost the same as constants).

    Protected also means it cannot be modified (and in many tools will not be part of the result-file either).