Originally Contributed by: Clayton Barrows
PowerSystems.jl supports serializing/deserializing data with JSON. This notebook
provides an example of how to write and read a System
to/from disk.
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
System Units Base |
SYSTEM_BASE |
Base Power |
100.0 |
Base Frequency |
60.0 |
Num Components |
30 |
Static Components
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 |
folder = mktempdir()
@show folder, typeof(folder)
(folder, typeof(folder)) = ("/tmp/jl_5R0VUk", String)
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
sys2 = System(path_to_file)
System
System Units Base |
SYSTEM_BASE |
Base Power |
100.0 |
Base Frequency |
60.0 |
Num Components |
30 |
Static Components
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 |