Skip to content

Commit

Permalink
refactor flow path expansion to combine cost with flow_paths.csv in t…
Browse files Browse the repository at this point in the history
…emplate
  • Loading branch information
nick-gorman committed Jan 31, 2025
1 parent 8cb3e57 commit 10da3c6
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 46 deletions.
5 changes: 3 additions & 2 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def create_ispypsa_inputs_from_config(
template_nem_region_to_single_sub_region_mapping(workbook_cache_location)
)
flow_path_template = template_flow_paths(
workbook_cache_location, config.network.nodes.regional_granularity
workbook_cache_location,
config.iasr_workbook_version,
config.network.nodes.regional_granularity,
)
ecaa_generators_template = _template_ecaa_generators_static_properties(
workbook_cache_location
Expand Down Expand Up @@ -312,7 +314,6 @@ def task_create_ispypsa_inputs():
"mapping_nem_region_to_single_sub_region.csv",
),
Path(_ISPYPSA_INPUT_TABLES_DIRECTORY, "flow_paths.csv"),
Path(_ISPYPSA_INPUT_TABLES_DIRECTORY, "transmission_expansion_costs.csv"),
Path(_ISPYPSA_INPUT_TABLES_DIRECTORY, "ecaa_generators.csv"),
Path(_ISPYPSA_INPUT_TABLES_DIRECTORY, "coal_prices.csv"),
Path(_ISPYPSA_INPUT_TABLES_DIRECTORY, "gas_prices.csv"),
Expand Down
47 changes: 46 additions & 1 deletion src/ispypsa/templater/flow_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@


def template_flow_paths(
parsed_workbook_path: Path | str, regional_granularity: str = "sub_regions"
parsed_workbook_path: Path | str,
iasr_workbook_version: str,
regional_granularity: str = "sub_regions",
) -> pd.DataFrame:
"""Creates a flow path template that describes the flow paths (i.e. lines) to be
modelled
Expand All @@ -22,6 +24,8 @@ def template_flow_paths(
Args:
parsed_workbook_path: Path to directory with table CSVs that are the
outputs from the `isp-workbook-parser`.
iasr_workbook_version: str specifying which version of the workbook is being
used to create the template.
regional_granularity: Regional granularity of the nodes obtained from the model
configuration. Defaults to "sub_regions".
Expand All @@ -33,12 +37,27 @@ def template_flow_paths(
)
if regional_granularity == "sub_regions":
template = _template_sub_regional_flow_paths(parsed_workbook_path)
template = _add_transmission_expansion_costs(template, iasr_workbook_version)
# Only keep forward_direction_mw_summer_typical limit col as that all that's
# being used for now.
cols = [
"flow_path_name",
"node_from",
"node_to",
"carrier",
"forward_direction_mw_summer_typical",
"indicative_transmission_expansion_cost_$/mw",
]
template = template.loc[:, cols]

elif regional_granularity == "nem_regions":
template = _template_regional_interconnectors(parsed_workbook_path)
elif regional_granularity == "single_region":
template = pd.DataFrame()

if not template.empty:
template = template.set_index("flow_path_name")

return template


Expand All @@ -54,6 +73,7 @@ def _template_sub_regional_flow_paths(
Returns:
`pd.DataFrame`: ISPyPSA sub-regional flow path template
"""

flow_path_capabilities = pd.read_csv(
Path(parsed_workbook_path, "flow_path_transfer_capability.csv")
)
Expand All @@ -62,9 +82,34 @@ def _template_sub_regional_flow_paths(
)
capability_columns = _clean_capability_column_names(flow_path_capabilities)
sub_regional_capabilities = pd.concat([from_to_carrier, capability_columns], axis=1)

return sub_regional_capabilities


