architecture-building-systems / CityEnergyAnalyst

The City Energy Analyst (CEA)
https://www.cityenergyanalyst.com/
MIT License
196 stars 66 forks source link

System component with zero interest rate results in Nan cost #3544

Closed peppenappi closed 7 months ago

peppenappi commented 7 months ago

Describe the bug When adding a new component in the database, with a zero interest rate, the calculation of the total cost results into a Nan value, which in turn causes the optimizer to infinitely iterate in the emo.py/sortNDHelperA function since the values from the pareto front cannot be compared. The calculation of the cost is performed in analysis/costs/equations/calc_capex_annualized.

To Reproduce Steps to reproduce the behavior:

  1. Introduce a new component in the component.py and in the database Conversion_new.xlsx with an IR = 0
  2. Run the domain.py for the optimisation of the system.
  3. Obtained error: RecursionError: maximum recursion depth exceeded while calling a Python object

Expected behaviour The IR set at zero will lead to a division by zero due to the way the equation is written, leading to all the failure of the optimisation. The code should check the value before performing the operation in order to avoid Nan values which would break the run.

reyery commented 7 months ago

@MatNif would you be able to look into this?

MatNif commented 7 months ago

Hey @reyery, sure. I've alreday had a look at this with @peppenappi. I can propose a fix tomorrow or early next week.