Name | Description |
---|---|
BaseClasses | Library with base classes for utility functions |
EfficiencyCurves | Package with functions for efficiency curves |
Examples | Collection of models that illustrate model use and test models |
extendedPolynomial | Polynomial that is linearly extended at user specified values |
massFlowRate_dp | Mass flow rate as a function of pressure drop |
polynomial | Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar |
pressureLoss_m_flow | Pressure loss as a function of flow rate |
y = c1 + c2 * x + ... + cN * x^(N-1)where N > 1 and xMin, xMax are parameters. For x < xMin and x > xMax, the polynomial is replaced with a linear function in such a way that the first derivative is continuous everywhere. Extends from Modelica.Icons.Function (Icon for a function).
Type | Name | Default | Description |
---|---|---|---|
Real | c[:] | Polynomial coefficients | |
Real | x | x value | |
Real | xMin | Minimum x value for polynomial | |
Real | xMax | Maximum x value for polynomial |
Type | Name | Description |
---|---|---|
Real | y | y value |
function extendedPolynomial "Polynomial that is linearly extended at user specified values" annotation(derivative=BaseClasses.der_extendedPolynomial); extends Modelica.Icons.Function; input Real[:] c "Polynomial coefficients"; input Real x "x value"; input Real xMin "Minimum x value for polynomial"; input Real xMax "Maximum x value for polynomial"; output Real y "y value"; protected Integer N = size(c,1) "Number of coefficients"; algorithm if x < xMin then y := c[1]; for i in 2:N loop y := y + xMin^(i - 1)*c[i] + (x - xMin)*(i - 1)*xMin^(i - 2)*c[i]; end for; elseif x < xMax then y := c[1]; for i in 2:N loop y := y + x^(i - 1)*c[i]; end for; else y := c[1]; for i in 2:N loop y := y + xMax^(i - 1)*c[i] + (x - xMax)*(i - 1)*xMax^(i - 2)*c[i]; end for; end if; end extendedPolynomial;
Type | Name | Default | Description |
---|---|---|---|
Pressure | dp | Pressure drop (dp = port_a.p - port_b.p) [Pa] | |
AbsolutePressure | dp_small | Turbulent flow if |dp| >= dp_small [Pa] | |
Real | k | Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2) |
Type | Name | Description |
---|---|---|
MassFlowRate | m_flow | Mass flow rate from port_a to port_b [kg/s] |
function massFlowRate_dp "Mass flow rate as a function of pressure drop" extends Modelica.Icons.Function; import SI = Modelica.SIunits; input SI.Pressure dp "Pressure drop (dp = port_a.p - port_b.p)"; input SI.AbsolutePressure dp_small "Turbulent flow if |dp| >= dp_small"; input Real k(min=0) "Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)"; output SI.MassFlowRate m_flow "Mass flow rate from port_a to port_b"; protected Real kk; algorithm kk:=k*k; m_flow:=Modelica_Fluid.Utilities.regRoot2(x=dp, x_small=dp_small, k1=kk, k2=kk); end massFlowRate_dp;
Type | Name | Default | Description |
---|---|---|---|
Real | c[:] | Coefficients | |
Real | x | Independent variable |
Type | Name | Description |
---|---|---|
Real | y | Dependent variable |
function polynomial "Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar" extends Modelica.Icons.Function; input Real[:] c "Coefficients"; input Real x "Independent variable"; output Real y "Dependent variable"; algorithm y := c[1]; for i in 2 : size(c,1) loop y := y + x^(i-1) * c[i]; end for; end polynomial;
Type | Name | Default | Description |
---|---|---|---|
MassFlowRate | m_flow | Mass flow rate from port_a to port_b [kg/s] | |
MassFlowRate | m_small_flow | Mass flow rate where function is approximated [kg/s] | |
Real | k | Flow coefficient, k=dp/m_flow^2 [1/(kg.m)] |
Type | Name | Description |
---|---|---|
Pressure | dp | Pressure drop (dp = port_a.p - port_b.p) [Pa] |
function pressureLoss_m_flow "Pressure loss as a function of flow rate" extends Modelica.Icons.Function; import SI = Modelica.SIunits; input SI.MassFlowRate m_flow "Mass flow rate from port_a to port_b"; input SI.MassFlowRate m_small_flow "Mass flow rate where function is approximated"; input Real k(min=0, unit="1/(kg.m)") "Flow coefficient, k=dp/m_flow^2"; output SI.Pressure dp "Pressure drop (dp = port_a.p - port_b.p)"; algorithm dp:=Modelica_Fluid.Utilities.regSquare2( x=m_flow, x_small=m_small_flow, k1=k, k2=k); end pressureLoss_m_flow;