Public API
Exported functions and types of ContGridMod.jl
.
Contents
Index
ContGridModML.DynamicSol
ContGridModML.StaticSol
ContGridModML.learn_dynamical_parameters
ContGridModML.learn_susceptances
ContGridModML.load_sol
ContGridModML.save_sol
Structs
ContGridModML.StaticSol
— TypeContains the results of the static training.
b::Vector{T} where T<:Real
: Vector of the nodal susceptances. The ordering is alternating $b_x$ and $b_y$. The values are ordered in the same order as in the DoF handlercm.dh₁
.
losses::Matrix{T} where T<:Real
: The training losses. The row corresponds to the epoch and the column to the data set.
train_pred::Matrix{T} where T<:Real
: Prediction of the values for each training data set with the trained values.
test_pred::Matrix{T} where T<:Real
: Prediction of the values for each test data set with the trained values.
t_train::Matrix{T} where T<:Real
: Ground truth data for the training data sets.
t_test::Matrix{T} where T<:Real
: qprojb Ground truth data for the test data sets.
train_losses::Vector{T} where T<:Real
: Loss values for all training data sets.
test_losses::Vector{T} where T<:Real
: Loss values for all test data sets.
model::ContGridModML.ContModel
: The continuous model with the updated susceptances.
train_models::Vector{<:ContGridModML.DiscModel}
: The discrete models used for training.
test_models::Vector{<:ContGridModML.DiscModel}
: The discrete models used for testing.
n_modes::Int64
: The number of eigenmodes of the Laplacian the model is trained on
ContGridModML.DynamicSol
— TypeContains the results of the dynamic training.
train_ix::Vector{<:Integer}
: Indices of the generators used to create the training ground truth data.
test_ix::Vector{<:Integer}
: Indices of the generators used to create the training ground truth data.
comp_ix::Vector{<:Integer}
: Indices of the nodes on which the frequency is compared to calculate the loss function.
m::Vector{<:Real}
: Vector of the nodal inertia. The values are ordered in the same order as in the DoF handlercm.dh₁
.
d::Vector{<:Real}
: Vector of the nodal damping. The values are ordered in the same order as in the DoF handlercm.dh₁
.
coeffs::Vector{<:Real}
: Coefficients of the modal expansion of the dynamical parameters. The realtion between the nodal values, the coefficients, and the eigenvectors is given byn = size(coeffs, 1) ÷ 2 m = eve[:, 1:n] * coeffs[1:n] d = eve[:, 1:n] * coeffs[n+1:end]
eve::Matrix{<:Real}
: Eigenvectors of the unweighted Laplacian of the grid of the continuous model.
losses::Matrix{<:Real}
: The training losses. The row corresponds to the epoch and the column to the data set.
train_losses::Vector{<:Real}
: Loss values for all training data sets.
test_losses::Vector{<:Real}
: Loss values for all test data sets.
model::ContGridModML.ContModel
: The continuous model with updated inertia and damping.
n_modes::Int64
: The number of eigenmodes of the Laplacian the model is trained on
Functions
ContGridModML.learn_susceptances
— Functionlearn_susceptances(
;
train_folder,
test_folder,
mesh_fn,
n_epoch,
n_batch,
n_modes,
n_coeffs,
comp_ix,
bx_init,
by_init,
rng,
opt,
bmin,
δ
) -> ContGridModML.StaticSol{Float64}
Learn the line susceptances.
The parameters are learned by calculating the stable solution for multiple dispatches and comparing them to the results from the discrete model. The comparison points are obtained by using the liear approximation provided by the finite element method.
Arguments
train_fn::String = MODULE_FOLDER * "/data/ml/training_
": The names of the files containing the training scenarios. The files must be labeledtrain_fn1.h5
,train_fn2.h5
, etc.test_fn::String = MODULE_FOLDER * "/data/ml/test_"
: The names of the files containing the test scenarios. The files must be labeledtest.h5
,test.h5
, etc.grid_fn::String = MODULE_FOLDER * "/data/panta.msh"
: Name of the file containing the meshn_train::Int = 48
: Number of training data setsn_test::Int = 12
: Number of test data setsn_epochs::Int = 10000
: Number of epochsn_batches::Int = 3
: Number of batches per epochtf::Real = 0.05
: Duration of the heat equation diffusion for the power distributionκ::Real = 0.02
: Diffusion constant of the heat equation diffusion for the power distributionσ::Real = 0.01
: Standard deviation for the initial Gaussian distribution of the parametersrng::AbstractRNG = Xoshiro()
: Random number generator used to draw all random numbersbmin::Real = 0.1
: Minimimum value of the suscpetancesδ = 0.5
: Parameter of the Huber loss function
ContGridModML.learn_dynamical_parameters
— Functionlearn_dynamical_parameters(
;
dm_fn,
cm_fn,
dP,
n_train,
n_test,
dt,
tf,
disc_solve_kwargs,
cont_solve_kwargs,
lambda_solve_kwargs,
seed,
n_points,
m_init,
d_init,
n_coeffs,
n_modes,
n_epochs,
max_function,
train_ix,
test_ix,
n_batches
)
Learn the inertia and damping distribution for the continuous model.
The frequency response of faults at multiple generators are compared on homogeneously spread buses across the grid. The gradient is calculated using an adjoint sensitivity method and the updates to the parameters are calculated using a constraint gradient descent method.
Arguments
dm_fn::String = MODULE_FOLDER * "/data/dm.h5"
: File name of the discrete modelcm_fn::String = MODULE_FOLDER * "/data/cm.h5"
: File name of the continuous modeldP::Real = -9.0
: Fault size to be simulatedn_train::Integer = 12
: Amount of faults to consider for trainingn_test::Integer = 4
: Amount of faults to consider for testingdt::Real = 0.01
: Step size at which the solutions of the ODEs are savedtf::Real = 25.0
: Duration of the simulationsdisc_solve_kwargs::Dict{Symbol, <:Any} = Dict{Symbol, Any}()
: Keyword arguments passed to the ODE solver for the discrete modelcont_solve_kwargs::Dict{Symbol, <:Any} = Dict{Symbol, Any}()
: Keyword arguments passed to the ODE solver for the continuous modellambda_solve_kwargs::Dict{Symbol, <:Any} = Dict{Symbol, Any}(:saveat => 0.1, :abstol => 1e-3, :reltol => 1e-2)
: Keyword arguments passed to the ODE solver of the adjoint equationsseed::Union{Nothing, Integer} = 1709
: Seed for the random number generator to be used to pick the training and test generatorsσ = 0.05
: Standard deviation of the Gaussian used to distribute the faultn_points = 40
: Number of points for comparison along the largest dimensionn_coeffs = 1
: Number of coefficients that are non-zero at the beginning of the training. They correspond to then_coeffs
lowest modes of the Laplacian.n_modes = 20
: Number of modes the Laplacian that are used to expand the parameters.n_epochs = 8000
: Number of epochs used for the training.max_function::Function = (x) -> 30 * 2^(x / 500)
: Function that changes the magnitude of the change vector of the parameters wrt the epoch.train_ix::Union{Nothing, Vector{<:Integer}} = nothing
: Indices of the generators used for training if they are not supposed to be picked randomly.test_ix::Union{Nothing, Vector{<:Integer}} = nothing
: Indices of the generators used for testing if they are not supposed to be picked randomly.
If the training and test generators are not supposed to be picked randomly, both train_ix
and test_ix
need to be passed.
ContGridModML.load_sol
— Functionload_sol(
fn::String
) -> Union{ContGridModML.DynamicSol, ContGridModML.StaticSol}
Load a solution from a HDF5 file.
ContGridModML.save_sol
— Functionsave_sol(fn::String, sol::ContGridModML.ContSol)
Save a solution to a HDF5 file.