Skip to content

Commit

Permalink
Add comments and do refactoring #1575
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraMaier committed Oct 6, 2023
1 parent e9c9b31 commit 0100780
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 417 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ equation
zen = if zenAng <= Modelica.Constants.pi/2 then
zenAng
else
Modelica.Constants.pi/2;
Modelica.Constants.pi/2 "Zenith angle";

airMas =
exp(-0.0001184*alt)/(cos(zen) + 0.5057*(96.080 -
zen*180/Modelica.Constants.pi)^(-1.634));
zen*180/Modelica.Constants.pi)^(-1.634)) "Air mass";

annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ block AirMassModifier
"This block computes the air mass modifier based on selected PV technology"
extends Modelica.Blocks.Icons.Block;

parameter IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType PVTechType=IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.
MonoSI "Type of PV technology";
parameter PVType PVTecTyp=IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
"Type of PV technology";

Modelica.Blocks.Interfaces.RealInput airMas(final unit="1") "Air mass of atmosphere"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
Expand All @@ -14,43 +14,37 @@ block AirMassModifier

// Air mass parameters based on PV technology. Mono-Si technology as default value
protected
parameter Real b_0=
if PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI then 0.935823
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI then 0.918093
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI then 0.938110
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous then 1.10044085
else 0.935823;
parameter Real b_1=
if PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI then 0.054289
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI then 0.086257
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI then 0.062191
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous then -0.06142323
else 0.054289;
parameter Real b_2=
if PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI then -0.008677
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI then -0.024459
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI then -0.015021
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous then -0.00442732
else -0.008677;
parameter Real b_3=
if PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI then 0.000527
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI then 0.002816
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI then 0.001217
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous then 0.000631504
else 0.000527;
parameter Real b_4=
if PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI then -0.000011
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI then -0.000126
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI then -0.000034
elseif PVTechType ==IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous then -0.000019184
else -0.000011;
parameter Real b0=if PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
then 0.935823 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI
then 0.918093 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI
then 0.938110 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous
then 1.10044085 else 0.935823 "Regression parameter 0 to calculate air mass modifier";
parameter Real b1=if PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
then 0.054289 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI
then 0.086257 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI
then 0.062191 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous
then -0.06142323 else 0.054289 "Regression parameter 1 to calculate air mass modifier";
parameter Real b2=if PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
then -0.008677 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI
then -0.024459 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI
then -0.015021 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous
then -0.00442732 else -0.008677 "Regression parameter 2 to calculate air mass modifier";
parameter Real b3=if PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
then 0.000527 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI
then 0.002816 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI
then 0.001217 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous
then 0.000631504 else 0.000527 "Regression parameter 3 to calculate air mass modifier";
parameter Real b4=if PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
then -0.000011 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.PolySI
then -0.000126 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThinFilmSI
then -0.000034 elseif PVTecTyp == IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.ThreeJuncAmorphous
then -0.000019184 else -0.000011 "Regression parameter 4 to calculate air mass modifier";

equation

airMasMod = if (b_0 + b_1*(airMas^1) + b_2*(airMas^2) + b_3*(
airMas^3) + b_4*(airMas^4)) <= 0 then
0 else
b_0 + b_1*(airMas^1) + b_2*(airMas^2) + b_3*(airMas^3) + b_4*(airMas^4);
airMasMod =if (b0 + b1*(airMas^1) + b2*(airMas^2) + b3*(airMas^3) + b4*(airMas^4)) <=
0 then 0 else b0 + b1*(airMas^1) + b2*(airMas^2) + b3*(airMas^3) + b4*(
airMas^4);

annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,27 @@ within IBPSA.Electrical.BaseClasses.PV.BaseClasses;
partial model PartialPVElectrical
"Partial electrical model for PV module model"

replaceable parameter IBPSA.Electrical.Data.PV.Generic data constrainedby
replaceable parameter Data.PV.Generic dat constrainedby
IBPSA.Electrical.Data.PV.Generic "PV Panel data definition"
annotation (choicesAllMatching);

// Adjustable parameters

parameter Integer n_mod "Number of connected PV modules";
parameter Integer nMod "Number of connected PV modules";

final parameter Modelica.Units.SI.Area A_mod=data.A_mod
final parameter Modelica.Units.SI.Area AMod=dat.AMod
"Area of one module (housing)";

final parameter Integer n_ser=data.n_ser
final parameter Integer nSer=dat.nSer
"Number of cells connected in series on the PV panel";

