]> www.ljiriste.work Git - emf.git/commitdiff
Add an EMF model I derived for a DC motor trunk
authorLukáš Jiřiště <redacted>
Tue, 9 Dec 2025 12:34:51 +0000 (13:34 +0100)
committerLukáš Jiřiště <redacted>
Tue, 9 Dec 2025 12:34:51 +0000 (13:34 +0100)
emf.mo [new file with mode: 0644]

diff --git a/emf.mo b/emf.mo
new file mode 100644 (file)
index 0000000..d2479ab
--- /dev/null
+++ b/emf.mo
@@ -0,0 +1,52 @@
+package EMF
+
+model EMF
+       import Modelica.Units.SI;
+       parameter SI.ElectricalTorqueConstant   k = 1;
+
+       SI.Voltage                      v;
+       SI.Current                      i;
+       SI.Angle                        phi(start = 1);
+       SI.AngularVelocity      omega;
+       SI.Torque                       tau;
+
+       Modelica.Electrical.Analog.Interfaces.PositivePin                                       p;
+       Modelica.Electrical.Analog.Interfaces.NegativePin                                       n;
+       Modelica.Mechanics.Rotational.Interfaces.Flange_b       flange;
+
+protected
+       parameter SI.ElectricalTorqueConstant   k_mod = k * 2 /
+       Modelica.Constants.pi;
+
+equation
+       omega = der(phi);
+       tau = k_mod * abs(sin(phi)) * i;
+       v = k_mod * abs(sin(phi)) * omega;
+
+       tau = flange.tau;
+       phi = flange.phi;
+       v = p.v - n.v;
+       0 = p.i + n.i;
+       i = p.i;
+end EMF;
+
+model DCMotor
+       import Elct = Modelica.Electrical.Analog.Basic;
+
+       EMF                                                                                                     emf;
+       Elct.Resistor                                                                           resistor(R = 1);
+       Elct.Inductor                                                                           inductor(L = 1);
+       Elct.Ground                                                                                     ground;
+       Modelica.Electrical.Analog.Sources.ConstantVoltage      source(V = 1);
+       Modelica.Mechanics.Rotational.Components.Inertia        inertia(J = 1);
+
+equation
+       connect(source.p, resistor.p);
+       connect(resistor.n, inductor.p);
+       connect(inductor.n, emf.p);
+       connect(emf.n, ground.p);
+       connect(source.n, ground.p);
+       connect(emf.flange, inertia.flange_a);
+end DCMotor;
+
+end EMF;