Skip to content

Commit

Permalink
Merge pull request #69 from CURENT/develop
Browse files Browse the repository at this point in the history
Prep for patch release v0.9.4
  • Loading branch information
jinningwang authored Mar 16, 2024
2 parents b45ce49 + b56a51b commit 32f5a28
Show file tree
Hide file tree
Showing 21 changed files with 379 additions and 221 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "misc"
ignore:
- dependency-name: "pytest"
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ Python Software for Power System Dispatch Modeling and Co-Simulation with Dynani
![platforms](https://anaconda.org/conda-forge/ltbams/badges/platforms.svg)
[![Python Versions](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/)
![Repo Size](https://img.shields.io/github/repo-size/CURENT/ams)
![Code Lines](https://tokei.rs/b1/github/CURENT/ams?category=code)
![Files](https://tokei.rs/b1/github/CURENT/ams?category=files)
[![GitHub last commit (master)](https://img.shields.io/github/last-commit/CURENT/ams/master?label=last%20commit%20to%20master)](https://github.com/CURENT/develop/commits/master)
[![GitHub last commit (develop)](https://img.shields.io/github/last-commit/CURENT/ams/develop?label=last%20commit%20to%20develop)](https://github.com/CURENT/develop/commits/develop)
[![GitHub last commit (master)](https://img.shields.io/github/last-commit/CURENT/ams/master?label=last%20commit%20to%20master)](https://github.com/CURENT/ams/commits/master/)
[![GitHub last commit (develop)](https://img.shields.io/github/last-commit/CURENT/ams/develop?label=last%20commit%20to%20develop)](https://github.com/CURENT/ams/commits/develop/)
[![HitCount](https://hits.dwyl.com/CURENT/ams.svg)](https://hits.dwyl.com/CURENT/ams)
[![libraries](https://img.shields.io/librariesio/release/pypi/ltbams)](https://libraries.io/pypi/ltbams)
[![Structure](https://img.shields.io/badge/code_base-visualize-blue)](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=CURENT%2Fams)
Expand Down
2 changes: 2 additions & 0 deletions ams/core/documenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def _tex_pre(docm, p, tex_map):
(r'\eta', 'ETA'),
(r'\gamma', 'GAMMA'),
(r'\theta', 'THETA'),
(r'\phi', 'PHI'),
(r'\frac', 'FRAC'),
(r'\overline', 'OVERLINE'),
(r'\underline', 'UNDERLINE'),
Expand All @@ -551,6 +552,7 @@ def _tex_pre(docm, p, tex_map):
('THETA', r'\theta'),
('ETA', r'\eta'),
('GAMMA', r'\gamma'),
('PHI', r'\phi'),
('FRAC', r'\frac'),
('OVERLINE', r'\overline'),
('UNDERLINE', r'\underline'),
Expand Down
7 changes: 7 additions & 0 deletions ams/core/symprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(self, parent):
(r'\bmul\b\((.*?),\s*(.*?)\)', r'\1 \2'),
(r'\bsum\b', 'SUM'),
(r'power\((.*?),\s*(\d+)\)', r'\1^\2'),
(r'(\w+).dual_variables\[0\]', r'\phi[\1]'),
])

# mapping dict for evaluating expressions
Expand Down Expand Up @@ -155,6 +156,12 @@ def generate_symbols(self, force_generate=False):
if not service.no_parse:
self.val_map[rf"\b{sname}\b"] = f"rtn.{sname}.v"

# Constraints
# NOTE: constraints are included in sub_map for ExpressionCalc
# thus, they don't have the suffix `.v`
for cname, constraint in self.parent.constrs.items():
self.sub_map[rf"\b{cname}\b"] = f'self.rtn.{cname}.optz'

# store tex names defined in `self.config`
for key in self.config.as_dict():
tmp = sp.symbols(key)
Expand Down
8 changes: 8 additions & 0 deletions ams/models/renewable/regc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ def __init__(self, system=None, config=None) -> None:
indexer=self.bus, export=False,
info='Retrieved zone idx',
vtype=str, default=None)
self.M = NumParam(default=10, tex_name='M',
info='Inertia emulation',
unit='s',
power=True,)
self.D = NumParam(default=0, tex_name='D',
info='Damping emulation',
unit='p.u.',
power=True,)
self.Mmax = NumParam(default=99, tex_name='M_{max}',
info='Maximum inertia emulation',
unit='s',
Expand Down
2 changes: 1 addition & 1 deletion ams/opt/omodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def init(self, no_code=True):
logger.debug(msg)
exec(code_prob, globals(), locals())
for key, val in self.rtn.exprs.items():
val.parse()
val.parse(no_code=no_code)

_, s_setup = elapsed(t_setup)
self.initialized = True
Expand Down
12 changes: 11 additions & 1 deletion ams/routines/dcopf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
class DCOPF(RoutineBase):
"""
DC optimal power flow (DCOPF).
The nodal price is calculated as ``pi`` in ``pic``.
"""

def __init__(self, system, config):
Expand Down Expand Up @@ -146,6 +148,10 @@ def __init__(self, system, config):
unit='rad',
name='aBus', tex_name=r'\theta_{bus}',
model='Bus', src='a',)
self.pi = Var(info='nodal price',
name='pi', tex_name=r'\pi',
unit='$/p.u.',
model='Bus',)
# --- power balance ---
pb = 'Bbus@aBus + Pbusinj + Cl@pd + Csh@gsh - Cg@pg'
self.pb = Constraint(name='pb', info='power balance',
Expand All @@ -170,9 +176,13 @@ def __init__(self, system, config):
self.plfc = ExpressionCalc(info='plf calculation',
name='plfc', var='plf',
e_str='Bf@aBus + Pfinj')
# NOTE: in CVXPY, dual_variables returns a list
self.pic = ExpressionCalc(info='dual of Constraint pb',
name='pic', var='pi',
e_str='pb.dual_variables[0]')

# --- objective ---
obj = 'sum(mul(c2, power(pg, 2)))'
obj = 'sum(mul(c2, pg**2))'
obj += '+ sum(mul(c1, pg))'
obj += '+ sum(mul(ug, c0))'
self.obj = Objective(name='obj',
Expand Down
1 change: 1 addition & 0 deletions ams/routines/ed.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(self) -> None:
self.pg.info = '2D Gen power'
self.aBus.horizon = self.timeslot
self.aBus.info = '2D Bus angle'
self.pi.horizon = self.timeslot


class ED(RTED, MPBase, SRBase):
Expand Down
9 changes: 7 additions & 2 deletions ams/routines/rted.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,12 @@ def __init__(self) -> None:
# --- Model Section ---
self.M = Var(info='Emulated startup time constant (M=2H)',
name='M', tex_name=r'M', unit='s',
model='VSG', nonneg=True,)
model='VSG', src='M',
nonneg=True,)
self.D = Var(info='Emulated damping coefficient',
name='D', tex_name=r'D', unit='p.u.',
model='VSG', nonneg=True,)
model='VSG', src='D',
nonneg=True,)

self.gvsg = ZonalSum(u=self.zvsg, zone='Region',
name='gvsg', tex_name=r'S_{g}',
Expand All @@ -530,6 +532,9 @@ class RTEDVIS(RTED, VISBase):
"""
RTED with virtual inertia scheduling.
This class implements real-time economic dispatch with virtual inertia scheduling.
Please ensure that the parameters `dvm` and `dvd` are set according to the system base.
Reference:
[1] B. She, F. Li, H. Cui, J. Wang, Q. Zhang and R. Bo, "Virtual
Expand Down
7 changes: 7 additions & 0 deletions docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ The APIs before v3.0.0 are in beta and may change without prior notice.
Pre-v1.0.0
==========

v0.9.4 (2024-03-16)
-------------------

- Add Var ``pi`` and ExpressionCalc ``pic`` to store the dual of constraint power balance
- Add Param ``M`` and ``D`` to model ``REGCV1``
- Add CPS1 score calculation in demo_AGC

v0.9.3 (2024-03-06)
-------------------

Expand Down
Loading

0 comments on commit 32f5a28

Please sign in to comment.