final parameter Integer n_par = data.n_par
final parameter Integer nPar=dat.nPar
"Number of parallel connected cells within the PV module";

final parameter Real Eg0(
unit = "eV") = data.Eg0
final parameter Real Eg0(unit="eV") = dat.Eg0
"Band gap energy under standard conditions";

Modelica.Units.SI.ElectricCurrent I_ph
"Photo current";
Modelica.Units.SI.ElectricCurrent IPh "Photo current";
Modelica.Blocks.Interfaces.RealInput TCel(final unit="K",final displayUnit="degC")
"Cell temperature"
annotation (Placement(transformation(extent={{-140,30},{-100,70}})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@ within IBPSA.Electrical.BaseClasses.PV.BaseClasses;
partial model PartialPVElectricalSingleDiode
"Partial electrical model for PV module model following the single diode approach"
extends IBPSA.Electrical.BaseClasses.PV.BaseClasses.PartialPVElectrical(
redeclare IBPSA.Electrical.Data.PV.SingleDiodeData data);
redeclare IBPSA.Electrical.Data.PV.SingleDiodeData dat);

replaceable parameter IBPSA.Electrical.Data.PV.SingleDiodeData data
replaceable parameter Data.PV.SingleDiodeData dat
constrainedby IBPSA.Electrical.Data.PV.SingleDiodeData
"PV Panel data definition" annotation (choicesAllMatching);

// Parameters from module data sheet

protected
final parameter Modelica.Units.SI.Efficiency eta_0=data.eta_0
final parameter Modelica.Units.SI.Efficiency eta0=dat.eta0
"Efficiency under standard conditions";

final parameter Modelica.Units.SI.Area A_pan=data.A_pan
final parameter Modelica.Units.SI.Area APan=dat.APan
"Area of one Panel, must not be confused with area of the whole module";

final parameter Modelica.Units.SI.Voltage V_oc0=data.V_oc0
final parameter Modelica.Units.SI.Voltage VOC0=dat.VOC0
"Open circuit voltage under standard conditions";

final parameter Modelica.Units.SI.ElectricCurrent I_sc0=data.I_sc0
final parameter Modelica.Units.SI.ElectricCurrent ISC0=dat.ISC0
"Short circuit current under standard conditions";

final parameter Modelica.Units.SI.Voltage V_mp0=data.V_mp0
final parameter Modelica.Units.SI.Voltage VMP0=dat.VMP0
"MPP voltage under standard conditions";

final parameter Modelica.Units.SI.ElectricCurrent I_mp0=data.I_mp0
final parameter Modelica.Units.SI.ElectricCurrent IMP0=dat.IMP0
"MPP current under standard conditions";

final parameter Modelica.Units.SI.Power P_Max=data.P_mp0*1.05
final parameter Modelica.Units.SI.Power PMax=dat.PMP0*1.05
"Maximal power of one PV module under standard conditions. P_MPP with 5 perc tolerance. This is used to limit DCOutputPower.";

final parameter Real TCoeff_Isc(unit = "A/K")=data.TCoeff_Isc
"Temperature coefficient for short circuit current, >0";
final parameter Real TCoeISC(unit="A/K") = dat.TCoeISC
"Temperature coefficient for short circuit current, >0";

final parameter Real TCoeff_Voc(unit = "V/K")=data.TCoeff_Voc
"Temperature coefficient for open circuit voltage, <0";
final parameter Real TCoeVOC(unit="V/K") = dat.TCoeVOC
"Temperature coefficient for open circuit voltage, <0";

final parameter Modelica.Units.SI.LinearTemperatureCoefficient alpha_Isc=data.alpha_Isc
final parameter Modelica.Units.SI.LinearTemperatureCoefficient alphaISC=dat.alphaISC
"Normalized temperature coefficient for short circuit current, >0";

final parameter Modelica.Units.SI.LinearTemperatureCoefficient beta_Voc=data.beta_Voc
final parameter Modelica.Units.SI.LinearTemperatureCoefficient betaVOC=dat.betaVOC
"Normalized temperature coefficient for open circuit voltage, <0";

final parameter Modelica.Units.SI.LinearTemperatureCoefficient gamma_Pmp=data.gamma_Pmp
final parameter Modelica.Units.SI.LinearTemperatureCoefficient gammaPMP=dat.gammaPMP
"Normalized temperature coefficient for power at MPP";

final parameter Modelica.Units.SI.Temperature TCel0 = 25.0 + 273.15
Expand Down
11 changes: 5 additions & 6 deletions IBPSA/Electrical/BaseClasses/PV/BaseClasses/PartialPVOptical.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ within IBPSA.Electrical.BaseClasses.PV.BaseClasses;
partial model PartialPVOptical


parameter BaseClasses.PVOptical.PVType PVTechType=
IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
parameter PVOptical.PVType PVTecTyp=IBPSA.Electrical.BaseClasses.PV.BaseClasses.PVOptical.PVType.MonoSI
"Type of PV technology";

parameter Boolean use_Til_in = false
Expand Down Expand Up @@ -38,14 +37,14 @@ Modelica.Blocks.Interfaces.RealInput tilSet(final unit="rad") if use_Til_in
extent={{-140,-80},{-100,-40}})));

