- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Set structural parameters at translation
Page Start Prev 1 Next End
Set structural parameters at translation
Set structural parameters at translation
Dec-19-19 11:39:33
Hello,
is it possible to set structural parameters (via mos-script) at translation time?
Something in the lines of:
Code:
buildModel(Simple.Model(param1=7));
buildModel(Simple.Model(param1=9));
would be of great use. I couldn't find any information on that, but maybe I'm missing something
I'm grateful for any tips or hints!
Robert
Re: Set structural parameters at translation
Dec-19-19 22:04:00
You can use setParameterValue or setComponentModifierValue to change the parameter in a model before building. See an example below.
Code:
loadString("
model M
parameter Real a = 1;
parameter Real x[2,2];
parameter Real y[2,2];
end M;"); getErrorString();
list(M); getErrorString();
// use setParameterValue
setParameterValue(M, x, fill(a, 2, 2)); getErrorString();
list(M); getErrorString();
// use setComponentModifierValue
setComponentModifierValue(M, y, $Code(= fill(a, size(x, 1), size(x, 2)))); getErrorString();
list(M); getErrorString();
setComponentModifierValue(M, y.start, $Code(= fill(a, size(x, 1), size(x, 2)))); getErrorString();
list(M); getErrorString();
instantiateModel(M); getErrorString();
- adrpo
- 885 Posts
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Set structural parameters at translation
There are 0 guests and 0 other users also viewing this topic