model Impedance "Single phase linear impedance"
import Modelica.ComplexMath.j;
import Modelica.ComplexMath.real;
import Modelica.ComplexMath.imag;
import Modelica.ComplexMath.conj;
extends Interfaces.OnePort;
parameter Modelica.SIunits.ComplexImpedance Z_ref(re(start = 1), im(start = 0)) "Complex impedance R_ref + j*X_ref";
parameter Modelica.SIunits.Temperature T_ref = 293.15 "Reference temperature";
parameter Modelica.SIunits.LinearTemperatureCoefficient alpha_ref = 0 "Temperature coefficient of resistance (R_actual = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(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));
Modelica.SIunits.Resistance R_actual "Resistance = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";
Modelica.SIunits.Reactance X_actual "Reactance considering possible frequency dependency";
final parameter Modelica.SIunits.Resistance R_ref = real(Z_ref) "Resistive component of impedance, resistance";
final parameter Modelica.SIunits.Reactance X_ref = imag(Z_ref) "Reactive component of impedance, reactance";
equation
assert(Modelica.Constants.eps <= 1 + alpha_ref * (T_heatPort - T_ref), "Temperature outside scope of model!");
v = Complex(R_actual, X_actual) * i;
LossPower = real(v * conj(i));
R_actual = R_ref * (1 + alpha_ref * (T_heatPort - T_ref));
X_actual = X_ref * (if not frequencyDependent then 1 else if 0 <= X_ref then omega / (2 * Modelica.Constants.pi * f_ref) else 2 * Modelica.Constants.pi * f_ref / omega);
annotation (
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})}),
Documentation(info = "<html>\n\n<p>The impedance model represents a <strong>series</strong> connection of a resistor and either an inductor or capacitor.<br>\n<img src=\"modelica://Modelica/Resources/Images/Electrical/QuasiStationary/SinglePhase/Basic/RX_impedance.png\"></p>\n\n<p>\nThe linear impedance connects the voltage <code><u>v</u></code> with the\ncurrent <code><u>i</u></code> by <code><u>v</u> = <u>Z</u>*<u>i</u></code>. The resistive\ncomponent is modeled temperature dependent, so the real part <code>R_actual = real(<u>Z</u>)</code> is determined from\nthe actual operating temperature and the reference input resistance <code>real(Z_ref)</code>.\nA <a href=\"modelica://Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort\">conditional heat port</a> is considered.\nThe reactive component <code>X_actual = imag(<u>Z</u>)</code>\nis 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) > 0</code>: inductive case</dt>\n<dd>The actual reactance <code>X_actual</code> is proportional to <code>f/f_ref</code></dd>\n<dt>(b) <code>imag(Z_ref) < 0</code>: capacitive case</dt>\n<dd>The actual reactance <code>X_actual</code> is proportional to <code>f_ref/f</code></dd>\n</dl>\n\n<h4>See also</h4>\n<p>\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Resistor\">Resistor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Conductor\">Conductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Capacitor\">Capacitor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.Admittance\">Admittance</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableResistor\">Variable resistor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableConductor\">Variable conductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableCapacitor\">Variable capacitor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableInductor\">Variable inductor</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableImpedance\">Variable impedance</a>,\n<a href=\"modelica://Modelica.Electrical.QuasiStationary.SinglePhase.Basic.VariableAdmittance\">Variable admittance</a>\n</p>\n</html>"));
end Impedance;