#include <complex.h>
#include <string.h>
#include "electrode.h"
#include "blas.h"
#include "lapack.h"
Go to the source code of this file.
|
int | fill_incidence_imm (_Complex double *wg, const Electrode *electrodes, size_t num_electrodes, const double *nodes, size_t num_nodes) |
|
int | fill_impedance_imm (_Complex double *wg, const _Complex double *zl, const _Complex double *zt, size_t num_electrodes, size_t num_nodes) |
|
int | solve_immittance (_Complex double *wg, _Complex double *ie, size_t num_electrodes, size_t num_nodes) |
|
int | fill_incidence_adm (_Complex double *a, _Complex double *b, const Electrode *electrodes, size_t num_electrodes, const double *nodes, size_t num_nodes) |
|
int | fill_impedance_adm (_Complex double *yn, _Complex double *zl, _Complex double *zt, _Complex double *a, _Complex double *b, size_t num_electrodes, size_t num_nodes) |
|
int | calculate_yla_ytb (_Complex double *yla, _Complex double *ytb, _Complex double *zl, _Complex double *zt, _Complex double *a, _Complex double *b, size_t num_electrodes, size_t num_nodes) |
|
int | fill_impedance_adm2 (_Complex double *yn, _Complex double *yla, _Complex double *ytb, _Complex double *a, _Complex double *b, size_t num_electrodes, size_t num_nodes) |
|
int | solve_admittance (_Complex double *yn, _Complex double *ic, size_t num_nodes) |
|
◆ calculate_yla_ytb()
int calculate_yla_ytb |
( |
_Complex double * |
yla, |
|
|
_Complex double * |
ytb, |
|
|
_Complex double * |
zl, |
|
|
_Complex double * |
zt, |
|
|
_Complex double * |
a, |
|
|
_Complex double * |
b, |
|
|
size_t |
num_electrodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Calculates the modified longitudinal and transversal admittances \( Z_L^{-1} A \) and \( Z_T^{-1} B \). \( Z_L \) and \( Z_T \) are replaced by their inverses in the process. Useful when they are needed to calculate the currents \( I_L = Z_L^{-1} A U \) and \( I_T = Z_T^{-1} B U \).
- Parameters
-
yla | modified longitudinal admittance \( Z_L^{-1} A \) of size \( m \times n \) |
ytb | modified transversal admittance \( Z_T^{-1} B \) of size \( m \times n \) |
a | longitudinal incidence matrix \( A \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
b | transversal incidence matrix \( B \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
zl | longitudinal impedance matrix \( Z_L \) as a flat array of size \( m^2 \) |
zt | transversal impedance matrix \( Z_T \) as a flat array of size \( m^2 \) |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_impedance_adm2
◆ fill_impedance_adm()
int fill_impedance_adm |
( |
_Complex double * |
yn, |
|
|
_Complex double * |
zl, |
|
|
_Complex double * |
zt, |
|
|
_Complex double * |
a, |
|
|
_Complex double * |
b, |
|
|
size_t |
num_electrodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Calculates the nodal admittance matrix \( Y_N = A^T Z_L^{-1} A + B^T Z_T^{-1} B \). As it is symmetric, only its lower half is stored (set).
- Parameters
-
yn | nodal admmitance matrix \( Y_N \) as flat array of size \( n^2 \) |
a | longitudinal incidence matrix \( A \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
b | transversal incidence matrix \( B \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
zl | longitudinal impedance matrix \( Z_L \) as a flat array of size \( m^2 \) |
zt | transversal impedance matrix \( Z_T \) as a flat array of size \( m^2 \) |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_impedance_adm2
-
solve_admittance
◆ fill_impedance_adm2()
int fill_impedance_adm2 |
( |
_Complex double * |
yn, |
|
|
_Complex double * |
yla, |
|
|
_Complex double * |
ytb, |
|
|
_Complex double * |
a, |
|
|
_Complex double * |
b, |
|
|
size_t |
num_electrodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Calculates the nodal admittance matrix \( Y_N = A^T Z_L^{-1} A + B^T Z_T^{-1} B \), were \( Z_L^{-1} A \) and \( Z_T^{-1} B \) are already calculated. Those matrices are preserved. Useful when they must be calculated to find the currents \( I_L = Z_L^{-1} A U \) and \( I_T = Z_T^{-1} B U \).
- Parameters
-
yn | nodal admmitance matrix \( Y_N \) as flat array of size \( n^2 \) |
a | longitudinal incidence matrix \( A \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
b | transversal incidence matrix \( B \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
yla | modified longitudinal admittance \( Z_L^{-1} A \) |
ytb | modified transversal admittance \( Z_T^{-1} B \) |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_impedance_adm
-
calculate_yla_ylb
-
solve_admittance
◆ fill_impedance_imm()
int fill_impedance_imm |
( |
_Complex double * |
wg, |
|
|
const _Complex double * |
zl, |
|
|
const _Complex double * |
zt, |
|
|
size_t |
num_electrodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Fills the Global Immittance matrix \( W_G = \begin{bmatrix} Y_E & A^T & B^T \\ A & -Z_L & 0 \\ B & 0 & -Z_T \end{bmatrix} \) with the impedance matrices \( Z_L,Z_T \). As it is symmetric, only its lower half is stored (set).
- Parameters
-
wg | Global Immittance matrix as flat array of size \( (2m + n)^2 \) |
zl | longitudinal impedance matrix \( Z_L \) as a flat array of size \( m^2 \) |
zt | transversal impedance matrix \( Z_T \) as a flat array of size \( m^2 \) |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_incidence_imm
-
solve_immittance
◆ fill_incidence_adm()
int fill_incidence_adm |
( |
_Complex double * |
a, |
|
|
_Complex double * |
b, |
|
|
const Electrode * |
electrodes, |
|
|
size_t |
num_electrodes, |
|
|
const double * |
nodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Fills the nodal incidence matrices \( A \) and \( B \) used in the calculation of the nodal admittance matrix \( Y_N = A^T Z_L^{-1} A + B^T Z_T^{-1} B \).
Note that \( B = |A|/2 \) and if it is desired to save memory, A and B can be set to be the same pointer and, in that case, it is guaranteed that the end result will be \( A \). In other words: when only \( A \) is desired, \( B \) can point to \( A, (B := A)\), saving memory space. Then call the function as: fill_incidence_adm(a, a, electrodes, m, nodes, n);
so that \( a:=A \).
- Parameters
-
a | longitudinal incidence matrix \( A \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
b | transversal incidence matrix \( B \) as flat array of size \( m \times n \) in COLUMN MAJOR ordering |
electrodes | array of electrodes |
num_electrodes | number of electrodes \( m \) |
nodes | array of nodes |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_impedance_adm
-
fill_impedance_adm2
◆ fill_incidence_imm()
int fill_incidence_imm |
( |
_Complex double * |
wg, |
|
|
const Electrode * |
electrodes, |
|
|
size_t |
num_electrodes, |
|
|
const double * |
nodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Fills the Global Immittance matrix \( W_G = \begin{bmatrix} Y_E & A^T & B^T \\ A & -Z_L & 0 \\ B & 0 & -Z_T \end{bmatrix} \) with the incidence matrices \( A,B \). This function is separated from fill_impedance because \( A,B \) depend only on geometry, while \( Z_L,Z_T \) will vary with frequency. It is expected that \( W_G \) was zero-ed before calling this function (or allocated through calloc). As \( W_G \) is symmetric, only its lower half is stored (set).
- Parameters
-
wg | Global Immittance matrix \( W_G \) as flat array of size \( (2m + n)^2 \) |
electrodes | array of electrodes |
num_electrodes | number of electrodes \( m \) |
nodes | array of nodes |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on success
- See also
- fill_impedance_imm
-
solve_immittance
◆ solve_admittance()
int solve_admittance |
( |
_Complex double * |
yn, |
|
|
_Complex double * |
ic, |
|
|
size_t |
num_nodes |
|
) |
| |
Solves the system of equations of the Nodal Admitance formulation \( Y_N U = I_E \). It is recommended to use the raw LAPACK routines instead of this function. That way, the same system can be used to solve multiple right hand sides (injection vectors), the optimal workspace can be queried just once when solving for multiple frequencies. See the source code of this function to have an idea.
- Parameters
-
yn | nodal admittance matrix \( Y_N = A^T Z_L^{-1} A + B^T Z_T^{-1} B \), assumed to be symmetric with lower half stored. The LU decomposition is done in-place. |
ie | RHS vector of injected currents in each node. The solution replaces this array in-place. |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on sucess
- See also
- fill_incidence_adm
-
fill_impedance_adm
-
fill_impedance_adm2
◆ solve_immittance()
int solve_immittance |
( |
_Complex double * |
wg, |
|
|
_Complex double * |
ie, |
|
|
size_t |
num_electrodes, |
|
|
size_t |
num_nodes |
|
) |
| |
Solves the system of equations of the Global Immitance formulation.
- Parameters
-
wg | global immittance matrix \( W_G \), assumed to be symmetric with lower half stored. The LU decomposition is done in-place. |
ie | RHS vector \([I_E, 0, 0]^T\) where \( I_E \) are injected currents in each node and 0 are null vectors of size \( m \) each. The solution replaces this array in-place becoming \( [U, I_L, I_T] \). Where \( U \) is the nodal potentials and \( I_L \) and \( I_T \) the longitudinal and transversal currents, respectively. It is recommended to use the raw LAPACK routines instead of this function. That way, the same system can be used to solve multiple right hand sides (injection vectors), the optimal workspace can be queried just once when solving for multiple frequencies. See the source code of this function to have an idea. |
num_electrodes | number of electrodes \( m \) |
num_nodes | number of nodes \( n \) |
- Returns
- 0 on sucess
- See also
- fill_incidence_imm
-
fill_impedance_imm