We first import the ams
library and configure the logger level.
import ams
import datetime
print("Last run time:", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
print(f'ams:{ams.__version__}')
Last run time: 2024-11-24 17:46:40 ams:0.9.12
ams.config_logger(stream_level=20)
Load an example case.
sp = ams.load(ams.get_case('5bus/pjm5bus_uced.xlsx'),
setup=True,
no_output=True,)
Working directory: "/Users/jinningwang/work/ams/examples" Parsing input file "/Users/jinningwang/work/miniconda3/envs/amsre/lib/python3.12/site-packages/ams/cases/5bus/pjm5bus_uced.xlsx"... Input file parsed in 0.0411 seconds. Zero line rates detacted in rate_b, rate_c, adjusted to 999. System set up in 0.0039 seconds.
print(sp.supported_models())
Supported Groups and Models Group | Models -------------+------------------------------- ACLine | Line ACShort | Jumper ACTopology | Bus Collection | Area, Region Cost | GCost, SFRCost, VSGCost, DCost DG | PVD1, ESD1, EV1, EV2 Horizon | TimeSlot, EDTSlot, UCTSlot Information | Summary RenGen | REGCA1 Reserve | SFR, SR, NSR, VSGR StaticGen | Slack, PV StaticLoad | PQ StaticShunt | Shunt Undefined | SRCost, NSRCost VSG | REGCV1, REGCV2
Similarly, all supported routiens can be listed.
print(sp.supported_routines())
Supported Types and Routines Type | Routines ------+----------------------------------------------------- ACED | ACOPF DCED | DCOPF, ED, EDDG, EDES, RTED, RTEDDG, RTEDES, RTEDVIS DCUC | UC, UCDG, UCES DED | DOPF, DOPFVIS PF | DCPF, PFlow, CPF, PFlow0, DCPF0
To check the documentation for the routine model, use its doc()
method.
print(sp.RTED.doc())
Routine <RTED> in Type <DCED> DC-based real-time economic dispatch (RTED). RTED extends DCOPF with: - Mapping dicts to interface with ANDES - Function ``dc2ac`` to do the AC conversion - Vars for SFR reserve: ``pru`` and ``prd`` - Param for linear SFR cost: ``cru`` and ``crd`` - Param for SFR requirement: ``du`` and ``dd`` - Param for ramping: start point ``pg0`` and ramping limit ``R10`` - Param ``pg0``, which can be retrieved from dynamic simulation results. The function ``dc2ac`` sets the ``vBus`` value from solved ACOPF. Without this conversion, dynamic simulation might fail due to the gap between DC-based dispatch results and AC-based dynamic initialization. Notes ----- 1. Formulations has been adjusted with interval ``config.t``, 5/60 [Hour] by default. 2. The tie-line flow has not been implemented in formulations. Objective Unit ---- $ Expressions Name | Description | Unit -------+----------------+----- plf | Line flow | p.u. pmaxe | Effective pmax | p.u. pmine | Effective pmin | p.u. Constraints Name | Description -------+---------------------------------- pb | power balance sbus | align slack bus angle pglb | pg min pgub | pg max plflb | line flow lower bound plfub | line flow upper bound alflb | line angle difference lower bound alfub | line angle difference upper bound rbu | RegUp reserve balance rbd | RegDn reserve balance rru | RegUp reserve source rrd | RegDn reserve source rgu | Gen ramping up rgd | Gen ramping down Vars Name | Description | Unit | Properties ------+-------------------+------+----------- pg | Gen active power | p.u. | aBus | Bus voltage angle | rad | pru | RegUp reserve | p.u. | nonneg prd | RegDn reserve | p.u. | nonneg ExpressionCalcs Name | Description | Unit -----+-------------------+------- pi | LMP, dual of <pb> | $/p.u. Services Name | Description | Type --------+--------------------------------------+---------- csb | select slack bus | VarSelect ctrle | Effective Gen controllability | NumOpDual nctrl | Effective Gen uncontrollability | NumOp nctrle | Effective Gen uncontrollability | NumOpDual gs | Sum Gen vars vector in shape of zone | ZonalSum ds | Sum pd vector in shape of zone | ZonalSum pdz | zonal total load | NumOpDual dud | zonal RegUp reserve requirement | NumOpDual ddd | zonal RegDn reserve requirement | NumOpDual Parameters Name | Description | Unit ---------+-------------------------------------------+----------- ug | Gen connection status | pg0 | Gen initial active power | p.u. gsh | shunt conductance | buss | Bus slack | pd | active demand | p.u. Cg | Gen connection matrix | Cl | Load connection matrix | CftT | Transpose of line connection matrix | Csh | Shunt connection matrix | Bbus | Bus admittance matrix | Bf | Bf matrix | Pbusinj | Bus power injection vector | Pfinj | Line power injection vector | c2 | Gen cost coefficient 2 | $/(p.u.^2) c1 | Gen cost coefficient 1 | $/(p.u.) c0 | Gen cost coefficient 0 | $ ctrl | Gen controllability | pmax | Gen maximum active power | p.u. pmin | Gen minimum active power | p.u. ul | Line connection status | rate_a | long-term flow limit | p.u. amax | max line angle difference | amin | min line angle difference | zg | Gen zone | zd | Load zone | R10 | 10-min ramp rate | p.u./h cru | RegUp reserve coefficient | $/(p.u.) crd | RegDown reserve coefficient | $/(p.u.) du | RegUp reserve requirement in percentage | % dd | RegDown reserve requirement in percentage | % Config Fields in [RTED] Option | Value | Info | Acceptable values -------+-------+------------------------+------------------ t | 0.083 | time interval in hours |
The summary()
method gives a brief summary of the system and routiens that passed the data check.
sp.summary()
-> Systen size: Base: 100 MVA; Frequency: 60 Hz 5 Buses; 7 Lines; 4 Static Generators Active load: 10.00 p.u.; Reactive load: 3.29 p.u. -> Data check results: ACED: ACOPF DCED: DCOPF, ED, RTED DCUC: UC DED: DOPF PF: DCPF, PFlow, CPF, PFlow0, DCPF0