{ "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\n", "\n", "import datetime" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Last run time: 2024-11-24 17:46:40\n", "ams:0.9.12\n" ] } ], "source": [ "print(\"Last run time:\", datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\"))\n", "\n", "print(f'ams:{ams.__version__}')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "ams.config_logger(stream_level=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load an example case." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Working directory: \"/Users/jinningwang/work/ams/examples\"\n", "Parsing input file \"/Users/jinningwang/work/miniconda3/envs/amsre/lib/python3.12/site-packages/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", "Input file parsed in 0.0411 seconds.\n", "Zero line rates detacted in rate_b, rate_c, adjusted to 999.\n", "System set up in 0.0039 seconds.\n" ] } ], "source": [ "sp = ams.load(ams.get_case('5bus/pjm5bus_uced.xlsx'),\n", " setup=True,\n", " no_output=True,)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## List all models and routines" ] }, { "cell_type": "code", "execution_count": 5, "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, Region \n", " Cost | GCost, SFRCost, VSGCost, DCost\n", " DG | PVD1, ESD1, EV1, EV2 \n", " Horizon | TimeSlot, 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", " Undefined | SRCost, NSRCost \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": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Supported Types and Routines\n", "\n", "Type | Routines \n", "------+-----------------------------------------------------\n", " ACED | ACOPF \n", " DCED | DCOPF, ED, EDDG, EDES, RTED, RTEDDG, RTEDES, RTEDVIS\n", " DCUC | UC, UCDG, UCES \n", " DED | DOPF, DOPFVIS \n", " PF | DCPF, PFlow, CPF, PFlow0, DCPF0 \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": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Routine in Type \n", "DC-based real-time economic dispatch (RTED).\n", "RTED extends DCOPF with:\n", "\n", "- Mapping dicts to interface with ANDES\n", "- Function ``dc2ac`` to do the AC conversion\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", "1. Formulations has been adjusted with interval ``config.t``, 5/60 [Hour] by default.\n", "\n", "2. The tie-line flow has not been implemented in formulations.\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", " 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", "\n", "Services\n", "\n", " Name | Description | Type \n", "--------+--------------------------------------+----------\n", " csb | select slack bus | 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 zone | ZonalSum \n", " ds | Sum pd vector in shape of zone | 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", " pd | 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 zone | \n", " zd | Load zone | \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": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "-> Systen size:\n", "Base: 100 MVA; Frequency: 60 Hz\n", "5 Buses; 7 Lines; 4 Static Generators\n", "Active load: 10.00 p.u.; Reactive load: 3.29 p.u.\n", "-> Data check results:\n", "ACED: ACOPF\n", "DCED: DCOPF, ED, RTED\n", "DCUC: UC\n", "DED: DOPF\n", "PF: DCPF, PFlow, CPF, PFlow0, DCPF0\n" ] } ], "source": [ "sp.summary()" ] } ], "metadata": { "kernelspec": { "display_name": "amsre", "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 }