diff --git a/switch_model/generators/extensions/storage.py b/switch_model/generators/extensions/storage.py index d1e9d614b..045ffea2d 100644 --- a/switch_model/generators/extensions/storage.py +++ b/switch_model/generators/extensions/storage.py @@ -359,8 +359,6 @@ def post_solve(instance, outdir): "load_zone", "IncrementalPowerCapacityMW", "IncrementalEnergyCapacityMWh", - "OnlinePowerCapacityMW", - "OnlineEnergyCapacityMWh", ), values=lambda m, g, bld_yr: ( g, @@ -368,18 +366,29 @@ def post_solve(instance, outdir): m.gen_load_zone[g], m.BuildGen[g, bld_yr], m.BuildStorageEnergy[g, bld_yr], - ( - m.GenCapacity[g, bld_yr] - if bld_yr in m.PERIODS - else m.BuildGen[g, bld_yr] - ), - ( - m.StorageEnergyCapacity[g, bld_yr] - if bld_yr in m.PERIODS - else m.BuildStorageEnergy[g, bld_yr] - ), ), ) + + reporting.write_table( + instance, + instance.STORAGE_GEN_PERIODS, + output_file=os.path.join(outdir, "storage_capacity.csv"), + headings=( + "generation_project", + "period", + "load_zone", + "OnlinePowerCapacityMW", + "OnlineEnergyCapacityMWh", + ), + values=lambda m, g, p: ( + g, + p, + m.gen_load_zone[g], + m.GenCapacity[g, p], + m.StorageEnergyCapacity[g, p], + ), + ) + reporting.write_table( instance, instance.STORAGE_GEN_TPS, diff --git a/switch_model/policies/carbon_policies.py b/switch_model/policies/carbon_policies.py index b0a995b74..f75493037 100644 --- a/switch_model/policies/carbon_policies.py +++ b/switch_model/policies/carbon_policies.py @@ -99,11 +99,15 @@ def get_row(model, period): model.AnnualEmissions[period], model.carbon_cap_tco2_per_yr[period], ] - # Only print the carbon cap dual value if it exists and if the problem - # is purely linear. + # Only print the carbon cap dual value if it exists + # Note: we previously only reported it if the model was also strictly + # continuous, but now we let the user worry about that (some solvers + # can report duals for integer models by fixing the variables to their + # integer values, which is often a reasonable approach and should give + # meaningful duals for the carbon cost, which occurs on a much higher + # level). if ( - not model.has_discrete_variables() - and period in model.Enforce_Carbon_Cap + period in model.Enforce_Carbon_Cap and model.Enforce_Carbon_Cap[period] in model.dual ): row.append(