Skip to content

Commit

Permalink
Fix wrong usage of quantities in Modelica.Electrical.Analog.Interface…
Browse files Browse the repository at this point in the history
…s.IdealSemiconductor (#4387)

* fixed bug #4386

* same issue with Electrical.Analog.Ideal.{IdealTwoWaySwitch, IdealIntermediateSwitch, ControlledIdealTwoWaySwitch, ControlledIdealIntermediateSwitch}

---------

Co-authored-by: Anton Haumer <anton.haumer@oth-regensburg.de>
  • Loading branch information
AHaumer and haa39214 authored Aug 16, 2024
1 parent afb8a8b commit c58f0c3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ protected
equation
control.i = 0;

p1.v - n1.v = (s1*unitCurrent)*(if (control.v > level) then 1 else Ron);
p2.v - n2.v = (s2*unitCurrent)*(if (control.v > level) then 1 else Ron);
p1.v - n2.v = (s3*unitCurrent)*(if (control.v > level) then Ron else 1);
p2.v - n1.v = (s4*unitCurrent)*(if (control.v > level) then Ron else 1);
p1.v - n1.v = s1*(if (control.v > level) then unitVoltage else Ron*unitCurrent);
p2.v - n2.v = s2*(if (control.v > level) then unitVoltage else Ron*unitCurrent);
p1.v - n2.v = s3*(if (control.v > level) then Ron*unitCurrent else unitVoltage);
p2.v - n1.v = s4*(if (control.v > level) then Ron*unitCurrent else unitVoltage);

p1.i = if control.v > level then s1*unitVoltage*Goff + s3*unitCurrent else
s1*unitCurrent + s3*unitVoltage*Goff;
p2.i = if control.v > level then s2*unitVoltage*Goff + s4*unitCurrent else
s2*unitCurrent + s4*unitVoltage*Goff;
n1.i = if control.v > level then -s1*unitVoltage*Goff - s4*unitCurrent
else -s1*unitCurrent - s4*unitVoltage*Goff;
n2.i = if control.v > level then -s2*unitVoltage*Goff - s3*unitCurrent
else -s2*unitCurrent - s3*unitVoltage*Goff;
-n1.i = if control.v > level then s1*unitVoltage*Goff + s4*unitCurrent else
s1*unitCurrent + s4*unitVoltage*Goff;
-n2.i = if control.v > level then s2*unitVoltage*Goff + s3*unitCurrent else
s2*unitCurrent + s3*unitVoltage*Goff;

LossPower = p1.i*p1.v + p2.i*p2.v + n1.i*n1.v + n2.i*n2.v;
annotation (defaultComponentName="switch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ equation
control.i = 0;
0 = p.i + n2.i + n1.i;

p.v - n1.v = (s1*unitCurrent)*(if (control.v > level) then 1 else Ron);
n1.i = -(s1*unitVoltage)*(if (control.v > level) then Goff else 1);
p.v - n2.v = (s2*unitCurrent)*(if (control.v > level) then Ron else 1);
n2.i = -(s2*unitVoltage)*(if (control.v > level) then 1 else Goff);
p.v - n1.v = s1*(if (control.v > level) then unitVoltage else Ron*unitCurrent);
n1.i = -s1*(if (control.v > level) then Goff*unitVoltage else unitCurrent);
p.v - n2.v = s2*(if (control.v > level) then Ron*unitCurrent else unitVoltage);
n2.i = -s2*(if (control.v > level) then unitCurrent else Goff*unitVoltage);
LossPower = p.i*p.v + n1.i*n1.v + n2.i*n2.v;
annotation (defaultComponentName="switch",
Documentation(info="<html>
Expand Down
24 changes: 12 additions & 12 deletions Modelica/Electrical/Analog/Ideal/IdealIntermediateSwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ protected
constant SI.Voltage unitVoltage=1 annotation (HideResult=true);
constant SI.Current unitCurrent=1 annotation (HideResult=true);
equation
p1.v - n1.v = (s1*unitCurrent)*(if (control) then 1 else Ron);
p2.v - n2.v = (s2*unitCurrent)*(if (control) then 1 else Ron);
p1.v - n2.v = (s3*unitCurrent)*(if (control) then Ron else 1);
p2.v - n1.v = (s4*unitCurrent)*(if (control) then Ron else 1);
p1.v - n1.v = s1*(if control then unitVoltage else Ron*unitCurrent);
p2.v - n2.v = s2*(if control then unitVoltage else Ron*unitCurrent);
p1.v - n2.v = s3*(if control then Ron*unitCurrent else unitVoltage);
p2.v - n1.v = s4*(if control then Ron*unitCurrent else unitVoltage);

p1.i = if control then s1*unitVoltage*Goff + s3*unitCurrent else s1*
unitCurrent + s3*unitVoltage*Goff;
p2.i = if control then s2*unitVoltage*Goff + s4*unitCurrent else s2*
unitCurrent + s4*unitVoltage*Goff;
n1.i = if control then -s1*unitVoltage*Goff - s4*unitCurrent else -s1*
unitCurrent - s4*unitVoltage*Goff;
n2.i = if control then -s2*unitVoltage*Goff - s3*unitCurrent else -s2*
unitCurrent - s3*unitVoltage*Goff;
p1.i = if control then s1*unitVoltage*Goff + s3*unitCurrent else
s1*unitCurrent + s3*unitVoltage*Goff;
p2.i = if control then s2*unitVoltage*Goff + s4*unitCurrent else
s2*unitCurrent + s4*unitVoltage*Goff;
-n1.i = if control then s1*unitVoltage*Goff + s4*unitCurrent else
s1*unitCurrent + s4*unitVoltage*Goff;
-n2.i = if control then s2*unitVoltage*Goff + s3*unitCurrent else
s2*unitCurrent + s3*unitVoltage*Goff;

LossPower = p1.i*p1.v + p2.i*p2.v + n1.i*n1.v + n2.i*n2.v;
annotation (defaultComponentName="switch",
Expand Down
8 changes: 4 additions & 4 deletions Modelica/Electrical/Analog/Ideal/IdealTwoWaySwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ protected
equation
0 = p.i + n2.i + n1.i;

p.v - n1.v = (s1*unitCurrent)*(if (control) then 1 else Ron);
n1.i = -(s1*unitVoltage)*(if (control) then Goff else 1);
p.v - n2.v = (s2*unitCurrent)*(if (control) then Ron else 1);
n2.i = -(s2*unitVoltage)*(if (control) then 1 else Goff);
p.v - n1.v = s1*(if control then unitVoltage else Ron*unitCurrent);
n1.i = -s1*(if control then Goff*unitVoltage else unitCurrent);
p.v - n2.v = s2*(if control then Ron*unitCurrent else unitVoltage);
n2.i = -s2*(if control then unitCurrent else Goff*unitVoltage);
LossPower = p.i*p.v + n1.i*n1.v + n2.i*n2.v;
annotation (defaultComponentName="switch",
Documentation(info="<html>
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Electrical/Analog/Interfaces/IdealSemiconductor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected
constant SI.Voltage unitVoltage=1 annotation (HideResult=true);
constant SI.Current unitCurrent=1 annotation (HideResult=true);
equation
v = (s*unitCurrent)*(if off then 1 else Ron) + Vknee;
i = (s*unitVoltage)*(if off then Goff else 1) + Goff*Vknee;
v = s*(if off then unitVoltage else Ron*unitCurrent) + Vknee;
i = s*(if off then Goff*unitVoltage else unitCurrent) + Goff*Vknee;
LossPower = v*i;
annotation (
Documentation(info="<html>
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Electrical/Analog/Interfaces/IdealSwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ protected
constant SI.Voltage unitVoltage=1 annotation (HideResult=true);
constant SI.Current unitCurrent=1 annotation (HideResult=true);
equation
v = (s*unitCurrent)*(if off then 1 else Ron);
i = (s*unitVoltage)*(if off then Goff else 1);
v = s*(if off then unitVoltage else Ron*unitCurrent);
i = s*(if off then Goff*unitVoltage else unitCurrent);
LossPower = v*i;
annotation (
Documentation(info="<html>
Expand Down

0 comments on commit c58f0c3

Please sign in to comment.