- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » replaceable dialog
replaceable dialog
replaceable dialog
In version 1.17 and 1.18 a dialog box appears for replaceable model, in my case for m. Is it possible to change from M1 to M2 using this dialog : (Sorry but I could not upload an image)
package TestRedeclare
// model1
model M1
parameter Real p1 = 1 "p1";
Real y "y";
equation
y = p1 * time;
end M1;
// model2
model M2
parameter Real p2 = 1 "p2";
Real y "y";
equation
y = p2 * time + 23.145;
end M2;
// system
model SYS
parameter Real a = 10 "a";
parameter Real b = -2 "b";
Real z "z";
replaceable M1 m annotation(
choices(choice(redeclare M1 m(p1 = 10) "Default"), choice(redeclare M2 m(p2 = 20) "Variant")));
equation
z = a * m.y + b;
end SYS;
// Test
model Essai
//SYS sys1 (redeclare M1 m (p1 = 2)) ;
//SYS sys1 (redeclare M2 m (p2 = 4)) ;
SYS sys (redeclare M2 m (p2 = 3.254)) annotation(
Placement(visible = true, transformation(origin = {4, 6}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
end Essai;
end TestRedeclare;
Re: replaceable dialog
I think you are looking for something like this:
package ModelicaTest30
model M
end M;
// model1
model M1
extends M;
parameter Real p1 = 1 "p1";
Real y "y";
equation
y = p1 * time;
end M1;
// model2
model M2
extends M;
parameter Real p2 = 1 "p2";
Real y "y";
equation
y = p2 * time + 23.145;
end M2;
// system
model SYS
parameter Real a = 10 "a";
parameter Real b = -2 "b";
Real z "z";
replaceable M1 m constrainedby M annotation(
choices(choice(redeclare M1 m(p1 = 10) "Default"), choice(redeclare M2 m(p2 = 20) "Variant")));
equation
z = a * m.y + b;
end SYS;
// Test
model Essai
//SYS sys1 (redeclare M1 m (p1 = 2)) ;
//SYS sys1 (redeclare M2 m (p2 = 4)) ;
SYS sys (redeclare M2 m (p2 = 3.254)) annotation(
Placement(visible = true, transformation(origin = {4, 6}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
end Essai;
end ModelicaTest30;
You can choose between the compatible models, and parameters ,in SYS, but you can't edit graphically the parameters in m. You can specify them manually.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » replaceable dialog