Skip to content

Commit

Permalink
01. Fix missing dt multiplication in ramping and co2 emission calcula…
Browse files Browse the repository at this point in the history
…tion when dt ≠ 1; 02. Fix repeated dt multiplication in generation cost calculation
  • Loading branch information
github-actions[bot] committed Sep 27, 2024
1 parent 3b9e5d5 commit ffafd01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions prepshot/_model/co2.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ def carbon_breakdown(
"""
model = self.model
ef = model.params['emission_factor'][te, y]
dt = model.params['dt']
return ef * dt * poi.quicksum(model.gen.select('*', '*', y, z, te))
w = model.params['weight']
return 1 / w * ef * poi.quicksum(model.gen.select('*', '*', y, z, te))
9 changes: 3 additions & 6 deletions prepshot/_model/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ def fuel_cost_breakdown(
"""
model = self.model
fp = model.params['fuel_price'][te, y]
dt = model.params['dt']
vf = model.params['var_factor'][y]
w = model.params['weight']
return (1 / w * fp * dt * vf
return (1 / w * fp * vf
* poi.quicksum(model.gen.select('*', '*', y, z, te)))

def cost_var_line_breakdown(
Expand All @@ -130,10 +129,9 @@ def cost_var_line_breakdown(
"""
model = self.model
lvc = model.params['transmission_line_variable_OM_cost'][z, z1]
dt = model.params['dt']
vf = model.params['var_factor'][y]
w = model.params['weight']
return (0.5 / w * lvc * dt * vf
return (0.5 / w * lvc * vf
* poi.quicksum(model.trans_export.select('*', '*', y, z, z1)))

def cost_var_tech_breakdown(
Expand All @@ -158,10 +156,9 @@ def cost_var_tech_breakdown(
"""
model = self.model
tvc = model.params['technology_variable_OM_cost'][te, y]
dt = model.params['dt']
vf = model.params['var_factor'][y]
w = model.params['weight']
return (1 / w * tvc * dt * vf
return (1 / w * tvc * vf
* poi.quicksum(model.gen.select('*', '*', y, z, te)))

def cost_fix_line_breakdown(
Expand Down
5 changes: 3 additions & 2 deletions prepshot/_model/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ def ramping_up_rule(
The constraint of the model.
"""
model = self.model
rp = model.params['ramp_up'][te] * model.params['dt']
dt = model.params['dt']
rp = model.params['ramp_up'][te] * dt
if rp < 1 < h:
lhs = (
model.gen[h, m, y, z, te] - model.gen[h-1, m, y, z, te]
- rp * model.cap_existing[y, z, te]
- rp * model.cap_existing[y, z, te] * dt
)
return model.add_linear_constraint(lhs, poi.Leq, 0)

Expand Down

0 comments on commit ffafd01

Please sign in to comment.