Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.2 #107

Merged
merged 6 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
gurobi.log
switch_model.egg-info/
venv
build/
build*/
dist*/
autodoc*
16 changes: 14 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
-------------------------------------------------------------------------------
Switch 2.0.2
-------------------------------------------------------------------------------

- General
- Added --assign-current-version argument to `switch upgrade`. This is
useful for updating version number in example directories to match
current version of Switch, even if the data files don't need an upgrade.

- Hawaii regional package
- Fixed bug in hawaii.rps that would crash `switch solve --help`.

-------------------------------------------------------------------------------
Switch 2.0.1
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -33,8 +45,8 @@ Switch 2.0.1
then re-solves to obtain duals. This flag is not needed with the cplexamp
solver.
- A new balancing.demand_response.iterative module has been added. This was
formerly in the Hawaii regional package. This moduel performs iterative solutions with any convex demand system, based on a bid-response
process.
formerly in the Hawaii regional package. This module performs iterative
solutions with any convex demand system, based on a bid-response process.
- New indexed sets have been added to allow efficient selection of groups of
generators that use a particular technology, fuel or non-fuel energy
source: GENS_BY_TECHNOLOGY, GENS_BY_FUEL, GENS_BY_NON_FUEL_ENERGY_SOURCE.
Expand Down
2 changes: 1 addition & 1 deletion examples/3zone_toy/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/carbon_cap/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/ccs/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/copperplate0/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/copperplate1/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/custom_extension/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/discrete_build/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/dr_simple/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/hydro_simple/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/hydro_system/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/new_builds_only/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/rps_simple/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion examples/storage/inputs/switch_inputs_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion switch_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/balancing/load_zones.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/balancing/operating_reserves/areas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
A simple and flexible model of spinning reserves that tracks the state of unit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
This is an advanced version of the basic spinning_reserves reserves module, and
Expand Down
2 changes: 1 addition & 1 deletion switch_model/balancing/planning_reserves.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
This module defines planning reserves margins to support resource adequacy
Expand Down
2 changes: 1 addition & 1 deletion switch_model/energy_sources/fuel_costs/markets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/energy_sources/fuel_costs/simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/energy_sources/properties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
4 changes: 2 additions & 2 deletions switch_model/financials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down Expand Up @@ -289,7 +289,7 @@ def calc_sys_costs_per_period(m, p):
mod.SystemCostPerPeriod = Expression(
mod.PERIODS,
rule=calc_sys_costs_per_period)
# starting with Pyomo 4.2, it is impossible to call Objective.reconstruct()
# starting with Pyomo 4.2, it is impossible to call Objective.reconstruct()
# or calculate terms like Objective / <some other model component>,
# so it's best to define a separate expression and use that for these purposes.
mod.SystemCost = Expression(
Expand Down
2 changes: 1 addition & 1 deletion switch_model/generators/core/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
Defines generation projects build-outs.
Expand Down
2 changes: 1 addition & 1 deletion switch_model/generators/core/dispatch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/generators/core/gen_discrete_build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/generators/core/no_commit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
44 changes: 22 additions & 22 deletions switch_model/hawaii/batteries_fixed_calendar_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from switch_model.financials import capital_recovery_factor as crf

def define_components(m):

# TODO: change this to allow multiple storage technologies.

# battery capital cost
# TODO: accept a single battery_capital_cost_per_mwh_capacity value or the annual values shown here
m.BATTERY_CAPITAL_COST_YEARS = Set() # list of all years for which capital costs are available
m.battery_capital_cost_per_mwh_capacity_by_year = Param(m.BATTERY_CAPITAL_COST_YEARS)

# TODO: merge this code with batteries.py and auto-select between fixed calendar life and cycle life
# based on whether battery_n_years or battery_n_cycles is provided. (Or find some hybrid that can
# handle both well?)
Expand All @@ -28,7 +28,7 @@ def define_components(m):
m.BuildBattery = Var(m.LOAD_ZONES, m.PERIODS, within=NonNegativeReals)
m.Battery_Capacity = Expression(m.LOAD_ZONES, m.PERIODS, rule=lambda m, z, p:
sum(
m.BuildBattery[z, bld_yr]
m.BuildBattery[z, bld_yr]
for bld_yr in m.CURRENT_AND_PRIOR_PERIODS_FOR_PERIOD[p] if bld_yr + m.battery_n_years > p
)
)
Expand All @@ -43,18 +43,18 @@ def define_components(m):
# add storage dispatch to the zonal energy balance
m.Zone_Power_Injections.append('DischargeBattery')
m.Zone_Power_Withdrawals.append('ChargeBattery')

# add the batteries to the objective function

# cost recovery for any battery capacity currently active
m.BatteryAnnualCost = Expression(
m.PERIODS,
rule=lambda m, p: sum(
m.BuildBattery[z, bld_yr]
* m.battery_capital_cost_per_mwh_capacity_by_year[bld_yr]
m.BuildBattery[z, bld_yr]
* m.battery_capital_cost_per_mwh_capacity_by_year[bld_yr]
* crf(m.interest_rate, m.battery_n_years)
for bld_yr in m.CURRENT_AND_PRIOR_PERIODS_FOR_PERIOD[p] if bld_yr + m.battery_n_years > p
for z in m.LOAD_ZONES
for z in m.LOAD_ZONES
)
)
m.Cost_Components_Per_Period.append('BatteryAnnualCost')
Expand All @@ -63,31 +63,31 @@ def define_components(m):
# NOTE: this is circular for each day
# NOTE: the overall level for the day is free, but the levels each timepoint are chained.
m.Battery_Level_Calc = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.BatteryLevel[z, t] ==
m.BatteryLevel[z, t] ==
m.BatteryLevel[z, m.tp_previous[t]]
+ m.tp_duration_hrs[t] * (
m.battery_efficiency * m.ChargeBattery[z, m.tp_previous[t]]
m.battery_efficiency * m.ChargeBattery[z, m.tp_previous[t]]
- m.DischargeBattery[z, m.tp_previous[t]]
)
)

# limits on storage level
m.Battery_Min_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.Battery_Min_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
(1.0 - m.battery_max_discharge) * m.Battery_Capacity[z, m.tp_period[t]]
<=
<=
m.BatteryLevel[z, t]
)
m.Battery_Max_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.Battery_Max_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.BatteryLevel[z, t]
<=
<=
m.Battery_Capacity[z, m.tp_period[t]]
)

m.Battery_Max_Charge_Rate = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.ChargeBattery[z, t]
<=
# changed 2018-02-20 to allow full discharge in min_discharge_time,
# (previously pegged to battery_max_discharge)
# changed 2018-02-20 to allow full discharge in min_discharge_time,
# (previously pegged to battery_max_discharge)
m.Battery_Capacity[z, m.tp_period[t]] / m.battery_min_discharge_time
)
m.Battery_Max_Discharge_Rate = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
Expand All @@ -112,32 +112,32 @@ def define_components(m):
# (this was pegged to battery_max_discharge before 2018-02-20)
m.Battery_Cycle_Limit = Constraint(m.LOAD_ZONES, m.PERIODS, rule=lambda m, z, p:
sum(m.DischargeBattery[z, tp] * m.tp_duration_hrs[tp] for tp in m.TPS_IN_PERIOD[p])
<=
<=
m.Battery_Capacity[z, p] * m.period_length_hours[p]
)

# Register with spinning reserves if it is available
if 'Spinning_Reserve_Up_Provisions' in dir(m):
m.BatterySpinningReserveUp = Expression(
m.BALANCING_AREA_TIMEPOINTS,
m.BALANCING_AREA_TIMEPOINTS,
rule=lambda m, b, t:
sum(m.BatterySlackUp[z, t]
for z in m.ZONES_IN_BALANCING_AREA[b])
)
m.Spinning_Reserve_Up_Provisions.append('BatterySpinningReserveUp')

m.BatterySpinningReserveDown = Expression(
m.BALANCING_AREA_TIMEPOINTS,
m.BALANCING_AREA_TIMEPOINTS,
rule=lambda m, b, t: \
sum(m.BatterySlackDown[g, t]
sum(m.BatterySlackDown[z, t]
for z in m.ZONES_IN_BALANCING_AREA[b])
)
m.Spinning_Reserve_Down_Provisions.append('BatterySpinningReserveDown')


def load_inputs(m, switch_data, inputs_dir):
"""
Import battery data from .dat and .tab files.
Import battery data from .dat and .tab files.
"""
switch_data.load(filename=os.path.join(inputs_dir, 'batteries.dat'))
switch_data.load_aug(
Expand Down
2 changes: 1 addition & 1 deletion switch_model/hawaii/hi_spinning_reserves.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
This customizes the behavior of balancing.operating_reserves.spinning_reserve
Expand Down
9 changes: 8 additions & 1 deletion switch_model/hawaii/kalaeloa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import os
from pyomo.environ import *

def define_arguments(argparser):
argparser.add_argument("--run-kalaeloa-even-with-high-rps", action='store_true', default=False,
help="Enforce the 75 MW minimum-output rule for Kalaeloa in all years (otherwise relaxed "
"if RPS or EV share >= 75%%). Mimics behavior from switch 2.0.0b2.")

def define_components(m):
# force Kalaeloa_CC3 offline unless 1&2 are at max (per John Cole e-mail 9/28/16)

Expand Down Expand Up @@ -82,7 +87,9 @@ def Kalaeloa_Must_Run_rule(m, tp):
ev_share = m.ev_share['Oahu', m.tp_period[tp]] if hasattr(m, 'ev_share') else 0.0
rps_level = m.rps_target_for_period[m.tp_period[tp]] if hasattr(m, 'rps_target_for_period') else 0.0

if both_units_out or ev_share >= 0.75 or rps_level >= 0.75:
if both_units_out or (
(ev_share >= 0.75 or rps_level >= 0.75) and not m.options.run_kalaeloa_even_with_high_rps
):
return Constraint.Skip
else:
return (sum(m.DispatchGen[g, tp] for g in m.KALAELOA_MAIN_UNITS) >= 75.0)
Expand Down
2 changes: 1 addition & 1 deletion switch_model/hawaii/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def define_arguments(argparser):
argparser.add_argument('--rps-no-wind', action='store_true', default=False,
help="Don't allow any new wind capacity or replacement of existing capacity.")
argparser.add_argument('--rps-prefer-dist-pv', action='store_true', default=False,
help="Don't allow any new large solar capacity unless 90% of distributed PV ('*DistPV') capacity has been developed.")
help="Don't allow any new large solar capacity unless 90%% of distributed PV ('*DistPV') capacity has been developed.")
argparser.add_argument(
'--rps-allocation', default=None,
choices=[
Expand Down
3 changes: 2 additions & 1 deletion switch_model/hawaii/scenario_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def write_tables(**args):
write_table('fuels.tab', """
SELECT DISTINCT replace(c.fuel_type, ' ', '_') AS fuel, co2_intensity, 0.0 AS upstream_co2_intensity, rps_eligible
FROM fuel_costs c JOIN energy_source_properties p on (p.energy_source = c.fuel_type)
WHERE load_zone in %(load_zones)s AND fuel_scen_id=%(fuel_scen_id)s;
WHERE load_zone in %(load_zones)s AND fuel_scen_id=%(fuel_scen_id)s
ORDER BY 1;
""", args)

#########################
Expand Down
2 changes: 1 addition & 1 deletion switch_model/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""Script to handle switch <cmd> calls from the command line."""
Expand Down
2 changes: 1 addition & 1 deletion switch_model/policies/carbon_policies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.
"""
Add emission policies to the model, either in the form of an added cost, or of
Expand Down
2 changes: 1 addition & 1 deletion switch_model/reporting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017 The Switch Authors. All rights reserved.
# Copyright (c) 2015-2019 The Switch Authors. All rights reserved.
# Licensed under the Apache License, Version 2.0, which is in the LICENSE file.

"""
Expand Down
Loading