{ "cells": [ { "cell_type": "markdown", "source": [ "# 5-bus Market simulation with [PowerSimulations.jl](https://github.com/NREL-SIIP/PowerSimulations.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 simulations that consist of sequential optimization problems\n", "where results from previous problems inform subsequent problems in a variety of ways. This\n", "example demonstrates some of these capabilities to represent electricity market clearing." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Dependencies and Data\n", "First, let's create `System`s to represent the Day-Ahead and Real-Time market clearing\n", "process with hourly, and 5-minute time series data, respectively." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "### Modeling Packages" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using PowerSystems\n", "using PowerSimulations\n", "using PowerSystemCaseBuilder" ], "metadata": {}, "execution_count": 1 }, { "cell_type": "markdown", "source": [ "### Data management packages" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Dates\n", "using DataFrames" ], "metadata": {}, "execution_count": 2 }, { "cell_type": "markdown", "source": [ "### Optimization packages" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "MathOptInterface.OptimizerWithAttributes(Ipopt.Optimizer, Pair{MathOptInterface.AbstractOptimizerAttribute,Any}[MathOptInterface.RawParameter(\"print_level\") => 0])" }, "metadata": {}, "execution_count": 3 } ], "cell_type": "code", "source": [ "using Cbc # mip solver\n", "solver = optimizer_with_attributes(Cbc.Optimizer, \"logLevel\" => 1, \"ratioGap\" => 0.5)\n", "using Ipopt # solver that supports duals\n", "ipopt_solver = optimizer_with_attributes(Ipopt.Optimizer, \"print_level\" => 0)" ], "metadata": {}, "execution_count": 3 }, { "cell_type": "markdown", "source": [ "### 5-bus Data\n", "The five bus system data here includes hourly day-ahead data, 5-minute real-time market\n", "data, and 6-second actual data. We'll only use the hourly and 5-minute data for the\n", "example simulations below, but the 6-second data is included for future development." ], "metadata": {} }, { "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "┌ Info: Building new system 5_bus_matpower_DA from raw data\n", "└ sys_descriptor.raw_data = \"/Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/matpower/case5_re_uc.m\"\n", "[ Info: extending matpower format with data: areas 1x3\n", "[ Info: extending matpower format with data: gen_name 7x4\n", "[ Info: extending matpower format by appending matrix \"gen_name\" in to \"gen\"\n", "[ Info: reversing the orientation of branch 6 (4, 3) to be consistent with other parallel branches\n", "[ Info: the voltage setpoint on generator 4 does not match the value at bus 4\n", "[ Info: the voltage setpoint on generator 1 does not match the value at bus 1\n", "[ Info: the voltage setpoint on generator 5 does not match the value at bus 10\n", "[ Info: the voltage setpoint on generator 2 does not match the value at bus 1\n", "[ Info: the voltage setpoint on generator 3 does not match the value at bus 3\n", "[ Info: removing 1 cost terms from generator 4: [4000.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 1: [1400.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 5: [1000.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 2: [1500.0, 0.0]\n", "[ Info: removing 3 cost terms from generator 6: Float64[]\n", "[ Info: removing 3 cost terms from generator 7: Float64[]\n", "[ Info: removing 1 cost terms from generator 3: [3000.0, 0.0]\n", "┌ Info: Constructing System from Power Models\n", "│ data[\"name\"] = \"nesta_case5_pjm\"\n", "└ data[\"source_type\"] = \"matpower\"\n", "[ Info: Reading bus data\n", "[ Info: Reading generator data\n", "[ Info: Reading branch data\n", "┌ Warning: Rate 1200.0 MW for bus2-bus3-i_4 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus1-bus2-i_1 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus1-bus4-i_2 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus4-bus5-i_7 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 1000.0 MW for bus1-bus5-i_3 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "[ Info: Reading branch data\n", "[ Info: Reading DC Line data\n", "[ Info: Reading storage data\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch2\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch2\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "[ Info: Serialized time series data to /Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/serialized_system/ForecastOnly/5_bus_matpower_DA_time_series_storage.h5.\n", "[ Info: Serialized System to /Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/serialized_system/ForecastOnly/5_bus_matpower_DA.json\n", "┌ Info: Building new system 5_bus_matpower_RT from raw data\n", "└ sys_descriptor.raw_data = \"/Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/matpower/case5_re_uc.m\"\n", "[ Info: extending matpower format with data: areas 1x3\n", "[ Info: extending matpower format with data: gen_name 7x4\n", "[ Info: extending matpower format by appending matrix \"gen_name\" in to \"gen\"\n", "[ Info: reversing the orientation of branch 6 (4, 3) to be consistent with other parallel branches\n", "[ Info: the voltage setpoint on generator 4 does not match the value at bus 4\n", "[ Info: the voltage setpoint on generator 1 does not match the value at bus 1\n", "[ Info: the voltage setpoint on generator 5 does not match the value at bus 10\n", "[ Info: the voltage setpoint on generator 2 does not match the value at bus 1\n", "[ Info: the voltage setpoint on generator 3 does not match the value at bus 3\n", "[ Info: removing 1 cost terms from generator 4: [4000.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 1: [1400.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 5: [1000.0, 0.0]\n", "[ Info: removing 1 cost terms from generator 2: [1500.0, 0.0]\n", "[ Info: removing 3 cost terms from generator 6: Float64[]\n", "[ Info: removing 3 cost terms from generator 7: Float64[]\n", "[ Info: removing 1 cost terms from generator 3: [3000.0, 0.0]\n", "┌ Info: Constructing System from Power Models\n", "│ data[\"name\"] = \"nesta_case5_pjm\"\n", "└ data[\"source_type\"] = \"matpower\"\n", "[ Info: Reading bus data\n", "[ Info: Reading generator data\n", "[ Info: Reading branch data\n", "┌ Warning: Rate 1200.0 MW for bus2-bus3-i_4 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus1-bus2-i_1 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus1-bus4-i_2 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 200.0 MW for bus4-bus5-i_7 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "┌ Warning: Rate 1000.0 MW for bus1-bus5-i_3 is larger than the max expected in the range of (min = 134.0, max = 145.0).\n", "└ @ PowerSystems ~/.julia/packages/PowerSystems/N2l8o/src/utils/IO/branchdata_checks.jl:148\n", "[ Info: Reading branch data\n", "[ Info: Reading DC Line data\n", "[ Info: Reading storage data\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch2\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch1\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "┌ Warning: no component category=Generator name=HydroDispatch3\n", "└ @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/lYELp/src/system_data.jl:448\n", "[ Info: Serialized time series data to /Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/serialized_system/ForecastOnly/5_bus_matpower_RT_time_series_storage.h5.\n", "[ Info: Serialized System to /Users/cbarrows/.julia/packages/PowerSystemCaseBuilder/1xViZ/data/serialized_system/ForecastOnly/5_bus_matpower_RT.json\n" ] }, { "output_type": "execute_result", "data": { "text/plain": "System\n======\nSystem Units Base: SYSTEM_BASE\nBase Power: 100.0\nBase Frequency: 60.0\n\nComponents\n==========\nNum components: 30\n\n\u001b[1m9×3 DataFrame\u001b[0m\n\u001b[1m Row \u001b[0m│\u001b[1m ConcreteType \u001b[0m\u001b[1m SuperTypes \u001b[0m\u001b[1m Count \u001b[0m\n\u001b[1m \u001b[0m│\u001b[90m String \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Int64 \u001b[0m\n─────┼────────────────────────────────────────────────────────────────────\n 1 │ Arc Topology <: Component <: Infrast… 6\n 2 │ Area AggregationTopology <: Topology … 1\n 3 │ Bus Topology <: Component <: Infrast… 5\n 4 │ Line ACBranch <: Branch <: Device <: … 5\n 5 │ LoadZone AggregationTopology <: Topology … 1\n 6 │ PhaseShiftingTransformer ACBranch <: Branch <: Device <: … 2\n 7 │ PowerLoad StaticLoad <: ElectricLoad <: St… 3\n 8 │ RenewableDispatch RenewableGen <: Generator <: Sta… 2\n 9 │ ThermalStandard ThermalGen <: Generator <: Stati… 5\n\nTimeSeriesContainer\n===================\nComponents with time series data: 5\nTotal StaticTimeSeries: 5\nTotal Forecasts: 5\nResolution: 60 minutes\nFirst initial time: 2020-01-01T00:00:00\nLast initial time: 2020-03-24T12:00:00\nHorizon: 12\nInterval: 60 minutes\nForecast window count: 2005\n", "text/html": [ "

System

\n", "

Base Power: 100.0

\n", "

Components

\n", "

Num components: 30

\n", "

9 rows × 3 columns

ConcreteTypeSuperTypesCount
StringStringInt64
1ArcTopology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any6
2AreaAggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any1
3BusTopology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any5
4LineACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any5
5LoadZoneAggregationTopology <: Topology <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any1
6PhaseShiftingTransformerACBranch <: Branch <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any2
7PowerLoadStaticLoad <: ElectricLoad <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any3
8RenewableDispatchRenewableGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any2
9ThermalStandardThermalGen <: Generator <: StaticInjection <: Device <: Component <: InfrastructureSystemsComponent <: InfrastructureSystemsType <: Any5
\n", "\n", "

TimeSeriesContainer

\n", "

Components with time series data: 5

\n", "

Total StaticTimeSeries: 5

\n", "

Total Forecasts: 5

\n", "

Resolution: 60 minutes

\n", "

First initial time: 2020-01-01T00:00:00

\n", "

Last initial time: 2020-03-24T12:00:00

\n", "

Horizon: 12

\n", "

Interval: 60 minutes

\n", "

Forecast window count: 2005

\n" ] }, "metadata": {}, "execution_count": 4 } ], "cell_type": "code", "source": [ "sys_DA = build_system(SIIPExampleSystems, \"5_bus_matpower_DA\")\n", "sys_RT = build_system(SIIPExampleSystems, \"5_bus_matpower_RT\")" ], "metadata": {}, "execution_count": 4 }, { "cell_type": "markdown", "source": [ "## `OperationsProblemTemplate`s" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "\nOperations Problem Specification\n============================================\nTransmission: CopperPlatePowerModel\n============================================\nDevices Models: \n\n\tType: ThermalStandard\n \tFormulation: ThermalDispatch\n\n\tType: HydroDispatch\n \tFormulation: HydroDispatchRunOfRiver\n\n\tType: PowerLoad\n \tFormulation: StaticPowerLoad\n\n\tType: RenewableFix\n \tFormulation: FixedOutput\n\n\tType: RenewableDispatch\n \tFormulation: RenewableFullDispatch\n\n\tType: HydroEnergyReservoir\n \tFormulation: HydroDispatchRunOfRiver\n\n\tType: InterruptibleLoad\n \tFormulation: InterruptiblePowerLoad\n\n============================================\nBranches Models: \n\n\tType: Line\n \tFormulation: StaticBranch\n\n\tType: TapTransformer\n \tFormulation: StaticBranch\n\n\tType: Transformer2W\n \tFormulation: StaticBranch\n\n\tType: HVDCLine\n \tFormulation: HVDCDispatch\n\n============================================\nServices Models:\n\n\tType: VariableReserve{ReserveDown}\n \tFormulation: RangeReserve\n\n\tType: VariableReserve{ReserveUp}\n \tFormulation: RangeReserve\n\n============================================\n" }, "metadata": {}, "execution_count": 5 } ], "cell_type": "code", "source": [ "template_uc = template_unit_commitment()\n", "template_ed = template_economic_dispatch()" ], "metadata": {}, "execution_count": 5 }, { "cell_type": "markdown", "source": [ "### Define the Simulation Sequence" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Feed Forward Chronology\n-----------------------\n\nED: SemiContinuousFF -> ThermalStandard\n\n UC--┐ from : On\n |\n┌----┬----┬----┬----┬----┼----┬----┬----┬----┬----┬----┐\n| | | | | | | | | | | |\n| | | | | | | | | | | |\n└─ED └─ED └─ED └─ED └─ED └─ED └─ED └─ED └─ED └─ED └─ED └─ED ... (x24) to : [\"P\"]\n\nInitial Condition Chronology\n----------------------------\n\n1\n|\n|\n2 --> 2 ... (x24) \n" }, "metadata": {}, "execution_count": 6 } ], "cell_type": "code", "source": [ "problems = SimulationProblems(\n", " UC = OperationsProblem(\n", " template_uc,\n", " sys_DA,\n", " optimizer = solver,\n", " balance_slack_variables = true,\n", " ),\n", " ED = OperationsProblem(\n", " template_ed,\n", " sys_RT,\n", " optimizer = ipopt_solver,\n", " constraint_duals = [:CopperPlateBalance],\n", " ),\n", ")\n", "\n", "feedforward_chronologies = Dict((\"UC\" => \"ED\") => Synchronize(periods = 24))\n", "\n", "feedforward = Dict(\n", " (\"ED\", :devices, :ThermalStandard) => SemiContinuousFF(\n", " binary_source_problem = ON,\n", " affected_variables = [ACTIVE_POWER],\n", " ),\n", ")\n", "\n", "#cache = Dict(\"UC\" => [TimeStatusChange(ThermalStandard, PSI.ON)])\n", "intervals = Dict(\"UC\" => (Hour(24), Consecutive()), \"ED\" => (Hour(1), Consecutive()))\n", "\n", "DA_RT_sequence = SimulationSequence(\n", " problems = problems,\n", " intervals = intervals,\n", " ini_cond_chronology = InterProblemChronology(),\n", " feedforward_chronologies = feedforward_chronologies,\n", " feedforward = feedforward,\n", ")" ], "metadata": {}, "execution_count": 6 }, { "cell_type": "markdown", "source": [ "## `Simulation`" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "Simulation()\n" }, "metadata": {}, "execution_count": 7 } ], "cell_type": "code", "source": [ "file_path = mkpath(joinpath(\".\", \"5-bus-simulation\"))\n", "sim = Simulation(\n", " name = \"5bus-test\",\n", " steps = 1,\n", " problems = problems,\n", " sequence = DA_RT_sequence,\n", " simulation_folder = file_path,\n", ")" ], "metadata": {}, "execution_count": 7 }, { "cell_type": "markdown", "source": [ "### Build simulation" ], "metadata": {} }, { "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "┌ Info: \n", "│ ──────────────────────────────────────────────────────────────────────────────\n", "│ Time Allocations \n", "│ ────────────────────── ───────────────────────\n", "│ Tot / % measured: 1.78s / 100% 148MiB / 100% \n", "│ \n", "│ Section ncalls time %tot avg alloc %tot avg\n", "│ ──────────────────────────────────────────────────────────────────────────────\n", "│ Build Simulation 1 1.78s 100% 1.78s 148MiB 100% 148MiB\n", "│ Build Problems 1 1.77s 100% 1.77s 148MiB 100% 148MiB\n", "│ Problem UC 1 1.21s 68.3% 1.21s 117MiB 79.2% 117MiB\n", "│ ThermalStandard 1 521ms 29.3% 521ms 41.0MiB 27.7% 41.0MiB\n", "│ Services 1 96.8ms 5.45% 96.8ms 10.5MiB 7.06% 10.5MiB\n", "│ Build pre-step 1 29.4ms 1.65% 29.4ms 2.79MiB 1.89% 2.79MiB\n", "│ RenewableDis... 1 4.12ms 0.23% 4.12ms 962KiB 0.63% 962KiB\n", "│ PowerLoad 1 2.98ms 0.17% 2.98ms 321KiB 0.21% 321KiB\n", "│ CopperPlateP... 1 747μs 0.04% 747μs 454KiB 0.30% 454KiB\n", "│ Objective 1 78.3μs 0.00% 78.3μs 109KiB 0.07% 109KiB\n", "│ HydroDispatch 1 59.2μs 0.00% 59.2μs 4.58KiB 0.00% 4.58KiB\n", "│ HydroEnergyR... 1 44.0μs 0.00% 44.0μs 4.70KiB 0.00% 4.70KiB\n", "│ RenewableFix 1 40.8μs 0.00% 40.8μs 4.58KiB 0.00% 4.58KiB\n", "│ Interruptibl... 1 17.7μs 0.00% 17.7μs 4.63KiB 0.00% 4.63KiB\n", "│ Line 1 2.40μs 0.00% 2.40μs 64.0B 0.00% 64.0B\n", "│ HVDCLine 1 1.44μs 0.00% 1.44μs 64.0B 0.00% 64.0B\n", "│ Transformer2W 1 1.22μs 0.00% 1.22μs 64.0B 0.00% 64.0B\n", "│ TapTransformer 1 1.11μs 0.00% 1.11μs 64.0B 0.00% 64.0B\n", "│ Problem ED 1 560ms 31.5% 560ms 30.6MiB 20.6% 30.6MiB\n", "│ PowerLoad 1 3.56ms 0.20% 3.56ms 113KiB 0.07% 113KiB\n", "│ RenewableDis... 1 1.85ms 0.10% 1.85ms 250KiB 0.17% 250KiB\n", "│ ThermalStandard 1 1.78ms 0.10% 1.78ms 915KiB 0.60% 915KiB\n", "│ Build pre-step 1 416μs 0.02% 416μs 61.7KiB 0.04% 61.7KiB\n", "│ CopperPlateP... 1 117μs 0.01% 117μs 54.3KiB 0.04% 54.3KiB\n", "│ Services 1 98.3μs 0.01% 98.3μs 10.4KiB 0.01% 10.4KiB\n", "│ RenewableFix 1 47.1μs 0.00% 47.1μs 4.58KiB 0.00% 4.58KiB\n", "│ HydroEnergyR... 1 33.2μs 0.00% 33.2μs 4.70KiB 0.00% 4.70KiB\n", "│ HydroDispatch 1 26.7μs 0.00% 26.7μs 4.58KiB 0.00% 4.58KiB\n", "│ Interruptibl... 1 20.4μs 0.00% 20.4μs 4.63KiB 0.00% 4.63KiB\n", "│ Objective 1 13.4μs 0.00% 13.4μs 5.22KiB 0.00% 5.22KiB\n", "│ Line 1 2.86μs 0.00% 2.86μs 64.0B 0.00% 64.0B\n", "│ HVDCLine 1 1.80μs 0.00% 1.80μs 64.0B 0.00% 64.0B\n", "│ TapTransformer 1 1.34μs 0.00% 1.34μs 64.0B 0.00% 64.0B\n", "│ Transformer2W 1 1.31μs 0.00% 1.31μs 64.0B 0.00% 64.0B\n", "│ Initialize Simul... 1 1.50ms 0.08% 1.50ms 19.7KiB 0.01% 19.7KiB\n", "│ Serializing Simu... 1 757μs 0.04% 757μs 16.0KiB 0.01% 16.0KiB\n", "│ Assign FeedForward 1 35.4μs 0.00% 35.4μs 3.16KiB 0.00% 3.16KiB\n", "│ Check Steps 1 25.0μs 0.00% 25.0μs 4.45KiB 0.00% 4.45KiB\n", "└ ──────────────────────────────────────────────────────────────────────────────\n" ] }, { "output_type": "execute_result", "data": { "text/plain": "BuildStatus.BUILT = 0" }, "metadata": {}, "execution_count": 8 } ], "cell_type": "code", "source": [ "build!(sim)" ], "metadata": {}, "execution_count": 8 }, { "cell_type": "markdown", "source": [ "### Execute simulation\n", "```julia" ], "metadata": {} }, { "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Presolve 701 (-2599) rows, 1589 (-5971) columns and 2930 (-11098) elements\n", "Perturbing problem by 0.001% of 10 - largest nonzero change 0.00010943053 ( 54.949531%) - largest zero change 0.00010938892\n", "0 Obj 0.0082926214 Primal inf 370.67927 (425)\n", "89 Obj 13060.303 Primal inf 182.89395 (301)\n", "178 Obj 24299.651 Primal inf 100.37047 (232)\n", "267 Obj 30950.67 Primal inf 56.412648 (179)\n", "356 Obj 31158.922 Primal inf 23.524935 (120)\n", "445 Obj 31571.851 Primal inf 5.3320629 (47)\n", "498 Obj 31907.354\n", "Optimal - objective value 31907.325\n", "After Postsolve, objective 31907.325, infeasibilities - dual 42318.909 (240), primal 0 (0)\n", "Presolved model was optimal, full model needs cleaning up\n", "0 Obj 31907.325\n", "Optimal - objective value 31907.325\n", "Optimal objective 31907.32482 - 498 iterations time 0.012, Presolve 0.01\n", "\n", "******************************************************************************\n", "This program contains Ipopt, a library for large-scale nonlinear optimization.\n", " Ipopt is released as open source code under the Eclipse Public License (EPL).\n", " For more information visit https://github.com/coin-or/Ipopt\n", "******************************************************************************\n", "\n" ] }, { "output_type": "execute_result", "data": { "text/plain": "RunStatus.SUCCESSFUL = 0" }, "metadata": {}, "execution_count": 9 } ], "cell_type": "code", "source": [ "execute!(sim, enable_progress_bar = false)" ], "metadata": {}, "execution_count": 9 }, { "cell_type": "markdown", "source": [ "```" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "# Results" ], "metadata": {}, "execution_count": 10 }, { "cell_type": "markdown", "source": [ "First we can load the result metadata\n", "```julia\n", "results = SimulationResults(sim);\n", "uc_results = get_problem_results(results, \"UC\")\n", "ed_results = get_problem_results(results, \"ED\");\n", "```" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Then we can read and examine the results of interest\n", "```julia\n", "prices = read_dual(ed_results, :CopperPlateBalance)\n", "```" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "or if we want to look at the realized values\n", "```julia\n", "read_realized_duals(ed_results)[:CopperPlateBalance]\n", "```" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "*note that in this simulation the prices are all equal to the balance slack\n", "penalty value of $100000/MWh because there is unserved energy in the result*" ], "metadata": {} }, { "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.4" }, "kernelspec": { "name": "julia-1.5", "display_name": "Julia 1.5.4", "language": "julia" } }, "nbformat": 4 }