def _add_transmission_expansion_costs(
flow_paths: pd.DataFrame, iasr_workbook_version: str
):
"""Read manually extracted transmission costs from csv and merge into flow paths df.
Args:
flow_paths: pd.DataFrame with flow path definitions
iasr_workbook_version: str specifying which version of the workbook is being
used to create the template.
Returns:
`pd.DataFrame`: ISPyPSA flow path template
"""
path_to_manually_extracted_expansion_costs = (
Path(__file__).parent
/ Path("manually_extracted_template_tables")
/ Path(iasr_workbook_version)
/ Path("transmission_expansion_costs.csv")
)
costs = pd.read_csv(path_to_manually_extracted_expansion_costs)
flow_paths = pd.merge(flow_paths, costs, how="left", on="flow_path_name")
return flow_paths


def _template_regional_interconnectors(
parsed_workbook_path: Path | str,
) -> pd.DataFrame:
Expand Down
2 changes: 0 additions & 2 deletions src/ispypsa/translator/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def translate_flow_paths_to_lines(
`pd.DataFrame`: PyPSA style generator attributes in tabular format.
"""
lines = pd.read_csv(ispypsa_inputs_path / Path("flow_paths.csv"))
costs = pd.read_csv(ispypsa_inputs_path / Path("transmission_expansion_costs.csv"))
lines = pd.merge(lines, costs, how="left", on="flow_path_name")

lines = lines.loc[:, _LINE_ATTRIBUTES.keys()]
lines = lines.rename(columns=_LINE_ATTRIBUTES)
Expand Down
7 changes: 4 additions & 3 deletions tests/templater/test_flow_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_flow_paths_templater_regional(workbook_table_cache_test_path: Path):
flow_paths_template = template_flow_paths(
workbook_table_cache_test_path, "nem_regions"
workbook_table_cache_test_path, "6.0", "nem_regions"
)
assert flow_paths_template.index.name == "flow_path_name"
assert all(
Expand Down Expand Up @@ -37,7 +37,7 @@ def test_flow_paths_templater_regional(workbook_table_cache_test_path: Path):

def test_flow_paths_templater_sub_regional(workbook_table_cache_test_path: Path):
flow_paths_template = template_flow_paths(
workbook_table_cache_test_path, "sub_regions"
workbook_table_cache_test_path, "6.0", "sub_regions"
)
assert flow_paths_template.index.name == "flow_path_name"
assert all(
Expand Down Expand Up @@ -65,10 +65,11 @@ def test_flow_paths_templater_sub_regional(workbook_table_cache_test_path: Path)
]
)
assert len(flow_paths_template) == 14
assert len(flow_paths_template.columns) == 5


def test_flow_paths_templater_single_region(workbook_table_cache_test_path: Path):
flow_paths_template = template_flow_paths(
workbook_table_cache_test_path, "single_region"
workbook_table_cache_test_path, "6.0", "single_region"
)
assert flow_paths_template.empty
50 changes: 12 additions & 38 deletions tests/test_workbook_table_cache/flow_path_transfer_capability.csv
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
Flow paths (Forward power flow direction),"Forward direction capability approximation (MW) - Notes 1,2&_Peak demand","Forward direction capability approximation (MW) - Notes 1,2&_Summer Typical","Forward direction capability approximation (MW) - Notes 1,2&_Winter Reference","Reverse direction capability approximation (MW) - Notes 1,2&_Peak demand","Reverse direction capability approximation (MW) - Notes 1,2&_Summer Typical","Reverse direction capability approximation (MW) - Notes 1,2&_Winter Reference",Dominant constraints_Forward direction,Dominant constraints_Reverse direction
CQ - NQ (Note 10),1200,1200,1400,1200,1200,1400,Voltage stability in NQ for the loss of NQ or CQ transmission network elements. ,Thermal capability of Strathmore to Ross 275 kV line for the loss of the Haughton River to Strathmore 275 kV line.
CQ ­– GG (Note 4),700,700,1050,750,750,1100,Thermal overload of Calvale to Wurdong 275 kV line,Thermal capacity of Calliope River-Woolooga for the loss of one of the parallel lines
Flow paths (Forward power flow direction),Forward direction capability approximation (MW)_Peak demand,Forward direction capability approximation (MW)_Summer Typical,Forward direction capability approximation (MW)_Winter Reference,Reverse direction capability approximation (MW)_Peak demand,Reverse direction capability approximation (MW)_Summer Typical,Reverse direction capability approximation (MW)_Winter Reference,Dominant constraints_Forward direction,Dominant constraints_Reverse direction
CQ - NQ,1200,1200,1400,1200,1200,1400,Voltage stability in NQ for the loss of NQ or CQ transmission network elements.,Thermal capability of Strathmore to Ross 275 kV line for the loss of the Haughton River to Strathmore 275 kV line.
CQ ­– GG,700,700,1050,750,750,1100,Thermal overload of Calvale to Wurdong 275 kV line,Thermal capacity of Calliope River-Woolooga for the loss of one of the parallel lines
SQ – CQ,1100,1100,1100,2100,2100,2100,Thermal capability of Blackwall -South Pine 275 kV line.,Transient stability or voltage stability for a contingency of the Calvale-Halys 275 kV circuit.
"NNSW – SQ (Northern part of ""QNI"")",685 (with QNI Minor),745 (with QNI Minor),745 (with QNI Minor),"1,205 (with QNI minor)
(Note 5)","1,165 (with QNI minor)
(Note 5","1,170 (with QNI minor)
(Note 5)",Voltage stability or transient stability for the loss of Kogan Creek generator. ,Thermal capability of Armidale-Sapphire and Armidale-Dumaresq 330 kV circuits and dispatch of generation at Sapphire.
"NNSW – SQ (Northern part of ""QNI"")",685,745,745,1205,1165,1170,Voltage stability or transient stability for the loss of Kogan Creek generator.,Thermal capability of Armidale-Sapphire and Armidale-Dumaresq 330 kV circuits and dispatch of generation at Sapphire.
NNSW – SQ (“Terranora”),0,50,50,130,150,200,Thermal capability of Lismore 132 kV lines (9U9).,Thermal capability of Mudgeeraba 275/110 kV transformers
"CNSW – NNSW (Southern part of ""QNI"")",910 (with QNI minor),910 (with QNI minor),910 (with QNI minor),930 (with QN Minor),930 (with QN Minor),"1,025 (with QNI Minor)",Voltage stability for an outage of Kogan Creek generator.,Thermal capability of Tamworth-Armidale 330 kV circuits.
CNSW ­– SNW Northern limit,"4,490
(Note 6)(Note 7)","4,490
(Note 6)(Note 7)","4,730
(Note 6)(Note 7)","4,490
(Note 7)","4,490
(Note 7)","4,730
(Note 7)",Maximum transfer capability is limited by several 330 kV lines and the most limiting elements are Liddell-Newcastle and Liddell-Tomago 330 kV lines. ,-
CNSW ­– SNW Southern limit,"2,540
(Note 6)(Note 7)","2,540
(Note 6)(Note 7)","2,720
(Note 6)(Note 7)","2,540
(Note 7)","2,540
(Note 7)","2,720
(Note 7)",Maximum transfer capability is limited by several 330 kV lines and the most limiting element is Bannaby-Sydney West 330 kV line. ,-
"SNSW – CNSW (Northern part of ""VNI"")","2,700
(Snowy 2.0 generation or pump load <= 660- Note 11)","2,700
(Snowy 2.0 generation or pump load <= 660 - Note 11)","2,950
(Snowy 2.0 generation or pump load <= 660 - Note 11)","2,320
","2,320
","2,590
","Thermal capability of Crookwell-Bannaby, Collector-Marula or Yass-Marulan 330 kV lines.
Prior to HumeLink service, Snowy 2.0 generation or pump load is limited by a transient stability limit.","Thermal capability of Yass-Canberra, Collector -Yass or Gullen Range-Yass 330 kV line."
"VIC – SNSW (Southern part of ""VNI"") ",870 (with VNI minor),"1,000 (with VNI minor)","1,000 (with VNI minor)","400 (with VNI SIPS) - Note 8
(Snowy 2.0 generation or pump load <= 660 - Note 11)","400
(Snowy 2.0 generation or pump load <= 660 - Note 11)","400
(Snowy 2.0 generation or pump load <= 660 - Note 11)",Transient stability for a fault on a Hazelwood-South 500 circuit or volage stability in Southern New South Wales for loss of largest load in Victoria.,"Voltage stability in SNSW for loss of the largest generator in Victoria.
Prior to HumeLink service, Snowy 2.0 generation or pump load is limited by a transient stability limit."
VIC – SESA (“Heywood”) - (Note 9),650,650,650,650,650,650,Thermal capacity of Heywood-South East 275 kV line or transient stability limit for loss of the largest generator in South Australia or transient stability limit of loss of South East - Tailem Bend 275 kV line.,Oscillatory stability limit.
SESA-CSA,650,650,650,650,650,650,Transient stability limit for loss of the largest generator in South Australia or transient stability limit of loss of South East - Tailem Bend 275 kV line.,Oscillatory stability limit.
"CNSW – NNSW (Southern part of ""QNI"")",910,910,910,930,930,1025,Voltage stability for an outage of Kogan Creek generator.,Thermal capability of Tamworth-Armidale 330 kV circuits.
CNSW ­– SNW Northern limit,4490,4490,4730,4490,4490,4730,Maximum transfer capability is limited by several 330 kV lines and the most limiting elements are Liddell-Newcastle and Liddell-Tomago 330 kV lines.,
CNSW ­– SNW Southern limit,2540,2540,2720,2540,2540,2720,Maximum transfer capability is limited by several 330 kV lines and the most limiting element is Bannaby-Sydney West 330 kV line.,
"SNSW – CNSW (Northern part of ""VNI"")",2700,2700,2950,2320,2320,2590,"Thermal capability of Crookwell-Bannaby, Collector-Marula or Yass-Marulan 330 kV lines. Prior to HumeLink service, Snowy 2.0 generation or pump load is limited by a transient stability limit.","Thermal capability of Yass-Canberra, Collector -Yass or Gullen Range-Yass 330 kV line."
"VIC – SNSW (Southern part of ""VNI"")",870,1000,1000,400,400,400,Transient stability for a fault on a Hazelwood-South 500 circuit or volage stability in Southern New South Wales for loss of largest load in Victoria.,"Voltage stability in SNSW for loss of the largest generator in Victoria. Prior to HumeLink service, Snowy 2.0 generation or pump load is limited by a transient stability limit."
VIC – SESA (“Heywood”),650,650,650,650,650,650,Thermal capacity of Heywood-South East 275 kV line or transient stability limit for loss of the largest generator in South Australia or transient stability limit of loss of South East - Tailem Bend 275 kV line.,Oscillatory stability limit.
SESA-CSA,650,650,650,650,650,650,Transient stability limit for loss of the largest generator in South Australia or transient stability limit of loss of South East - Tailem Bend 275 kV line.,Oscillatory stability limit.
VIC – CSA (Murraylink),220,220,220,100,200,200,Murraylink thermal capacity. Assumes high renewable generation in North West Victoria during high ambient temperature.,Thermal capability of 132 kV lines between Robertstown and North West Bend
TAS – VIC (Note 12),594,594,594,478,478,478,Basslink HVDC submarine cable transfer limit. ,Basslink HVDC submarine cable transfer limit.
TAS – VIC,594,594,594,478,478,478,Basslink HVDC submarine cable transfer limit.,Basslink HVDC submarine cable transfer limit.
14 changes: 14 additions & 0 deletions tests/test_workbook_table_cache/transmission_expansion_costs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
,flow_path_name,indicative_transmission_expansion_cost_$/mw
0,CQ-NQ,1.126363636
1,CQ-GG,0.838709677
2,SQ-CQ,0.513333333
3,NNSW-SQ,1.702027027
4,Terranora,
5,CNSW-NNSW,0.497666667
6,CNSW-SNW,0.284
7,SNSW-CNSW,0.502333333
8,VIC-SNSW,2.00554939
9,Heywood,0.454333333
10,SESA-CSA,0.602333333
11,Murraylink,
12,Basslink,3.646666667

0 comments on commit 10da3c6

Please sign in to comment.