Commit 888d1626 authored by Pierre Haessig's avatar Pierre Haessig

Add comments in models

parent 891fcdf3
within CarProject; within CarProject;
model Air model Air "Air moving a constant speed + sinus perturbation"
parameter Velocity v(displayUnit="km/h") "reverse wind speed"; parameter Velocity v(displayUnit="km/h") "reverse wind speed";
parameter Velocity v_pert(displayUnit="km/h") "wind speed periodic perturbation"; parameter Velocity v_pert(displayUnit="km/h") "wind speed periodic perturbation";
Force f "total aerdynamic drag force"; Force f "total aerdynamic drag force";
......
within CarProject; within CarProject;
model Car model Car "Car with a speed control"
Position s "car position"; Position s "car position";
Velocity v(displayUnit = "km/h") "car velocity"; Velocity v(displayUnit = "km/h") "car velocity";
parameter Modelica.SIunits.Mass m_car=1e3 "car mass"; parameter Modelica.SIunits.Mass m_car=1e3 "car mass";
...@@ -11,7 +11,7 @@ model Car ...@@ -11,7 +11,7 @@ model Car
Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
CarProject.Components.Controller controller1 "contrôleur de vitesse" annotation( CarProject.Components.Controller controller1 "contrôleur de vitesse" annotation(
Placement(visible = true, transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
CarProject.Components.Engine engine1 annotation( CarProject.Components.Engine engine annotation(
Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.Translational.Sensors.SpeedSensor speedSensor1 annotation( Modelica.Mechanics.Translational.Sensors.SpeedSensor speedSensor1 annotation(
Placement(visible = true, transformation(origin = {30, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {30, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
...@@ -32,16 +32,16 @@ equation ...@@ -32,16 +32,16 @@ equation
Line(points = {{20, 0}, {20, -30}}, color = {0, 127, 0})); Line(points = {{20, 0}, {20, -30}}, color = {0, 127, 0}));
connect(speedSensor1.v, controller1.v) annotation( connect(speedSensor1.v, controller1.v) annotation(
Line(points = {{41, -30}, {74, -30}, {74, -50}, {-72, -50}, {-72, -4}, {-62, -4}}, color = {0, 0, 127})); Line(points = {{41, -30}, {74, -30}, {74, -50}, {-72, -50}, {-72, -4}, {-62, -4}}, color = {0, 0, 127}));
connect(engine1.flange_b, mass1.flange_a) annotation( connect(engine.flange_b, mass1.flange_a) annotation(
Line(points = {{0, 0}, {20, 0}}, color = {0, 127, 0})); Line(points = {{0, 0}, {20, 0}}, color = {0, 127, 0}));
connect(engine1.flange_a, flange_road) annotation( connect(engine.flange_a, flange_road) annotation(
Line(points = {{-10, -10}, {-10, -30}}, color = {0, 127, 0})); Line(points = {{-10, -10}, {-10, -30}}, color = {0, 127, 0}));
connect(controller1.f, engine1.f) annotation( connect(controller1.f, engine.f) annotation(
Line(points = {{-38, 0}, {-22, 0}}, color = {0, 0, 127})); Line(points = {{-38, 0}, {-22, 0}}, color = {0, 0, 127}));
/*define car position*/ /*define car position*/
s = mass1.s; s = mass1.s;
v = mass1.v; v = mass1.v;
annotation( annotation(
Icon(graphics = {Polygon(fillColor = {239, 41, 41}, fillPattern = FillPattern.Solid, points = {{-100, -60}, {100, -60}, {100, 0}, {40, 60}, {-80, 60}, {-100, 0}, {-100, -60}}), Ellipse(origin = {-50, -70}, fillColor = {136, 138, 133}, fillPattern = FillPattern.Solid, extent = {{-30, -30}, {30, 30}}, endAngle = 360), Ellipse(origin = {50, -70}, fillColor = {136, 138, 133}, fillPattern = FillPattern.Solid, extent = {{-30, -30}, {30, 30}}, endAngle = 360), Text(origin = {0, 120}, extent = {{-100, 20}, {100, -20}}, textString = "%name"), Text(origin = {-3, -9}, extent = {{-97, 29}, {103, -31}}, textString = "m=%m_car"), Line(origin = {60, 70}, points = {{20, 0}, {-20, 0}}, color = {79, 138, 226}, thickness = 1, arrow = {Arrow.None, Arrow.Open})}, coordinateSystem(initialScale = 0.1)), Icon(graphics = {Polygon(fillColor = {239, 41, 41}, fillPattern = FillPattern.Solid, points = {{-100, -60}, {100, -60}, {100, 0}, {40, 60}, {-80, 60}, {-100, 0}, {-100, -60}}), Ellipse(origin = {-50, -70}, fillColor = {136, 138, 133}, fillPattern = FillPattern.Solid, extent = {{-30, -30}, {30, 30}}, endAngle = 360), Ellipse(origin = {50, -70}, fillColor = {136, 138, 133}, fillPattern = FillPattern.Solid, extent = {{-30, -30}, {30, 30}}, endAngle = 360), Text(origin = {0, 80}, lineColor = {0, 67, 168}, fillColor = {0, 67, 168}, extent = {{-100, 20}, {40, -20}}, textString = "%name"), Text(origin = {-3, -9}, extent = {{-97, 29}, {103, -31}}, textString = "m=%m_car"), Line(origin = {60, 70}, points = {{20, 0}, {-20, 0}}, color = {79, 138, 226}, thickness = 1, arrow = {Arrow.None, Arrow.Open})}, coordinateSystem(initialScale = 0.1)),
Diagram(graphics = {Text(origin = {51, 53}, extent = {{-33, 5}, {33, -5}}, textString = "frottement de l'air")})); Diagram(graphics = {Text(origin = {51, 53}, extent = {{-33, 5}, {33, -5}}, textString = "frottement de l'air")}));
end Car; end Car;
\ No newline at end of file
within CarProject; within CarProject;
model CarTest model CarTest "Demo for the Car"
extends Modelica.Icons.Example; extends Modelica.Icons.Example;
CarProject.Car car1(m_car = 1e3, v_sp = 27.7778) annotation( CarProject.Car car(m_car = 1e3, v_sp = 27.7778) annotation(
Placement(visible = true, transformation(origin = {0, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); Placement(visible = true, transformation(origin = {0, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
CarProject.Air air1(v = 11.1111, v_pert = 5.55556) annotation( CarProject.Air air1(v = 11.1111, v_pert = 5.55556) annotation(
Placement(visible = true, transformation(origin = {70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
CarProject.Road road1 annotation( CarProject.Road road1 annotation(
Placement(visible = true, transformation(origin = {10, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {10, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation equation
connect(air1.flange_b, car1.flange_air) annotation( connect(air1.flange_b, car.flange_air) annotation(
Line(points = {{60, 10}, {18, 10}, {18, 14}, {18, 14}}, color = {0, 127, 0})); Line(points = {{60, 10}, {18, 10}, {18, 14}, {18, 14}}, color = {0, 127, 0}));
connect(air1.flange_a, road1.flange) annotation( connect(air1.flange_a, road1.flange) annotation(
Line(points = {{70, 0}, {70, -49}, {10, -49}}, color = {0, 127, 0})); Line(points = {{70, 0}, {70, -49}, {10, -49}}, color = {0, 127, 0}));
connect(car1.flange_road, road1.flange) annotation( connect(car.flange_road, road1.flange) annotation(
Line(points = {{10, -20}, {10, -49}}, color = {0, 127, 0})); Line(points = {{10, -20}, {10, -49}}, color = {0, 127, 0}));
annotation( annotation(
experiment(StopTime=180), experiment(StopTime=180),
Diagram(graphics = {Text(origin = {0, 80}, extent = {{-100, 20}, {100, -20}}, textString = "Car test on the road")})); Diagram(graphics = {Text(origin = {0, 80}, extent = {{-100, 20}, {100, -20}}, textString = "Car test on the road"), Text(origin = {1, -81}, extent = {{-99, 15}, {99, -15}}, textString = "observe car.v and car.v_sp", textStyle = {TextStyle.Italic})}, coordinateSystem(initialScale = 0.1)));
end CarTest; end CarTest;
\ No newline at end of file
within CarProject.Components; within CarProject.Components;
model Controller model Controller "Speed controller"
parameter Modelica.SIunits.Time tc = 5 "expected closed loop time constant (cf. Skogestad 2003)"; parameter Modelica.SIunits.Time tc = 5 "expected closed loop time constant (cf. Skogestad 2003)";
Modelica.Blocks.Interfaces.RealOutput f "force control" annotation( Modelica.Blocks.Interfaces.RealOutput f "force control" annotation(
Placement(visible = true, transformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Placement(visible = true, transformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
......
within CarProject;
type Velocity = Modelica.SIunits.Velocity(displayUnit = "km/h");
\ No newline at end of file
...@@ -2,3 +2,16 @@ ...@@ -2,3 +2,16 @@
This project is a minimal simulation of car on a road. This project is a minimal simulation of car on a road.
It is intended as a generic example for all Modelica Modeling projects It is intended as a generic example for all Modelica Modeling projects
## Checklist
* The package structure is reasonably "tidy"
* All models have a description string
* All parameters and variables have a physical unit and, when applicable,
a reasonable displayUnit
Simulation models:
* It is clear which models are supposed to be simulated
(e.g. by extending from `Modelica.Icons.Example`)
* A default simulation duration is set (`annotation(experiment(StopTime=180));`)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment