Open danielolsen opened 2 years ago
In this situation, I think we can safely replace any NaN values with zeros, and potentially warn the user/log of what's going on. In a situation for which there is non-zero demand for a zone with all-zero Pd values, I think we should detect this when loading the input files and halt before trying to build the model.
I agree with both of these suggestions.
There's a hotfix branch daniel/zero_zone_Pd_fix
that overrides any NaN
values with zeros, which is good in the case of zero demand for the zone but not in the case of non-zero demand, which still needs to be handled appropriately.
:beetle:
Bug summary
If all buses within a zone have a
Pd
of zero, model building will crash within the_add_constraint_power_balance!
function, due to aNaN
value withinbus_demand
. The origin of this isNaN
value is the following line:bus_share = bus_df[:, :load] ./ bus_df_with_zone_load[:, :load_sum]
which divides by zero for at least one zone since the sum of all Pd values for the zone is zero.https://github.com/Breakthrough-Energy/REISE.jl/blob/420dc059a785dc3db3781734ec0e264f31f04a28/src/model.jl#L55
Code for reproduction
Can be reproduced using the current HIFLD grid model for the Eastern interconnect, which has all zeros for
Pd
values for buses within the"Colorado Eastern"
zone (zone_id = 6). To reproduce, you can callREISE.run_scenario_gurobi
orREISE.run_scenario
. Checking the data with python we see the root of the data problem.Actual outcome
The output produced by the above code, which may be a screenshot, console output, etc.
Expected outcome
In the case I was running into, I had set the demand to zero for that zone anyway, so I would have hoped that
bus_demand
would be all zeros for that zone. In this situation, I think we can safely replace any NaN values with zeros, and potentially warn the user/log of what's going on. In a situation for which there is non-zero demand for a zone with all-zero Pd values, I think we should detect this when loading the input files and halt before trying to build the model.Environment
This bug should be environment agnostic.
Please specify your platform and versions of the relevant libraries you are using:
git rev-parse origin/HEAD
):e8639dd8a2fe42299e58e0c7ed49bc84527f5d07