Читайте также:
|
|
Выполнения заданий в программе DYMOLA.
Задание:
Для заданных преподавателем: схемы, переменного сопротивления, определенного при помощи функции R(i) от тока, источника питания и параметров:
Вариант: 1-1-1
1. Электрическая цепь:
2. Источник питания: Пилообразное напряжение
3. Вид нелинейного сопротивления:
4. Параметры модели: L = 1, C = 1, R 1 = 0.1, R 2 = 0.01, A = 2, i max = 3
Выполнение:
Выполняем работу поэтапно, используя готовые классы пространства имен Modelica.Electrical.Analog стандартной библиотеки Modelica.Electrical, вместо того, чтобы самостоятельно создавать необходимые классы. Электрическую цепь моделируем с помощью визуальной модели, перенося необходимые нам компоненты.
Сначала соберем схему с обычным синусоидальным источником тока и обычным сопротивлением. Используем следующие компоненты:
1. Синусоидальный источник питания, класс Modelica.Electrical.Analog.Sources.SawToothVoltage
2. Резисторы, класс Modelica.Electrical.Analog.Basic.Resistor
3. Конденсатор, класс Modelica.Electrical.Analog.Basic.Capacitor
4. Катушка индуктивности, класс Modelica.Electrical.Analog.Basic.Inductor
5. Заземление, класс Modelica.Electrical.Analog.Basic.Resistor
В собранном виде визуальная модель имеет вид:
В визуальную модель внесем нелинейное сопротивление, заданное вариантом. Его нет среди стандартных компонент, поэтому соответствующий класс необходимо реализовать вручную. Создадим класс Resistor, реализующий нелинейное сопротивление, как наследника класса Modelica.Electrical.Analog.Interfaces.OnePort, представляющего собой простой однопортовик – электрический элемент с двумя контактами («pin»), положительным и отрицательным. Нам необходимо придать однопортовику новую характеристику – сопротивление R, которое будет вычисляться в соответствии с вариантом.
Исходный код нелинейного сопротивления (аннотации опущены):
model Resistor "Ideal linear electrical resistor"
Modelica.SIunits.Resistance R "Resistance";
parameter Modelica.SIunits.Temperature T_ref=300.15 "Reference temperature";
parameter Modelica.SIunits.LinearTemperatureCoefficient alpha=0
"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))";
extends Modelica.Electrical.Analog.Interfaces.OnePort;
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref);
Modelica.SIunits.Resistance R_actual
"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))";
parameter SI.Current imax = 3;
parameter Real A = 2;
equation
assert((1 + alpha*(T_heatPort - T_ref)) >= Modelica.Constants.eps, "Temperature outside scope of model!");
R_actual = R*(1 + alpha*(T_heatPort - T_ref));
v = R_actual*i;
LossPower = v*i;
R = if abs(i) <= imax then A*abs(i)^3 else A*imax^3;
annotation (
Documentation(info="<html>
<p>The linear resistor connects the branch voltage <i>v</i> with the branch current <i>i</i> by <i>i*R = v</i>. The Resistance <i>R</i> is allowed to be positive, zero, or negative.</p>
</html>",
revisions="<html>
<ul>
<li><i> August 07, 2009 </i>
by Anton Haumer<br> temperature dependency of resistance added<br>
</li>
<li><i> March 11, 2009 </i>
by Christoph Clauss<br> conditional heat port added<br>
</li>
<li><i> 1998 </i>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
grid={2,2}), graphics={
Rectangle(
extent={{-70,30},{70,-30}},
lineColor={0,0,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(points={{-90,0},{-70,0}}, color={0,0,255}),
Line(points={{70,0},{90,0}}, color={0,0,255}),
Text(
extent={{-144,-40},{142,-72}},
lineColor={0,0,0},
textString="imax=%imax,A=%A"),
Line(
visible=useHeatPort,
points={{0,-100},{0,-30}},
color={127,0,0},
smooth=Smooth.None,
pattern=LinePattern.Dot),
Text(
extent={{-152,87},{148,47}},
textString="%name",
lineColor={0,0,255})}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
grid={2,2}), graphics={
Rectangle(extent={{-70,30},{70,-30}}, lineColor={0,0,255}),
Line(points={{-96,0},{-70,0}}, color={0,0,255}),
Line(points={{70,0},{96,0}}, color={0,0,255})}));
end Resistor;
Визуальное представление:
После замены сопротивления визуальная модель приобретает вид:
Теперь в соответствии с вариантом заменим в визуальной модели источник питания на Пилообразное напряжение. Используем объект класса Modelica.Electrical.Analog.Sources.PulseVoltage.
Визуальная модель преобразуется к виду:
Приступим к верификации модели. Запишем для цепи систему аналитических уравнений в соответствии с законами Кирхгофа для независимых переменных, характеризующих токи и сопротивления в цепи:
model Model3
import Baranova;
SI.Voltage v1;
SI.Voltage v2;
SI.Voltage v3;
SI.Voltage v4;
SI.Voltage v5;
SI.Voltage v6;
SI.Current i1;
SI.Current i2;
SI.Current i3;
SI.Current i4;
SI.Current i5;
SI.Current i6;
Modelica.Electrical.Analog.Basic.Ground G1
annotation (Placement(transformation(extent={{-70,-40},{-50,-20}})));
Modelica.Electrical.Analog.Basic.Resistor R2(R=0.01) annotation (
Placement(transformation(
extent={{-10,10},{10,-10}},
rotation=180,
origin={-20,-12})));
Modelica.Electrical.Analog.Basic.Resistor R1(R=0.1)
annotation (Placement(transformation(extent={{28,36},{48,56}})));
Modelica.Electrical.Analog.Basic.Capacitor C1(
C=1) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=-90,
origin={76,12})));
Modelica.Electrical.Analog.Basic.Inductor L1(
L=1)
annotation (Placement(transformation(extent={{28,64},{48,84}})));
Modelica.Electrical.Analog.Sources.SineVoltage E(V=220, freqHz=50)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=-90,
origin={-60,24})));
Resistor R3 annotation (Placement(transformation(extent={{-28,50},{-8,70}})));
equation
v1 = v2 + v3 + v5 + v6;
v3 = v4;
i1 = i2;
i2 = i3 + i4;
i3 + i4 = i5;
i5 = i6;
v4 = i4*R1.R;
v6 = i6*R2.R;
v2 = i2*R3.R;
L1.L*der(i3) = v3;
C1.C*der(v5) = i5;
v1 = E.v;
connect(L1.p,R1. p)
annotation (Line(
points={{28,74},{24,74},{24,46},{28,46}},
color={0,0,255},
smooth=Smooth.None));
connect(L1.n,R1. n)
annotation (Line(
points={{48,74},{54,74},{54,46},{48,46}},
color={0,0,255},
smooth=Smooth.None));
connect(L1.n, C1.p)
annotation (Line(
points={{48,74},{54,74},{54,62},{76,62},{76,22}},
color={0,0,255},
smooth=Smooth.None));
connect(C1.n,R2. p)
annotation (Line(
points={{76,2},{76,-12},{-10,-12}},
color={0,0,255},
smooth=Smooth.None));
connect(E.n, G1.p)
annotation (Line(
points={{-60,14},{-60,-20}},
color={0,0,255},
smooth=Smooth.None));
connect(G1.p,R2. n)
annotation (Line(
points={{-60,-20},{-60,-12},{-30,-12}},
color={0,0,255},
smooth=Smooth.None));
connect(E.p, R3.p) annotation (Line(
points={{-60,34},{-60,60},{-28,60}},
color={0,0,255},
smooth=Smooth.None));
connect(R3.n, R1.p) annotation (Line(
points={{-8,60},{24,60},{24,46},{28,46}},
color={0,0,255},
smooth=Smooth.None));
annotation (Diagram(graphics));
end Model3;
Совпадение токов и напряжений на элементах модели:
1. Ток на элементах С.v и v2:
2. Напряжение на элементах R1 и L:
3. Сила тока на входе и на выходе источника питания (по закону Кирхгофа):
Построение математической модели маятника
Задание на вариант №3
Решение:
model Geometry1
parameter SI.Length R1 = 0.3;
parameter SI.Length R2 = 1;
parameter SI.Length R3 = 0.8;
parameter SI.Length R4 = 1;
parameter SI.Length R5 = 0.5;
parameter SI.Angle phi10 = 0;
parameter SI.Angle phi20 = 2.1;
parameter SI.Angle phi30 = 0.7;
parameter SI.Angle phi40 = 5.2;
parameter SI.Position xE0 = R1*cos(phi10) + R2*cos(phi20) + R3*cos(phi30);
parameter SI.Position yE0 = R1*sin(phi10) + R2*sin(phi20) + R3*sin(phi30);
parameter SI.Position xC0 = R1*sin(phi10) + R2*sin(phi20) + (R3 + R3/2)*sin(phi30) + R4*sin(phi40);
parameter SI.Position yC0 = R1*sin(phi10) + R2*sin(phi20) + (R3 + R3/2)*sin(phi30) + R4*sin(phi40);
SI.Angle phi1;
SI.Angle phi2(start = phi20);
SI.Angle phi3(start = phi30);
SI.Angle phi4(start = phi40);
SI.Angle phi5;
VisualShape Beam1(
r0 = {0, 0, 0.15},
Shape = "beam",
Length = R1,
Width = 0.05,
Height = 0.05,
LengthDirection = {1, 0, 0},
WidthDirection = {0, 1, 0},
Material = {1, 0, 0, 0.3});
VisualShape Beam2(
r0 = {0, 0, 0.20},
Shape = "beam",
Length = R2,
Width = 0.05,
Height = 0.05,
LengthDirection = {1, 0, 0},
WidthDirection = {0, 1, 0},
Material = {0, 1, 0, 0.3});
VisualShape Beam3(
r0 = {0, 0, 0.15},
Shape = "beam",
Length = R3 + R3/2,
Width = 0.05,
Height = 0.05,
LengthDirection = {1, 0, 0},
WidthDirection = {0, 1, 0},
Material = {0, 0, 1, 0.3});
VisualShape Beam4(
r0 = {0, 0, 0.20},
Shape = "beam",
Length = R4,
Width = 0.05,
Height = 0.05,
LengthDirection = {1, 0, 0},
WidthDirection = {0, 1, 0},
Material = {1, 1, 0, 0.3});
VisualShape Wheel(
r0 = {0, 0, 0},
Shape = "cylinder",
Length = 0.05,
Width = 2*R5,
Height = 2*R5,
LengthDirection = {0, 0, 1},
WidthDirection = {0, 1, 0},
Material = {1, 0, 1, 0.3});
VisualShape Joint1(
r0 = {0, 0, -0.05},
Shape = "cylinder",
Length = 0.25,
Width = 0.05,
Height = 0.05,
LengthDirection = {0, 0, 1},
WidthDirection = {0, 1, 0},
Material = {0, 0.1, 1, 0});
VisualShape Cone1(
r0 = {0, -0.1, 0},
Shape = "cone",
Length = 0.1,
Width = 0.1,
Height = 0.1,
LengthDirection = {0, 1, 0},
WidthDirection = {1, 0, 0},
Material = {0, 0.1, 1, 0});
VisualShape Box1(
r0 = {0, -0.15, 0},
Shape = "box",
Length = 0.05,
Width = 0.2,
Height = 0.2,
LengthDirection = {0, 1, 0},
WidthDirection = {1, 0, 0},
Material = {0, 0.1, 1, 0});
VisualShape Joint2(
r0 = {0, 0, -0.05},
Shape = "cylinder",
Length = 0.25,
Width = 0.05,
Height = 0.05,
LengthDirection = {0, 0, 1},
WidthDirection = {0, 1, 0},
Material = {0, 1, 1, 0});
VisualShape Cone2(
r0 = {0, -0.1, 0},
Shape = "cone",
Length = 0.1,
Width = 0.1,
Height = 0.1,
LengthDirection = {0, 1, 0},
WidthDirection = {1, 0, 0},
Material = {0, 1, 1, 0});
VisualShape Box2(
r0 = {0, -0.15, 0},
Shape = "box",
Length = 0.05,
Width = 0.2,
Height = 0.2,
LengthDirection = {0, 1, 0},
WidthDirection = {1, 0, 0},
Material = {0, 1, 1, 0});
VisualShape Box3(
r0 = {xC0 - R5, yC0, 0},
Shape = "box",
Length = 0.05,
Width = 1.5,
Height = 0.3,
LengthDirection = {-1, 0, 0},
WidthDirection = {0, 1, 0},
Material = {0, 1, 1, 0});
VisualShape Joint3(
r0 = {0, 0, -0.05},
Shape = "cylinder",
Length = 0.3,
Width = 0.05,
Height = 0.05,
LengthDirection = {0, 0, 1},
WidthDirection = {0, 1, 0},
Material = {0, 1, 1, 0});
SI.Position[3] rE;
SI.Position[3] rC;
equation
phi1 = time;
Beam1.r = {0, 0, 0};
Beam1.S = [cos(phi1), -sin(phi1), 0;
sin(phi1), cos(phi1), 0;
0, 0, 1];
Beam2.r = Beam1.r + Beam1.S*{R1, 0, 0};
Beam2.S = [cos(phi2), -sin(phi2), 0;
sin(phi2), cos(phi2), 0;
0, 0, 1];
Beam3.r = Beam2.r + Beam2.S*{R2, 0, 0};
Beam3.S = [cos(phi3), -sin(phi3), 0;
sin(phi3), cos(phi3), 0;
0, 0, 1];
rE = Beam3.r + Beam3.S*{R3, 0, 0};
rE[1] = xE0;
rE[2] = yE0;
Beam4.r = Beam3.r + Beam3.S*{R3 + R3/2, 0, 0};
Beam4.S = [cos(phi4), -sin(phi4), 0;
sin(phi4), cos(phi4), 0;
0, 0, 1];
rC = Beam4.r + Beam4.S*{R4, 0, 0};
rC[1] = xC0;
Wheel.r = rC;
Wheel.S = [cos(phi5), -sin(phi5), 0;
sin(phi5), cos(phi5), 0;
0, 0, 1];
rC[2] - yC0 = R5*phi5;
Joint1.r = {0, 0, 0};
Joint1.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Cone1.r = {0, 0, 0};
Cone1.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Box1.r = {0, 0, 0};
Box1.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Joint2.r = rE;
Joint2.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Cone2.r = rE;
Cone2.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Box2.r = rE;
Box2.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Box3.r = zeros(3);
Box3.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
Joint3.r = rC;
Joint3.S = [1, 0, 0;
0, 1, 0;
0, 0, 1];
annotation (experiment(
StopTime=50,
NumberOfIntervals=5000,
Tolerance=1e-006), __Dymola_experimentSetupOutput);
end Geometry1;
Дата добавления: 2015-11-30; просмотров: 154 | Нарушение авторских прав