Skip to content

Commit

Permalink
Fix pic e_str
Browse files Browse the repository at this point in the history
  • Loading branch information
jinningwang committed Mar 9, 2024
1 parent f9f325d commit c4f2646
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ams/routines/dcopf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
class DCOPF(RoutineBase):
"""
DC optimal power flow (DCOPF).
Note that Var ``pi`` is the dual variable of the power balance constraint ``pb``.
"""

def __init__(self, system, config):
Expand Down Expand Up @@ -104,6 +102,10 @@ def __init__(self, system, config):
name='Cl', tex_name=r'C_{l}',
model='mats', src='Cl',
no_parse=True, sparse=True,)
self.Cft = RParam(info='Line connection matrix',
name='Cft', tex_name=r'C_{ft}',
model='mats', src='Cft',
no_parse=True, sparse=True,)
self.CftT = RParam(info='Transpose of line connection matrix',
name='CftT', tex_name=r'C_{ft}^T',
model='mats', src='CftT',
Expand Down Expand Up @@ -148,7 +150,7 @@ def __init__(self, system, config):
unit='rad',
name='aBus', tex_name=r'\theta_{bus}',
model='Bus', src='a',)
self.pi = Var(info='dual of power balance constr pb',
self.pi = Var(info='nodal price',
name='pi', tex_name=r'\pi',
unit='$/p.u.',
model='Bus',)
Expand Down Expand Up @@ -177,9 +179,11 @@ def __init__(self, system, config):
name='plfc', var='plf',
e_str='Bf@aBus + Pfinj')
# NOTE: in CVXPY, dual_variables returns a list
pic = 'pb.dual_variables[0] '
pic += '+ Cft @ (plfub.dual_variables[0] + plflb.dual_variables[0])'
self.pic = ExpressionCalc(info='pi calculation',
name='pic', var='pi',
e_str='pb.dual_variables[0]')
e_str=pic)

# --- objective ---
obj = 'sum(mul(c2, pg**2))'
Expand Down

0 comments on commit c4f2646

Please sign in to comment.