SIIP Tutorial

Serializing PowerSystem Data

Originally Contributed by: Clayton Barrows

Introduction

PowerSystems.jl supports serializing/deserializing data with JSON. This notebook provides an example of how to write and read a System to/from disk.

Dependencies

Let's use a dataset from the tabular data parsing example

using PowerSystems
using TimeSeries

base_dir = PowerSystems.download(PowerSystems.TestData; branch="master");
sys = System(joinpath(base_dir, "matpower", "case5_re.m"))
sys
┌ Error: Generator voltage set-points for bus 3 are inconsistent. This can lead to unexpected results
└ @ PowerSystems ~/.julia/packages/PowerSystems/zVsmd/src/parsers/pm_io/matpower.jl:245
┌ Error: Generator voltage set-points for bus 10 are inconsistent. This can lead to unexpected results
└ @ PowerSystems ~/.julia/packages/PowerSystems/zVsmd/src/parsers/pm_io/matpower.jl:245
System
Property Value
System Units Base SYSTEM_BASE
Base Power 100.0
Base Frequency 60.0
Num Components 30
Static Components
Type Count Has Static Time Series Has Forecasts
Arc 6 false false
Area 1 false false
Bus 5 false false
Line 5 false false
LoadZone 1 false false
PhaseShiftingTransformer 2 false false
PowerLoad 3 false false
RenewableDispatch 2 false false
ThermalStandard 5 false false

Write data to a temporary directory

folder = mktempdir()
@show folder, typeof(folder)
(folder, typeof(folder)) = ("/tmp/jl_5R0VUk", String)

Test

path_to_file = joinpath(folder, "system.json")
println("Serializing to $path")
to_json(sys, path_to_file, force=true)

filesize(path_to_file) / (1024 * 1024)
Serializing to path
0.02394390106201172

Read the JSON file and create a new System

sys2 = System(path_to_file)
System
Property Value
System Units Base SYSTEM_BASE
Base Power 100.0
Base Frequency 60.0
Num Components 30
Static Components
Type Count Has Static Time Series Has Forecasts
Arc 6 false false
Area 1 false false
Bus 5 false false
Line 5 false false
LoadZone 1 false false
PhaseShiftingTransformer 2 false false
PowerLoad 3 false false
RenewableDispatch 2 false false
ThermalStandard 5 false false
CC BY-SA 4.0 "Dheepak Krishnamurthy". Last modified: August 26, 2022. Website built with Franklin.jl and the Julia programming language.