Skip to content

Commit

Permalink
Merge pull request #135 from DesmondZhong/master
Browse files Browse the repository at this point in the history
fix typo in planning_reserves and split storage_builds.csv into storage_builds.csv and storage_capacity.csv
  • Loading branch information
mfripp authored and staadecker committed Jan 29, 2023
2 parents 529af02 + f3eb800 commit a6f360c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
33 changes: 21 additions & 12 deletions switch_model/generators/extensions/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,27 +359,36 @@ def post_solve(instance, outdir):
"load_zone",
"IncrementalPowerCapacityMW",
"IncrementalEnergyCapacityMWh",
"OnlinePowerCapacityMW",
"OnlineEnergyCapacityMWh",
),
values=lambda m, g, bld_yr: (
g,
bld_yr,
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,
Expand Down
12 changes: 8 additions & 4 deletions switch_model/policies/carbon_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a6f360c

Please sign in to comment.