23
23
idx = pd .IndexSlice
24
24
25
25
26
- def add_brownfield (n , n_p , year ):
26
+ def add_brownfield (
27
+ n ,
28
+ n_p ,
29
+ year ,
30
+ h2_retrofit = False ,
31
+ h2_retrofit_capacity_per_ch4 = None ,
32
+ capacity_threshold = None ,
33
+ ):
34
+ """
35
+ Add brownfield capacity from previous network.
36
+
37
+ Parameters
38
+ ----------
39
+ n : pypsa.Network
40
+ Network to add brownfield to
41
+ n_p : pypsa.Network
42
+ Previous network to get brownfield from
43
+ year : int
44
+ Planning year
45
+ h2_retrofit : bool
46
+ Whether to allow hydrogen pipeline retrofitting
47
+ h2_retrofit_capacity_per_ch4 : float
48
+ Ratio of hydrogen to methane capacity for pipeline retrofitting
49
+ capacity_threshold : float
50
+ Threshold for removing assets with low capacity
51
+ """
27
52
logger .info (f"Preparing brownfield for the year { year } " )
28
53
29
54
# electric transmission grid set optimised capacities of previous as minimum
@@ -49,11 +74,9 @@ def add_brownfield(n, n_p, year):
49
74
& c .df .index .str .contains ("heat" )
50
75
]
51
76
52
- threshold = snakemake .params .threshold_capacity
53
-
54
77
if not chp_heat .empty :
55
78
threshold_chp_heat = (
56
- threshold
79
+ capacity_threshold
57
80
* c .df .efficiency [chp_heat .str .replace ("heat" , "electric" )].values
58
81
* c .df .p_nom_ratio [chp_heat .str .replace ("heat" , "electric" )].values
59
82
/ c .df .efficiency [chp_heat ].values
@@ -67,7 +90,7 @@ def add_brownfield(n, n_p, year):
67
90
c .name ,
68
91
c .df .index [
69
92
(c .df [f"{ attr } _nom_extendable" ] & ~ c .df .index .isin (chp_heat ))
70
- & (c .df [f"{ attr } _nom_opt" ] < threshold )
93
+ & (c .df [f"{ attr } _nom_opt" ] < capacity_threshold )
71
94
],
72
95
)
73
96
@@ -85,7 +108,7 @@ def add_brownfield(n, n_p, year):
85
108
n .import_series_from_dataframe (c .pnl [tattr ], c .name , tattr )
86
109
87
110
# deal with gas network
88
- if snakemake . params . H2_retrofit :
111
+ if h2_retrofit :
89
112
# subtract the already retrofitted from the maximum capacity
90
113
h2_retrofitted_fixed_i = n .links [
91
114
(n .links .carrier == "H2 pipeline retrofitted" )
@@ -118,7 +141,7 @@ def add_brownfield(n, n_p, year):
118
141
pipe_capacity = n .links .loc [gas_pipes_i , "p_nom" ]
119
142
fr = "H2 pipeline retrofitted"
120
143
to = "gas pipeline"
121
- CH4_per_H2 = 1 / snakemake . params . H2_retrofit_capacity_per_CH4
144
+ CH4_per_H2 = 1 / h2_retrofit_capacity_per_ch4
122
145
already_retrofitted .index = already_retrofitted .index .str .replace (fr , to )
123
146
remaining_capacity = (
124
147
pipe_capacity
@@ -301,7 +324,14 @@ def update_heat_pump_efficiency(n: pypsa.Network, n_p: pypsa.Network, year: int)
301
324
302
325
update_heat_pump_efficiency (n , n_p , year )
303
326
304
- add_brownfield (n , n_p , year )
327
+ add_brownfield (
328
+ n ,
329
+ n_p ,
330
+ year ,
331
+ h2_retrofit = snakemake .params .H2_retrofit ,
332
+ h2_retrofit_capacity_per_ch4 = snakemake .params .H2_retrofit_capacity_per_CH4 ,
333
+ capacity_threshold = snakemake .params .threshold_capacity ,
334
+ )
305
335
306
336
disable_grid_expansion_if_limit_hit (n )
307
337
0 commit comments