package Circuitos package Units type Voltage = Real(unit = "V"); type Current = Real(unit = "A"); end Units; package Interfaces connector Pin Units.Voltage v; flow Units.Current i; annotation( Icon(graphics = {Rectangle(origin = {-1, 0}, fillColor = {0, 0, 255}, fillPattern = FillPattern.Solid, extent = {{-95, 96}, {95, -96}})})); end Pin; partial model OnePort Pin p annotation( Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Pin n annotation( Placement(visible = true, transformation(origin = {98, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {98, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Units.Voltage v; Units.Current i; equation p.v-n.v = v; p.i=i; p.i+n.i=0; end OnePort; end Interfaces; package Components model Capacitor extends Circuitos.Interfaces.OnePort; parameter Real C(unit = "F") = 1; equation C * der(v) = i; annotation( Icon(graphics = {Line(origin = {-56, -1}, points = {{-36, 1}, {36, 1}, {36, -1}}), Line(origin = {54, 0}, points = {{34, 0}, {-34, 0}}), Line(origin = {-20, 1}, points = {{0, 61}, {0, -61}}), Line(origin = {18, 2}, points = {{0, 58}, {0, -58}}), Text(origin = {5, 85}, extent = {{-67, 29}, {63, -17}}, textString = "C=%C"), Text(origin = {4, -84}, extent = {{-72, 16}, {82, -30}}, textString = "%name")})); end Capacitor; model Resistor extends Circuitos.Interfaces.OnePort; parameter Real R(unit="Ohm")=1; equation R*i=v; annotation( Icon(graphics = {Line(origin = {-0.82918, 3}, points = {{-87.1708, -3}, {-79.1708, -3}, {-57.1708, 59}, {-21.1708, -57}, {4.82918, 61}, {46.8292, -61}, {62.8292, 55}, {84.8292, -7}, {86.8292, -3}})}));end Resistor; model Ground Interfaces.Pin p annotation( Placement(visible = true, transformation(origin = {0, 94}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {0, 94}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation p.v=0; annotation( Icon(graphics = {Line(origin = {3.20711, 62.7929}, points = {{-65.2071, 1.20711}, {62.7929, 1.20711}, {64.7929, -0.792893}}), Line(origin = {3, 34}, points = {{-47, 0}, {47, 0}}), Line(origin = {6, 8}, points = {{-26, 0}, {26, 0}})}));end Ground; end Components; package Examples model RC Components.Ground ground annotation( Placement(visible = true, transformation(origin = {-2, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Components.Resistor r1 annotation( Placement(visible = true, transformation(origin = {20, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Circuitos.Components.Capacitor c1(v(start = 1)) annotation( Placement(visible = true, transformation(origin = {-34, 6}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); equation connect(c1.p, r1.p) annotation( Line(points = {{-34, 16}, {-34, 30}, {10, 30}})); connect(r1.n, ground.p) annotation( Line(points = {{30, 30}, {46, 30}, {46, -20}, {-2, -20}, {-2, -20}})); connect(c1.n, ground.p) annotation( Line(points = {{-34, -4}, {-34, -20}, {-2, -20}})); end RC; end Examples; end Circuitos;