Skip to content

Commit

Permalink
Add simlpified Lambert W function #1575
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraMaier committed Oct 11, 2022
1 parent 5014b4d commit 3125854
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions IBPSA/Electrical/BaseClasses/PVSystem/BaseClasses.mo
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ package BaseClasses "Base parameters for PV Model"

partial model PartialPVOptical
Modelica.Blocks.Interfaces.RealInput HGloHor annotation (Placement(
transformation(extent={{-122,-16},{-90,16}}), iconTransformation(
extent={{-122,-16},{-90,16}})));
transformation(extent={{-132,-16},{-100,16}}),iconTransformation(
extent={{-132,-16},{-100,16}})));
Modelica.Blocks.Interfaces.RealOutput absRadRat
"Ratio of absorbed radiation under operating conditions to standard conditions"
annotation (Placement(transformation(extent={{94,42},{114,62}})));
annotation (Placement(transformation(extent={{100,42},{120,62}})));
Modelica.Blocks.Interfaces.RealOutput radTil
"Total solar radiation on the tilted surface"
annotation (Placement(transformation(extent={{94,-60},{114,-40}})));
annotation (Placement(transformation(extent={{100,-60},{120,-40}})));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(
extent={{-78,76},{-22,24}},
Expand All @@ -138,6 +138,21 @@ package BaseClasses "Base parameters for PV Model"
coordinateSystem(preserveAspectRatio=false)));
end PartialPVOptical;

function lambertWSimple
"Simple approximation for Lambert W function for x >= 2, should only
be used for large input values as error decreases for increasing input values"

input Real x(min=2);
output Real W;

algorithm
W:= log(x)*(1-log(log(x))/(log(x)+1));
annotation (Documentation(info="<html>
<p><span style=\"font-family: Roboto; color: #202124; background-color: #ffffff;\">The Lambert W function solves mathematical equations in which the unknown is both inside and outside of an exponential function or a logarithm.</span></p>
<p>This function is a simple approximation for Lambert W function following Baetzelis, 2016:</p>
</html>"));
end lambertWSimple;

package Icons
partial model partialPVIcon "Partial model for basic PV model icon"
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Expand Down

0 comments on commit 3125854

Please sign in to comment.