title : Example Case 3 - Year Planning author : Andrew Rosemberg date : 20th Feb 2019 –-

Introduction

This an example of the HydroPowerModels package for solving a simple stochastic case with the following specifications:

  • 3 Buses

  • 3 Lines

  • 2 Generators

  • 1 Reservoir and Hydrogenerator

  • 3 Scenarios

  • 12 Stages

  • SOC Formulation

Case

Importing package and optimizer

using ECOS
using HydroPowerModels

Initialization

if !@isdefined plot_bool
    plot_bool = true
end
using Random
seed = 1221

Load Case Specifications

Data

alldata = HydroPowerModels.parse_folder(joinpath(WEAVE_ARGS[:testcases_dir], "case3"));

Plot power grid graph

if plot_bool == true
    Random.seed!(seed)
    HydroPowerModels.plot_grid(alldata[1]; node_label=false)
end
ERROR: UndefVarError: `plot_grid` not defined

Parameters

params = create_param(;
    stages=12,
    model_constructor_grid=SOCWRConicPowerModel,
    post_method=PowerModels.build_opf,
    optimizer=ECOS.Optimizer,
)
Dict{Any, Any} with 12 entries:
  "optimizer"                       => Optimizer
  "discount_factor"                 => 1.0
  "post_method"                     => build_opf
  "setting"                         => Dict{String, Dict{String, Bool}}("ou
tput…
  "stage_hours"                     => 1
  "model_constructor_grid"          => SOCWRConicPowerModel
  "stages"                          => 12
  "optimizer_backward"              => Optimizer
  "model_constructor_grid_forward"  => SOCWRConicPowerModel
  "verbose"                         => false
  "optimizer_forward"               => Optimizer
  "model_constructor_grid_backward" => SOCWRConicPowerModel

Build Model

m = hydrothermaloperation(alldata, params);

Train

start_time = time()
HydroPowerModels.train(
    m;
    iteration_limit=100,
    stopping_rules=[SDDP.Statistical(; num_replications=20, iteration_period=20)],
)
end_time = time() - start_time

Termination Status and solve time (s)

(SDDP.termination_status(m.policygraph), end_time)
ERROR: UndefVarError: `m` not defined

Bounds

if plot_bool == true
    HydroPowerModels.plot_bound(m)
end
ERROR: UndefVarError: `plot_bound` not defined

Simulation

using Random: Random
Random.seed!(seed)
results = HydroPowerModels.simulate(m, 100);

Testing Results

using Test

Bound

@test isapprox(SDDP.calculate_bound(m.policygraph), 11637.76, atol=10)

Number of Simulations

@test length(results[:simulations]) == 100

Plot Aggregated Results

if plot_bool == true
    HydroPowerModels.plot_aggregated_results(results)
end
ERROR: UndefVarError: `plot_aggregated_results` not defined

Annex 1: Case Summary

if plot_bool == true
    PowerModels.print_summary(alldata[1]["powersystem"])
end
Metadata
  baseMVA: 100
  cost_deficit: 1000
  name: case3
  per_unit: true
  source_type: matpower
  source_version: 2

Table Counts
  bus: 3
  load: 3
  shunt: 0
  gen: 3
  storage: 0
  switch: 0
  branch: 3
  dcline: 0


Table: bus
         bus_i, bus_type
      1:     1,        3
      2:     2,        2
      3:     3,        2

  default values:
    base_kv: 0
    vm: 1
    va: 0
    vmin: 0.900
    vmax: 1.100
    area: 1
    zone: 1


Table: load
         load_bus, pd,    qd
      1:        3,  1,     0
      2:        1,  0, 0.000
      3:        2,  0, 0.000

  default values:
    status: 1


Table: gen
         gen_bus,  pmax, ncost,  cost
      1:       2,     1,     2, [(2)]
      2:       3, 0.500,     2, [(2)]
      3:       1, 0.800,     0, [(0)]

  default values:
    pg: 0
    qg: 0
    vg: 1
    mbase: 100
    pmin: 0
    qmin: -100
    qmax: 100
    gen_status: 1
    model: 2
    startup: 0
    shutdown: 0
    apf: 0
    pc1: 0
    pc2: 0
    qc1max: 0
    qc1min: 0
    qc2max: 0
    qc2min: 0
    ramp_10: 0
    ramp_30: 0
    ramp_agc: 0
    ramp_q: 0


Table: branch
         f_bus, t_bus,  br_r,  br_x,  b_fr,  b_to, rate_a
      1:     1,     3, 0.065,     1, 0.225, 0.225,      1
      2:     3,     2, 0.025, 0.500, 0.350, 0.350,  0.650
      3:     1,     2, 0.042,     1, 0.150, 0.150,  0.250

  default values:
    g_fr: 0
    g_to: 0
    tap: 1
    shift: 0
    br_status: 1
    angmax: 1.047
    angmin: -1.047
    transformer: false

Annex 2: Plot Results

if plot_bool == true
    HydroPowerModels.plotresults(results)
end
ERROR: UndefVarError: `plotresults` not defined