protected
Modelica.Blocks.Interfaces.RealInput Til_in_internal
"Needed to connect to conditional tilt connector";
Modelica.Blocks.Interfaces.RealInput Til_in_int
"Needed to connect to conditional tilt connector";

equation
connect(tilSet, Til_in_internal);
connect(tilSet, Til_in_int);

if not use_Til_in then
Til_in_internal = til;
Til_in_int = til;
end if;

annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
within IBPSA.Electrical.BaseClasses.PV.BaseClasses;
partial model PartialPVThermal
"Partial model for computing the cell temperature of a PV moduleConnector for PV record data"
replaceable parameter IBPSA.Electrical.Data.PV.Generic data constrainedby
IBPSA.Electrical.Data.PV.Generic
"PV Panel data definition"
replaceable parameter Data.PV.Generic dat constrainedby
IBPSA.Electrical.Data.PV.Generic "PV Panel data definition"
annotation (choicesAllMatching);
Modelica.Blocks.Interfaces.RealOutput TCel(final unit="K", final displayUnit="degC")
"Cell temperature"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ partial model PartialPVThermalEmp
"Empirical thermal models for PV cells to calculate cell temperature"
extends IBPSA.Electrical.BaseClasses.PV.BaseClasses.PartialPVThermal;

final parameter Modelica.Units.SI.Temperature T_NOCT=data.T_NOCT
final parameter Modelica.Units.SI.Temperature TNOCT=dat.TNOCT
"Cell temperature under NOCT conditions";

final parameter Modelica.Units.SI.Irradiance HNOCT= 800
Expand Down
31 changes: 17 additions & 14 deletions IBPSA/Electrical/BaseClasses/PV/PVElectricalSingleDiodeMPP.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ model PVElectricalSingleDiodeMPP "Analytical 5-p model for PV I-V characteristic
constant Real q(unit = "C")= 1.602176620924561e-19
"Elementary charge";

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

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

Expand All @@ -52,40 +53,42 @@ equation

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

a_0 = V_oc0*(1-TCel0*beta_Voc)/(50.1-TCel0*alpha_Isc);
a_0 =VOC0*(1 - TCel0*betaVOC)/(50.1 - TCel0*alphaISC);

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

R_s0 = (a_0*(w_0-1)-V_mp0)/I_mp0;
R_s0 =(a_0*(w_0 - 1) - VMP0)/IMP0;

R_sh0 = a_0*(w_0-1)/(I_sc0*(1-1/w_0)-I_mp0);
R_sh0 =a_0*(w_0 - 1)/(ISC0*(1 - 1/w_0) - IMP0);

I_ph0 = (1+R_s0/R_sh0)*I_sc0;
I_ph0 =(1 + R_s0/R_sh0)*ISC0;

I_s0 = I_ph0*exp(-1/(a_0/V_oc0));
I_s0 =I_ph0*exp(-1/(a_0/VOC0));

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

a/a_0 = TCel/TCel0;

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

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

R_s = R_s0;

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

R_sh/R_sh0 = 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 I_ph*(1-1/w)-a*(w-1)/R_sh;
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;

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

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

w = if noEvent(V_oc >= Modelica.Constants.eps) then
IBPSA.Electrical.BaseClasses.PV.BaseClasses.lambertWSimple(exp(1/(a/V_oc)
Expand All @@ -95,11 +98,11 @@ equation
// Efficiency and Performance

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

P_mod = V_mp*I_mp;

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

annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},
{100,80}})), Diagram(
Expand Down
Loading

0 comments on commit 0100780

Please sign in to comment.