{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Inspecting Models" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "We first import the `ams` library and configure the logger level." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import ams" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ams.config_logger(stream_level=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load an example case." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/work/ams/ams/cases/5bus/pjm5bus_demo.xlsx\"...\n", "Input file parsed in 0.0709 seconds.\n", "Zero Line parameters detected, adjusted to default values: rate_b, rate_c.\n", "All bus type are PQ, adjusted given load and generator connection status.\n", "System set up in 0.0021 seconds.\n" ] } ], "source": [ "sp = ams.load(ams.get_case('5bus/pjm5bus_demo.xlsx'),\n", " setup=True,\n", " no_output=True,)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## List all models and routines" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Supported Groups and Models\n", "\n", " Group | Models \n", "-------------+------------------------------------------------\n", " ACLine | Line \n", " ACShort | Jumper \n", " ACTopology | Bus \n", " Collection | Area, Zone \n", " Cost | GCost, SFRCost, SRCost, NSRCost, VSGCost, DCost\n", " DG | PVD1, ESD1, EV1, EV2 \n", " Horizon | EDTSlot, UCTSlot \n", " Information | Summary \n", " RenGen | REGCA1 \n", " Reserve | SFR, SR, NSR, VSGR \n", " StaticGen | Slack, PV \n", " StaticLoad | PQ \n", " StaticShunt | Shunt \n", " VSG | REGCV1, REGCV2 \n", "\n", "\n" ] } ], "source": [ "print(sp.supported_models())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Similarly, all supported routiens can be listed." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Supported Types and Routines\n", "\n", "Type | Routines \n", "------+-----------------------------------------------------------------------\n", " ACED | ACOPF, ACOPF1, OPF \n", " DCED | DCOPF, DCOPF2, RTED, RTEDDG, RTEDESP, RTEDES, RTEDVIS, RTED2, RTED2DG,\n", " | RTED2ES, ED, EDDG, EDES, ED2, ED2DG, ED2ES, DCOPF1 \n", " DCUC | UC, UCDG, UCES, UC2, UC2DG, UC2ES \n", " DED | DOPF, DOPFVIS \n", " PF | DCPF, PFlow, DCPF1, PFlow1 \n", "\n", "\n" ] } ], "source": [ "print(sp.supported_routines())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Check routine documentation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To check the documentation for the routine model, use its ``doc()`` method." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Routine in Type \n", "DC-based real-time economic dispatch (RTED).\n", "\n", "RTED extends DCOPF with:\n", "\n", "- Vars for SFR reserve: ``pru`` and ``prd``\n", "- Param for linear SFR cost: ``cru`` and ``crd``\n", "- Param for SFR requirement: ``du`` and ``dd``\n", "- Param for ramping: start point ``pg0`` and ramping limit ``R10``\n", "- Param ``pg0``, which can be retrieved from dynamic simulation results.\n", "\n", "The function ``dc2ac`` sets the ``vBus`` value from solved ACOPF.\n", "Without this conversion, dynamic simulation might fail due to the gap between\n", "DC-based dispatch results and AC-based dynamic initialization.\n", "\n", "Notes\n", "-----\n", "- Formulations have been adjusted with interval ``config.t``, 5/60 [Hour] by default.\n", "- The tie-line flow related constraints are omitted in this formulation.\n", "- Power generation is balanced for the entire system.\n", "- SFR is balanced for each area.\n", "\n", "Objective\n", "\n", "Unit\n", "----\n", " $ \n", "\n", "Expressions\n", "\n", " Name | Description | Unit\n", "-------+----------------+-----\n", " plf | Line flow | p.u.\n", " pmaxe | Effective pmax | p.u.\n", " pmine | Effective pmin | p.u.\n", "\n", "Constraints\n", "\n", " Name | Description \n", "-------+----------------------------------\n", " pb | power balance \n", " sbus | align slack bus angle \n", " pglb | pg min \n", " pgub | pg max \n", " plflb | line flow lower bound \n", " plfub | line flow upper bound \n", " alflb | line angle difference lower bound\n", " alfub | line angle difference upper bound\n", " rbu | RegUp reserve balance \n", " rbd | RegDn reserve balance \n", " rru | RegUp reserve source \n", " rrd | RegDn reserve source \n", " rgu | Gen ramping up \n", " rgd | Gen ramping down \n", "\n", "Vars\n", "\n", "Name | Description | Unit | Properties\n", "------+------------------------------------+------+-----------\n", " pg | Gen active power | p.u. | \n", " vBus | Bus voltage magnitude, placeholder | p.u. | \n", " aBus | Bus voltage angle | rad | \n", " pru | RegUp reserve | p.u. | nonneg \n", " prd | RegDn reserve | p.u. | nonneg \n", "\n", "ExpressionCalcs\n", "\n", "Name | Description | Unit \n", "-----+---------------------------------------+-------\n", " pi | LMP, dual of | $/p.u.\n", " mu1 | Lagrange multipliers, dual of | $/p.u.\n", " mu2 | Lagrange multipliers, dual of | $/p.u.\n", "\n", "Services\n", "\n", " Name | Description | Type \n", "--------+--------------------------------------+----------\n", " pd | effective active demand | NumOpDual\n", " isb | Index slack bus from all buses | VarSelect\n", " ctrle | Effective Gen controllability | NumOpDual\n", " nctrl | Effective Gen uncontrollability | NumOp \n", " nctrle | Effective Gen uncontrollability | NumOpDual\n", " gs | Sum Gen vars vector in shape of area | ZonalSum \n", " ds | Sum pd vector in shape of area | ZonalSum \n", " pdz | zonal total load | NumOpDual\n", " dud | zonal RegUp reserve requirement | NumOpDual\n", " ddd | zonal RegDn reserve requirement | NumOpDual\n", "\n", "Parameters\n", "\n", " Name | Description | Unit \n", "---------+-------------------------------------------+-----------\n", " ug | Gen connection status | \n", " pg0 | Gen initial active power | p.u. \n", " gsh | shunt conductance | \n", " buss | Bus slack | \n", " ud | Load connection status | \n", " pd0 | active demand | p.u. \n", " Cg | Gen connection matrix | \n", " Cl | Load connection matrix | \n", " CftT | Transpose of line connection matrix | \n", " Csh | Shunt connection matrix | \n", " Bbus | Bus admittance matrix | \n", " Bf | Bf matrix | \n", " Pbusinj | Bus power injection vector | \n", " Pfinj | Line power injection vector | \n", " c2 | Gen cost coefficient 2 | $/(p.u.^2)\n", " c1 | Gen cost coefficient 1 | $/(p.u.) \n", " c0 | Gen cost coefficient 0 | $ \n", " ctrl | Gen controllability | \n", " pmax | Gen maximum active power | p.u. \n", " pmin | Gen minimum active power | p.u. \n", " ul | Line connection status | \n", " rate_a | long-term flow limit | p.u. \n", " amax | max line angle difference | \n", " amin | min line angle difference | \n", " zg | Gen area | \n", " zd | Load area | \n", " R10 | 10-min ramp rate | p.u./h \n", " cru | RegUp reserve coefficient | $/(p.u.) \n", " crd | RegDown reserve coefficient | $/(p.u.) \n", " du | RegUp reserve requirement in percentage | % \n", " dd | RegDown reserve requirement in percentage | % \n", "\n", "\n", "Config Fields in [RTED]\n", "\n", "Option | Value | Info | Acceptable values\n", "-------+-------+------------------------+------------------\n", " t | 0.083 | time interval in hours | \n", "\n", "\n" ] } ], "source": [ "print(sp.RTED.doc())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Check" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ``summary()`` method gives a brief summary of the system and routiens that passed the data check." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "PTDF is not available, build it now\n", "Building system matrices\n", "Parameters c2, c1 are set to 0 as they are associated with ESD1 for following GCost: GCost_5\n", "-> Systen size:\n", "Base: 100 MVA; Frequency: 60 Hz\n", "5 Buses; 7 Lines; 5 Static Generators\n", "Active load: 10.00 p.u.; Reactive load: 3.29 p.u.\n", "-> Data check results:\n", "DCED: DCOPF, DCOPF2, RTED, RTEDDG, RTEDESP, RTEDES, RTEDVIS, RTED2, RTED2DG, RTED2ES, ED, EDDG, EDES, ED2, ED2DG, ED2ES\n", "DCUC: UC, UCDG, UCES, UC2, UC2DG, UC2ES\n", "DED: DOPF, DOPFVIS\n", "PF: DCPF, PFlow\n" ] } ], "source": [ "sp.summary()" ] } ], "metadata": { "kernelspec": { "display_name": "ams", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.0" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }