VariableImpedance

model VariableImpedance "Multiphase variable impedance"
    extends Interfaces.TwoPlug;

    parameter Modelica.SIunits.Temperature T_ref[m] = fill(293.15, m) "Reference temperatures";
    parameter Modelica.SIunits.LinearTemperatureCoefficient alpha_ref[m] = zeros(m) "Temperature coefficient of resistance (R_actual = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";

    extends Modelica.Electrical.MultiPhase.Interfaces.ConditionalHeatPort(final mh = m, T = T_ref);

    parameter Boolean frequencyDependent = false "Consider frequency dependency, if true"
        annotation (
            Evaluate = true,
            HideResult = true,
            choices(checkBox = true));
    parameter Modelica.SIunits.Frequency f_ref = 1 "Reference frequency, if frequency dependency is considered"
        annotation (Dialog(enable = frequencyDependent));
    ComplexBlocks.Interfaces.ComplexInput Z_ref[m] "Variable complex impedances"
        annotation (Placement(
            transformation(
                origin = {0, 120},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = 270),
            iconTransformation(
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = 270,
                origin = {0, 120})));
    SinglePhase.Basic.VariableImpedance variableImpedance[m](final T_ref = T_ref, final alpha_ref = alpha_ref, each final useHeatPort = useHeatPort, final T = T, final frequencyDependent = fill(frequencyDependent, m), final f_ref = fill(f_ref, m)) annotation (Placement(transformation(extent = {
        {-10, -10}, 
        {10, 10}})));
equation
    connect(variableImpedance.Z_ref,Z_ref) annotation (Line(
        points = {
            {0, 12}, 
            {0, 64}, 
            {0, 120}},
        color = {85, 170, 255}));
    connect(variableImpedance.heatPort,heatPort) annotation (Line(
        points = {
            {0, -10}, 
            {0, -100}},
        color = {191, 0, 0}));
    connect(variableImpedance.pin_n,plugToPins_n.pin_n) annotation (Line(
        points = {
            {10, 0}, 
            {39, 0}, 
            {68, 0}},
        color = {85, 170, 255}));
    connect(variableImpedance.pin_p,plugToPins_p.pin_p) annotation (Line(
        points = {
            {-10, 0}, 
            {-24.5, 0}, 
            {-39, 0}, 
            {-68, 0}},
        color = {85, 170, 255}));

    annotation (
        defaultComponentName = "impedance",
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {60, 0}, 
                        {90, 0}},
                    color = {85, 170, 255}), 
                Line(
                    points = {
                        {-90, 0}, 
                        {-60, 0}},
                    color = {85, 170, 255}), 
                Rectangle(
                    extent = {
                        {-70, 30}, 
                        {70, -30}},
                    lineColor = {85, 170, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-70, -30}, 
                        {70, 30}, 
                        {70, -30}, 
                        {-70, -30}},
                    lineColor = {85, 170, 255},
                    fillColor = {85, 170, 255},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-150, 90}, 
                        {150, 50}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Text(
                    extent = {
                        {150, -80}, 
                        {-150, -40}},
                    textString = "m=%m")}),
        Documentation(info = "<html>\n<p>The impedance model represents a <strong>series</strong> connection of a resistor and either an inductor or capacitor\nin each phase.<br>\n<img src=\"modelica://Modelica/Resources/Images/Electrical/QuasiStationary/SinglePhase/Basic/RX_impedance.png\"></p>\n\n<p>\nThe linear impedance connects the complex voltage <code><u>v</u></code> with the\ncomplex current <code><u>i</u></code> by <code><u>i</u>*<u>Z</u> = <u>v</u></code> in each phase,\nusing <code>m</code>\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableImpedance\">\nvariable singlephase impedances</a>.\nThe impedances <code>Z_ref = R_ref + j*X_ref</code> are given as complex input signals, representing the\nresistive and reactive components of the input impedances. The resistive\ncomponents are modeled temperature dependent, so the real part <code>R_actual = real(<u>Z</u>)</code> are determined from\nthe actual operating temperatures and the reference input resistances <code>real(Z_ref)</code>.\n<a href=\"modelica://Modelica.Electrical.MultiPhase.Interfaces.ConditionalHeatPort\">Conditional heat ports</a> are considered.\nThe reactive components <code>X_actual = imag(<u>Z</u>)</code>\nare equal to <code>imag(Z_ref)</code> if <code>frequencyDependent = false</code>.\nFrequency dependency is considered by <code>frequencyDependent = true</code>, distinguishing two cases:\n</p>\n\n<dl>\n<dt>(a) <code>imag(Z_ref) &gt; 0</code>: inductive case</dt>\n<dd>The actual reactances <code>X_actual</code> are proportional to <code>f/f_ref</code></dd>\n<dt>(b) <code>imag(Z_ref) &lt; 0</code>: capacitive case</dt>\n<dd>The actual reactances <code>X_actual</code> are proportional to <code>f_ref/f</code></dd>\n</dl>\n\n<h4>Note</h4>\n<p>\nZero crossings of the real or imaginary parts of the impedance signals <code>Z_ref</code> could cause\nsingularities due to the actual structure of the connected network.\n</p>\n\n<h4>See also</h4>\n<p>\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableResistor\">VariableResistor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Resistor\">Resistor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Conductor\">Conductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Capacitor\">Capacitor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Inductor\">Inductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Impedance\">Impedance</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.Admittance\">Admittance</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.VariableConductor\">Variable conductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.VariableCapacitor\">Variable capacitor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.VariableInductor\">Variable inductor</a>\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.MultiPhase.Basic.VariableAdmittance\">Variable admittance</a>\n</p>\n</html>"));
end VariableImpedance;