Browse Source

power window scenario with obstacle and equations made by hand

Cláudio Gomes 7 years ago
parent
commit
b3b221e9a1

ModelicaModels/Echo.mo → ModelicaModels/BuggyModels/Echo.mo


+ 20 - 0
ModelicaModels/BuggyModels/Obstacle.mo

@@ -0,0 +1,20 @@
+model Obstacle
+  Modelica.Blocks.Interfaces.RealInput in_height annotation(Placement(visible = true, transformation(origin = {-100, 34}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
+  Modelica.Blocks.Math.Add add1(k1 = -1)  annotation(Placement(visible = true, transformation(origin = {-50, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Sources.RealExpression realExpression1(y = 0.4)  annotation(Placement(visible = true, transformation(origin = {-86, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Interfaces.RealOutput object_reaction annotation(Placement(visible = true, transformation(origin = {110, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 0)  annotation(Placement(visible = true, transformation(origin = {-18, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Logical.Switch switch1 annotation(Placement(visible = true, transformation(origin = {76, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Sources.RealExpression realExpression2(y = 0.0) annotation(Placement(visible = true, transformation(origin = {30, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Math.Gain gain1(k = -10e10)  annotation(Placement(visible = true, transformation(origin = {-2, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+equation
+  connect(switch1.u1, gain1.y) annotation(Line(points = {{64, 0}, {34, 0}, {34, 40}, {8, 40}, {8, 40}, {10, 40}}, color = {0, 0, 127}));
+  connect(realExpression2.y, switch1.u3) annotation(Line(points = {{42, -26}, {52, -26}, {52, -16}, {64, -16}, {64, -16}}, color = {0, 0, 127}));
+  connect(switch1.y, object_reaction) annotation(Line(points = {{87, -8}, {110, -8}}, color = {0, 0, 127}));
+  connect(greaterEqualThreshold1.y, switch1.u2) annotation(Line(points = {{-7, -8}, {64, -8}}, color = {255, 0, 255}));
+  connect(add1.y, gain1.u) annotation(Line(points = {{-38, 40}, {-14, 40}, {-14, 40}, {-14, 40}}, color = {0, 0, 127}));
+  connect(add1.y, greaterEqualThreshold1.u) annotation(Line(points = {{-38, 40}, {-36, 40}, {-36, -8}, {-30, -8}}, color = {0, 0, 127}));
+  connect(in_height, add1.u2) annotation(Line(points = {{-100, 34}, {-62, 34}}, color = {0, 0, 127}));
+  connect(realExpression1.y, add1.u1) annotation(Line(points = {{-74, 70}, {-68, 70}, {-68, 46}, {-62, 46}, {-62, 46}}, color = {0, 0, 127}));
+  annotation(uses(Modelica(version = "3.2.2")));
+end Obstacle;

ModelicaModels/PW_PowerSystem.mo → ModelicaModels/BuggyModels/PW_PowerSystem.mo


ModelicaModels/PW_PowerSystem_Test.mo → ModelicaModels/BuggyModels/PW_PowerSystem_Test.mo


ModelicaModels/PW_Window.mo → ModelicaModels/BuggyModels/PW_Window.mo


+ 12 - 0
ModelicaModels/NoObstacle_Test.mo

@@ -0,0 +1,12 @@
+model NoObstacle_Test
+  PowerSystem power;
+  Window window;
+equation
+  power.u = 1.0;
+  power.d = 0.0;
+  window.omega_input = power.omega;
+  window.theta_input = power.theta;
+  power.tau = - window.tau;
+  annotation(
+    experiment(StartTime = 0, StopTime = 2, Tolerance = 1e-07, Interval = 0.002));
+end NoObstacle_Test;

+ 9 - 17
ModelicaModels/Obstacle.mo

@@ -1,20 +1,12 @@
 model Obstacle
-  Modelica.Blocks.Interfaces.RealInput in_height annotation(Placement(visible = true, transformation(origin = {-100, 34}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
-  Modelica.Blocks.Math.Add add1(k1 = -1)  annotation(Placement(visible = true, transformation(origin = {-50, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Sources.RealExpression realExpression1(y = 0.4)  annotation(Placement(visible = true, transformation(origin = {-86, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Interfaces.RealOutput object_reaction annotation(Placement(visible = true, transformation(origin = {110, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 0)  annotation(Placement(visible = true, transformation(origin = {-18, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Logical.Switch switch1 annotation(Placement(visible = true, transformation(origin = {76, -8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Sources.RealExpression realExpression2(y = 0.0) annotation(Placement(visible = true, transformation(origin = {30, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-  Modelica.Blocks.Math.Gain gain1(k = -10e10)  annotation(Placement(visible = true, transformation(origin = {-2, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  parameter Real c = 1e5;
+  parameter Real fixed_x = 0.45;
+  input Real x;
+  input Real v;
+  output Real F;
 equation
-  connect(switch1.u1, gain1.y) annotation(Line(points = {{64, 0}, {34, 0}, {34, 40}, {8, 40}, {8, 40}, {10, 40}}, color = {0, 0, 127}));
-  connect(realExpression2.y, switch1.u3) annotation(Line(points = {{42, -26}, {52, -26}, {52, -16}, {64, -16}, {64, -16}}, color = {0, 0, 127}));
-  connect(switch1.y, object_reaction) annotation(Line(points = {{87, -8}, {110, -8}}, color = {0, 0, 127}));
-  connect(greaterEqualThreshold1.y, switch1.u2) annotation(Line(points = {{-7, -8}, {64, -8}}, color = {255, 0, 255}));
-  connect(add1.y, gain1.u) annotation(Line(points = {{-38, 40}, {-14, 40}, {-14, 40}, {-14, 40}}, color = {0, 0, 127}));
-  connect(add1.y, greaterEqualThreshold1.u) annotation(Line(points = {{-38, 40}, {-36, 40}, {-36, -8}, {-30, -8}}, color = {0, 0, 127}));
-  connect(in_height, add1.u2) annotation(Line(points = {{-100, 34}, {-62, 34}}, color = {0, 0, 127}));
-  connect(realExpression1.y, add1.u1) annotation(Line(points = {{-74, 70}, {-68, 70}, {-68, 46}, {-62, 46}, {-62, 46}}, color = {0, 0, 127}));
-  annotation(uses(Modelica(version = "3.2.2")));
+  F = if x > fixed_x then c*(x - fixed_x) else 0;
+annotation(
+  experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)
+);
 end Obstacle;

+ 25 - 0
ModelicaModels/PowerSystem.mo

@@ -0,0 +1,25 @@
+model PowerSystem
+  parameter Real J = 0.085;
+  parameter Real b = 5;
+  parameter Real K = 1.8;
+  parameter Real R = 0.15;
+  parameter Real L = 0.036;
+  parameter Real V_abs = 12;
+  Real V;
+  output Real theta;
+  output Real i;
+  output Real omega;
+  input Real tau;
+  input Real u;
+  input Real d;
+equation
+  V = if u > 0.5 then V_abs 
+      else if d > 0.5 then - V_abs
+      else 0.0;
+  J * der(omega) = K * i + tau - b * omega;
+  L * der(i) = V - R * i - K * omega;
+  der(theta) = omega;
+annotation(
+  experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)
+);
+end PowerSystem;

+ 8 - 6
ModelicaModels/PowerSystemStandAlone.mo

@@ -5,16 +5,18 @@ model PowerSystemStandAlone
   parameter Real R = 1;
   parameter Real L = 0.5;
   parameter Real V = 12;
-  Real thetha;
+  Real theta;
   Real e;
   Real i;
   Real T;
-  Real dthetha;
-  input Real tau;
+  Real omega;
 equation
   T = K * i;
-  e = K * der(thetha);
-  J * der(dthetha) + b * der(thetha) = T;
+  e = K * omega;
+  J * der(omega) + b * omega = T;
   L * der(i) + R * i = V - e;
-  der(thetha) = dthetha;
+  der(theta) = omega;
+annotation(
+  experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)
+);
 end PowerSystemStandAlone;

+ 7 - 0
ModelicaModels/PowerSystem_Test.mo

@@ -0,0 +1,7 @@
+model PowerSystem_Test
+  PowerSystem power();
+equation
+  power.tau = 0.0;
+  power.u = if time < 0.5 then 0.0 else 1.0;
+  power.d = 0.0;
+end PowerSystem_Test;

+ 15 - 0
ModelicaModels/UncontrolledScenario.mo

@@ -0,0 +1,15 @@
+model UncontrolledScenario
+  PowerSystem power();
+  Window window();
+  Obstacle obstacle();
+equation
+  power.u = 1.0;
+  power.d = 0.0;
+  window.omega_input = power.omega;
+  window.theta_input = power.theta;
+  power.tau = -(window.tau + obstacle.F*window.r);
+  obstacle.x = window.x;
+  obstacle.v = window.v;
+  annotation(
+    experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.004));
+end UncontrolledScenario;

+ 25 - 0
ModelicaModels/Window.mo

@@ -0,0 +1,25 @@
+model Window
+  parameter Real J = 0.08;
+  parameter Real r = 0.017;
+  parameter Real b = 150;
+  parameter Real c = 1e5;
+  input Real omega_input;
+  input Real theta_input;
+  output Real tau;
+  output Real x;
+  output Real v;
+  output Real omega;
+  output Real theta;
+  output Real friction;
+equation
+  der(theta) = omega;
+  tau = c * (theta_input - theta) - friction;
+  //tau = c * (theta - theta_input);
+  der(omega) = tau/J;
+  x = r * theta;
+  v = r * omega;
+  friction = b*v;
+annotation(
+  experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002)
+);
+end Window;