iapws.ammonia module - Calculation of density
Closed this issue · 1 comments
Hi all,
while comparing ammonia densities against other property modules I noticed some abnormality around Tc= 405.4K with huge changes in density.
`from iapws import ammonia as iapws
NH3_1 = iapws.NH3(T=273.15+115,P=0.1)
NH3_1.calculo()
print(f"Density at 110°C, 1 bar: {NH3_1.rho} [kg/m³]")
print(f"x = {NH3_1.x}")
#print(f"h = {NH3_1.x} kJ/kg")
NH3_2 = iapws.NH3(T=273.15+130,P=0.1)
NH3_2.calculo()
print(f"Density at 130°C, 1 bar: {NH3_2.rho} [kg/m³]")
print(f"x = {NH3_2.x}")
#print(f"h = {NH3_2.x} kJ/kg")
NH3_3 = iapws.NH3(T=273.15+140,P=0.1)
NH3_3.calculo()
print(f"Density at 140°C, 1 bar: {NH3_3.rho} [kg/m³]")
print(f"x = {NH3_3.x}")`
Best regards,
Florian
Hi, the output in terminal show the problem, the density solver iteration fail, the problem, iapws use the returned value to do the properties calculation
from iapws.ammonia import NH3
ammonia = NH3(T=273.15+130, P=0.1)
print(f"Density at 130°C, 1 bar: {ammonia.rho} [kg/m³]")
print(f"x = {ammonia.x}")
/home/jjgomera/Programacion/iapws/iapws/iapws95.py:141: RuntimeWarning: overflow encountered in exp
fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c)
/home/jjgomera/Programacion/iapws/iapws/iapws95.py:141: RuntimeWarning: invalid value encountered in add
fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c)
/usr/local/lib/python3.9/dist-packages/scipy/optimize/minpack.py:175: RuntimeWarning: The iteration is not making good progress, as measured by the
improvement from the last ten iterations.
warnings.warn(msg, RuntimeWarning)
Density at 130°C, 1 bar: 156.7684068421287 [kg/m³]
x = 1
By the way, the calculo procedure is internal and not necessary call from user.
Dirty solution, define a initial value of density like that:
ammonia = NH3(T=273.15+130,P=0.1, rho0=0.5)
and you get the correct value
Density at 130°C, 1 bar: 0.5097610127632395 [kg/m³]
x = 1
Thanks for report, I have to improve density solver convergence