PSSE 240 Bus Case system with Renewables
Originally Contributed by: José Daniel Lara
Introduction
This tutorial will introduce the industry models of Renewable Energy the comparisons between DiffEq Integration techniques for comparison. We show the uses of Sundials and OrdinaryDiffEq to obtain the transient response of a system to a perturbation.
julia> using PowerSimulationsDynamics
julia> using PowerSystemCaseBuilder
julia> using PowerSystems
julia> const PSY = PowerSystems
PowerSystems
julia> using Sundials
julia> using Plots
julia> using OrdinaryDiffEq
PowerSystemCaseBuilder.jl
is a helper library that makes it easier to reproduce examples in the documentation and tutorials. Normally you would pass your local files to create the system data instead of calling the function build_system
. For more details visit PowerSystemCaseBuilder Documentation
Load the system and transform load data
To load the system we use PowerSystemCaseBuilder.jl
:
julia> # We remove the checks in this example to avoid large prints sys = build_system(PSIDSystems, "WECC 240 Bus"; runchecks = false) # Transform the system's load
ERROR: UndefVarError: `build_system` not defined
julia> for l in get_components(PSY.StandardLoad, sys) transform_load_to_constant_impedance(l) end
ERROR: UndefVarError: `sys` not defined
Build the simulation and initialize the problem
The next step is to create the simulation structure. This will create the indexing of our system that will be used to formulate the differential-algebraic system of equations. To do so, it is required to specify the perturbation that will occur in the system. In this case, we will use a ResidualModel formulation, for more details about the formulation checkout the Models Section in PowerSimulationsDynamics.jl
documentation.
julia> using Logging
julia> sim_ida = Simulation( ResidualModel, sys, #system pwd(), (0.0, 20.0), #time span BranchTrip(1.0, Line, "CORONADO -1101-PALOVRDE -1401-i_10"); console_level = Logging.Info, )
ERROR: UndefVarError: `sys` not defined
Run the simulation using Sundials
We will now run the simulation using Sundials.jl solver IDA() by specifying the maximum dt we want for the simulation. In our experience with this solver, solution times are faster when supplying information about the maximum time step than the tolerances as we can see in the example
julia> execute!(sim_ida, IDA(), dtmax = 0.01)
ERROR: UndefVarError: `sim_ida` not defined
Read the results and plot a system variable
After the simulation is completed, we can extract the results and make plots as desired. In this case, we will plot the voltage magnitude at the bus at which the line was connected.
julia> res_ida = read_results(sim_ida)
ERROR: UndefVarError: `sim_ida` not defined
julia> v1101_ida = get_voltage_magnitude_series(res_ida, 1101);
ERROR: UndefVarError: `res_ida` not defined
julia> plot(v1101_ida);
ERROR: UndefVarError: `v1101_ida` not defined
Run the simulation using Rodas4()
In this case, we will use a MassMatrixModel formulation, for more details about the formulation checkout the Models Section in PowerSimulationsDynamics.jl
documentation
julia> sim_rodas = Simulation( MassMatrixModel, sys, #system pwd(), (0.0, 20.0), #time span BranchTrip(1.0, Line, "CORONADO -1101-PALOVRDE -1401-i_10"); console_level = Logging.Info, )
ERROR: UndefVarError: `sys` not defined
We will now run the simulation using OrdinaryDiffEq.jl solver Rodas4() by specifying the tolerance we want for the simulation. In our experience with this solver, solution times are faster when supplying information about the atol and rtol values as we can see in the example. The solver will also work with a specified dtmax but take a significantly longer time to solve. When using OrdinaryDiffEq.jl solvers always pass the option initializealg = NoInit()
to avoid unnecessary re-initialization of the algebraic equations.
julia> execute!( sim_rodas, Rodas4(), saveat = 0.01, atol = 1e-10, rtol = 1e-10, initializealg = NoInit(), )
ERROR: UndefVarError: `sim_rodas` not defined
Read the results
After the simulation is completed, we can extract the results and make plots as desired. In this case, we will plot the voltage magnitude at the bus at which the line was connected.
julia> res_rodas = read_results(sim_rodas)
ERROR: UndefVarError: `sim_rodas` not defined
Compare the results
After the simulation is completed, we can extract the results and make plots as desired. In this case, we will plot the voltage magnitude at the bus at which the line was connected. For both of the solution techniques.
julia> v1101 = get_voltage_magnitude_series(res_rodas, 1101);
ERROR: UndefVarError: `res_rodas` not defined
julia> plot(v1101, label = "RODAS4");
ERROR: UndefVarError: `v1101` not defined
julia> plot!(v1101_ida, label = "IDA");
ERROR: UndefVarError: `v1101_ida` not defined