Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix docs tom file #52

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![PowerNetworkMatrices.jl Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/PowerNetworkMatrices)](https://pkgs.genieframework.com?packages=PowerNetworkMatrices)

`PowerNetworkMatrices.jl` is able to build classic power systems modeling network matrices such as
[Ybus](https://en.wikipedia.org/wiki/Nodal_admittance_matrix), [PTDF](https://www.powerworld.com/WebHelp/Content/MainDocumentation_HTML/Power_Transfer_Distribution_Factors.htm) and LODF.
[Ybus](https://en.wikipedia.org/wiki/Nodal_admittance_matrix), [PTDF](https://www.powerworld.com/WebHelp/Content/MainDocumentation_HTML/Power_Transfer_Distribution_Factors.htm) and [LODF](https://www.powerworld.com/WebHelp/Content/MainDocumentation_HTML/Line_Outage_Distribution_Factors_LODFs.htm#:~:text=Line%20Outage%20Distribution%20Factors%20(LODFs)%20are%20a%20sensitivity%20measure%20of,other%20lines%20in%20the%20system.).

## Version Advisory

Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
PowerNetworkMatrices = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
PowerSystemCaseBuilder = "f00506e0-b84f-492a-93c2-c0a9afc4364e"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"

[compat]
Documenter = "^0.27"
Expand Down
8 changes: 3 additions & 5 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CurrentModule = PowerNetworkMatrices
## Overview

`PowerNetworkMatrices.jl` is a [`Julia`](http://www.julialang.org) package for
the evaluation of network matrices given the system's data. The package allows to compute
the matrices according to different methods, providing a flexibe and powerful tool.
the evaluation of network matrices given the system's data. The package allows to compute
the matrices according to different methods, providing a flexible and powerful tool.

The documentation and code are organized according to the needs of different
users depending on their skillset and requirements. In broad terms there are three categories:
Expand Down Expand Up @@ -37,6 +37,4 @@ For the current development version, "checkout" this package with
```

------------
PowerNetworkMatrices has been developed as part of the Scalable Integrated Infrastructure Planning
(SIIP) initiative at the U.S. Department of Energy's National Renewable Energy
Laboratory ([NREL](https://www.nrel.gov/)).
PowerNetworkMatrices has been developed as part of the Scalable Integrated Infrastructure Planning (SIIP) initiative at the U.S. Department of Energy's National Renewable Energy Laboratory ([NREL](https://www.nrel.gov/)).
38 changes: 19 additions & 19 deletions docs/src/tutorials/tutorial_Incidence_BA_ABA_matrices.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Incidence, BA and ABA matrices

In this tutorial the `IncidenceMatrix`, `BA_matrix` and `ABA_matrix` are presented.
The methods used for their evaluation, as well as how data is stored is shown in
In this tutorial the `IncidenceMatrix`, `BA_matrix` and `ABA_matrix` are presented.
The methods used for their evaluation, as well as how data is stored is shown in
the following subsections.

The matrices here presented are the building blocks for the compuation of the PTDF and LODF matrices.

## IncidenceMatrix

The `PowerNetworkMatrices` package defines the structure `IncidenceMatrix`, which
The `PowerNetworkMatrices` package defines the structure `IncidenceMatrix`, which
store the Incidence Matrix of the considered system as well as the most relevant network data.

At first, the `System` data is loaded.
Expand All @@ -29,7 +29,7 @@ Then the Incidence Matrix is computed as follows:
incidence_matrix = PNM.IncidenceMatrix(sys);
```

The `incidence_matrix` variable is a structure of type `IncidenceMatrix`
The `incidence_matrix` variable is a structure of type `IncidenceMatrix`
featuring the following fields:

``` @repl tutorial_Incidence_BA_ABA_matrices
Expand All @@ -41,13 +41,13 @@ incidence_matrix.axes
# data: Incidence Matrix
incidence_matrix.data

# lookup: dictionary linking the branche names and bus numbers with the row
# lookup: dictionary linking the branches names and bus numbers with the row
# and column numbers, respectively.
incidence_matrix.axes

# ref_bus_positions: set containing the positions of the reference buses.
# this represents the positions where to add the column of zeros. Please refer to the
# exaple in the BA matrix for more details.
# this represents the positions where to add the column of zeros. Please refer to the
# example in the BA matrix for more details.
incidence_matrix.ref_bus_positions
```

Expand All @@ -57,13 +57,13 @@ Please note that the matrix data can be easily access by using the following fun
PNM.get_data(incidence_matrix)
```

Note that the number of columns is lower than the actual number of system buses since
Note that the number of columns is lower than the actual number of system buses since
the column related to the reference bus is discarded.

## BA_Matrix

The `BA_Matrix` is a structure containing the matrix coming from the product of the
`IncidenceMatrix` and the diagonal matrix contianing the impedence of the system's branches ("B" matrix).
`IncidenceMatrix` and the diagonal matrix containing the impedence of the system's branches ("B" matrix).

The `BA_Matrix` is computed as follows:

Expand All @@ -81,27 +81,27 @@ ba_matrix.data
# or by using the "get_data" function
PNM.get_data(ba_matrix)
```
Note that the number of columns is lower than the actual number of system buses since
Note that the number of columns is lower than the actual number of system buses since
the column related to the reference bus is discarded.

To add the column of zeros related to the reference bus, it is necessary to use the
To add the column of zeros related to the reference bus, it is necessary to use the
information contained in the `ref_bus_positions` field.

``` @repl tutorial_Incidence_BA_ABA_matrices
new_ba_matrix = hcat(
ba_matrix.data[:,1:collect(ba_matrix.ref_bus_positions)[1]-1],
zeros(size(ba_matrix, 1), 1),
ba_matrix.data[:,1:collect(ba_matrix.ref_bus_positions)[1]-1],
zeros(size(ba_matrix, 1), 1),
ba_matrix.data[:, collect(ba_matrix.ref_bus_positions)[1]:end]
)
```

However, trying to change the data field with a matrix of different dimension
However, trying to change the data field with a matrix of different dimension
will result in an error.

``` @repl tutorial_Incidence_BA_ABA_matrices
ba_matrix.data = hcat(
ba_matrix.data[:,1:collect(ba_matrix.ref_bus_positions)[1]-1],
zeros(size(ba_matrix, 1), 1),
ba_matrix.data[:,1:collect(ba_matrix.ref_bus_positions)[1]-1],
zeros(size(ba_matrix, 1), 1),
ba_matrix.data[:, collect(ba_matrix.ref_bus_positions)[1]:end]
)
```
Expand All @@ -112,7 +112,7 @@ ba_matrix.data = hcat(
The `ABA_Matrix` is a structure containing the matrix coming from the product of the
`IncidenceMatrix` and the `BA_Matrix`.
It features the same fields as the `IncidenceMatrix` and the `BA_Matrix`, plus the `K` one.
The field `ABA_Matrix.K` stores the LU factorization matrices (using the
The field `ABA_Matrix.K` stores the LU factorization matrices (using the
methods contained in the package `KLU`).

To evaluate the `ABA_Matrix`, the following command is sufficient:
Expand Down Expand Up @@ -141,5 +141,5 @@ aba_matrix.K
The following command can then be used to check if the `ABA_Matrix` contains the LU factorization matrices:

``` @repl tutorial_Incidence_BA_ABA_matrices
is_factorized(aba_matrix_new)
```
is_factorized(aba_matrix)
```
6 changes: 3 additions & 3 deletions docs/src/tutorials/tutorial_LODF_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before diving into this tutorial we encourage the user to load `PowerNetworkMatr

As for the `PTDF` matrix, the `LODF` one can be evaluated according to two different approaches:
- `Dense`: considers functions for dense matrix multiplication and inversion
- `KLU`: considers functions for sparse matrix multiplication and inversion(**default**)
- `KLU`: considers functions for sparse matrix multiplication and inversion (**default**)

The evaluation of the `LODF` matrix can be easily performed starting from importing the system's data and then by simply calling the `LODF` method.

Expand Down Expand Up @@ -69,7 +69,7 @@ lodf_5 = LODF(a, aba, ba);

For those methods that either require the evaluation of the `PTDF` matrix, or that execute this evaluation internally, two different approaches casen be used.

As for the `PTDF` matrix, here too the optional argument `linear_solver` can be specified with either `KLU` (for spars matrix calculation) or `Dense` (for sparse matrix calculation).
As for the `PTDF` matrix, here too the optional argument `linear_solver` can be specified with either `KLU` (for sparse matrix calculation) or `Dense` (for sparse matrix calculation).

``` @repl tutorial_PTDF_matrix
lodf_dense = LODF(sys, linear_solver="Dense");
Expand Down Expand Up @@ -97,4 +97,4 @@ Please consider that 0.4 was used for the purpose of this tutorial. In practice

**NOTE (2):** the `tol` argument does not refer to the "sparsification" tolerance of the `PTDF` matrix that is computed in the `LODF` method.

**NOTE (3):** in case the method `LODF(a::IncidenceMatrix, ptdf::PTDF)` is considerd, an error will be thrown whenever the `tol` argument in the `PTDF` structure used as input is different then 1e-15.
**NOTE (3):** in case the method `LODF(a::IncidenceMatrix, ptdf::PTDF)` is considered, an error will be thrown whenever the `tol` argument in the `PTDF` structure used as input is different than `1e-15`.
8 changes: 4 additions & 4 deletions docs/src/tutorials/tutorial_PTDF_matrix.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PTDF matrix

In this tutorial the methods for computing the Power Transfer Distribution Factors (`PTDF`) are presented.
Before diving into this tutorial we encourage the user to load `PowerNetworkMatrices`, hit the `?` key in the REPL terminal and look for the documentiont of the different `PTDF` methods avialable.
Before diving into this tutorial we encourage the user to load `PowerNetworkMatrices`, hit the `?` key in the REPL terminal and look for the documention of the different `PTDF` methods available.

## Evaluation of the `PTDF` matrix

Expand Down Expand Up @@ -59,11 +59,11 @@ get_ptdf_data(ptdf_klu)
```

By default the "KLU" method is selected, which appeared to require significant less time and memory with respect to "Dense".
Please note that either the `KLU` or `Dense` method isi used, the resultig `PTDF` matrix is stored as a dense one.
Please note that either the `KLU` or `Dense` method is used, the resulting `PTDF` matrix is stored as a dense one.

## Evaluating the `PTDF` matrix considering distributed slack bus

Whenever needed, the `PTDF` matrix can be computed with a distributed slack bus. To do so, a vecotr of type `Vector{Float64}` needs to be defined, specifying the weights for each bus of the system. These weights identify how the load on the slakc bus is redistributed accross the system.
Whenever needed, the `PTDF` matrix can be computed with a distributed slack bus. To do so, a vector of type `Vector{Float64}` needs to be defined, specifying the weights for each bus of the system. These weights identify how the load on the slakc bus is redistributed accross the system.

``` @repl tutorial_PTDF_matrix
# consider equal distribution accross each bus for this example
Expand All @@ -78,7 +78,7 @@ Once the vector of the weights is defined, the `PTDF` matrix can be computed by
ptdf_distr = PTDF(sys, dist_slack=dist_slack_array);
```

The diffrence between a the matrix computed with and without the `dist_slack` field defined can be seen as follows:
The difference between a the matrix computed with and without the `dist_slack` field defined can be seen as follows:

``` @repl tutorial_PTDF_matrix
# with no distributed slack bus
Expand Down
10 changes: 5 additions & 5 deletions docs/src/tutorials/tutorial_VirtualLODF_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Refer to the different arguments of the `VirtualLODF` methods by looking at the

The `VirtualLODF` structure retains many of the similarities of the `VirtualPTDF`. However, its computation is more complex and requires some additional data.

Starting from the system data, the `IncidenceMatrix`, `BA_Matrix` and `ABA_Matrix` (with relative LU factorization matrices) are evaluated. The `ABA_Matrix` and `BA_Matrix` are used for the computation of the diagonal elements of the `PTDF` matrix, and this vector is stored in the `VirtualLODF` structure together with the other structures abovementioned.
Starting from the system data, the `IncidenceMatrix`, `BA_Matrix` and `ABA_Matrix` (with relative LU factorization matrices) are evaluated. The `ABA_Matrix` and `BA_Matrix` are used for the computation of the diagonal elements of the `PTDF` matrix, and this vector is stored in the `VirtualLODF` structure together with the other structures mentioned above.

Once the `VirtualLODF` is initialized, each row of the matrix can be evaluated separately and on user request. The algorithmic procedure is the following:
1. Define the `VirtualPTDF` structure
Expand All @@ -19,12 +19,12 @@ Regarding point 2, if the row has been stored previosly then the desired element
The flowchart below shows how the `VirtualLODF` is structured and how it works. Examples will be presented in the following sections.

```@raw html
<img src="../assets/VirtualLODF_scheme.png"/>
<img src="../../assets/VirtualLODF_scheme.png"/>
```

## Initialize `VirtualLODF` and compute/access row/element

As for the `LODF` matrix, at first the `System` data must be loaded. The "RTS GMLC" systems is considered as example:
As for the `LODF` matrix, at first the `System` data must be loaded. The "RTS-GMLC" systems is considered as example:

``` @repl tutorial_VirtualPTDF_matrix
using PowerNetworkMatrices
Expand Down Expand Up @@ -58,9 +58,9 @@ col_number = v_lodf.lookup[2]["A3"]
el_C31_2_105_bis = v_lodf[row_number, col_number]
```

**NOTE**: this example was made for the sake of completeness and considering the actual branch names is reccomended.
**NOTE**: this example was made for the sake of completeness and considering the actual branch names is recommended.

As previosly mentioned, in order to evalute a single element of the `VirtualLODF`, the entire row related to the selected branch must be considered. For this reason it is cached for later calls.
As previosly mentioned, in order to evaluate a single element of the `VirtualLODF`, the entire row related to the selected branch must be considered. For this reason it is cached for later calls.
This is evident by looking at the following example:

``` @repl tutorial_VirtualPTDF_matrix
Expand Down
10 changes: 5 additions & 5 deletions docs/src/tutorials/tutorial_VirtualPTDF_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Regarding point 2, if the row has been stored previosly then the desired element
The flowchart below shows how the `VirtualPTDF` is structured and how it works. Examples will be presented in the following sections.

```@raw html
<img src="../assets/VirtualPTDF_scheme.png"/>
<img src="../../assets/VirtualPTDF_scheme.png"/>
```

## Initialize `VirtualPTDF` and compute/access row/element

As for the `PTDF` matrix, at first the `System` data must be loaded. The "RTS GMLC" systems is considered as example:
As for the `PTDF` matrix, at first the `System` data must be loaded. The "RTS-GMLC" systems is considered as example:

``` @repl tutorial_VirtualPTDF_matrix
using PowerNetworkMatrices
Expand Down Expand Up @@ -57,7 +57,7 @@ el_C31_2_105_bis = v_ptdf[row_number, col_number]

**NOTE**: this example was made for the sake of completeness and considering the actual branch name and bus number is reccomended.

As previosly mentioned, in order to evalute a single element of the `VirtualPTDF`, the entire row related to the selected branch must be considered. For this reason it is cached in the `VirtualPTDF` structure for later calls.
As previosly mentioned, in order to evaluate a single element of the `VirtualPTDF`, the entire row related to the selected branch must be considered. For this reason it is cached in the `VirtualPTDF` structure for later calls.
This is evident by looking at the following example:

``` @repl tutorial_VirtualPTDF_matrix
Expand All @@ -75,7 +75,7 @@ v_ptdf_2k = VirtualPTDF(sys_2k);
## `VirtualPTDF` with distributed slack bus

As for the `PTDF` matrix, here too each row can be evaluated considering distibuted slack buses.
A vecotr of type `Vector{Float64}` is defined, specifying the weights for each bus of the system.
A vector of type `Vector{Float64}` is defined, specifying the weights for each bus of the system.

``` @repl tutorial_VirtualPTDF_matrix
# smaller system for the next examples
Expand All @@ -94,7 +94,7 @@ v_ptdf_distr = VirtualPTDF(sys_2, dist_slack=dist_slack_array);
v_ptdf_orig = VirtualPTDF(sys_2);
```

Now check the difference with the same row related to the branch `"1"` evaluated withou considering distributed slack bus.
Now check the difference with the same row related to the branch `"1"` evaluated without considering distributed slack bus.

``` @repl tutorial_VirtualPTDF_matrix
row_distr = [v_ptdf_distr["1", j] for j in v_ptdf_distr.axes[2]]
Expand Down
2 changes: 1 addition & 1 deletion src/virtual_ptdf_calculations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ matrix.
- `axes<:NTuple{2, Dict}`:
Tuple containing two vectors: the first one showing the branches names,
the second showing the buses numbers. There is no link between the
order of the vector of the branche names and the way the PTDF rows are
order of the vector of the branches names and the way the PTDF rows are
stored in the cache.
- `lookup<:NTuple{2, Dict}`:
Tuple containing two dictionaries, mapping the branches
Expand Down
Loading