ladybug-tools / uwg

:city_sunrise: The Urban Weather Generator (uwg) is a Python application for modeling the urban heat island effect.
https://www.ladybug.tools/uwg/docs/
GNU General Public License v3.0
48 stars 24 forks source link

Error in saturation_pressure calculation #262

Open biglimp opened 2 years ago

biglimp commented 2 years ago

I am experiencing an error where a log of zero or a negative value probably happens. Input files are attached.

Version of uwg according to pip list is 5.8.7 (using uwg.version gives me 5.4.3, maybe needs to be updated?).

The region is Gothenburg, Sweden and I have successfully run uwg on similar settings (also attached). I assume there is something strange with the Warehouse building type?

model.simulate()
File "C:\OSGeo4W\apps\Python39\lib\site-packages\uwg\uwg.py", line 1350, in simulate
self.UCM, self.UBL, self.BEM = urbflux(
File "C:\OSGeo4W\apps\Python39\lib\site-packages\uwg\urbflux.py", line 38, in urbflux
BEM[j].building.BEMCalc(UCM, BEM[j], forc, parameter, simTime)
File "C:\OSGeo4W\apps\Python39\lib\site-packages\uwg\building.py", line 539, in BEMCalc
psychrometrics(self.indoor_temp, self.indoor_hum, forc.pres)
File "C:\OSGeo4W\apps\Python39\lib\site-packages\uwg\psychrometrics.py", line 41, in psychrometrics
Pws = saturation_pressure(Tdb) # Get saturation pressure for given Tdb
File "C:\OSGeo4W\apps\Python39\lib\site-packages\uwg\psychrometrics.py", line 77, in saturation_pressure
6.5459673 * log(T)) # Pa
ValueError: math domain error

error.zip success.zip

saeranv commented 2 years ago

@biglimp are you making a custom building type?

biglimp commented 2 years ago

No, I am using the existing ones from the pickle coming with the pypi downlaod.

saeranv commented 2 years ago

@biglimp this is something that we've run into before (there's a note in the code about it).

The problem may be due to large timesteps (i.e. 3600s) causing instability in the numerical differentiation. Is your timestep very large, and if so, can you try rerunning with something smaller, like 300s?

And I agree, best to update UWG to its latest version.

biglimp commented 2 years ago

Timesteps (dtSim) is already in 300s. I also tried to change the building type to MidRiseApartments but still the same error.

biglimp commented 2 years ago

Some additional information. I played around a bit and found that if I increased the verToHor parameter I could run the files in error.zip without error. The error area has a few large footprint buildings which might cause the model to fail...

biglimp commented 2 years ago

Any updates on this issue?

I debugged the code a bit more using the input in the attached error.zip and found out that it is the quickservicerestaurant building class that is causing the issue. This class is unstable using low verToHor numbers creating T_wallex and T_wallin to become very large negative numbers, which in turn finally cause the saturation pressure calculation too fail.

Why is building classes with no fractions in the uwg-file included in the calculation in the first place?

PetitMote commented 2 years ago

Hi, Just to say I ran into this error too. Increasing verToHor to 0.2 was enough to proceed to the calculation, but it’s a poor way to solve the issue.