Commit c667bca7 authored by Markus Mirz's avatar Markus Mirz
Browse files

rename SimNode variable

parent e89fec70
......@@ -30,7 +30,7 @@ namespace CPS {
public SharedFactory<Node<VarType>> {
protected:
///
std::vector<UInt> mSimNode = { 0 };
std::vector<UInt> mMatrixNodeIndex = { 0 };
/// List of considered network harmonics
Matrix mFrequencies;
/// Number of harmonics
......@@ -47,7 +47,7 @@ namespace CPS {
static Ptr GND;
/// This very general constructor is used by other constructors.
Node(String name, String uid, std::vector<UInt> simNode,
Node(String name, String uid, std::vector<UInt> matrixNodeIndex,
PhaseType phaseType, std::vector<Complex> initialVoltage);
/// Create ground node if no parameters are given.
Node(PhaseType phaseType = PhaseType::Single);
......@@ -58,13 +58,13 @@ namespace CPS {
: Node(name, name, { 0, 0, 0 }, phaseType, initialVoltage) { }
/// Create node with name and node number.
/// This is mostly used by functions.
Node(String uid, String name, UInt simNode,
Node(String uid, String name, UInt matrixNodeIndex,
PhaseType phaseType = PhaseType::Single, std::vector<Complex> initialVoltage = { 0, 0, 0 })
: Node(uid, name, { simNode, simNode + 1, simNode + 2 }, phaseType, initialVoltage) {}
: Node(uid, name, { matrixNodeIndex, matrixNodeIndex + 1, matrixNodeIndex + 2 }, phaseType, initialVoltage) {}
/// Create node with default name and node number.
/// This is mostly used by functions.
Node(UInt simNode, PhaseType phaseType = PhaseType::Single)
: Node("N" + std::to_string(simNode), "N" + std::to_string(simNode), simNode, phaseType) { }
Node(UInt matrixNodeIndex, PhaseType phaseType = PhaseType::Single)
: Node("N" + std::to_string(matrixNodeIndex), "N" + std::to_string(matrixNodeIndex), matrixNodeIndex, phaseType) { }
/// Initialize state matrices with size according to phase type and frequency number
void initialize(Matrix frequencies);
......@@ -74,35 +74,35 @@ namespace CPS {
&& (mPhaseType == PhaseType::Single
|| mPhaseType == PhaseType::A
|| mPhaseType == PhaseType::ABC))
return mSimNode[0];
return mMatrixNodeIndex[0];
else if (phaseType == PhaseType::B
&& (mPhaseType == PhaseType::B
|| mPhaseType == PhaseType::ABC))
return mSimNode[1];
return mMatrixNodeIndex[1];
else if (phaseType == PhaseType::C
&& (mPhaseType == PhaseType::C
|| mPhaseType == PhaseType::ABC))
return mSimNode[2];
return mMatrixNodeIndex[2];
else
return 0;
}
/// Returns all matrix indices
std::vector<UInt> matrixNodeIndices() {
if (mPhaseType == PhaseType::B)
return { mSimNode[1] };
return { mMatrixNodeIndex[1] };
else if (mPhaseType == PhaseType::C)
return { mSimNode[2] };
return { mMatrixNodeIndex[2] };
else if (mPhaseType == PhaseType::ABC)
return mSimNode;
return mMatrixNodeIndex;
else // phaseType == PhaseType::Single || mPhaseType == PhaseType::A
return { mSimNode[0] };
return { mMatrixNodeIndex[0] };
}
///
VarType singleVoltage(PhaseType phaseType = PhaseType::Single);
///
MatrixVar<VarType> voltage() { return mVoltage; }
///
void setSimNode(UInt phase, UInt simNode) { mSimNode[phase] = simNode; }
void setMatrixNodeIndex(UInt phase, UInt matrixNodeIndex) { mMatrixNodeIndex[phase] = matrixNodeIndex; }
///
void setVoltage(VarType newVoltage) { }
......
......@@ -45,9 +45,9 @@ namespace CPS {
PhaseType mPhaseType = PhaseType::Single;
/// "Cached" list of simulation nodes (to avoid shared_ptr accesses during simulation)
std::vector<UInt> mSimNodes;
std::vector<UInt> mMatrixNodeIndices;
/// "Cached" flags for whether the connected nodes are grounded
std::vector<bool> mSimNodeIsGround;
std::vector<bool> mMatrixNodeIndexIsGround;
/// Flag indicating that parameters are set via setParameters() function
bool parametersSet = false;
......@@ -93,8 +93,8 @@ namespace CPS {
/// Sets Terminal at index terminalPosition.
void setTerminalAt(typename Terminal<VarType>::Ptr terminal, UInt terminalPosition);
/// Update the "cached" mSimNodes and mSimNodeIsGround members
void updateSimNodes();
/// Update the "cached" mMatrixNodeIndices and mMatrixNodeIndexIsGround members
void updateMatrixNodeIndices();
// #### Nodes ####
/// Returns the actual number of Nodes / Terminals that are already set to valid Nodes.
......@@ -107,12 +107,12 @@ namespace CPS {
return mTerminals[index]->node();
};
UInt matrixNodeIndex(UInt nodeIndex) {
return mSimNodes[nodeIndex * 3];
return mMatrixNodeIndices[nodeIndex * 3];
}
UInt matrixNodeIndex(UInt nodeIndex, UInt phaseIndex) {
return mSimNodes[nodeIndex * 3 + phaseIndex];
return mMatrixNodeIndices[nodeIndex * 3 + phaseIndex];
}
/// TODO replace with access to mSimNodes
/// TODO replace with access to mMatrixNodeIndices
std::vector<UInt> matrixNodeIndices(UInt index) { return node(index)->matrixNodeIndices(); }
/// Get nodes as base type TopologicalNode
TopologicalNode::List topologicalNodes();
......@@ -127,9 +127,9 @@ namespace CPS {
/// Get pointer to virtual node
typename Node<VarType>::Ptr virtualNode(UInt index);
/// Get vector of simulation node numbers from virtual Node
std::vector<UInt> virtualSimNodes(UInt index) { return virtualNode(index)->matrixNodeIndices(); }
std::vector<UInt> virtualMatrixNodeIndices(UInt index) { return virtualNode(index)->matrixNodeIndices(); }
/// Get simulation node number from virtual node
UInt virtualSimNode(UInt nodeIndex, UInt phaseIndex = 0) { return virtualSimNodes(nodeIndex)[phaseIndex]; }
UInt virtualSimNode(UInt nodeIndex, UInt phaseIndex = 0) { return virtualMatrixNodeIndices(nodeIndex)[phaseIndex]; }
// #### States ####
const MatrixVar<VarType>& intfCurrent() { return mIntfCurrent; }
......@@ -140,7 +140,7 @@ namespace CPS {
///
Complex initialSingleVoltage(UInt index) { return mTerminals[index]->initialSingleVoltage(); }
///
Bool terminalNotGrounded(UInt index) { return !mSimNodeIsGround[index]; }
Bool terminalNotGrounded(UInt index) { return !mMatrixNodeIndexIsGround[index]; }
// #### Setters ####
void setIntfCurrent(MatrixVar<VarType> current) { mIntfCurrent = current; }
......
......@@ -62,6 +62,6 @@ namespace CPS {
///
virtual std::vector<UInt> matrixNodeIndices() = 0;
///
virtual void setSimNode(UInt phase, UInt simNode) = 0;
virtual void setMatrixNodeIndex(UInt phase, UInt matrixNodeIndex) = 0;
};
}
......@@ -237,7 +237,7 @@ void Reader::processSvVoltage(SvVoltage* volt) {
Real voltagePhase = volt->angle.value * PI / 180;
mPowerflowNodes[node->mRID]->setInitialVoltage(std::polar<Real>(voltageAbs, voltagePhase));
mSLog->info("Node {} SimNode {}: {} V, {} deg",
mSLog->info("Node {} MatrixNodeIndex {}: {} V, {} deg",
mPowerflowNodes[node->mRID]->uid(),
mPowerflowNodes[node->mRID]->matrixNodeIndex(),
std::abs(mPowerflowNodes[node->mRID]->initialSingleVoltage()),
......@@ -700,8 +700,8 @@ void Reader::writeSvVoltageFromStaticSysTopology(SystemTopology& sysStatic, Syst
template<typename VarType>
void Reader::processTopologicalNode(IEC61970::Base::Topology::TopologicalNode* topNode) {
// Add this node to global node list and assign simulation node incrementally.
int simNode = Int(mPowerflowNodes.size());
mPowerflowNodes[topNode->mRID] = Node<VarType>::make(topNode->mRID, topNode->name, simNode, mPhase);
int matrixNodeIndex = Int(mPowerflowNodes.size());
mPowerflowNodes[topNode->mRID] = Node<VarType>::make(topNode->mRID, topNode->name, matrixNodeIndex, mPhase);
if (mPhase == PhaseType::ABC) {
mSLog->info("TopologicalNode {} phase A as simulation node {} ", topNode->mRID, mPowerflowNodes[topNode->mRID]->matrixNodeIndex(PhaseType::A));
......
......@@ -389,7 +389,7 @@ void DP::Ph1::AvVoltageSourceInverterDQ::initializeFromPowerflow(Real frequency)
void DP::Ph1::AvVoltageSourceInverterDQ::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
if (mGenProfile)
mCurrentPower = mGenProfile->begin();
if(!mLoadProfile.empty())
......
......@@ -71,7 +71,7 @@ void DP::Ph1::Capacitor::initializeFromPowerflow(Real frequency) {
void DP::Ph1::Capacitor::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
Real equivCondReal = 2.0 * mCapacitance / timeStep;
Real prevVoltCoeffReal = 2.0 * mCapacitance / timeStep;
......@@ -103,7 +103,7 @@ void DP::Ph1::Capacitor::mnaInitialize(Real omega, Real timeStep, Attribute<Matr
void DP::Ph1::Capacitor::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
Real equivCondReal = 2.0 * mCapacitance / timeStep;
Real prevVoltCoeffReal = 2.0 * mCapacitance / timeStep;
......
......@@ -55,7 +55,7 @@ void DP::Ph1::ControlledVoltageSource::mnaInitialize(Real omega, Real timeStep,
checkForUnconnectedTerminals();
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
......
......@@ -70,7 +70,7 @@ void DP::Ph1::CurrentSource::initializeFromPowerflow(Real frequency) {
void DP::Ph1::CurrentSource::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mCurrentRef = attribute<Complex>("I_ref");
mIntfCurrent(0,0) = mCurrentRef->get();
......
......@@ -89,7 +89,7 @@ void DP::Ph1::Inductor::initVars(Real timeStep) {
void DP::Ph1::Inductor::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
initVars(timeStep);
......@@ -110,7 +110,7 @@ void DP::Ph1::Inductor::mnaInitialize(Real omega, Real timeStep, Attribute<Matri
void DP::Ph1::Inductor::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
initVars(timeStep);
......
......@@ -125,7 +125,7 @@ void DP::Ph1::Inverter::calculatePhasors() {
void DP::Ph1::Inverter::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
......@@ -136,7 +136,7 @@ void DP::Ph1::Inverter::mnaInitialize(Real omega, Real timeStep, Attribute<Matri
void DP::Ph1::Inverter::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPreStepHarm>(*this));
mMnaTasks.push_back(std::make_shared<MnaPostStepHarm>(*this, leftVectors));
......
......@@ -74,7 +74,7 @@ void DP::Ph1::NetworkInjection::initializeFromPowerflow(Real frequency) {
void DP::Ph1::NetworkInjection::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mIntfVoltage(0,0) = mVoltageRef->get();
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
......@@ -84,7 +84,7 @@ void DP::Ph1::NetworkInjection::mnaInitialize(Real omega, Real timeStep, Attribu
void DP::Ph1::NetworkInjection::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mIntfVoltage(0,0) = mVoltageRef->get();
......
......@@ -112,7 +112,7 @@ void DP::Ph1::PQLoadCS::initializeFromPowerflow(Real frequency) {
void DP::Ph1::PQLoadCS::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mSubCurrentSource->mnaInitialize(omega, timeStep, leftVector);
setAttributeRef("right_vector", mSubCurrentSource->attribute("right_vector"));
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
......
......@@ -120,7 +120,7 @@ void DP::Ph1::PiLine::initializeFromPowerflow(Real frequency) {
void DP::Ph1::PiLine::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
MNAInterface::List subComps({mSubSeriesResistor, mSubSeriesInductor});
mSubSeriesResistor->mnaInitialize(omega, timeStep, leftVector);
......
......@@ -131,7 +131,7 @@ void DP::Ph1::RXLoad::setParameters(Real activePower, Real reactivePower, Real v
void DP::Ph1::RXLoad::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mRightVector = Matrix::Zero(leftVector->get().rows(), 1);
if (mSubResistor) {
mSubResistor->mnaInitialize(omega, timeStep, leftVector);
......
......@@ -90,7 +90,7 @@ void DP::Ph1::ResIndSeries::initVars(Real timeStep) {
void DP::Ph1::ResIndSeries::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
initVars(timeStep);
......@@ -111,7 +111,7 @@ void DP::Ph1::ResIndSeries::mnaInitialize(Real omega, Real timeStep, Attribute<M
void DP::Ph1::ResIndSeries::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
initVars(timeStep);
......
......@@ -63,14 +63,14 @@ void DP::Ph1::Resistor::initializeFromPowerflow(Real frequency) {
// #### MNA functions ####
void DP::Ph1::Resistor::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
}
void DP::Ph1::Resistor::mnaInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPostStepHarm>(*this, leftVectors));
}
......
......@@ -78,7 +78,7 @@ void DP::Ph1::RxLine::initializeFromPowerflow(Real frequency) {
void DP::Ph1::RxLine::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mSubInductor->mnaInitialize(omega, timeStep, leftVector);
mSubResistor->mnaInitialize(omega, timeStep, leftVector);
mInitialResistor->mnaInitialize(omega, timeStep, leftVector);
......
......@@ -65,7 +65,7 @@ void DP::Ph1::Switch::initialize(Matrix frequencies) {
void DP::Ph1::Switch::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
}
......
......@@ -73,7 +73,7 @@ void DP::Ph1::SynchronGeneratorIdeal::initializeFromPowerflow(Real frequency) {
void DP::Ph1::SynchronGeneratorIdeal::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mSubVoltageSource->mnaInitialize(omega, timeStep, leftVector);
// since there is no additional behaviour, just use the tasks and right-vector from the voltage source
setAttributeRef("right_vector", mSubVoltageSource->attribute("right_vector"));
......
......@@ -200,7 +200,7 @@ void DP::Ph1::SynchronGeneratorTrStab::step(Real time) {
void DP::Ph1::SynchronGeneratorTrStab::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
MNAInterface::mnaInitialize(omega, timeStep);
updateSimNodes();
updateMatrixNodeIndices();
mSubVoltageSource->mnaInitialize(omega, timeStep, leftVector);
mSubInductor->mnaInitialize(omega, timeStep, leftVector);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment