UWG model simulation failed

  1. Solution exception:The UWG failed to run:
    UWG model simulation failed.
    math domain error
    Traceback (most recent call last):
    File “C:\Users\Mohammad El-Ghandour\ladybug_tools\python\lib\site-packages\uwg\cli\simulate.py”, line 50, in simulate_json_model
    uwg_model.simulate()
    File “C:\Users\Mohammad El-Ghandour\ladybug_tools\python\lib\site-packages\uwg\uwg.py”, line 1352, in simulate
    self.RSM)
    File “C:\Users\Mohammad El-Ghandour\ladybug_tools\python\lib\site-packages\uwg\urbflux.py”, line 38, in urbflux
    BEM[j].building.BEMCalc(UCM, BEM[j], forc, parameter, simTime)
    File “C:\Users\Mohammad El-Ghandour\ladybug_tools\python\lib\site-packages\uwg\building.py”, line 539, in BEMCalc
    psychrometrics(self.indoor_temp, self.indoor_hum, forc.pres)
    File “C:\Users\Mohammad El-Ghandour\ladybug_tools\python\lib\site-packages\uwg\psychrometrics.py”, line 52, in psychrometrics
    alpha = log(_pw)
    ValueError: math domain error

I am trying to create a simulation but I receive this error
Kindly does anyone know the reason for it? I need some help

Hey @Mohammad.ElGhandour ,

Thanks for reporting and it looks like you might have found a bug (or at least a limitation) in the psychrometric calculations performed by the Urban Weather Generator (UWG). You can see that this is the specific line of code where things are failing:

And I imagine that we’re somehow trying to take the log of a negative number. It’s possible that this results from something odd about the EPW file that you are trying to morph for urban heat island. Would you be able to share this EPW file so that we can see whether there’s something erroneous about it? If the EPW all looks good, then I imagine that we could implement a patch for this case in the UWG.

CC: @SaeranVasanthakumar , @josephyang

These kinds of errors could just be part of the general limitations of the finite difference approach, which can be derailed by big swings in input data, coarse discretizations, or rounding errors caused by our floating point tolerances.

The domain of log excludes 0, so I think a very small increment that gets rounded to 0 is definitely likely. Trying to figure out what caused that error is tricky though, since it could be caused by something several timesteps prior, by any of the values contributing to the heat balance.

There are solutions, or improvements that can be made to the code to fix this (a simple one may be to include a warm-up period so the starting conditions), however, in the past I’ve usually found the error occurs when users use extreme input values, that aren’t intended to be modeled by the UWG.

This could be the case here. In the error screenshot, I noticed there seems to be some extreme values for inputs that don’t align with the kind of urban conditions needed for the UWG:

image

@Mohammad.ElGhandour are these the values you’re actually using as inputs to the simulation? If not, can you share your inputs?

Thanks Chris for your consideration.

These are the two epw files that I used.
https://energyplus-weather.s3.amazonaws.com/africa_wmo_region_1/EGY/EGY_Cairo.623660_IWEC/EGY_Cairo.623660_IWEC.zip

https://energyplus-weather.s3.amazonaws.com/africa_wmo_region_1/EGY/EGY_Helwan.623780_ETMY/EGY_Helwan.623780_ETMY.zip

Many thanks for your consideration.
Kindly find my rhino and gh files in this link

Just a side note, if you’re using this for work, do try to use the updated ones from https://climate.onebuilding.org/. Especially for the Helwan file, the data is all from 1960’s.

1 Like

Good catch, @SaeranVasanthakumar . Having a building footprint area near zero seems to be the reason why everything was failing and it’s definitely not realistic.

@Mohammad.ElGhandour ,
You really need to check the outputs of the components since you were joining the entire urban area into a single building, thereby resulting in a building footprint from only one of your solid geometries. For your UWG simulation, I wouldn’t bother with separating the ground stories to make them Retail until you have gotten a better sense of data list/tree management in Grasshopper and a better understanding of the Dragonfly Room/Story/Building object hierarchy described in this tutorial:

You’re just going to be making your simulation less accurate unless you understand what you are doing with each component.

I also just wouldn’t put in a detailed terrain surface that includes all of this area outside of the actual buildings and you should probably watch this tutorial on simulation with the UWG in particular:

Here’s a version of your file that runs successfully:
UWGmodel.gh (1.0 MB)

Many many thanks for your feedback, I really appreciate it so much. I wish you the best really, Thanks again!!

Dear @chris,

Two years after creating this topic, I encountered the same error. I was generating various urban morphed files using the UWG, but at a certain point (which I’m unsure about what has changed), I started getting the following error:

1. Solution exception: The UWG failed to run:
   UWG model simulation failed.
   math domain error
   Traceback (most recent call last):
   File "C:\Users\remotoB\ladybug_tools\python\lib\site-packages\uwg\cli\simulate.py", line 50, in simulate_json_model
      uwg_model.simulate()
   File "C:\Users\remotoB\ladybug_tools\python\lib\site-packages\uwg\uwg.py", line 1353, in simulate
      self.UCM, self.UBL, self.BEM = urbflux(
   File "C:\Users\remotoB\ladybug_tools\python\lib\site-packages\uwg\urbflux.py", line 38, in urbflux
      BEM[j].building.BEMCalc(UCM, BEM[j], forc, parameter, simTime)
   File "C:\Users\remotoB\ladybug_tools\python\lib\site-packages\uwg\building.py", line 542, in BEMCalc
      psychrometrics(self.indoor_temp, self.indoor_hum, forc.pres)
   File "C:\Users\remotoB\ladybug_tools\python\lib\site-packages\uwg\psychrometrics.py", line 58, in psychrometrics
      pow(_pw, 0.1984) * 0.4569  # valid for Tdp between 0 C and 93 C
   ValueError: math domain error

I’ve tried all the suggested solutions, such as upgrading, uninstalling, and reinstalling. I even tested the sample file you provided (both UWGmodel.gh and uwg_example.gh).

At this point, I’m not sure what else to try, so I’m posting here to ask if anyone has any suggestions. Since this used to work previously, even with a large urban file, I suspect something might have changed in my personal settings or system.

Any help would be greatly appreciated!

Thanks in advance,
Ali

Hi all,
I get the same error when running the uwg_example.
Could anybody help us?
Thanks in advance,
Patricia

@PatriciaEdithCampore

If you open the gh file exemple without opening Rhino first, your rhino model unit could be in millimeters.
Try this :
Open new rhino file
Check the unit (put it in meters if it’s not the case)
Open grasshopper
Run gh file

What @SaeranVasanthakumar said is the key I guess : “The domain of log excludes 0, so I think a very small increment that gets rounded to 0 is definitely likely”. A rhino model in millimeters is likely 0 for this kind of simulation

Let me know if I’m wrong on this one

Thank you Damien but that is not why it fails. My model is in meters