Ticket #5581: fbSystemTest.mo

File fbSystemTest.mo, 7.1 KB (added by massimo ceraolo, 5 years ago)
Line 
1package fbSystemTest
2 model fbSystem
3 Modelica.Blocks.Continuous.PI PI(T = 1) annotation(
4 Placement(visible = true, transformation(origin = {-20, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
5 Modelica.Mechanics.Rotational.Components.Inertia inertia1(J = 0.1) annotation(
6 Placement(visible = true, transformation(origin = {46, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
7 Modelica.Mechanics.Rotational.Sources.Torque torque1 annotation(
8 Placement(visible = true, transformation(origin = {14, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
9 Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor1 annotation(
10 Placement(visible = true, transformation(origin = {74, -16}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
11 Modelica.Blocks.Math.Feedback feedback1 annotation(
12 Placement(visible = true, transformation(origin = {-52, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
13 Modelica.Blocks.Sources.Constant const(k = 1) annotation(
14 Placement(visible = true, transformation(origin = {-82, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
15 equation
16 connect(inertia1.flange_b, speedSensor1.flange) annotation(
17 Line(points = {{56, 0}, {74, 0}, {74, -6}}));
18 connect(feedback1.u2, speedSensor1.w) annotation(
19 Line(points = {{-52, -8}, {-52, -36}, {74, -36}, {74, -27}}, color = {0, 0, 127}));
20 connect(feedback1.y, PI.u) annotation(
21 Line(points = {{-42, 0}, {-34, 0}, {-34, 0}, {-32, 0}}, color = {0, 0, 127}));
22 connect(PI.y, torque1.tau) annotation(
23 Line(points = {{-8, 0}, {0, 0}, {0, 0}, {2, 0}}, color = {0, 0, 127}));
24 connect(inertia1.flange_a, torque1.flange) annotation(
25 Line(points = {{36, 0}, {24, 0}, {24, 0}, {24, 0}, {24, 0}}));
26 connect(const.y, feedback1.u1) annotation(
27 Line(points = {{-70, 0}, {-62, 0}, {-62, 0}, {-60, 0}}, color = {0, 0, 127}));
28 annotation(
29 uses(Modelica(version = "3.2.2")),
30 Diagram(coordinateSystem(extent = {{-100, -60}, {100, 60}}, initialScale = 0.1), graphics = {Rectangle(origin = {26, -11}, lineColor = {255, 0, 0}, pattern = LinePattern.Dash, extent = {{-64, 33}, {64, -33}})}),
31 Icon(coordinateSystem(extent = {{-100, -60}, {100, 60}})),
32 version = "",
33 __OpenModelica_commandLineOptions = "");
34 end fbSystem;
35
36 model fbSubSysDX
37 Modelica.Blocks.Continuous.PI PI(T = 1) annotation(
38 Placement(visible = true, transformation(origin = {-42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
39 Modelica.Mechanics.Rotational.Components.Inertia inertia1(J = 0.1) annotation(
40 Placement(visible = true, transformation(origin = {28, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
41 Modelica.Mechanics.Rotational.Sources.Torque torque1 annotation(
42 Placement(visible = true, transformation(origin = {-6, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
43 Modelica.Blocks.Interfaces.RealInput PIu annotation(
44 Placement(visible = true, transformation(origin = {-92, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-92, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
45 Modelica.Blocks.Interfaces.RealOutput w annotation(
46 Placement(visible = true, transformation(origin = {94, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {94, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
47 Modelica.Mechanics.Rotational.Sensors.SpeedSensor wSens annotation(
48 Placement(visible = true, transformation(origin = {60, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
49 equation
50 connect(wSens.w, w) annotation(
51 Line(points = {{72, 0}, {86, 0}, {86, 0}, {94, 0}}, color = {0, 0, 127}));
52 connect(inertia1.flange_b, wSens.flange) annotation(
53 Line(points = {{38, 0}, {50, 0}, {50, 0}, {50, 0}}));
54 connect(inertia1.flange_a, torque1.flange) annotation(
55 Line(points = {{18, 0}, {4, 0}}));
56 connect(PI.y, torque1.tau) annotation(
57 Line(points = {{-31, 0}, {-18, 0}}, color = {0, 0, 127}));
58 connect(PI.u, PIu) annotation(
59 Line(points = {{-54, 0}, {-92, 0}}, color = {0, 0, 127}));
60 annotation(
61 uses(Modelica(version = "3.2.2")),
62 Diagram(coordinateSystem(extent = {{-100, -60}, {100, 60}})),
63 Icon(coordinateSystem(extent = {{-100, -60}, {100, 60}})),
64 version = "",
65 __OpenModelica_commandLineOptions = "");
66 end fbSubSysDX;
67
68 model fbSystemFMU
69 Modelica.Blocks.Math.Feedback feedback1 annotation(
70 Placement(visible = true, transformation(origin = {-8, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
71 Modelica.Blocks.Sources.Constant const(k = 1) annotation(
72 Placement(visible = true, transformation(origin = {-36, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
73 fbSystemPkg_fbSubSysDX_me_FMU fmu annotation(
74 Placement(visible = true, transformation(origin = {26, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
75 equation
76 connect(fmu.w, feedback1.u2) annotation(
77 Line(points = {{37, 9}, {45, 9}, {45, -17}, {-9, -17}, {-9, -1}}, color = {0, 0, 127}));
78 connect(fmu.PIu, feedback1.y) annotation(
79 Line(points = {{15, 9}, {9, 9}, {9, 7}, {3, 7}}, color = {0, 0, 127}));
80 connect(const.y, feedback1.u1) annotation(
81 Line(points = {{-25, 8}, {-16, 8}}, color = {0, 0, 127}));
82 annotation(
83 uses(Modelica(version = "3.2.2")),
84 Diagram(coordinateSystem(extent = {{-80, -40}, {80, 40}})),
85 Icon(coordinateSystem(extent = {{-100, -60}, {100, 60}})),
86 version = "",
87 __OpenModelica_commandLineOptions = "");
88 end fbSystemFMU;
89 annotation(
90 Diagram(coordinateSystem(extent = {{-100, -80}, {100, 80}})),
91 uses(Modelica(version = "3.2.3")),
92 Documentation(info = "<html><head></head><body><font size=\"5\">Questo package mostra un semplice utilizzo di fmu e integrazione in modelica.&nbsp;</font><div><font size=\"5\">La parte inserita nell'fmu è il nodo sommatore, un'inerzia e un sensore di velocità.</font></div><div><br></div><div><font size=\"5\">I files nella radice del package mostrano come questa parte può essere sostituita con la fmu e i risultati vengono identici.</font></div><div><font size=\"5\">Essa però mostra come non risulti possibile fissare il valore iniziale della velocità angolare dell'inerzia. Una semplice analisi ha mostrato che in effetti le condizioni inziali dell'inerzia vengono gestiti in maniera molto più sofisticata che nel caso del PI, facendo uso anche si una record StateSelect.&nbsp;</font></div><div><font size=\"5\">Pertanto nella cartella\"myInertia\" è stata realizata una versione differente dell'inerzia, che non fa uso di stateSelect e gestisce i valori iniziali in maniera simile al PI. Con questa modifica col modello fbSystemFMUmi si riescono a modificare tutti i valori iniziali, inclusi quelli dell'inerzia. &nbsp;</font></div><div><font size=\"5\"><br></font></div><div><font size=\"5\">Notare che l'importazine di FMU in OMEdit si può fare solo con le model exchange; per la co-simulation occorre ricorrere a OMSimulator.</font></div></body></html>"));
93end fbSystemTest;