Skip to content

Commit

Permalink
Merge pull request #126 from transition-zero/trade-capacity-bug
Browse files Browse the repository at this point in the history
Updated trade capacity constraints to include TradeRoute
  • Loading branch information
abhishek0208 authored Jun 12, 2024
2 parents e0c612d + 1dbccbd commit 3b33f2d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tz/osemosys/model/constraints/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,23 @@ def add_trade_constraints(ds: xr.Dataset, m: Model, lex: Dict[str, LinearExpress
if ds["TradeRoute"].notnull().any():

# Energy Balance
con = (m["Export"] - m["Import"].rename({"REGION": "_REGION", "_REGION": "REGION"})) * ds[
"TradeRoute"
] == 0
con = (
m["Export"]
- m["Import"].rename({"REGION": "_REGION", "_REGION": "REGION"}) * ds["TradeRoute"]
== 0
)
m.add_constraints(con, name="EBa10_EnergyBalanceEachTS4_trn")

# Capacity
# TODO: add TradeCapacityToActivityUnit for first 2 trade capacity constraints
con = lex["GrossTradeCapacity"] * (1 - ds["TradeLossBetweenRegions"]) >= (
m["Export"] / (ds["YearSplit"])
)
con = lex["GrossTradeCapacity"] * ds["TradeRoute"] * (
1 - ds["TradeLossBetweenRegions"]
) >= m["Export"] / (ds["YearSplit"])
m.add_constraints(con, name="TC1a_TradeConstraint_Export")

con = lex["GrossTradeCapacity"] * (1 - ds["TradeLossBetweenRegions"]) >= m["Import"].rename(
{"REGION": "_REGION", "_REGION": "REGION"}
) / (ds["YearSplit"])
con = lex["GrossTradeCapacity"] * ds["TradeRoute"] * (
1 - ds["TradeLossBetweenRegions"]
) >= m["Import"].rename({"REGION": "_REGION", "_REGION": "REGION"}) / (ds["YearSplit"])
m.add_constraints(con, name="TC1b_TradeConstraint_Import")

con = lex["NewTradeCapacity"] <= ds["TotalAnnualMaxTradeInvestment"] * ds["TradeRoute"]
Expand Down

0 comments on commit 3b33f2d

Please sign in to comment.