VariableAdmittance

model VariableAdmittance "Multiphase variable admittance"
    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 Y_ref[m] "Variable complex admittances"
        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.VariableAdmittance 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(Y_ref,variableImpedance.Y_ref) annotation (Line(
        points = {
            {0, 120}, 
            {0, 12}},
        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}, 
            {68, 0}},
        color = {85, 170, 255}));
    connect(variableImpedance.pin_p,plugToPins_p.pin_p) annotation (Line(
        points = {
            {-10, 0}, 
            {-68, 0}},
        color = {85, 170, 255}));

    annotation (
        defaultComponentName = "admittance",
        Icon(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 admittance model represents a <strong>parallel</strong> connection of a resistor and either a capacitor or inductor\nin each phase.<br>\n<img src=\"modelica://Modelica/Resources/Images/Electrical/QuasiStationary/SinglePhase/Basic/GB_admittance.png\"></p>\n\n<p>\nThe linear admittance connects the complex voltage <code><u>v</u></code> with the\ncomplex current <code><u>i</u></code> by <code><u>v</u>*<u>Y</u> = <u>i</u></code> in each phase,\nusing <code>m</code>\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableAdmittance\">\nvariable singlephase admittances</a>.\nThe admittances <code>Y_ref = G_ref + j*B_ref</code> are given as complex input signals, representing the\nresistive and reactive components of the input admittances. The resistive\ncomponents are modeled temperature dependent, so the real part <code>G_actual = real(<u>Y</u>)</code> are determined from\nthe actual operating temperatures and the reference input conductances <code>real(Y_ref)</code>.\n<a href=\"modelica://Modelica.Electrical.MultiPhase.Interfaces.ConditionalHeatPort\">Conditional heat ports</a> are considered.\nThe reactive components <code>B_actual = imag(<u>Y</u>)</code>\nare equal to <code>imag(Y_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(Y_ref) &gt; 0</code>: capacitive case</dt>\n<dd>The actual susceptances <code>B_actual</code> are proportional to <code>f/f_ref</code></dd>\n<dt>(b) <code>imag(Y_ref) &lt; 0</code>: inductive case</dt>\n<dd>The actual susceptances <code>B_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 admittance signals <code>Y_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.VariableImpedance\">Variable impedance</a>,\n</p>\n</html>"));
end VariableAdmittance;