{ "cells": [ { "cell_type": "markdown", "source": [ "# Time-varying bid problems with [PowerSimulations.jl](https://github.com/NREL-SIIP/PowerSimulations.jl)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "**Originally Contributed by**: Sourabh Dalvi" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Introduction" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "PowerSimulations.jl supports the construction of Operations problems in power system\n", "with three part cost bids for each time step. MarketBidCost allows the user to pass a\n", "time-series of variable cost for energy and ancillary services jointly.\n", "This example shows how to build a Operations problem with MarketBidCost and how to add\n", "the time-series data to the devices." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Dependencies\n", "### Modeling Packages" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using SIIPExamples\n", "using PowerSystems\n", "using PowerSimulations\n", "const PSI = PowerSimulations" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Data management packages" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using PowerSystemCaseBuilder\n", "using Dates\n", "using DataFrames\n", "using TimeSeries" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Optimization packages" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using HiGHS #solver" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Data\n", "Create a `System` from RTS-GMLC data" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "sys = build_system(PSITestSystems, \"modified_RTS_GMLC_DA_sys\")" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Creating the Time Series data for Energy bid" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "MultiDay = collect(\n", " DateTime(\"2020-01-01T00:00:00\"):Hour(1):(DateTime(\"2020-01-01T00:00:00\") + Hour(8783)),\n", ");" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Adding a MarketBidCost time series\n", "Here we add the energy bid\n", "time series to the system. The TimeSeriesData that holds the energy bid data can be of any\n", "type (i.e. `SingleTimeSeries` or `Deterministic`), but it has to be consistent with the existing\n", "data in the `sys`. So, we'll first remove the existing `DeterministicSingleTimeSeries`, then add\n", "the bid time series as `SingleTimeSeries`, then re-transform all of the time series in `sys`." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "remove_time_series!(sys, DeterministicSingleTimeSeries)\n", "\n", "for gen in get_components(ThermalGen, sys)\n", " varcost = get_operation_cost(gen)\n", " data = TimeArray(MultiDay, repeat([get_cost(get_variable(varcost))], 8784))\n", " _time_series = SingleTimeSeries(\"variable_cost\", data)\n", " add_time_series!(sys, gen, _time_series)\n", " #set_variable_cost!(sys, gen, _time_series)\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "### Transforming SingleTimeSeries into Deterministic" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "transform_single_time_series!(sys, 24, Dates.Hour(24))" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "In the [OperationsProblem example](https://nbviewer.jupyter.org/github/NREL-SIIP/SIIPExamples.jl/blob/master/notebook/3_PowerSimulations_examples/01_operations_problems.ipynb)\n", "we defined a unit-commitment problem with a copper plate representation of the network.\n", "Here, we want do define unit-commitment problem with ThermalMultiStartUnitCommitment\n", "formulation for thermal device representation." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "For now, let's just choose a standard UC formulation." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "uc_template = template_unit_commitment()" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "And adjust the thermal generator formulation to use `ThermalMultiStartUnitCommitment`" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "set_device_model!(uc_template, ThermalMultiStart, ThermalMultiStartUnitCommitment)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Now we can build a 4-hour economic dispatch problem with the RTS data." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "solver = optimizer_with_attributes(HiGHS.Optimizer, \"mip_rel_gap\" => 0.5)\n", "\n", "problem = DecisionModel(uc_template, sys, horizon = 4, optimizer = solver)\n", "build!(problem, output_dir = mktempdir())" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "And solve it ..." ], "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.7.2" }, "kernelspec": { "name": "julia-1.7", "display_name": "Julia 1.7.2", "language": "julia" } }, "nbformat": 4 }