| 1 | within ;
|
|---|
| 2 | package TestExample
|
|---|
| 3 | model SimpleLossTable "Test of simple DC loss model"
|
|---|
| 4 | extends Modelica.Icons.Example;
|
|---|
| 5 | TestExample.Loss loss annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
|
|---|
| 6 | Modelica.Electrical.Analog.Basic.Ground ground1 annotation (Placement(transformation(extent={{-80,-50},{-60,-30}})));
|
|---|
| 7 | Modelica.Electrical.Analog.Basic.Ground ground2 annotation (Placement(transformation(extent={{50,-52},{70,-32}})));
|
|---|
| 8 | Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent annotation (Placement(transformation(
|
|---|
| 9 | extent={{-10,-10},{10,10}},
|
|---|
| 10 | rotation=270,
|
|---|
| 11 | origin={60,0})));
|
|---|
| 12 | Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=100) annotation (Placement(transformation(
|
|---|
| 13 | extent={{-10,-10},{10,10}},
|
|---|
| 14 | rotation=270,
|
|---|
| 15 | origin={-70,0})));
|
|---|
| 16 | Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor1 annotation (Placement(transformation(extent={{-50,10},{-30,30}})));
|
|---|
| 17 | Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor2 annotation (Placement(transformation(extent={{30,10},{50,30}})));
|
|---|
| 18 | Modelica.Blocks.Tables.CombiTable1Ds combiTable(table=[0,10; 2000,200]) annotation (Placement(transformation(extent={{-8,-60},{12,-40}})));
|
|---|
| 19 | Modelica.Blocks.Sources.Ramp ramp(duration=1, height=10) annotation (Placement(transformation(extent={{100,-10},{80,10}})));
|
|---|
| 20 | equation
|
|---|
| 21 | connect(ground1.p, constantVoltage.n) annotation (Line(points={{-70,-30},{-70,-10}}, color={0,0,255}));
|
|---|
| 22 | connect(loss.n1, constantVoltage.n) annotation (Line(points={{-10,-10},{-20,-10},
|
|---|
| 23 | {-20,-20},{-70,-20},{-70,-10}}, color={0,0,255}));
|
|---|
| 24 | connect(loss.n2, signalCurrent.n) annotation (Line(points={{10,-10},{20,-10},{
|
|---|
| 25 | 20,-20},{60,-20},{60,-10}}, color={0,0,255}));
|
|---|
| 26 | connect(ground2.p, signalCurrent.n) annotation (Line(points={{60,-32},{60,-10}}, color={0,0,255}));
|
|---|
| 27 | connect(loss.p2, powerSensor2.pc) annotation (Line(points={{10,10},{20,10},{20,
|
|---|
| 28 | 20},{30,20}}, color={0,0,255}));
|
|---|
| 29 | connect(powerSensor2.pc, powerSensor2.pv) annotation (Line(points={{30,20},{30,30},{40,30}}, color={0,0,255}));
|
|---|
| 30 | connect(powerSensor2.nc, signalCurrent.p) annotation (Line(points={{50,20},{60,20},{60,10}}, color={0,0,255}));
|
|---|
| 31 | connect(powerSensor2.nv, ground2.p) annotation (Line(points={{40,10},{40,-20},{60,-20},{60,-32}}, color={0,0,255}));
|
|---|
| 32 | connect(powerSensor1.nv, ground1.p) annotation (Line(points={{-40,10},{-40,-20},{-70,-20},{-70,-30}}, color={0,0,255}));
|
|---|
| 33 | connect(powerSensor1.nc, loss.p1) annotation (Line(points={{-30,20},{-20,20},{
|
|---|
| 34 | -20,10},{-10,10}}, color={0,0,255}));
|
|---|
| 35 | connect(constantVoltage.p, powerSensor1.pc) annotation (Line(points={{-70,10},{-70,20},{-50,20}}, color={0,0,255}));
|
|---|
| 36 | connect(powerSensor1.pc, powerSensor1.pv) annotation (Line(points={{-50,20},{-50,30},{-40,30}}, color={0,0,255}));
|
|---|
| 37 | connect(ramp.y, signalCurrent.i) annotation (Line(points={{79,0},{72,0}}, color={0,0,127}));
|
|---|
| 38 | connect(combiTable.y[1], loss.lossPower) annotation (Line(points={{13,-50},{20,-50},{20,-30},{6,-30},{6,-12}},
|
|---|
| 39 | color={0,0,127}));
|
|---|
| 40 | connect(loss.outputPower, combiTable.u) annotation (Line(points={{-6,-11},{-6,
|
|---|
| 41 | -30},{-20,-30},{-20,-50},{-10,-50}}, color={0,0,127}));
|
|---|
| 42 | annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
|
|---|
| 43 | end SimpleLossTable;
|
|---|
| 44 |
|
|---|
| 45 | model Loss "Efficiency model considering variable efficiency"
|
|---|
| 46 | extends Modelica.Electrical.Analog.Interfaces.TwoPort;
|
|---|
| 47 | Modelica.SIunits.Current i_loss "Loss current considering equal voltages on both sides";
|
|---|
| 48 | Modelica.Blocks.Interfaces.RealInput lossPower(unit="W") "Loss power" annotation (Placement(transformation(
|
|---|
| 49 | extent={{-20,-20},{20,20}},
|
|---|
| 50 | rotation=90,
|
|---|
| 51 | origin={60,-120})));
|
|---|
| 52 | Modelica.Blocks.Interfaces.RealOutput outputPower(unit="W") "Output power" annotation (Placement(transformation(
|
|---|
| 53 | extent={{-10,-10},{10,10}},
|
|---|
| 54 | rotation=270,
|
|---|
| 55 | origin={-60,-110})));
|
|---|
| 56 | equation
|
|---|
| 57 | // Equal voltages on both sides
|
|---|
| 58 | v1 = v2;
|
|---|
| 59 | // Currents take loss into account
|
|---|
| 60 | i1 + i2 = i_loss;
|
|---|
| 61 | i_loss * v1 = lossPower;
|
|---|
| 62 | outputPower = smooth(0, if v1*i1 < 0 then -v1*i1 else -v2*i2);
|
|---|
| 63 | annotation(defaultComponentName="efficiency",Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics={ Rectangle(extent = {{-100, 100}, {100, -100}}, lineColor = {0, 0, 0},
|
|---|
| 64 | fillPattern = FillPattern.Solid, fillColor = {255, 255, 255}), Text(extent = {{-150, 150}, {150, 110}}, textString = "%name", lineColor = {0, 0, 255}), Text(extent = {{-40, 40}, {40, -40}}, lineColor = {0, 0, 0},
|
|---|
| 65 | fillPattern = FillPattern.Sphere, fillColor = {255, 255, 255}, textString = "%%")}), Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}})),
|
|---|
| 66 | Documentation(info="<html>
|
|---|
| 67 | <p>Model variable loss dependent on output power.</p>
|
|---|
| 68 | </html>"));
|
|---|
| 69 | end Loss;
|
|---|
| 70 | annotation (uses(Modelica(version="3.2.3")));
|
|---|
| 71 | end TestExample;
|
|---|