Skip to content

Commit f8c1f53

Browse files
Implement a check for bidirectional transmission lines being specified in input files, so the implementation matches documentation.
1 parent e2466eb commit f8c1f53

File tree

1 file changed

+25
-1
lines changed
  • switch_model/transmission/transport

1 file changed

+25
-1
lines changed

switch_model/transmission/transport/build.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
Defines transmission build-outs.
66
"""
77

8+
import logging
89
import os
10+
11+
import pandas as pd
912
from pyomo.environ import *
13+
1014
from switch_model.financials import capital_recovery_factor as crf
11-
import pandas as pd
1215

1316
dependencies = 'switch_model.timescales', 'switch_model.balancing.load_zones',\
1417
'switch_model.financials'
@@ -180,6 +183,27 @@ def define_components(mod):
180183
# (e.g., island interconnect scenarios). However, presence of this column will still be
181184
# checked by load_data_aug.
182185
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+
183207
mod.trans_dbid = Param(mod.TRANSMISSION_LINES, default=lambda m, tx: tx)
184208
mod.trans_length_km = Param(mod.TRANSMISSION_LINES, within=NonNegativeReals)
185209
mod.trans_efficiency = Param(

0 commit comments

Comments
 (0)