Infinite Coke Demand because of division by 0 leading to infeasible solution
Timon-R opened this issue · 1 comments
I used a forked version of the newest PyPSA code that has some additional features which, however, shouldn't be cause of the bug. (https://github.com/Timon-R/pypsa-eur/tree/model_testing version:7bad187)
Bug description
The coke demand for NL is inf leading to an infeasible solution.
The proximate cause is infinite values in the resource industry_sector_ratios_2040.
I could solve/avoid the error by replacing the line:
today_sector_ratios = demand.div(production, axis=1)
in the script build_industry_sector_ratios_intermediate.py
by
today_sector_ratios = demand.div(production, axis=1).replace([np.inf, -np.inf], 0)
(also importing numpy in the header)
I am not sure if this fix is elegant or if there are deeper issues leading to this error.
Hi @Timon-R this is probably related to our update of the JRC-IDEES and could happen if you use another reference year then we tested for in the config (year=2019). If the production in one country is zero this lieads to infinity values for the today_sector_ratios. I will adapt the code as you suggested!