psychrometrics / psychrolib

📚 Library of psychrometric functions to calculate 🌡️ thermodynamic properties of air for Python, C, C#, Fortran, R, JavaScript and VBA/Excel
MIT License
228 stars 61 forks source link

Initial guess of bisection loop of GetTWetBulbFromHumRatio leading to an error for high dry bulb temperatures and high humidity ratios #96

Open hsallandt-arup opened 1 year ago

hsallandt-arup commented 1 year ago

Describe the bug Dry bulb temperature returned by GetTWetBulbFromHumRatio for high dry bulb temperatures and high humidity ratios.

To Reproduce Steps to reproduce the behavior: psychrolib.GetTWetBulbFromHumRatio(150, 1,101325) returns 149.9995190883829

Expected behavior The wet bulb temperature should not exceed 100°C at standard sea level pressure.

Additional context The issue is created by the lines and following code. The bisection loop starts with the maximum theoretical wet bulb temperature (WBT) and minimum theoretical WBT as initial bounds. Min WBT --> dew point Max WBT --> dry bulb temperature The latter is not correct (for dry bulb temperatures >100°C at this pressure), as at standard sea level pressure, the WBT cannot exceed ~100°C. The code then takes the average of the min and max WBT and starts the iteration. If the average of dew point and dry bulb temperature is higher than the maximum possible WBT at this pressure, this line returns 0 and therefore the error occurs: error

A solution would be to set initially the max WBT to the minimum of the dry bulb temperature and the boiling temperature of water at the given pressure.

didierthevenard commented 1 year ago

Thanks for that, definitely a but. Actually, any calculation with dry bulb temperature > 100 C and relative humidity above a certain level leads to values that don't make sense. We are due to fix a few other bugs soon and we'll add that one to the list. I think the fix you suggest will work but we'll confirm with more tests.