7 Bool isTerminal1NotGrounded,
8 Bool isTerminal2NotGrounded,
10 SPDLOG_LOGGER_DEBUG(mSLog,
"Start stamping conductance...");
12 stampValue(conductance, mat, node1Index, node2Index, isTerminal1NotGrounded,
13 isTerminal2NotGrounded, 1, 0, mSLog);
15 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
20 Bool isTerminal1NotGrounded,
21 Bool isTerminal2NotGrounded,
25 mSLog,
"Start stamping admittance for frequency index {:d}...", freqIdx);
27 stampValue(admittance, mat, node1Index, node2Index, isTerminal1NotGrounded,
28 isTerminal2NotGrounded, maxFreq, freqIdx, mSLog);
30 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
36 Bool isTerminal1NotGrounded,
37 Bool isTerminal2NotGrounded,
39 SPDLOG_LOGGER_DEBUG(mSLog,
"Start stamping conductance matrix...");
41 stampMatrix(conductanceMat, mat, node1Index, node2Index,
42 isTerminal1NotGrounded, isTerminal2NotGrounded, 1, 0, mSLog);
44 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
51 mSLog,
"Start stamping 3x3 conductance matrix between two nodes...");
53 stampMatrixBetween2Nodes(conductanceMat, 3, mat, node1Index, node2Index, 1, 0,
56 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
63 mSLog,
"Start stamping 3x3 conductance matrix from node to ground...");
65 stampMatrixNodeToGround(conductanceMat, 3, mat, nodeIndex, 1, 0, mSLog);
67 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
72 UInt node2Index,
Bool isTerminal1NotGrounded,
Bool isTerminal2NotGrounded,
75 mSLog,
"Start stamping admittance matrix for frequency index {:d}...",
78 stampMatrix(admittanceMat, mat, node1Index, node2Index,
79 isTerminal1NotGrounded, isTerminal2NotGrounded, maxFreq, freqIdx,
82 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
87 Bool isTerminal1NotGrounded,
Bool isTerminal2NotGrounded,
89 SPDLOG_LOGGER_DEBUG(mSLog,
90 "Start stamping conductance as 3x3 scalar matrix...");
92 stampValueAsScalarMatrix(conductance, 3, mat, node1Index, node2Index,
93 isTerminal1NotGrounded, isTerminal2NotGrounded, 1, 0,
96 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
101 Bool isTerminal1NotGrounded,
Bool isTerminal2NotGrounded,
103 SPDLOG_LOGGER_DEBUG(mSLog,
104 "Start stamping admittance as 3x3 scalar matrix for "
105 "frequency index {:d}...",
108 stampValueAsScalarMatrix(admittance, 3, mat, node1Index, node2Index,
109 isTerminal1NotGrounded, isTerminal2NotGrounded,
110 maxFreq, freqIdx, mSLog);
112 SPDLOG_LOGGER_DEBUG(mSLog,
"Stamping completed.");
117 UInt node2Index,
Bool isTerminal1NotGrounded,
118 Bool isTerminal2NotGrounded,
Int maxFreq,
120 if (isTerminal1NotGrounded && isTerminal2NotGrounded) {
121 stampToMatrix(value, mat, node1Index, node1Index, node2Index, node2Index,
122 maxFreq, freqIdx, mSLog);
123 }
else if (isTerminal1NotGrounded) {
124 addToMatrixElement(mat, node1Index, node1Index, value, maxFreq, freqIdx,
126 }
else if (isTerminal2NotGrounded) {
127 addToMatrixElement(mat, node2Index, node2Index, value, maxFreq, freqIdx,
133void MNAStampUtils::stampMatrix(
const MatrixVar<T> &matrix,
135 UInt node2Index,
Bool isTerminal1NotGrounded,
136 Bool isTerminal2NotGrounded,
Int maxFreq,
138 Int numRows = matrix.rows();
139 Int numCols = matrix.cols();
140 if (numRows != numCols) {
141 throw InvalidArgumentException();
144 if (isTerminal1NotGrounded && isTerminal2NotGrounded) {
145 stampMatrixBetween2Nodes(matrix, numRows, mat, node1Index, node2Index,
146 maxFreq, freqIdx, mSLog);
147 }
else if (isTerminal1NotGrounded) {
148 stampMatrixNodeToGround(matrix, numRows, mat, node1Index, maxFreq, freqIdx,
150 }
else if (isTerminal2NotGrounded) {
151 stampMatrixNodeToGround(matrix, numRows, mat, node2Index, maxFreq, freqIdx,
157void MNAStampUtils::stampMatrixBetween2Nodes(
const MatrixVar<T> &matrix,
163 for (
UInt i = 0; i < sizeOfMatrix; i++) {
164 for (
UInt j = 0; j < sizeOfMatrix; j++) {
165 stampToMatrix(matrix(i, j), mat, node1Index + i, node1Index + j,
166 node2Index + i, node2Index + j, maxFreq, freqIdx, mSLog);
172void MNAStampUtils::stampMatrixNodeToGround(
175 for (
UInt i = 0; i < sizeOfMatrix; i++) {
176 for (
UInt j = 0; j < sizeOfMatrix; j++) {
177 addToMatrixElement(mat, nodeIndex + i, nodeIndex + j, matrix(i, j),
178 maxFreq, freqIdx, mSLog);
184void MNAStampUtils::stampValueAsScalarMatrix(
186 UInt node2Index,
Bool isTerminal1NotGrounded,
Bool isTerminal2NotGrounded,
188 if (isTerminal1NotGrounded && isTerminal2NotGrounded) {
189 for (
UInt i = 0; i < sizeOfScalarMatrix; i++) {
190 stampToMatrix(value, mat, node1Index + i, node1Index + i, node2Index + i,
191 node2Index + i, maxFreq, freqIdx, mSLog);
193 }
else if (isTerminal1NotGrounded) {
194 for (
UInt i = 0; i < sizeOfScalarMatrix; i++) {
195 addToMatrixElement(mat, node1Index + i, node1Index + i, value, maxFreq,
198 }
else if (isTerminal2NotGrounded) {
199 for (
UInt i = 0; i < sizeOfScalarMatrix; i++) {
200 addToMatrixElement(mat, node2Index + i, node2Index + i, value, maxFreq,
211 addToMatrixElement(mat, row1, column1, value, maxFreq, freqIdx, mSLog);
212 addToMatrixElement(mat, row1, column2, -value, maxFreq, freqIdx, mSLog);
213 addToMatrixElement(mat, row2, column1, -value, maxFreq, freqIdx, mSLog);
214 addToMatrixElement(mat, row2, column2, value, maxFreq, freqIdx, mSLog);
219void MNAStampUtils::addToMatrixElement(
SparseMatrixRow &mat, Matrix::Index row,
220 Matrix::Index column,
Real value,
223 SPDLOG_LOGGER_DEBUG(mSLog,
224 "- Adding {:s} to system matrix element ({:d},{:d})",
230void MNAStampUtils::addToMatrixElement(
SparseMatrixRow &mat, Matrix::Index row,
231 Matrix::Index column,
Complex value,
234 SPDLOG_LOGGER_DEBUG(mSLog,
235 "- Adding {:s} to system matrix element ({:d},{:d})",
std::shared_ptr< spdlog::logger > Log
static String complexToString(const Complex &num)
static String realToString(const Real &num)
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 stampConductance(Real conductance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog)
static void stampAdmittanceMatrix(const MatrixComp &admittanceMat, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
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...
static void stampAdmittance(Complex admittance, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
static void stamp3x3ConductanceMatrixBetween2Nodes(const Matrix &conductanceMat, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, const Logger::Log &mSLog)
static void stampConductanceMatrix(const Matrix &conductanceMat, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog)
static void stamp3x3ConductanceMatrixNodeToGround(const Matrix &conductanceMat, SparseMatrixRow &mat, UInt nodeIndex, const Logger::Log &mSLog)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::Matrix< VarType, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixVar
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).