Imagine the following case. I have a set of different partial base components. Then I have a model library with different model for the components extending from the base classes. Now I built up a partial model from the base classes and set some modifications to parameters. As the next step I want to extend the complex model with a lot of base components. Then I will change each base class to an extended class of the base class. But while changing the class the modification is lost. Hence, my question, is there any way to keep the modification?
I prepared a short example. For Dymola users I attached it as a library, too.
In the TestBaseModel I set one modification and in the TestCase1 the modification is lost...
regards
Carsten
QUELLTEXT
package TestExtends
partial model BaseModel "base class of a component"
parameter Real const = 1 "parameter, which later should be modified";
extends Modelica.Blocks.Interfaces.SISO;
equation
end BaseModel;
model ModelOpt0 "component model based on BaseModel"
extends BaseModel;
equation
y=u;
end ModelOpt0;
model ModelOpt1 "component model based on BaseModel"
extends BaseModel;
equation
y=u*const;
end ModelOpt1;
model ModelOpt2 "component model based on BaseModel"
extends BaseModel;
equation
y = u + const;
end ModelOpt2;
partial model TestBaseModel
"partial complex model based on partial component models"
replaceable BaseModel baseModel(const=const.k) extends BaseModel
"Component base model, which have to be replaced, but the parameter modification should be adhered"
Modelica.Blocks.Sources.Constant const(k=2);
Modelica.Blocks.Sources.Sine sine;
equation
connect(sine.y, baseModel.u);
end TestBaseModel;
model TestCase1
"test case one, based on the base clase of the complex model, including changes in the components"
extends TestBaseModel(redeclare ModelOpt1 baseModel);
// "baseModel" is changed to an extended model, but the parameter modification is lost"
end TestCase1;
end TestExtends;
partial model BaseModel "base class of a component"
parameter Real const = 1 "parameter, which later should be modified";
extends Modelica.Blocks.Interfaces.SISO;
equation
end BaseModel;
model ModelOpt0 "component model based on BaseModel"
extends BaseModel;
equation
y=u;
end ModelOpt0;
model ModelOpt1 "component model based on BaseModel"
extends BaseModel;
equation
y=u*const;
end ModelOpt1;
model ModelOpt2 "component model based on BaseModel"
extends BaseModel;
equation
y = u + const;
end ModelOpt2;
partial model TestBaseModel
"partial complex model based on partial component models"
replaceable BaseModel baseModel(const=const.k) extends BaseModel
"Component base model, which have to be replaced, but the parameter modification should be adhered"
Modelica.Blocks.Sources.Constant const(k=2);
Modelica.Blocks.Sources.Sine sine;
equation
connect(sine.y, baseModel.u);
end TestBaseModel;
model TestCase1
"test case one, based on the base clase of the complex model, including changes in the components"
extends TestBaseModel(redeclare ModelOpt1 baseModel);
// "baseModel" is changed to an extended model, but the parameter modification is lost"
end TestCase1;
end TestExtends;