CenterForTheBuiltEnvironment / pythermalcomfort

Package to calculate several thermal comfort indices (e.g. PMV, PPD, SET, adaptive) and convert physical variables.
https://pythermalcomfort.readthedocs.io/en/latest/
MIT License
142 stars 52 forks source link

Differences between cooling_effect.py and calcCE.R #142

Open number9527-12 opened 1 week ago

number9527-12 commented 1 week ago

Here are the differences we found between the Python package and the R package for calculating the cooling effect:

Determination of wind speed conditions

In python, When the wind speed is less than or equal to 0.1 m/s, the cooling effect is directly returned to 0. link

    if vr <= 0.1:
        return 0

In R, A wind speed threshold of 0.2 m/s is used, if the wind speed is below this value, the cooling effect is 0. link

   if (vel <= 0.2){
   ce = 0
   warning('For velocity less than or equal to 0.2, cooling effect is Zero')
   print(paste0("Cooling Effect: ", ce ))
  }

Calculation logic of cooling effect

In python, Use the scipy.optimize.brentq function to perform a bisection root search in the interval [0, 40]. link

ce = optimize.brentq(function, 0.0, 40)

In R, Use a custom bisect function to perform a bisection root search in the interval [0, 15] link

ce = bisect(f,0,15)

The Python version searches in the interval [0, 40], while the R version searches in the interval [0, 15]. This may cause the R version to fail to find the solution correctly at higher temperature differences. I did reduce the number of cases where I failed after changing to [0, 40] in R.

Output issues

In python, Use the round() function to round the result to two decimal places. link

return round(ce, 2)

In R, The ce value is not returned, so there will be some problems when testing. We have corrected it and kept it consistent. link

print(paste0("Cooling Effect: ", lapply(ce, round,2)))
FedericoTartarini commented 1 week ago

@marcelschweiker in the 2024 version of the ASHRAE 55 the wind speed has been changed to 0.1m/s therefore we should update it in R.

marcelschweiker commented 1 day ago

@FedericoTartarini Yes, agree