{ "cells": [ { "cell_type": "markdown", "source": [ "# ACOPF with [PowerSimulations.jl](https://github.com/NREL-SIIP/PowerSimulations.jl) using [PowerModels.jl](https://github.com/lanl-ansi/PowerModels.jl)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "**Originally Contributed by**: Clayton Barrows" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Introduction" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "PowerSimulations.jl supports non-linear AC optimal power flow through a deep integration\n", "with [PowerModels.jl](https://github.com/lanl-ansi/PowerModels.jl). This example shows a\n", "single multi-period optimization of economic dispatch with a full representation of\n", "AC optimal power flow." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Dependencies" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using SIIPExamples\n", "using PowerSystems\n", "using PowerSimulations\n", "using PowerSystemCaseBuilder" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "We can use the a [TAMU synthetic ERCOT dataset](https://electricgrids.engr.tamu.edu/electric-grid-test-cases/).\n", "The TAMU data format relies on a folder containing `.m` or `.raw` files and `.csv`\n", "files for the time series data. We have provided a parser for the TAMU data format with\n", "the `TamuSystem()` function. A version of the system with only one week of time series\n", "is included in PowerSystemCaseBuilder.jl, we can use that version here:" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "sys = build_system(PSYTestSystems, \"tamu_ACTIVSg2000_sys\")\n", "transform_single_time_series!(sys, 2, Hour(1))" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Since we'll be doing non-linear optimization, we need a solver that supports non-linear\n", "problems. Ipopt is quite good." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Ipopt\n", "solver = optimizer_with_attributes(Ipopt.Optimizer)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "In the [OperationsProblem example](../../notebook/3_PowerSimulations_examples/1_operations_problems.ipynb)\n", "we defined a unit-commitment problem with a copper plate representation of the network.\n", "Here, we want do define an economic dispatch (linear generation decisions) with an ACOPF\n", "network representation.\n", "So, starting with the network, we can select from _almost_ any of the endpoints on this\n", "tree:" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "print_tree(PowerSimulations.PM.AbstractPowerModel)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "For now, let's just choose a standard ACOPF formulation." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "ed_template = OperationsProblemTemplate(QCLSPowerModel)\n", "set_device_model!(ed_template, ThermalStandard, ThermalDispatch)\n", "set_device_model!(ed_template, PowerLoad, StaticPowerLoad)\n", "#set_device_model!(ed_template, FixedAdmittance, StaticPowerLoad) #TODO add constructor for shunts in PSI" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Now we can build a 4-hour economic dispatch / ACOPF problem with the TAMU data." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "problem = OperationsProblem(\n", " ed_template,\n", " sys,\n", " horizon = 1,\n", " optimizer = solver,\n", " balance_slack_variables = true,\n", ")\n", "build!(problem, output_dir = mktempdir())" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "And solve it ... (it's infeasible)" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "solve!(problem)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.5.2" }, "kernelspec": { "name": "julia-1.5", "display_name": "Julia 1.5.2", "language": "julia" } }, "nbformat": 4 }