pyCBD.loopsolvers.linearsolver module¶
This module provides a Gauss-Jordan solver to solve linear algebraic loops.
- class pyCBD.loopsolvers.linearsolver.LinearSolver(logger=None)[source]¶
Bases:
pyCBD.loopsolvers.solver.SolverSolves linear algebraic loops using matrices.
- checkValidity(path, component)[source]¶
Checks the validity of an algebraic loop.
- Parameters
path (str) – The path of the top-level block.
component (list) – The blocks in the algebraic loop.
- constructInput(strongComponent, curIteration)[source]¶
Constructs input for a solver of systems of linear equations Input consists of two matrices:
M1: coefficient matrix, where each row represents an equation of the system
M2: result matrix, where each element is the result for the corresponding equation in M1
- class pyCBD.loopsolvers.linearsolver.Matrix(rows, cols)[source]¶
Bases:
objectCustom, efficient matrix class. This class is used for efficiency purposes.
Using a while/for loop is slow.
Using
[[0] * n] * nwill have n references to the same list.Using
[[0] * size for _ in range(size)]can be 5 times slower than this class!
Numpy could be used to even further increase efficiency, but this increases the required dependencies for external hardware systems (that may not provide these options).
Note
Internally, the matrix is segmented into chunks of 500.000.000 items.