From 742353abae207d6d4f8ca79b2f846ccb4065edf5 Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 23 Apr 2024 17:25:06 +0200 Subject: [PATCH 1/3] AdditionalSqrt --- Modelica/ComplexBlocks/ComplexMath/ComplexToPolar.mo | 2 +- Modelica/Media/Water/IF97_Utilities.mo | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modelica/ComplexBlocks/ComplexMath/ComplexToPolar.mo b/Modelica/ComplexBlocks/ComplexMath/ComplexToPolar.mo index e9db7bb423..018710de5f 100644 --- a/Modelica/ComplexBlocks/ComplexMath/ComplexToPolar.mo +++ b/Modelica/ComplexBlocks/ComplexMath/ComplexToPolar.mo @@ -12,7 +12,7 @@ block ComplexToPolar "Converts complex to polar representation" parameter Boolean useConjugateInput=false "If true, input is processed conjugate complex"; equation - len = (u.re^2 + u.im^2)^0.5; + len = sqrt(u.re^2 + u.im^2); phi = (if useConjugateInput then Modelica.Math.atan2(-u.im, u.re) else Modelica.Math.atan2(u.im, u.re)); diff --git a/Modelica/Media/Water/IF97_Utilities.mo b/Modelica/Media/Water/IF97_Utilities.mo index 588d2df33f..ac736f5d5a 100644 --- a/Modelica/Media/Water/IF97_Utilities.mo +++ b/Modelica/Media/Water/IF97_Utilities.mo @@ -229,7 +229,7 @@ email: hubertus@modelon.se "IF97 medium function boundary23ofp called with too low pressure\n" + "p = " + String(p) + " Pa <= " + String(triple.ptriple) + " Pa (triple point pressure)"); - t := n[4] + ((pi - n[5])/n[3])^0.5; + t := n[4] + sqrt((pi - n[5])/n[3]); end boundary23ofp; function hlowerofp5 From 853c68edda631903d14c0075952b8e1bf82fa6ef Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 30 Apr 2024 14:12:55 +0200 Subject: [PATCH 2/3] More sqrt; have review all. Remaining are: documentation, or combined with other fractional exponents. --- Modelica/ComplexMath.mo | 2 +- Modelica/Fluid/Dissipation.mo | 8 ++++---- Modelica/Media/Water/IF97_Utilities.mo | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modelica/ComplexMath.mo b/Modelica/ComplexMath.mo index f29ef9ef7a..209081eedf 100644 --- a/Modelica/ComplexMath.mo +++ b/Modelica/ComplexMath.mo @@ -488,7 +488,7 @@ end Vectors; input Complex c "Complex number"; output Real result "= abs(c)"; algorithm - result := (c.re^2 + c.im^2)^0.5; //changed from sqrt + result := .sqrt(c.re^2 + c.im^2); // Real, not complex sqrt annotation(Inline=true, Documentation(info="

This function returns the Real absolute of the Complex input, i.e., its length.

