Electrical network¶
Numerical core of groundinsight. ElectricalNetwork assembles
the nodal admittance matrix \(Y(f)\) per frequency, fills the
right-hand side with source and mutual-coupling Norton currents,
solves the linear system via sparse LU and derives branch
currents, reduction factors and grounding impedances.
Physical / modelling context¶
For each frequency \(f\) in the network's frequency list the model reduces to a sparse complex linear system
with
- \(Y(f)\) the nodal admittance matrix. The diagonal holds the
admittances of the bus electrodes, \(1/Z_B(f, \rho)\) (the symbol
\(Z_E\) is reserved for the earthing impedance of EN 50522, see the
glossary); the branch
self-admittances \(1/Z_b(f, l)\) of the branches with
grounding_conductor=Truejoin the buses they connect. - \(\underline{u}(f)\) the bus-EPR vector.
- \(\underline{i}(f)\) the source currents (scaled by the fault scaling at \(f\)) plus the Norton equivalents of the mutual coupling between phase and grounding conductor along the source-to-fault path.
After the per-frequency solve the network derives:
- Branch currents from \(\Delta u\) and the impressed mutual current.
- Two reduction factors.
valueis the EPR ratio \(|\underline{u}_\text{with}|/|\underline{u}_\text{without}|\) at the fault bus, where the second solve omits the mutual Norton sources — a property of the line, not the reduction factor of EN 50522.value_currentis \(|I_E|/|I_F|\), the earth-return current over the fault current: the reduction factor \(r\) of EN 50522. Both are stored inResultReductionFactor(which one is which). - Earthing impedance \(Z_G = Z_E = Z_\text{dp}(F)\) per frequency
(EN 50522): the driving-point impedance of the earthing network
at the fault bus -- electrodes and shields, without the coupling
and without Thevenin loop closures. The earthing voltage \(U_E\) is
the EPR at the fault bus. The current-weighted mean of the earth
group and its quotient by \(I_E\), reported as \(U_E\)/\(Z_E\) before
audit pass 19, remain available as
u_earthing_group/z_earthing_group.
The ElectricalNetwork is held as a PrivateAttr of Network,
not exposed in the JSON / DB serialisation; it carries the raw
NumPy / SciPy working arrays used by the LU solver.
Example¶
# fragment: assumes a network `net` with the fault "f1"
import groundinsight as gi
# Assume `net` was built via gi.create_* factories with a fault `f1`.
gi.run_fault(network=net, fault="f1") # attaches net.electrical_network
# Inspect derived quantities through the public Network accessors:
df_bus = net.res_buses() # EPR per bus
df_branch = net.res_branches() # branch currents
df_zg = net.res_all_impedances() # grounding impedance + reduction factor
Direct use of ElectricalNetwork is rarely needed; access is
mostly via gi.run_fault and the Network.res_* DataFrame
accessors.
API reference¶
electrical_network ¶
The numerical kernel of the fault solve, built from the core models.
:class:ElectricalNetwork computes with the matrix form of the network:
Y * u = i u = Y^-1 * i
where:
Y - admittance matrix, branches and buses are used to build this matrix u - vector of bus voltages (earth potential rise per bus) i - vector of source injections plus the Norton-equivalent injections that represent the inductive coupling between phase conductors and shield (grounding) conductors along each branch.
Sign convention for the mutual coupling (see _add_mutual_currents): U_from - U_to = Z_self * I_s - Z_mutual * I_p where I_p is the phase current through the branch in from->to direction and I_s is the shield current in the same direction. The induced EMF enters the nodal form as a Norton current i_mut = (Z_mutual / Z_self) * I_p which is injected as +i_mut out of the from bus (nodal: i_vector[from] -= i_mut) and +i_mut into the to bus (nodal: i_vector[to] += i_mut).
Two strategies are available to determine the phase current I_p per branch:
1) Path-based (auto_phase_currents=False, the default of this class;
run_fault(phase_current_mode="paths")). For every simple path from
source to fault, the branch direction is derived from the actual path
traversal (no index heuristic). The user may scale the contribution per
branch via Branch.parallel_coefficient, the knob for splitting current
between parallel paths in this mode.
2) Automatic distribution (auto_phase_currents=True; the default of
:func:~groundinsight.run_fault, phase_current_mode="auto"). A
reduced phase-only network is solved with +I at each source bus and the
fault bus as reference. The resulting branch currents are used directly.
In this mode parallel_coefficient is ignored. This mode is
topology-agnostic and is the intended integration point for an external
phase-current source (e.g. pandapower single-phase short-circuit results).
Sparse kernel
Both linear systems of a frequency are sparse -- a grounding network has a few entries per row -- and the kernel treats them that way end to end.
Model values as arrays. The impedance dictionaries of all buses, branches
and voltage sources are read once per assembly into (elements, F) arrays
(:class:_NetworkTables), with the 0 Hz stand-in applied to them as a
whole. Every later stage indexes into those arrays instead of resolving one
impedance per element and frequency in Python.
Index tables instead of dense matrices. Where a stamp lands -- a bus
diagonal, the four entries of a grounding branch or of a Thevenin loop
closure -- depends on the topology only. The positions are laid out once
per network (:class:_StampPattern: CSC indices/indptr and the
entry of every stamp); a frequency then costs one vector of admittances and
one summation per entry, straight into the CSC matrix the LU factorises
(:attr:ElectricalNetwork.Y_sparse). A dense n x n matrix kept per
frequency would make the memory grow as n**2 * F; Y_matrices is
therefore only a dense view that materialises a matrix when someone reads
it.
One factorisation, many right-hand sides. The phase-conductor network is
the same matrix for every source, so it is factorised once per frequency
(:func:scipy.sparse.linalg.splu) and solved for all sources as the columns
of one right-hand side. A dense n x n solve per source and frequency
would be the dominant cost of a run, growing faster than n**2.
Result objects with the collector paused. A solve creates one
:class:ComplexNumber per element, quantity and frequency. Those objects
form no reference cycles, but their sheer number keeps triggering the cyclic
garbage collector, which then walks the whole network model each time. The
result rows are therefore built inside :func:_gc_paused, which restores
the collector afterwards.
Program order, kept on purpose. Matrices are assembled from stamps whose
contributions are summed entry by entry in the order an element-by-element
dense assembly adds them (:func:_assemble_csc), so the sums are those of
that reference. What differs from it is rounding: the admittances come from
NumPy's complex division, which differs from Python's in the last bit for
about a quarter of all values, and the factorisation is a sparse LU instead
of LAPACK's dense one. On the badly conditioned phase network of a long
radial feeder the sparse LU is the more accurate of the two.
ElectricalNetwork ¶
ElectricalNetwork(
network: Network,
auto_phase_currents: bool = False,
*,
input_checks: bool = False,
)
Represents the electrical properties of a network, enabling calculations.
This class handles the construction of admittance matrices, voltage and current vectors, and performs network analysis to compute results such as bus voltages, branch currents, reduction factors, and grounding impedances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
Network
|
The Network instance containing buses, branches, sources, and faults. |
required |
auto_phase_currents
|
bool
|
If True the phase current through each
branch is computed by solving a reduced phase-only network (Variant B).
If False (default) the phase current is derived from the enumerated
source-to-fault paths using each branch's |
False
|
input_checks
|
bool
|
Run the input checks of :func: |
False
|
Notes
An instance is copied and pickled together with the :class:Network it
is attached to (copy.deepcopy(network), network.model_copy(deep=True),
pickle.dumps(network)). Every attribute travels with it except the
entries named in :attr:_UNCOPYABLE_CACHES: those hold SciPy SuperLU
factorisations, which can be neither pickled nor deep-copied. They are
pure caches -- a copy starts without them and the solver refactorises
when it needs a factor again -- so dropping them loses no information.
The back-reference :attr:network is copied through the copy memo and
therefore points at the copied network, which is what
:meth:matches_network_state needs.
Initialize the ElectricalNetwork with a given Network model.
Sets up necessary data structures and initializes the network calculations; the parameters are documented on the class.
Source code in src/groundinsight/electrical_network.py
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 | |
__getstate__ ¶
State for pickle and copy.deepcopy, without the factor caches.
copy.deepcopy and pickle both go through this method, so one
override covers both. The caches are replaced by empty dictionaries,
not removed, so that every method can keep reading them as before.
Returns:
| Type | Description |
|---|---|
Dict[str, object]
|
A shallow copy of the instance dictionary with every entry of
:attr: |
Source code in src/groundinsight/electrical_network.py
compute_branch_currents ¶
Compute branch currents for each frequency and store them in the Result object.
This method calculates the current flowing through each branch based on the bus voltages
and branch impedances. The results are stored as ResultBranch instances within the
network's results object.
Source code in src/groundinsight/electrical_network.py
compute_grounding_impedance ¶
Compute the grounding impedance for the fault bus.
The grounding impedance is the earthing impedance of EN 50522 at the fault bus::
Z_G = Z_E = Z_dp(F)
the driving-point impedance of the earthing network at the fault bus:
the voltage one ampere injected there raises the bus to against remote
earth, with every electrode and shield in place, without the inductive
coupling and without the Thevenin loop closures of voltage sources. It
is a property of the earthing system -- what an earthing-impedance
measurement at the station sees, the stations bonded to it through
cable shields included -- and it is computed alongside the reduction
factors as ResultReductionFactor.z_earthing, which this method
copies. With U_E the EPR at the fault bus and
r = |1 - Z_m/Z_s| the norm's chain U_E = r * 3*I_0 * Z_E then
holds where the norm's assumptions hold (a fault far from the infeed
on a long bonded run), as a physical statement rather than by
construction.
The quotient U_E / I_E over the earth group is not used for
Z_E (it is kept as z_earthing_group): on a long homogeneous
chain it comes out 44.5 % below the driving-point impedance.
docs/explanation/reduction-factors.md and
docs/api/electrical_network.md state the same definition.
The results are stored in the network's results object.
Source code in src/groundinsight/electrical_network.py
4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 | |
compute_phase_currents ¶
Compute the signed phase current per branch at a given frequency.
Internal API: also used by :mod:groundinsight.simulation.transient;
not exported from groundinsight and free to change in any release.
In the path-based mode (auto_phase_currents=False) the contributions are
accumulated from each source's paths to the active fault. Direction comes from
the actual path traversal (from-bus vs to-bus ordering) and the magnitude is
scaled by Branch.parallel_coefficient. A branch that lies on any path
receives exactly one contribution per source (not one per path): the paths
of a source are taken as one set of branches.
In the automatic mode (auto_phase_currents=True) a reduced phase-only
network is solved per source using the branch self-impedance as the phase
impedance proxy and the fault bus as the reference node. The resulting branch
current is used directly and parallel_coefficient is ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
The frequency at which to compute the phase currents. |
required |
sources_with_path
|
Iterable[str]
|
Names of sources that have a path to the active fault. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, complex]
|
Mapping from branch name to signed phase current (positive when
the current flows from |
Source code in src/groundinsight/electrical_network.py
compute_reduction_factors ¶
Compute the reduction factors by solving the network with and without mutual currents.
This method calculates how much the presence of mutual currents affects the Earth Potential Rise (EPR). The reduction factors are stored in the network's results object.
Warns:
| Type | Description |
|---|---|
ModelAssumptionWarning
|
|
Notes
The no-mutual system uses the same Y(f) that
:meth:solve_network has already factorised, only with a different
right-hand side. The sparse LU factors kept in self._lu_factors
are therefore reused and the second solve costs one triangular
back-substitution. The earlier numpy.linalg.solve refactorised
the matrix densely -- 2.5 s of a 6.9 s profile on a 200-bus chain
over 50 frequencies -- and did so with a different singularity
treatment than the first solve, so the two paths could disagree
about whether the same matrix was solvable. Frequencies without a
stored factor (compute_reduction_factors called on its own)
factorise :attr:Y_sparse afresh with the same sparse LU.
Source code in src/groundinsight/electrical_network.py
3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 | |
earthed_buses ¶
Buses with a path to remote earth of their own at freq.
Internal API: also used by :mod:groundinsight.analysis.response; not
exported from groundinsight and free to change in any release.
The admittance is the one the assembly stamped (0 Hz stand-in
applied), so a missing, open ("nan") or non-finite electrode does
not count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
A frequency of the network. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean mask in :attr: |
Source code in src/groundinsight/electrical_network.py
earthing_admittance_matrix ¶
Y(freq) of the earthing network alone, Thevenin loops removed.
The nodal matrix that is solved also carries the loop closures of the
voltage sources (:meth:thevenin_loop_admittances). They belong to
the fault loop, not to the earthing system, so a property of the
earthing system -- its driving-point impedance at the fault bus,
Z_E of EN 50522 -- is taken from this matrix instead. Without a
voltage source it is a copy of the solved one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
Frequency in Hz; |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A new dense array; the assembled matrix is not modified. |
Notes
Like :attr:Y_matrices this is a dense view, materialised on
request: Z_E itself is computed from the sparse form
(:meth:_earthing_admittance_sparse), so run_fault never builds
an n x n array for it.
Source code in src/groundinsight/electrical_network.py
grounding_shunts ¶
Grounding impedance of every active bus, and the admittance stamped.
Internal API: also used by :mod:groundinsight.analysis.response; not
exported from groundinsight and free to change in any release.
The interface :func:~groundinsight.analysis.response.bus_response
uses to take one bus's electrode back out of the assembled matrix.
Subtracting exactly the value that was added -- rather than a
reciprocal recomputed with a different rounding -- leaves an exact
zero where the electrode was a bus's only connection, so such a
system is still recognised as singular.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
A frequency of the network. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
impedance |
ndarray
|
Resolved grounding impedance per bus in :attr: |
admittance |
ndarray
|
The admittance on the diagonal of :attr: |
Source code in src/groundinsight/electrical_network.py
matches_network_state ¶
True while the assembled matrices still describe self.network.
See :meth:state_fingerprint for what "still describe" covers.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the network's state fingerprint equals the one recorded when the matrices were built. |
Source code in src/groundinsight/electrical_network.py
nodal_parts ¶
The parts of the assembled system a re-assembly of Y reads.
Internal API: used by the study sessions of
:mod:groundinsight.analysis._session (P4); not exported from
groundinsight and free to change in any release.
Returns:
| Type | Description |
|---|---|
NodalParts or None
|
|
Source code in src/groundinsight/electrical_network.py
remove_loop_closures ¶
matrix with the Thevenin loop-closure stamps of freq taken out.
Internal API: also used by :mod:groundinsight.analysis.response; not
exported from groundinsight and free to change in any release.
The stamps of :meth:thevenin_loop_admittances are subtracted source
by source, exactly as the dense definition of the earthing matrix
does it -- every entry is bit for bit the one the dense
Y - loops gives for the same Y -- and entries that cancel to
zero leave the sparsity pattern. Used for the earthing matrix of the
solved system and, in :func:~groundinsight.analysis.response.bus_response,
for the solved system with one electrode removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
csc_matrix
|
A nodal matrix of this network at |
required |
freq
|
float
|
Frequency in Hz. |
required |
Returns:
| Type | Description |
|---|---|
csc_matrix
|
A new matrix (a copy when there is no loop closure); |
Source code in src/groundinsight/electrical_network.py
resolved_impedance ¶
Complex value of a stored impedance, with a 0 Hz short substituted.
Internal API: also used by :mod:groundinsight.analysis.decomposition;
not exported from groundinsight and free to change in any release.
Every place that inverts an impedance has to see the same value,
otherwise the admittance matrix and the currents derived from it would
describe two different networks. This is that single place. Away from
0 Hz, and for every value that is not a short circuit, it is a plain
conversion to :class:complex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impedance
|
ComplexNumber or None
|
The stored value, or |
required |
freq
|
float
|
The frequency the value belongs to, in Hz. |
required |
Returns:
| Type | Description |
|---|---|
complex or None
|
The value to invert, or |
Source code in src/groundinsight/electrical_network.py
solve_network ¶
Solve the network equations Y * u = i for each frequency.
This method computes the bus voltages by solving the admittance matrix equations for each frequency. The results are stored in the network's results object. It uses the csc_matrix and splu functions from scipy, assuming the Y-Matrix is a sparse matrix.
.. warning::
This **replaces** ``network.results[fault]`` with a fresh
:class:`Result` that carries bus rows only. The branch rows are
filled in by :meth:`compute_branch_currents`, which must be
called afterwards -- :func:`groundinsight.run_fault` does exactly
that. Calling ``solve_network`` on its own, e.g. on a hand-built
:class:`ElectricalNetwork` used to inspect ``Y``, ``i`` or ``u``,
therefore discards the branch results of a previous ``run_fault``.
Clearing them is deliberate -- stale branch currents next to fresh
bus voltages would be silently inconsistent -- and the thermal
checks raise on the resulting gap rather than reporting an
incomplete result as free of violations.
To inspect the nodal system without touching the stored results,
build the :class:`ElectricalNetwork` (its constructor has no side
effects on ``network.results``) and read ``u`` back from
``network.results[fault].buses`` instead of re-solving.
Source code in src/groundinsight/electrical_network.py
3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 | |
state_fingerprint ¶
Digest of every model value the assembled matrices depend on.
The assembled system is a snapshot: once Y is built, later
changes to a bus impedance, to an active flag or to the active
fault do not reach it. Anything that reads Y_sparse back out
afterwards -- :func:~groundinsight.analysis.response.bus_response
above all -- therefore has to be able to tell whether the snapshot
still describes the network in hand. This fingerprint is that test:
it covers exactly the inputs :meth:_construct_Y_matrices reads, in
their stored form, so an equal fingerprint means an equal matrix.
Returns:
| Type | Description |
|---|---|
tuple
|
Hashable digest. Compare it against :attr: |
Notes
The model is read afresh into arrays (:class:_NetworkTables) and
digested with BLAKE2 (:meth:_NetworkTables.fingerprint); the
digest covers every stored value, including values at frequencies the
network is not solved at. A call here reads the model afresh (about
25 ms on a 4000-bus ring at seven frequencies); the fingerprint of a
build reuses the tables of the assembly and costs about 5 ms.
Source code in src/groundinsight/electrical_network.py
thevenin_loop_admittances ¶
The loop-closure stamps the Thevenin sources put into Y(freq).
A voltage source closes its loop with Y_src = 1/Z_src between its
own bus and the active fault bus: the non-grounding part of the fault
loop (transformer, phase conductor) that the earthing network does not
model. :meth:_construct_Y_matrices stamps them and
:meth:earthing_admittance_matrix takes them back out, both from
:meth:_NetworkTables.thevenin_loops -- one rule in one place, so
the two cannot drift apart, and the values here are bit for bit the
ones in :attr:Y_sparse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float
|
Frequency in Hz, one of the network frequencies. |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of (int, int, complex)
|
|
Source code in src/groundinsight/electrical_network.py
NodalParts ¶
Bases: NamedTuple
What a re-assembly of Y for other bus impedances needs from a solve.
Internal API: handed to :mod:groundinsight.analysis._session by
:meth:ElectricalNetwork.nodal_parts; not exported from
groundinsight and free to change in any release.
Attributes:
| Name | Type | Description |
|---|---|---|
pattern |
_StampPattern
|
Where every stamp of |
bus_z |
ndarray
|
Resolved grounding impedance per active bus and frequency, |
bus_present |
ndarray
|
Where a bus impedance is stored, same shape. |
grid_admittance |
ndarray
|
Admittance per grounding branch and frequency. |
loop_admittance |
ndarray
|
Admittance per Thevenin loop closure and frequency. |
i_vectors |
list of numpy.ndarray
|
The injection vector per network frequency, in frequency order. |
dc_substitute |
bool
|
Whether a 0 Hz stand-in is in use (its size may follow a bus
impedance, so the parts do not describe |
assemble_nodal_matrices ¶
assemble_nodal_matrices(
pattern: _StampPattern,
y_bus: ndarray,
y_grid: ndarray,
y_loop: ndarray,
frequencies: List[float],
) -> Dict[float, csc_matrix]
The nodal matrices from the stamp pattern and the stamp admittances.
Internal API: also used by :mod:groundinsight.analysis._session; not
exported from groundinsight and free to change in any release.
The bus admittances are the first n stamps of the pattern; the four
stamps of every grounding branch and of every Thevenin loop closure
follow, in the order an element-by-element dense assembly adds them, and
every entry is summed in that order (:meth:_StampPattern.matrix). The
assembly and the study sessions that re-assemble Y for changed bus
impedances both go through here, so the same admittances give bit for
bit the same matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
_StampPattern
|
Where every stamp lands. |
required |
y_bus
|
ndarray
|
Grounding admittance per active bus and frequency, |
required |
y_grid
|
ndarray
|
Admittance per grounding branch and frequency. |
required |
y_loop
|
ndarray
|
Admittance per Thevenin loop closure and frequency. |
required |
frequencies
|
list of float
|
The network frequencies, one per column. |
required |
Returns:
| Type | Description |
|---|---|
dict of float to scipy.sparse.csc_matrix
|
One matrix per frequency. |
Source code in src/groundinsight/electrical_network.py
bus_admittances ¶
The grounding admittance each bus stamps on the diagonal of Y.
Internal API: also used by :mod:groundinsight.analysis._session; not
exported from groundinsight and free to change in any release.
The one rule for it, shared by the assembly and by the study sessions
that re-assemble Y for changed bus impedances (P4): 1/Z where a
value is stored and not open, zero elsewhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bus_z
|
ndarray
|
Resolved grounding impedances, |
required |
present
|
ndarray
|
Where a value is stored, same shape. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex admittances, same shape. |
Source code in src/groundinsight/electrical_network.py
component_labels ¶
Connected groups of buses of a nodal matrix, from its off-diagonal entries.
Internal API: also used by :mod:groundinsight.analysis.response; not
exported from groundinsight and free to change in any release.
Two buses belong together when the matrix couples them: a shield with a
non-zero admittance at that frequency, or -- in the solved matrix -- the
loop closure of a voltage source. An electrode sits on the diagonal and
couples nothing. Whether a group reaches remote earth is then a question
of structure, answered without a tolerance: it does if and only if one of
its buses has a finite, non-zero electrode admittance. The linear solver
cannot be asked instead. The matrix of a floating group of two or more
buses is singular only up to rounding -- every row of a shield stamp sums
to zero in exact arithmetic, not in floating point -- and splu then
returns potentials of 1e15 Ohm per ampere and more instead of raising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
spmatrix
|
A square nodal matrix. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Integer group label per row. |
Source code in src/groundinsight/electrical_network.py
restricted_columns ¶
Unit-injection columns of matrix, solved on one group of buses only.
Internal API: also used by :mod:groundinsight.analysis.response; not
exported from groundinsight and free to change in any release.
The buses outside rows are decoupled from it by construction (see
:func:component_labels), so the columns inside the group do not
depend on them -- and a floating group elsewhere in the matrix cannot
make this solve singular.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
spmatrix
|
Square nodal matrix. |
required |
rows
|
ndarray
|
Boolean mask of the group. |
required |
units
|
list of int
|
Rows (inside the group) at which one ampere is injected, one column each. |
required |
Returns:
| Type | Description |
|---|---|
ndarray or None
|
|
Source code in src/groundinsight/electrical_network.py
rms_columns ¶
RMS over the frequency columns, the convention of the result rows.
Internal API: also used by :mod:groundinsight.analysis._session; not
exported from groundinsight and free to change in any release.
sqrt(sum |x|**2), accumulated frequency by frequency (see
:meth:ElectricalNetwork._calculate_rms). The result rows and the study
sessions (P4) both take their RMS from here, so that a re-solved trial
reports bit for bit the value a full run_fault stores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Complex array |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Float array |
Source code in src/groundinsight/electrical_network.py
stack_columns ¶
Per-frequency vectors as the columns of one (rows, F) array.
Internal API: also used by :mod:groundinsight.analysis._session; not
exported from groundinsight and free to change in any release.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
list of numpy.ndarray or None
|
One vector per frequency, in frequency order; |
required |
rows
|
int
|
Length of every vector. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex array; column |