You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly, thanks for this well written and concise library - I'm attempting to simulate adiabatic cooling of air and have found this to be very helpful!
I noticed a small bug when iterating through a bunch of scenarios (some purely theoretical states).
Firstly, there is sensible behaviour around RH == 0 behaviour, which generates a math error. As it's practically impossible to have this state, I'm happy with this!
However, if something causes a state calculation to have a WBT < 0 C, or causes the lower wet bulb temp window edge to dip below zero, a type error is thrown because of a None value in the depths of the calculation:
>>> si.state('DBT', 283.15, 'WBT', 273, 101325)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/srv/anaconda2/envs/devicegenerator/lib/python3.6/site-packages/psypy/psySI.py", line
213, in state
W=__W_DBT_WBT_P(DBT, WBT, P)
File "/srv/anaconda2/envs/devicegenerator/lib/python3.6/site-packages/psypy/psySI.py", line
342, in __W_DBT_WBT_P
return ((2501-2.326*WBT)*__W_DBT_RH_P(WBT+273.15,1,P)-1.006*(DBT-WBT))/\
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
and
>>> si.state('DBT', 303.15, 'RH', 0.01, 101325)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/srv/anaconda2/envs/devicegenerator/lib/python3.6/site-packages/psypy/psySI.py", line
222, in state
WBT=__WBT_DBT_W_P(DBT, W, P)
File "/srv/anaconda2/envs/devicegenerator/lib/python3.6/site-packages/psypy/psySI.py", line
352, in __WBT_DBT_W_P
Ws=__W_DBT_WBT_P(DBT, WBT, P)
File "/srv/anaconda2/envs/devicegenerator/lib/python3.6/site-packages/psypy/psySI.py", line
342, in __W_DBT_WBT_P
return ((2501-2.326*WBT)*__W_DBT_RH_P(WBT+273.15,1,P)-1.006*(DBT-WBT))/\
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
This is happening in the following class (psySI.py, lines 337 to 343):
Note that in the return statement of the first class, the Wet Bulb Temperature is being passed to a fn named for the Dry Bulb Temperature, which is then checked against the valid DBT check method. The need for a DBT check is obvious as behaviour of air changes for DBT < 0 C, but unfortunately this causes nothing to be returned from these two classes in the instance that we are passing a -ve C wet bulb temperature.
The same happens here when called from a second class (psySI.py, lines 179 - 187):
Unfortunately I don't have access to the 2009 edition of the ASHRAE handbook - the copy I have here is the older 1993 version with rather different equation numbers!
I originally attempted to pass dry bulb temp in line 342 instead, but that caused my unit tests (sanity checked against values read of the ASHRAE psychrometric chart) to fail and be obviously incorrect. Instead I added optional params to these two broken classes, like so:
I'm writing this story to help other users, if you're happy with this fix I can add a pull request with some logging changes and these improvements implemented.
Thanks,
Tim
The text was updated successfully, but these errors were encountered:
Hi,
Firstly, thanks for this well written and concise library - I'm attempting to simulate adiabatic cooling of air and have found this to be very helpful!
I noticed a small bug when iterating through a bunch of scenarios (some purely theoretical states).
Firstly, there is sensible behaviour around RH == 0 behaviour, which generates a math error. As it's practically impossible to have this state, I'm happy with this!
However, if something causes a state calculation to have a WBT < 0 C, or causes the lower wet bulb temp window edge to dip below zero, a type error is thrown because of a None value in the depths of the calculation:
and
This is happening in the following class (psySI.py, lines 337 to 343):
which calls (psySI.py, lines 326 to 330):
Note that in the return statement of the first class, the Wet Bulb Temperature is being passed to a fn named for the Dry Bulb Temperature, which is then checked against the valid DBT check method. The need for a DBT check is obvious as behaviour of air changes for DBT < 0 C, but unfortunately this causes nothing to be returned from these two classes in the instance that we are passing a -ve C wet bulb temperature.
The same happens here when called from a second class (psySI.py, lines 179 - 187):
Unfortunately I don't have access to the 2009 edition of the ASHRAE handbook - the copy I have here is the older 1993 version with rather different equation numbers!
I originally attempted to pass dry bulb temp in line 342 instead, but that caused my unit tests (sanity checked against values read of the ASHRAE psychrometric chart) to fail and be obviously incorrect. Instead I added optional params to these two broken classes, like so:
lines 179 - 187:
lines 326 - 330:
This allows for sensible handling of low RH and negative wet bulb values, and all unit tests still pass:
and
I'm writing this story to help other users, if you're happy with this fix I can add a pull request with some logging changes and these improvements implemented.
Thanks,
Tim
The text was updated successfully, but these errors were encountered: