|
5 | 5 | Defines transmission build-outs. |
6 | 6 | """ |
7 | 7 |
|
| 8 | +import logging |
8 | 9 | import os |
| 10 | + |
| 11 | +import pandas as pd |
9 | 12 | from pyomo.environ import * |
| 13 | + |
10 | 14 | from switch_model.financials import capital_recovery_factor as crf |
11 | | -import pandas as pd |
12 | 15 |
|
13 | 16 | dependencies = 'switch_model.timescales', 'switch_model.balancing.load_zones',\ |
14 | 17 | 'switch_model.financials' |
@@ -180,6 +183,27 @@ def define_components(mod): |
180 | 183 | # (e.g., island interconnect scenarios). However, presence of this column will still be |
181 | 184 | # checked by load_data_aug. |
182 | 185 | mod.min_data_check('trans_lz1', 'trans_lz2') |
| 186 | + |
| 187 | + def _check_tx_duplicate_paths(m): |
| 188 | + forward_paths = set([ |
| 189 | + (m.trans_lz1[tx], m.trans_lz2[tx]) for tx in m.TRANSMISSION_LINES |
| 190 | + ]) |
| 191 | + reverse_paths = set([ |
| 192 | + (m.trans_lz2[tx], m.trans_lz1[tx]) for tx in m.TRANSMISSION_LINES |
| 193 | + ]) |
| 194 | + overlap = forward_paths.intersection(reverse_paths) |
| 195 | + if overlap: |
| 196 | + logging.error( |
| 197 | + "Transmission lines have bi-directional paths specified " |
| 198 | + "in input files. They are expected to specify a single path " |
| 199 | + "per pair of connected load zones. " |
| 200 | + "(Ex: either A->B or B->A, but not both). " |
| 201 | + "Over-specified lines: {}".format(overlap)) |
| 202 | + return(False) |
| 203 | + else: |
| 204 | + return(True) |
| 205 | + mod.check_tx_duplicate_paths = BuildCheck(rule=_check_tx_duplicate_paths) |
| 206 | + |
183 | 207 | mod.trans_dbid = Param(mod.TRANSMISSION_LINES, default=lambda m, tx: tx) |
184 | 208 | mod.trans_length_km = Param(mod.TRANSMISSION_LINES, within=NonNegativeReals) |
185 | 209 | mod.trans_efficiency = Param( |
|
0 commit comments