Skip to content

Commit 95b427a

Browse files
authored
Merge pull request #40 from Zhanwei-Liu/dev
Allow setting carbon emission limits by zone
2 parents b842e7a + 752131b commit 95b427a

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"general_parameters": {
3-
"input_folder": "input",
3+
"input_folder": "southeast_asia",
44
"output_folder": "output",
55
"output_filename": "year",
66
"hour": 48,
@@ -12,9 +12,9 @@
1212
"hydro_parameters": {
1313
"isinflow": true,
1414
"error_threshold": 0.001,
15-
"iteration_number": 3
15+
"iteration_number": 1
1616
},
1717
"solver_parameters": {
18-
"solver": "highs"
18+
"solver": "gurobi"
1919
}
2020
}

params.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"file_name": "carbon_emission_limit",
2121
"index_cols": [0],
2222
"header_rows": [0],
23-
"unstack_levels": null,
24-
"first_col_only": true,
23+
"unstack_levels": [0],
24+
"first_col_only": false,
2525
"drop_na": true
2626
},
2727
"emission_factor": {

prepshot/_model/co2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def __init__(self, model : object) -> None:
4949
rule=self.emission_calc_rule
5050
)
5151
model.emission_limit_cons = poi.make_tupledict(
52-
model.year,
52+
model.year, model.zone,
5353
rule=self.emission_limit_rule
5454
)
5555

56-
def emission_limit_rule(self, y : int) -> poi.ConstraintIndex:
56+
def emission_limit_rule(self, y : int, z : str) -> poi.ConstraintIndex:
5757
"""Annual carbon emission limits across all zones and technologies.
5858
5959
Parameters
@@ -67,10 +67,10 @@ def emission_limit_rule(self, y : int) -> poi.ConstraintIndex:
6767
A constraint of the model.
6868
"""
6969
model = self.model
70-
limit = model.params['carbon_emission_limit']
71-
if limit[y] == np.Inf:
70+
limit = model.params['carbon_emission_limit'][z, y]
71+
if limit == np.Inf:
7272
return None
73-
lhs = model.carbon[y] - limit[y]
73+
lhs = model.carbon_capacity[y, z] - limit
7474
return model.add_linear_constraint(lhs, poi.Leq, 0)
7575

7676
def emission_calc_rule(self, y : int) -> poi.ConstraintIndex:
@@ -135,4 +135,6 @@ def carbon_breakdown(
135135
model = self.model
136136
ef = model.params['emission_factor'][te, y]
137137
w = model.params['weight']
138+
if ef == 0:
139+
return poi.ExprBuilder(0)
138140
return 1 / w * ef * poi.quicksum(model.gen.select('*', '*', y, z, te))
-1.46 KB
Binary file not shown.

0 commit comments

Comments
 (0)