Skip to content

Commit

Permalink
Adapt units and cleanup #1575
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraMaier committed Oct 13, 2023
1 parent 5d04aad commit 7875491
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 319 deletions.
54 changes: 24 additions & 30 deletions IBPSA/Electrical/BaseClasses/PV/BaseClasses/Icons/partialPVIcon.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,55 @@ partial model partialPVIcon "Partial model for basic PV model icon"
Rectangle(extent={{-100,100},{100,-100}},
lineColor={215,215,215},fillColor={215,215,215},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-62,18},{-34,-10}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-62,30},{-34,2}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-30,18},{-2,-10}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-30,30},{-2,2}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{2,18},{30,-10}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{2,30},{30,2}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-62,-14},{-34,-42}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-62,-2},{-34,-30}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-30,-14},{-2,-42}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-30,-2},{-2,-30}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{2,-14},{30,-42}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{2,-2},{30,-30}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-62,-46},{-34,-74}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-62,-34},{-34,-62}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-30,50},{-2,22}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-30,62},{-2,34}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{2,50},{30,22}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{2,62},{30,34}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-62,50},{-34,22}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-62,62},{-34,34}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-30,-46},{-2,-74}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-30,-34},{-2,-62}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{2,-46},{30,-74}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{2,-34},{30,-62}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-94,50},{-66,22}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-94,62},{-66,34}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-94,18},{-66,-10}},
lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{-94,30},{-66,2}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-94,-14},{-66,-42}},
Rectangle(extent={{-94,-2},{-66,-30}},
lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{-94,-46},{-66,-74}},
Rectangle(extent={{-94,-34},{-66,-62}},
lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{34,50},{62,22}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{34,62},{62,34}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{34,18},{62,-10}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{34,30},{62,2}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{34,-14},{62,-42}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{34,-2},{62,-30}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{34,-46},{62,-74}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{34,-34},{62,-62}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{66,-46},{94,-74}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{66,-34},{94,-62}},lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{66,-14},{94,-42}},lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{66,-2},{94,-30}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{66,18},{94,-10}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{66,30},{94,2}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Rectangle(extent={{66,50},{94,22}}, lineColor={0,0,255},fillColor={0,0,255},
Rectangle(extent={{66,62},{94,34}}, lineColor={0,0,255},fillColor={0,0,255},
fillPattern = FillPattern.Solid),
Text(
extent={{-150,150},{150,110}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ partial model PartialPVElectrical
final parameter Integer nPar=dat.nPar
"Number of parallel connected cells within the PV module";

final parameter Real Eg0(unit="eV") = dat.Eg0
final parameter Modelica.Units.SI.Energy Eg0 = dat.Eg0
"Band gap energy under standard conditions";

Modelica.Units.SI.ElectricCurrent IPh "Photo current";
Expand Down
83 changes: 39 additions & 44 deletions IBPSA/Electrical/BaseClasses/PV/PVElectricalSingleDiodeMPP.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,104 @@ model PVElectricalSingleDiodeMPP

// Main parameters under standard conditions

Modelica.Units.SI.ElectricCurrent I_ph0
Modelica.Units.SI.ElectricCurrent IPh0
"Photo current under standard conditions";
Modelica.Units.SI.ElectricCurrent I_s0
Modelica.Units.SI.ElectricCurrent IS0
"Saturation current under standard conditions";
Modelica.Units.SI.Resistance R_s0
Modelica.Units.SI.Resistance RS0
"Series resistance under standard conditions";
Modelica.Units.SI.Resistance R_sh0
Modelica.Units.SI.Resistance RSh0
"Shunt resistance under standard conditions";
Real a_0(unit = "V")
"Modified diode ideality factor under standard conditions";
Real w_0(final unit = "1")
Real a0(unit="V") "Modified diode ideality factor under standard conditions";
Real w0(final unit="1")
"MPP auxiliary correlation coefficient under standard conditions";

// Additional parameters and constants

constant Real euler=Modelica.Math.exp(1.0)
"Euler constant";
constant Real q(unit = "C")= 1.602176620924561e-19
constant Real q(unit = "A.s")= 1.602176620924561e-19
"Elementary charge";

Modelica.Units.SI.ElectricCurrent I_mp(start=0.5*IMP0)
Modelica.Units.SI.ElectricCurrent IMP(start=0.5*IMP0)
"MPP current at operating conditions";

Modelica.Units.SI.Voltage V_mp "MPP voltage at operating conditions";
Modelica.Units.SI.Voltage VMP "MPP voltage at operating conditions";

Modelica.Units.SI.Energy Eg "Band gap energy at operating conditions";

Modelica.Units.SI.ElectricCurrent I_s "Saturation current at operating conditions";
Modelica.Units.SI.ElectricCurrent IS
"Saturation current at operating conditions";

Modelica.Units.SI.Resistance R_s "Series resistance at operating conditions";
Modelica.Units.SI.Resistance RS "Series resistance at operating conditions";

Modelica.Units.SI.Resistance R_sh "Shunt resistance at operating conditions";
Modelica.Units.SI.Resistance RSh "Shunt resistance at operating conditions";

Real a(final unit = "V", start = 1.3)
"Modified diode ideality factor";

Modelica.Units.SI.Power P_mod "Output power of one PV module";
Modelica.Units.SI.Power PMod "Output power of one PV module";

Real w(final unit = "1", start = 0)
"MPP auxiliary correlation coefficient";

Modelica.Units.SI.Voltage V_oc
Modelica.Units.SI.Voltage VOC
"Open circuit voltage under operating conditions";

equation

// Analytical parameter extraction equations under standard conditions (Batzelis et al., 2016)

a_0 =VOC0*(1 - TCel0*betaVOC)/(50.1 - TCel0*alphaISC);
a0 = VOC0*(1 - TCel0*betaVOC)/(50.1 - TCel0*alphaISC);

w_0 =IBPSA.Electrical.BaseClasses.PV.BaseClasses.lambertWSimple(
exp(1/(a_0/VOC0) + 1));
w0 = IBPSA.Electrical.BaseClasses.PV.BaseClasses.lambertWSimple(exp(1/(a0/
VOC0) + 1));

R_s0 =(a_0*(w_0 - 1) - VMP0)/IMP0;
RS0 = (a0*(w0 - 1) - VMP0)/IMP0;

R_sh0 =a_0*(w_0 - 1)/(ISC0*(1 - 1/w_0) - IMP0);
RSh0 = a0*(w0 - 1)/(ISC0*(1 - 1/w0) - IMP0);

I_ph0 =(1 + R_s0/R_sh0)*ISC0;
IPh0 = (1 + RS0/RSh0)*ISC0;

I_s0 =I_ph0*exp(-1/(a_0/VOC0));
IS0 = IPh0*exp(-1/(a0/VOC0));

// Parameter extrapolation equations to operating conditions (DeSoto et al., 2006)

a/a_0 = TCel/TCel0;
a/a0 = TCel/TCel0;

I_s/I_s0 = (TCel/TCel0)^3*exp(1/k*(Eg0*q/TCel0-Eg/TCel));
IS/IS0 = (TCel/TCel0)^3*exp(1/k*(Eg0/TCel0 - Eg/TCel));

Eg/(Eg0*q) =1 - dat.C*(TCel - TCel0);
Eg/(Eg0) =1 - dat.C*(TCel - TCel0);

R_s = R_s0;
RS = RS0;

IPh = if absRadRat > 0
then absRadRat*(I_ph0 + TCoeISC*(TCel - TCel0))
else 0;
IPh =if absRadRat > 0 then absRadRat*(IPh0 + TCoeISC*(TCel - TCel0)) else 0;

R_sh/R_sh0 = if noEvent(absRadRat > Modelica.Constants.eps)
then 1/absRadRat
else 0;
RSh/RSh0 = if noEvent(absRadRat > Modelica.Constants.eps) then 1/absRadRat
else 0;

// Simplified power correlations at MPP using Lambert W function (Batzelis et al., 2016)

I_mp =if noEvent(absRadRat <= Modelica.Constants.eps
or w <= Modelica.Constants.eps)
then 0 else IPh*(1 - 1/w) - a*(w - 1)/R_sh;
IMP = if noEvent(absRadRat <= Modelica.Constants.eps or w <= Modelica.Constants.eps)
then 0 else IPh*(1 - 1/w) - a*(w - 1)/RSh;

V_mp = if absRadRat <= 0 then 0 else a*(w-1)-R_s*I_mp;
VMP = if absRadRat <= 0 then 0 else a*(w - 1) - RS*IMP;

V_oc =if IPh >= Modelica.Constants.eps*10 then a*log(abs((IPh/I_s + 1)))
else 0;
VOC = if IPh >= Modelica.Constants.eps*10 then a*log(abs((IPh/IS + 1))) else 0;

w = if noEvent(V_oc >= Modelica.Constants.eps) then
IBPSA.Electrical.BaseClasses.PV.BaseClasses.lambertWSimple(exp(1/(a/V_oc)
+ 1)) else 0;
w =if noEvent(VOC >= Modelica.Constants.eps) then
IBPSA.Electrical.BaseClasses.PV.BaseClasses.lambertWSimple(exp(1/(a/VOC) + 1))
else 0;


// Efficiency and Performance

eta=if noEvent(HGloTil <= Modelica.Constants.eps*10) then 0 else P_mod/(
eta=if noEvent(HGloTil <= Modelica.Constants.eps*10) then 0 else PMod/(
HGloTil*APan);

P_mod = V_mp*I_mp;
PMod = VMP*IMP;

P=max(0, min(PMax*nMod, P_mod*nMod));
P=max(0, min(PMax*nMod, PMod*nMod));

annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},
{100,80}})), Diagram(
Expand Down
28 changes: 19 additions & 9 deletions IBPSA/Electrical/BaseClasses/PV/PartialPVSystem.mo
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
within IBPSA.Electrical.BaseClasses.PV;
partial model PartialPVSystem "Base PV model with internal or external MPP tracking"

extends IBPSA.Electrical.BaseClasses.PV.BaseClasses.Icons.partialPVIcon;

replaceable package PhaseSystem =
IBPSA.Electrical.PhaseSystems.PartialPhaseSystem constrainedby
IBPSA.Electrical.PhaseSystems.PartialPhaseSystem "Phase system"
annotation (choicesAllMatching=true);

replaceable parameter Data.PV.Generic dat constrainedby
IBPSA.Electrical.Data.PV.Generic "PV Panel data definition"
annotation (choicesAllMatching=true);
Expand Down Expand Up @@ -34,6 +38,9 @@ partial model PartialPVSystem "Base PV model with internal or external MPP track
"If true then the zenith angle is needed as input for absorption ratio calculations"
annotation(Dialog(tab="Advanced"), Evaluate=true, HideResult=true);

parameter Boolean use_ter = true
"If true then the electrical terminal connector is used";

parameter Boolean use_incAng = true
"If true then the incidence angle is needed as input for absorption ratio calculations"
annotation(Dialog(tab="Advanced"), Evaluate=true, HideResult=true);
Expand All @@ -53,17 +60,17 @@ partial model PartialPVSystem "Base PV model with internal or external MPP track
"Global irradiation on tilted surface"
annotation (Placement(transformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-70}),
origin={-120,-90}),
iconTransformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-70})));
origin={-120,-90})));
Modelica.Blocks.Interfaces.RealInput TDryBul(final unit="K") "Ambient dry bulb temperature"
annotation (Placement(transformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-10}),
origin={-120,-30}),
iconTransformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-10})));
origin={-120,-30})));
Modelica.Blocks.Interfaces.RealInput vWinSpe(final unit="m/s") "Wind speed" annotation (
Placement(transformation(extent={{-20,-20},{20,20}},
rotation=0,
Expand Down Expand Up @@ -103,18 +110,18 @@ partial model PartialPVSystem "Base PV model with internal or external MPP track
"Global irradiation on horizontal surface" annotation (Placement(
transformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-40}), iconTransformation(extent={{-20,-20},
origin={-120,-60}), iconTransformation(extent={{-20,-20},
{20,20}},
rotation=0,
origin={-120,-40})));
origin={-120,-60})));
Modelica.Blocks.Interfaces.RealInput HDifHor(final unit="W/m2") if use_HDifHor
"Diffuse irradiation on horizontal surface" annotation (Placement(
transformation(extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-100}), iconTransformation(
origin={-120,-120}), iconTransformation(
extent={{-20,-20},{20,20}},
rotation=0,
origin={-120,-100})));
origin={-120,-120})));
Modelica.Blocks.Interfaces.RealInput incAng(final unit="rad") if use_incAng
"Incidence angle of irradiation"
annotation (Placement(transformation(extent={{-140,30},{-100,70}},
Expand All @@ -123,6 +130,9 @@ partial model PartialPVSystem "Base PV model with internal or external MPP track
"Zenith angle of irradiation"
annotation (Placement(transformation(extent={{-140,60},{-100,100}},
rotation=0)));
replaceable Buildings.Electrical.Interfaces.Terminal terminal(
redeclare final package PhaseSystem = PhaseSystem) if use_ter "Generalized terminal"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));

protected
Modelica.Blocks.Interfaces.RealInput Til_in_int
Expand Down
Loading

0 comments on commit 7875491

Please sign in to comment.