")); diff --git a/Modelica/Fluid/Dissipation.mo b/Modelica/Fluid/Dissipation.mo index b625ae2cf8..a87c490e73 100644 --- a/Modelica/Fluid/Dissipation.mo +++ b/Modelica/Fluid/Dissipation.mo @@ -4417,9 +4417,9 @@ This record is used as input record for the pressure loss funct DP := 0.5*IN_var.zeta_TOT* Modelica.Fluid.Dissipation.Utilities.Functions.General.SmoothPower( m_flow, - (IN_con.dp_smooth/(0.5*IN_var.zeta_TOT*IN_var.rho))^0.5*IN_var.rho + sqrt(IN_con.dp_smooth/(0.5*IN_var.zeta_TOT*IN_var.rho))*IN_var.rho *IN_con.A_cross, - 2)/(IN_var.rho*(IN_con.A_cross)^2); + 2)/(IN_var.rho*sqrt(IN_con.A_cross)); annotation (Inline=true, smoothOrder(normallyConstant=IN_con) = 2, inverse(m_flow=Modelica.Fluid.Dissipation.PressureLoss.General.dp_pressureLossCoefficient_MFLOW( IN_con, @@ -4463,7 +4463,7 @@ Generally this function is numerically best used for the incompressible Modelica.Fluid.Dissipation.Utilities.Functions.General.SmoothPower( dp, IN_con.dp_smooth, - 0.5)/(0.5*IN_var.zeta_TOT*IN_var.rho)^0.5; + 0.5)/sqrt(0.5*IN_var.zeta_TOT*IN_var.rho); annotation (Inline=true, smoothOrder(normallyConstant=IN_con) = 2, inverse(dp=Modelica.Fluid.Dissipation.PressureLoss.General.dp_pressureLossCoefficient_DP( IN_con, @@ -12865,7 +12865,7 @@ In the picture below the input x is increased from 0 to 1. The range of interpol "Rectangular cross sectional area", enable=geometry == Modelica.Fluid.Dissipation.Utilities.Types.GeometryOfInternalFlow.Rectangular)); //triangular(5) - SI.Length a_tri=d_cir*(1 + 2^0.5) "Length of base line" annotation (Dialog( + SI.Length a_tri=d_cir*(1 + sqrt(2)) "Length of base line" annotation (Dialog( group="Rectangular cross sectional area", enable=geometry == Modelica.Fluid.Dissipation.Utilities.Types.GeometryOfInternalFlow.Rectangular)); SI.Length h_tri=0.5*a_tri diff --git a/Modelica/Media/Water/IF97_Utilities.mo b/Modelica/Media/Water/IF97_Utilities.mo index ac736f5d5a..40e9eaa17c 100644 --- a/Modelica/Media/Water/IF97_Utilities.mo +++ b/Modelica/Media/Water/IF97_Utilities.mo @@ -423,7 +423,7 @@ email: hubertus@modelon.se "IF97 medium function hlowerofp2 called with too low pressure\n" + "p = " + String(p) + " Pa <= " + String(triple.ptriple) + " Pa (triple point pressure)"); - q1 := 572.54459862746 + 31.3220101646784*(-13.91883977887 + pi)^0.5; + q1 := 572.54459862746 + 31.3220101646784*sqrt(-13.91883977887 + pi); q2 := -0.5 + 540./q1; o[1] := q1*q1; o[2] := o[1]*o[1]; @@ -514,7 +514,7 @@ email: hubertus@modelon.se "IF97 medium function slowerofp2 called with too low pressure\n" + "p = " + String(p) + " Pa <= " + String(triple.ptriple) + " Pa (triple point pressure)"); - q1 := 572.54459862746 + 31.3220101646784*(-13.91883977887 + pi)^0.5; + q1 := 572.54459862746 + 31.3220101646784*sqrt(-13.91883977887 + pi); q2 := -0.5 + 540.0/q1; o[1] := pi*pi; o[2] := o[1]*pi; @@ -3143,9 +3143,9 @@ email: hubertus@modelon.se o[7] := 14.9151086135300*o[6]; o[8] := 405113.40542057 + o[5] + o[7]; p_sat := 16.0e6*o[8]*o[8]*o[8]*o[8]*1/(3.2325550322333e6 - - 12020.8247024700*o[4] + 17.0738469400920*o[6] + (-4.0*(-724213.16703206 + 12020.8247024700*o[4] + 17.0738469400920*o[6] + sqrt(-4.0*(-724213.16703206 + 1167.05214527670*o[4] + o[6])*o[8] + (-3.2325550322333e6 + - 12020.8247024700*o[4] - 17.0738469400920*o[6])^2.0)^0.5)^4.0; + 12020.8247024700*o[4] - 17.0738469400920*o[6])^2.0))^4.0; annotation (derivative=psat_der); end psat; @@ -4093,7 +4093,7 @@ Ordinary Water Substance
deltam1 := delta - 1.0; tau := tstar/T; taum1 := tau - 1.0; - Psi0 := 1/(n0 + (n1 + (n2 + n3*tau)*tau)*tau)/(tau^0.5); + Psi0 := 1/(n0 + (n1 + (n2 + n3*tau)*tau)*tau)/(sqrt(tau)); Psi1 := 0.0; tfun := 1.0; for i in 1:6 loop From ce824c7759c1dbf52db6e74578f55214e5be1a37 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Thu, 2 May 2024 08:58:27 +0200 Subject: [PATCH 3/3] Update Modelica/Fluid/Dissipation.mo --- Modelica/Fluid/Dissipation.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modelica/Fluid/Dissipation.mo b/Modelica/Fluid/Dissipation.mo index a87c490e73..58c62718ea 100644 --- a/Modelica/Fluid/Dissipation.mo +++ b/Modelica/Fluid/Dissipation.mo @@ -4419,7 +4419,7 @@ This record is used as input record for the pressure loss funct m_flow, sqrt(IN_con.dp_smooth/(0.5*IN_var.zeta_TOT*IN_var.rho))*IN_var.rho *IN_con.A_cross, - 2)/(IN_var.rho*sqrt(IN_con.A_cross)); + 2)/(IN_var.rho*(IN_con.A_cross)^2); annotation (Inline=true, smoothOrder(normallyConstant=IN_con) = 2, inverse(m_flow=Modelica.Fluid.Dissipation.PressureLoss.General.dp_pressureLossCoefficient_MFLOW( IN_con,