DPsim
MNAStampUtils.h
1 #pragma once
2 
3 #include <dpsim-models/Logger.h>
4 #include <dpsim-models/MathUtils.h>
5 
6 namespace CPS {
7 class MNAStampUtils {
8 public:
9  static void stampConductance(Real conductance, SparseMatrixRow &mat,
10  UInt node1Index, UInt node2Index,
11  Bool isTerminal1NotGrounded,
12  Bool isTerminal2NotGrounded,
13  const Logger::Log &mSLog);
14 
15  static void stampAdmittance(Complex admittance, SparseMatrixRow &mat,
16  UInt node1Index, UInt node2Index,
17  Bool isTerminal1NotGrounded,
18  Bool isTerminal2NotGrounded,
19  const Logger::Log &mSLog, Int maxFreq = 1,
20  Int freqIdx = 0);
21 
22  static void stampConductanceMatrix(const Matrix &conductanceMat,
23  SparseMatrixRow &mat, UInt node1Index,
24  UInt node2Index,
25  Bool isTerminal1NotGrounded,
26  Bool isTerminal2NotGrounded,
27  const Logger::Log &mSLog);
28 
29  static void stamp3x3ConductanceMatrixBetween2Nodes(
30  const Matrix &conductanceMat, SparseMatrixRow &mat, UInt node1Index,
31  UInt node2Index, const Logger::Log &mSLog);
32 
33  static void stamp3x3ConductanceMatrixNodeToGround(const Matrix &conductanceMat,
34  SparseMatrixRow &mat,
35  UInt nodeIndex,
36  const Logger::Log &mSLog);
37 
38  static void stampAdmittanceMatrix(
39  const MatrixComp &admittanceMat, SparseMatrixRow &mat, UInt node1Index,
40  UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded,
41  const Logger::Log &mSLog, Int maxFreq = 1, Int freqIdx = 0);
42 
45  Real conductance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index,
46  Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded,
47  const Logger::Log &mSLog);
48 
51  Complex admittance, SparseMatrixRow &mat, UInt node1Index,
52  UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded,
53  const Logger::Log &mSLog, Int maxFreq = 1, Int freqIdx = 0);
54 
55 private:
56  template <typename T>
57  static void stampValue(T value, SparseMatrixRow &mat, UInt node1Index,
58  UInt node2Index, Bool isTerminal1NotGrounded,
59  Bool isTerminal2NotGrounded, Int maxFreq, Int freqIdx,
60  const Logger::Log &mSLog);
61 
62  template <typename T>
63  static void stampMatrix(const MatrixVar<T> &matrix, SparseMatrixRow &mat,
64  UInt node1Index, UInt node2Index,
65  Bool isTerminal1NotGrounded,
66  Bool isTerminal2NotGrounded, Int maxFreq, Int freqIdx,
67  const Logger::Log &mSLog);
68 
69  template <typename T>
70  static void stampMatrixBetween2Nodes(const MatrixVar<T> &matrix,
71  UInt sizeOfMatrix, SparseMatrixRow &mat,
72  UInt node1Index, UInt node2Index,
73  Int maxFreq, Int freqIdx,
74  const Logger::Log &mSLog);
75 
76  template <typename T>
77  static void stampMatrixNodeToGround(const MatrixVar<T> &matrix,
78  UInt sizeOfMatrix, SparseMatrixRow &mat,
79  UInt nodeIndex, Int maxFreq, Int freqIdx,
80  const Logger::Log &mSLog);
81 
82  template <typename T>
83  static void stampValueAsScalarMatrix(T value, UInt sizeOfScalarMatrix,
84  SparseMatrixRow &mat, UInt node1Index,
85  UInt node2Index,
86  Bool isTerminal1NotGrounded,
87  Bool isTerminal2NotGrounded, Int maxFreq,
88  Int freqIdx, const Logger::Log &mSLog);
89 
90  template <typename T>
91  static void stampToMatrix(T value, SparseMatrixRow &mat, UInt row1,
92  UInt column1, UInt row2, UInt column2, Int maxFreq,
93  Int freqIdx, const Logger::Log &mSLog);
94 
95  static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
96  Matrix::Index column, Real value, Int maxFreq,
97  Int freqIdx, const Logger::Log &mSLog);
98 
99  static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
100  Matrix::Index column, Complex value,
101  Int maxFreq, Int freqIdx,
102  const Logger::Log &mSLog);
103 };
104 } // namespace CPS
static void stampConductanceAs3x3ScalarMatrix(Real conductance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog)
Stamps conductance as a 3x3 scalar matrix (a diagonal matrix, where all diagonal elements are equal t...
static void stampAdmittanceAs3x3ScalarMatrix(Complex admittance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
Stamps admittance as a 3x3 scalar matrix (a diagonal matrix, where all diagonal elements are equal to...