Skip to content

Commit

Permalink
Reuse conductance stamping logic for EMT synchron generators
Browse files Browse the repository at this point in the history
Signed-off-by: Georgii Tishenin <[email protected]>
  • Loading branch information
georgii-tishenin committed Jul 17, 2024
1 parent 15ed6ee commit c06b0e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 155 deletions.
140 changes: 6 additions & 134 deletions dpsim-models/src/EMT/EMT_Ph3_ReducedOrderSynchronGeneratorVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,8 @@ void EMT::Ph3::ReducedOrderSynchronGeneratorVBR::mnaCompApplySystemMatrixStamp(
SparseMatrixRow &systemMatrix) {

if (mModelAsNortonSource) {
// Stamp conductance matrix
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 0), mConductanceMatrix(0, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 1), mConductanceMatrix(0, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 2), mConductanceMatrix(0, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 0), mConductanceMatrix(1, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 1), mConductanceMatrix(1, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 2), mConductanceMatrix(1, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 0), mConductanceMatrix(2, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 1), mConductanceMatrix(2, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 2), mConductanceMatrix(2, 2));
MNAStampUtils::stamp3x3ConductanceMatrixNodeToGround(
mConductanceMatrix, systemMatrix, matrixNodeIndex(0), mSLog);
} else {
// Stamp voltage source
Math::addToMatrixElement(
Expand All @@ -225,121 +208,10 @@ void EMT::Ph3::ReducedOrderSynchronGeneratorVBR::mnaCompApplySystemMatrixStamp(
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C), 1);

// Stamp conductance matrix

// set upper left block, 3x3 entries
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mConductanceMatrix(0, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mConductanceMatrix(0, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mConductanceMatrix(0, 2));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mConductanceMatrix(1, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mConductanceMatrix(1, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mConductanceMatrix(1, 2));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
mConductanceMatrix(2, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
mConductanceMatrix(2, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
mConductanceMatrix(2, 2));

// set buttom right block, 3x3 entries
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 0), mConductanceMatrix(0, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 1), mConductanceMatrix(0, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 2), mConductanceMatrix(0, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 0), mConductanceMatrix(1, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 1), mConductanceMatrix(1, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 2), mConductanceMatrix(1, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 0), mConductanceMatrix(2, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 1), mConductanceMatrix(2, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 2), mConductanceMatrix(2, 2));

// Set off diagonal blocks
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
matrixNodeIndex(0, 0), -mConductanceMatrix(0, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
matrixNodeIndex(0, 1), -mConductanceMatrix(0, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
matrixNodeIndex(0, 2), -mConductanceMatrix(0, 2));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
matrixNodeIndex(0, 0), -mConductanceMatrix(1, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
matrixNodeIndex(0, 1), -mConductanceMatrix(1, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
matrixNodeIndex(0, 2), -mConductanceMatrix(1, 2));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
matrixNodeIndex(0, 0), -mConductanceMatrix(2, 0));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
matrixNodeIndex(0, 1), -mConductanceMatrix(2, 1));
Math::addToMatrixElement(systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
matrixNodeIndex(0, 2), -mConductanceMatrix(2, 2));

Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
-mConductanceMatrix(0, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
-mConductanceMatrix(0, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
-mConductanceMatrix(0, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
-mConductanceMatrix(1, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
-mConductanceMatrix(1, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
-mConductanceMatrix(1, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A),
-mConductanceMatrix(2, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::B),
-mConductanceMatrix(2, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
mVirtualNodes[0]->matrixNodeIndex(PhaseType::C),
-mConductanceMatrix(2, 2));
MNAStampUtils::stamp3x3ConductanceMatrixBetween2Nodes(
mConductanceMatrix, systemMatrix,
mVirtualNodes[0]->matrixNodeIndex(PhaseType::A), matrixNodeIndex(0),
mSLog);
}
}

Expand Down
23 changes: 2 additions & 21 deletions dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,8 @@ void EMT::Ph3::SynchronGeneratorVBR::mnaCompPreStep(Real time,
void EMT::Ph3::SynchronGeneratorVBR::mnaCompApplySystemMatrixStamp(
SparseMatrixRow &systemMatrix) {
if (terminalNotGrounded(0)) {
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 0), mConductanceMat(0, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 1), mConductanceMat(0, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 0),
matrixNodeIndex(0, 2), mConductanceMat(0, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 0), mConductanceMat(1, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 1), mConductanceMat(1, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 1),
matrixNodeIndex(0, 2), mConductanceMat(1, 2));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 0), mConductanceMat(2, 0));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 1), mConductanceMat(2, 1));
Math::addToMatrixElement(systemMatrix, matrixNodeIndex(0, 2),
matrixNodeIndex(0, 2), mConductanceMat(2, 2));
// SPDLOG_LOGGER_INFO(mSLog, "Add {} to {}, {}", conductance, matrixNodeIndex(0,0), matrixNodeIndex(0,0));
// SPDLOG_LOGGER_INFO(mSLog, "Add {} to {}, {}", conductance, matrixNodeIndex(0,1), matrixNodeIndex(0,1));
// SPDLOG_LOGGER_INFO(mSLog, "Add {} to {}, {}", conductance, matrixNodeIndex(0,2), matrixNodeIndex(0,2));
MNAStampUtils::stamp3x3ConductanceMatrixNodeToGround(
mConductanceMat, systemMatrix, matrixNodeIndex(0), mSLog);
}
}

Expand Down

0 comments on commit c06b0e9

Please sign in to comment.