Commit 3214ce56 authored by Philipp Fensch's avatar Philipp Fensch
Browse files

Adjusted dpsim-files to pass cpp-check


Signed-off-by: Philipp Fensch's avatarPhilipp Fensch <philipp.fensch@rwth-aachen.de>
parent e4baf100
......@@ -70,7 +70,7 @@ namespace DPsim {
public:
/// Create solve object with given parameters
DAESolver(String name, CPS::SystemTopology system, Real dt, Real t0);
DAESolver(String name, const CPS::SystemTopology &system, Real dt, Real t0);
/// Deallocate all memory
~DAESolver();
/// Initialize Components & Nodes with inital values
......
......@@ -78,7 +78,7 @@ namespace DPsim {
public:
using SharedFactory<SwitchEvent>::make;
SwitchEvent(CPS::Real t, std::shared_ptr<CPS::Base::Ph1::Switch> sw, CPS::Bool state) :
SwitchEvent(CPS::Real t, const std::shared_ptr<CPS::Base::Ph1::Switch> &sw, CPS::Bool state) :
Event(t),
mSwitch(sw),
mNewState(state)
......@@ -101,7 +101,7 @@ namespace DPsim {
public:
using SharedFactory<SwitchEvent3Ph>::make;
SwitchEvent3Ph(CPS::Real t, std::shared_ptr<CPS::Base::Ph3::Switch> sw, CPS::Bool state) :
SwitchEvent3Ph(CPS::Real t, const std::shared_ptr<CPS::Base::Ph3::Switch> &sw, CPS::Bool state) :
Event(t),
mSwitch(sw),
mNewState(state)
......
......@@ -30,8 +30,8 @@
namespace DPsim {
/// Shmem interface used in combination with VILLAS
class InterfaceShmem :
public Interface,
class InterfaceShmem :
public Interface,
public SharedFactory<InterfaceShmem> {
public:
......@@ -106,7 +106,9 @@ namespace DPsim {
* @param conf The configuration object for the output queue (see VILLASnode's documentation), or nullptr for sensible defaults.
*/
InterfaceShmem(const String &wn, const String &rn, Config *conf = nullptr, Bool sync = true, UInt downsampling = 1) :
mLastSample(nullptr),
mOpened(false),
mSequence(0),
mRName(rn),
mWName(wn),
mSync(sync),
......
......@@ -167,7 +167,7 @@ namespace DPsim {
// #### Setter and Getter ####
///
void setSystem(CPS::SystemTopology system);
void setSystem(const CPS::SystemTopology &system);
///
Matrix& leftSideVector() { return mLeftSideVector; }
///
......@@ -215,7 +215,7 @@ namespace DPsim {
for (auto node : solver.mNodes) {
mModifiedAttributes.push_back(node->attribute("v"));
}
for(Int freq = 0; freq < solver.mSystem.mFrequencies.size(); freq++) {
for(Int freq = 0; freq < solver.mSystem.mFrequencies.size(); ++freq) {
mModifiedAttributes.push_back(solver.attribute("left_vector_"+std::to_string(freq)));
}
}
......
......@@ -32,17 +32,17 @@ namespace DPsim {
// ###ARKode-specific variables ###
/// Memory block allocated by ARKode
void* mArkode_mem=NULL;
void* mArkode_mem {nullptr};
/// State vector
N_Vector mStates = NULL;
N_Vector mStates {nullptr};
//for implicit solve:
/// Indicates whether the ODE shall be solved using an implicit scheme
bool mImplicitIntegration;
/// Empty matrix for linear solve in each Newton step while solving the Jacobian Matrix
SUNMatrix A = NULL;
SUNMatrix A {nullptr};
/// Empty linear solver object
SUNLinearSolver LS = NULL;
SUNLinearSolver LS {nullptr};
/// Constant time step
Real mTimestep;
......@@ -60,7 +60,7 @@ namespace DPsim {
SUNLinearSolver LS = NULL; */
/// reusable error-checking flag
int mFlag;
int mFlag {0};
// Similar to DAE-Solver
CPS::ODEInterface::StSpFn mStSpFunction;
......@@ -75,11 +75,11 @@ namespace DPsim {
int Jacobian(realtype t, N_Vector y, N_Vector fy, SUNMatrix J,
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
/// ARKode- standard error detection function; in DAE-solver not detection function is used -> for efficiency purposes?
int check_flag(void *flagvalue, const std::string funcname, int opt);
int check_flag(void *flagvalue, const std::string &funcname, int opt);
public:
/// Create solve object with corresponding component and information on the integration type
ODESolver(String name, CPS::ODEInterface::Ptr comp, bool implicit_integration, Real timestep);
ODESolver(String name, const CPS::ODEInterface::Ptr &comp, bool implicit_integration, Real timestep);
/// Deallocate all memory
~ODESolver();
......
......@@ -43,7 +43,7 @@ namespace DPsim {
///static pointer to current object; only one instance currently allowed
inline static ODEintSolver *self = nullptr;
/// State space of the System and corresponding static wrapper
static void StateSpaceWrapper( const std::vector<double> y, std::vector<double> ydot, double t);
static void StateSpaceWrapper( const std::vector<double> &y, std::vector<double> ydot, double t);
public:
......
......@@ -67,7 +67,7 @@ namespace DPsim {
void calculateNodalInjection();
public:
/// Constructor to be used in simulation examples.
PFSolverPowerPolar(CPS::String name, CPS::SystemTopology system, CPS::Real timeStep, CPS::Logger::Level logLevel);
PFSolverPowerPolar(CPS::String name, const CPS::SystemTopology &system, CPS::Real timeStep, CPS::Logger::Level logLevel);
///
virtual ~PFSolverPowerPolar() { };
};
......
......@@ -34,11 +34,10 @@ namespace DPsim {
///
Scheduler(CPS::Logger::Level logLevel = CPS::Logger::Level::off) :
mRoot(std::make_shared<Root>()) {
mRoot(std::make_shared<Root>()),
// Logging
mLogLevel = logLevel;
mSLog = CPS::Logger::get("scheduler", logLevel);
mLogLevel(logLevel),
mSLog(CPS::Logger::get("scheduler", logLevel)) {
mSLog->set_pattern("[%L] %v");
}
///
......
......@@ -162,7 +162,7 @@ namespace DPsim {
// #### Simulation Settings ####
///
void setSystem(CPS::SystemTopology system) { mSystem = system; }
void setSystem(const CPS::SystemTopology &system) { mSystem = system; }
///
void setTimeStep(Real timeStep) { mTimeStep = timeStep; }
///
......@@ -180,7 +180,7 @@ namespace DPsim {
mTearComponents = tearComponents;
}
/// Set the scheduling method
void setScheduler(std::shared_ptr<Scheduler> scheduler) {
void setScheduler(const std::shared_ptr<Scheduler> &scheduler) {
mScheduler = scheduler;
}
/// Compute phasors of different frequencies in parallel
......
......@@ -57,11 +57,10 @@ namespace DPsim {
typedef std::vector<Ptr> List;
Solver(String name, CPS::Logger::Level logLevel) :
mName(name), mLogLevel(logLevel) {
mName(name),
mLogLevel(logLevel),
// Solver global logging
mSLog = CPS::Logger::get(name + "_Solver", logLevel);
}
mSLog(CPS::Logger::get(name + "_Solver", logLevel)) { }
virtual ~Solver() { }
......@@ -78,7 +77,7 @@ namespace DPsim {
mFrequencyParallel = freqParallel;
}
///
virtual void setSystem(CPS::SystemTopology system) {}
virtual void setSystem(const CPS::SystemTopology &system) {}
// #### Initialization ####
///
......
......@@ -15,7 +15,7 @@ using namespace CPS;
//#define NVECTOR_DATA(vec) NV_DATA_S (vec) // Returns pointer to the first element of array vec
DAESolver::DAESolver(String name, CPS::SystemTopology system, Real dt, Real t0) :
DAESolver::DAESolver(String name, const CPS::SystemTopology &system, Real dt, Real t0) :
Solver(name, CPS::Logger::Level::info),
mSystem(system),
mTimestep(dt) {
......@@ -53,15 +53,15 @@ DAESolver::DAESolver(String name, CPS::SystemTopology system, Real dt, Real t0)
std::cout <<"Processing Nodes"<<std::endl;
UInt matrixNodeIndexIdx = 0;
for (UInt idx = 0; idx < mNodes.size(); idx++) {
for (UInt idx = 0; idx < mNodes.size(); ++idx) {
mNodes[idx]->setMatrixNodeIndex(0, matrixNodeIndexIdx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
if (mNodes[idx]->phaseType() == PhaseType::ABC) {
mNodes[idx]->setMatrixNodeIndex(1, matrixNodeIndexIdx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
mNodes[idx]->setMatrixNodeIndex(2, matrixNodeIndexIdx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
}
}
......
......@@ -72,7 +72,7 @@ void DataLogger::logDataLine(Real time, const Matrix& data) {
return;
mLogFile << std::scientific << std::right << std::setw(14) << time;
for (Int i = 0; i < data.rows(); i++) {
for (Int i = 0; i < data.rows(); ++i) {
mLogFile << ", " << std::right << std::setw(13) << data(i, 0);
}
mLogFile << '\n';
......@@ -82,7 +82,7 @@ void DataLogger::logDataLine(Real time, const MatrixComp& data) {
if (!mEnabled)
return;
mLogFile << std::scientific << std::right << std::setw(14) << time;
for (Int i = 0; i < data.rows(); i++) {
for (Int i = 0; i < data.rows(); ++i) {
mLogFile << ", " << std::right << std::setw(13) << data(i, 0);
}
mLogFile << '\n';
......@@ -95,14 +95,14 @@ void DataLogger::logPhasorNodeValues(Real time, const Matrix& data, Int freqNum)
Int harmonicOffset = data.rows() / freqNum;
Int complexOffset = harmonicOffset / 2;
for (Int freq = 0; freq < freqNum; freq++) {
for (Int node = 0; node < complexOffset; node++) {
for (Int freq = 0; freq < freqNum; ++freq) {
for (Int node = 0; node < complexOffset; ++node) {
std::stringstream name;
name << "n" << std::setfill('0') << std::setw(5) << node
<< "f" << std::setfill('0') << std::setw(2) << freq << ".re";
names.push_back(name.str());
}
for (Int node = 0; node < complexOffset; node++) {
for (Int node = 0; node < complexOffset; ++node) {
std::stringstream name;
name << "n" << std::setfill('0') << std::setw(5) << node
<< "f" << std::setfill('0') << std::setw(2) << freq << ".im";
......@@ -117,7 +117,7 @@ void DataLogger::logPhasorNodeValues(Real time, const Matrix& data, Int freqNum)
void DataLogger::logEMTNodeValues(Real time, const Matrix& data) {
if (mLogFile.tellp() == std::ofstream::pos_type(0)) {
std::vector<String> names;
for (Int i = 0; i < data.rows(); i++) {
for (Int i = 0; i < data.rows(); ++i) {
std::stringstream name;
name << "node" << std::setfill('0') << std::setw(5) << i;
names.push_back(name.str());
......@@ -179,14 +179,14 @@ void DataLogger::addAttribute(const std::vector<String> &name, CPS::MatrixRealAt
addAttribute(name[0], attrMat->coeff(0, 0));
}
else if (m.cols() == 1) {
for (UInt k = 0; k < m.rows(); k++) {
for (UInt k = 0; k < m.rows(); ++k) {
addAttribute(name[k],
attrMat->coeff(k, 0));
}
}
else {
for (UInt k = 0; k < m.rows(); k++) {
for (UInt l = 0; l < m.cols(); l++) {
for (UInt k = 0; k < m.rows(); ++k) {
for (UInt l = 0; l < m.cols(); ++l) {
addAttribute(name[k*m.cols()+l],
attrMat->coeff(k, l));
}
......@@ -202,14 +202,14 @@ void DataLogger::addAttribute(const String &name, CPS::MatrixRealAttribute::Ptr
addAttribute(name, attrMat->coeff(0, 0));
}
else if (m.cols() == 1) {
for (UInt k = 0; k < m.rows(); k++) {
for (UInt k = 0; k < m.rows(); ++k) {
addAttribute(name + "_" + std::to_string(k),
attrMat->coeff(k, 0));
}
}
else {
for (UInt k = 0; k < m.rows(); k++) {
for (UInt l = 0; l < m.cols(); l++) {
for (UInt k = 0; k < m.rows(); ++k) {
for (UInt l = 0; l < m.cols(); ++l) {
addAttribute(name + "_" + std::to_string(k) + "_" + std::to_string(l) + "_",
attrMat->coeff(k, l));
}
......@@ -229,15 +229,15 @@ void DataLogger::addAttribute(const String &name, CPS::MatrixCompAttribute::Ptr
mAttributes[name + ".im"] = attrMat->coeffImag(0,0);
}
else if (m.cols() == 1) {
for (UInt k = 0; k < rowsMax; k++) {
for (UInt k = 0; k < rowsMax; ++k) {
//addAttribute(name + "(" + std::to_string(k) + ")", attrMat->coeff(k, 0));
mAttributes[name + "_" + std::to_string(k) + ".re"] = attrMat->coeffReal(k,0);
mAttributes[name + "_" + std::to_string(k) + ".im"] = attrMat->coeffImag(k,0);
}
}
else {
for (UInt k = 0; k < rowsMax; k++) {
for (UInt l = 0; l < colsMax; l++) {
for (UInt k = 0; k < rowsMax; ++k) {
for (UInt l = 0; l < colsMax; ++l) {
mAttributes[name + "_" + std::to_string(k) + "_" + std::to_string(l)
+ ".re"] = attrMat->coeffReal(k,l);
mAttributes[name + "_" + std::to_string(k) + "_" + std::to_string(l)
......
......@@ -55,7 +55,7 @@ void DiakopticsSolver<VarType>::init(SystemTopology& system) {
template <typename VarType>
void DiakopticsSolver<VarType>::initSubnets(const std::vector<SystemTopology>& subnets) {
mSubnets.resize(subnets.size());
for (UInt i = 0; i < subnets.size(); i++) {
for (UInt i = 0; i < subnets.size(); ++i) {
// Add nodes to the list and ignore ground nodes.
for (auto baseNode : subnets[i].mNodes) {
if (!baseNode->isGround()) {
......@@ -83,14 +83,14 @@ void DiakopticsSolver<VarType>::initSubnets(const std::vector<SystemTopology>& s
}
}
for (UInt idx = 0; idx < mTearComponents.size(); idx++) {
for (UInt idx = 0; idx < mTearComponents.size(); ++idx) {
auto comp = mTearComponents[idx];
auto tComp = std::dynamic_pointer_cast<MNATearInterface>(comp);
if (!tComp)
throw SystemError("Unsupported component type for diakoptics");
if (comp->hasVirtualNodes()) {
for (UInt node = 0; node < comp->virtualNodesNumber(); node++) {
for (UInt node = 0; node < comp->virtualNodesNumber(); ++node) {
// sim node number doesn't matter here because it shouldn't be used anyway
// TODO adapt this to new concept
comp->setVirtualNodeAt(std::make_shared<CPS::SimNode<VarType>>(node), node);
......@@ -114,7 +114,7 @@ void DiakopticsSolver<VarType>::initSubnets(const std::vector<SystemTopology>& s
}
}
for (UInt i = 0; i < subnets.size(); i++) {
for (UInt i = 0; i < subnets.size(); ++i) {
collectVirtualNodes(i);
assignMatrixNodeIndices(i);
}
......@@ -131,8 +131,8 @@ void DiakopticsSolver<VarType>::collectVirtualNodes(int net) {
continue;
if (pComp->hasVirtualNodes()) {
for (UInt node = 0; node < pComp->virtualNodesNumber(); node++) {
mSubnets[net].mVirtualNodeNum++;
for (UInt node = 0; node < pComp->virtualNodesNumber(); ++node) {
++(mSubnets[net].mVirtualNodeNum);
mSubnets[net].nodes.push_back(pComp->virtualNode(node));
}
}
......@@ -144,20 +144,20 @@ void DiakopticsSolver<VarType>::collectVirtualNodes(int net) {
template <typename VarType>
void DiakopticsSolver<VarType>::assignMatrixNodeIndices(int net) {
UInt matrixNodeIndexIdx = 0;
for (UInt idx = 0; idx < mSubnets[net].nodes.size(); idx++) {
for (UInt idx = 0; idx < mSubnets[net].nodes.size(); ++idx) {
auto& node = mSubnets[net].nodes[idx];
node->setMatrixNodeIndex(0, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to node {}", matrixNodeIndexIdx, node->name());
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
if (node->phaseType() == CPS::PhaseType::ABC) {
node->setMatrixNodeIndex(1, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to node {} phase B", matrixNodeIndexIdx, node->name());
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
node->setMatrixNodeIndex(2, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to node {} phase C", matrixNodeIndexIdx, node->name());
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
}
}
setSubnetSize(net, matrixNodeIndexIdx);
......@@ -189,7 +189,7 @@ template<>
void DiakopticsSolver<Complex>::setLogColumns() {
std::vector<String> names;
for (auto& subnet : mSubnets) {
for (UInt i = subnet.sysOff; i < subnet.sysOff + subnet.sysSize; i++) {
for (UInt i = subnet.sysOff; i < subnet.sysOff + subnet.sysSize; ++i) {
std::stringstream name;
if (i < subnet.sysOff + subnet.mCmplOff)
name << "node" << std::setfill('0') << std::setw(5) << i - subnet.sysOff / 2 << ".real";
......@@ -244,7 +244,7 @@ void DiakopticsSolver<Complex>::createTearMatrices(UInt totalSize) {
template <typename VarType>
void DiakopticsSolver<VarType>::initComponents() {
for (UInt net = 0; net < mSubnets.size(); net++) {
for (UInt net = 0; net < mSubnets.size(); ++net) {
for (auto comp : mSubnets[net].components) {
auto pComp = std::dynamic_pointer_cast<SimPowerComp<VarType>>(comp);
if (!pComp) continue;
......@@ -285,7 +285,7 @@ void DiakopticsSolver<VarType>::initMatrices() {
mSLog->info("Complete system matrix: \n{}", mSystemMatrix);
// initialize tear topology matrix and impedance matrix of removed network
for (UInt compIdx = 0; compIdx < mTearComponents.size(); compIdx++) {
for (UInt compIdx = 0; compIdx < mTearComponents.size(); ++compIdx) {
applyTearComponentStamp(compIdx);
}
mSLog->info("Topology matrix: \n{}", mTearTopology);
......@@ -338,7 +338,7 @@ template <typename VarType>
Task::List DiakopticsSolver<VarType>::getTasks() {
Task::List l;
for (UInt net = 0; net < mSubnets.size(); net++) {
for (UInt net = 0; net < mSubnets.size(); ++net) {
for (auto node : mSubnets[net].nodes) {
for (auto task : node->mnaTasks())
l.push_back(task);
......@@ -408,7 +408,7 @@ template <typename VarType>
void DiakopticsSolver<VarType>::PostSolveTask::execute(Real time, Int timeStepCount) {
// pass the voltages and current of the solution to the torn components
mSolver.mTearVoltages = -mSolver.mTearTopology.transpose() * mSolver.mLeftSideVector;
for (UInt compIdx = 0; compIdx < mSolver.mTearComponents.size(); compIdx++) {
for (UInt compIdx = 0; compIdx < mSolver.mTearComponents.size(); ++compIdx) {
auto comp = mSolver.mTearComponents[compIdx];
auto tComp = std::dynamic_pointer_cast<MNATearInterface>(comp);
Complex voltage = Math::complexFromVectorElement(mSolver.mTearVoltages, compIdx);
......@@ -417,8 +417,8 @@ void DiakopticsSolver<VarType>::PostSolveTask::execute(Real time, Int timeStepCo
}
// TODO split into separate task? (dependent on x, updating all v attributes)
for (UInt net = 0; net < mSolver.mSubnets.size(); net++) {
for (UInt node = 0; node < mSolver.mSubnets[net].mRealNetNodeNum; node++) {
for (UInt net = 0; net < mSolver.mSubnets.size(); ++net) {
for (UInt node = 0; node < mSolver.mSubnets[net].mRealNetNodeNum; ++node) {
mSolver.mSubnets[net].nodes[node]->mnaUpdateVoltage(*(mSolver.mSubnets[net].leftVector));
}
}
......
......@@ -25,7 +25,7 @@ MnaSolver<VarType>::MnaSolver(String name, CPS::Domain domain, CPS::Logger::Leve
}
template <typename VarType>
void MnaSolver<VarType>::setSystem(CPS::SystemTopology system) {
void MnaSolver<VarType>::setSystem(const CPS::SystemTopology &system) {
mSystem = system;
}
......@@ -56,7 +56,7 @@ void MnaSolver<VarType>::initialize() {
// Register attribute for solution vector
if (mFrequencyParallel) {
mSLog->info("Computing network harmonics in parallel.");
for(Int freq = 0; freq < mSystem.mFrequencies.size(); freq++) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); ++freq) {
addAttribute<Matrix>("left_vector_"+std::to_string(freq), mLeftSideVectorHarm.data()+freq, Flags::read);
mLeftVectorHarmAttributes.push_back(attribute<Matrix>("left_vector_"+std::to_string(freq)));
}
......@@ -146,7 +146,7 @@ void MnaSolver<Complex>::initializeComponents() {
if (stamp.size() != 0) mRightVectorStamps.push_back(&stamp);
}
// Initialize nodes
for (UInt nodeIdx = 0; nodeIdx < mNodes.size(); nodeIdx++) {
for (UInt nodeIdx = 0; nodeIdx < mNodes.size(); ++nodeIdx) {
mNodes[nodeIdx]->mnaInitializeHarm(mLeftVectorHarmAttributes);
}
}
......@@ -185,11 +185,11 @@ template <typename VarType>
void MnaSolver<VarType>::initializeSystemWithParallelFrequencies() {
// iterate over all possible switch state combinations
for (std::size_t i = 0; i < (1ULL << mSwitches.size()); i++) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); freq++)
for(Int freq = 0; freq < mSystem.mFrequencies.size(); ++freq)
mSwitchedMatricesHarm[std::bitset<SWITCH_NUM>(i)][freq].setZero();
}
for(Int freq = 0; freq < mSystem.mFrequencies.size(); freq++) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); ++freq) {
// Create system matrix if no switches were added
// TODO add case for switches and possibly merge with no harmonics
for (auto comp : mMNAComponents)
......@@ -235,7 +235,7 @@ void MnaSolver<VarType>::initializeSystemWithPrecomputedMatrices() {
for (auto& sys : mSwitchedMatrices) {
for (auto comp : mMNAComponents)
comp->mnaApplySystemMatrixStamp(sys.second);
for (UInt i = 0; i < mSwitches.size(); i++)
for (UInt i = 0; i < mSwitches.size(); ++i)
mSwitches[i]->mnaApplySwitchSystemMatrixStamp(sys.second, sys.first[i]);
// Compute LU-factorization for system matrix
#ifdef WITH_SPARSE
......@@ -250,7 +250,7 @@ void MnaSolver<VarType>::initializeSystemWithPrecomputedMatrices() {
// Initialize source vector for debugging
// CAUTION: this does not always deliver proper source vector initialization
// as not full pre-step is executed (not involving necessary electrical or signal
// as not full pre-step is executed (not involving necessary electrical or signal
// subcomp updates before right vector calculation)
for (auto comp : mMNAComponents) {
comp->mnaApplyRightSideVectorStamp(mRightSideVector);
......@@ -264,7 +264,7 @@ void MnaSolver<VarType>::initializeSystemWithPrecomputedMatrices() {
template <typename VarType>
void MnaSolver<VarType>::updateSwitchStatus() {
for (UInt i = 0; i < mSwitches.size(); i++) {
for (UInt i = 0; i < mSwitches.size(); ++i) {
mCurrentSwitchStatus.set(i, mSwitches[i]->mnaIsClosed());
}
}
......@@ -309,17 +309,17 @@ void MnaSolver<VarType>::identifyTopologyObjects() {
template <typename VarType>
void MnaSolver<VarType>::assignMatrixNodeIndices() {
UInt matrixNodeIndexIdx = 0;
for (UInt idx = 0; idx < mNodes.size(); idx++) {
for (UInt idx = 0; idx < mNodes.size(); ++idx) {
mNodes[idx]->setMatrixNodeIndex(0, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to phase A of node {}", matrixNodeIndexIdx, idx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
if (mNodes[idx]->phaseType() == CPS::PhaseType::ABC) {
mNodes[idx]->setMatrixNodeIndex(1, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to phase B of node {}", matrixNodeIndexIdx, idx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
mNodes[idx]->setMatrixNodeIndex(2, matrixNodeIndexIdx);
mSLog->info("Assigned index {} to phase B of node {}", matrixNodeIndexIdx, idx);
matrixNodeIndexIdx++;
++matrixNodeIndexIdx;
}
if (idx == mNumNetNodes-1) mNumNetMatrixNodeIndices = matrixNodeIndexIdx;
}
......@@ -343,7 +343,7 @@ void MnaSolver<Real>::createEmptyVectors() {
template<>
void MnaSolver<Complex>::createEmptyVectors() {
if (mFrequencyParallel) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); freq++) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); ++freq) {
mRightSideVectorHarm.push_back(Matrix::Zero(2*(mNumMatrixNodeIndices), 1));
mLeftSideVectorHarm.push_back(Matrix::Zero(2*(mNumMatrixNodeIndices), 1));
}
......@@ -378,8 +378,8 @@ void MnaSolver<Complex>::createEmptySystemMatrix() {
throw SystemError("Too many Switches.");
if (mFrequencyParallel) {
for (UInt i = 0; i < std::pow(2,mSwitches.size()); i++) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); freq++) {
for (UInt i = 0; i < std::pow(2,mSwitches.size()); ++i) {
for(Int freq = 0; freq < mSystem.mFrequencies.size(); ++freq) {
mSwitchedMatricesHarm[std::bitset<SWITCH_NUM>(i)].push_back(
Matrix::Zero(2*(mNumMatrixNodeIndices), 2*(mNumMatrixNodeIndices)));
}
......@@ -414,7 +414,7 @@ void MnaSolver<VarType>::collectVirtualNodes() {
// Check if component requires virtual node and if so get a reference
if (pComp->hasVirtualNodes()) {
for (UInt node = 0; node < pComp->virtualNodesNumber(); node++) {
for (UInt node = 0; node < pComp->virtualNodesNumber(); ++node) {
mNodes.push_back(pComp->virtualNode(node));
mSLog->info("Collected virtual node {} of {}", virtualNode, node, pComp->name());
}
......@@ -424,7 +424,7 @@ void MnaSolver<VarType>::collectVirtualNodes() {
// TODO: recursive behavior
if (pComp->hasSubComponents()) {
for (auto pSubComp : pComp->subComponents()) {
for (UInt node = 0; node < pSubComp->virtualNodesNumber(); node++) {
for (UInt node = 0; node < pSubComp->virtualNodesNumber(); ++node) {
mNodes.push_back(pSubComp->virtualNode(node));
mSLog->info("Collected virtual node {} of {}", virtualNode, node, pComp->name());
}
......@@ -515,7 +515,7 @@ void MnaSolver<VarType>::steadyStateInitialization() {
// Calculate new simulation time
time = time + initTimeStep;
timeStepCount++;
++timeStepCount;
// Calculate difference
diff = prevLeftSideVector - mLeftSideVector;
......@@ -560,7 +560,7 @@ Task::List MnaSolver<VarType>::getTasks() {
}
}
if (mFrequencyParallel) {
for (UInt i = 0; i < mSystem.mFrequencies.size(); i++)
for (UInt i = 0; i < mSystem.mFrequencies.size(); ++i)
l.push_back(std::make_shared<MnaSolver<VarType>::SolveTaskHarm>(*this, i));
} else {
l.push_back(std::make_shared<MnaSolver<VarType>::SolveTask>(*this));
......@@ -583,7 +583,7 @@ void MnaSolver<VarType>::solve(Real time, Int timeStepCount) {
mLeftSideVector = mLuFactorizations[mCurrentSwitchStatus].solve(mRightSideVector);
// TODO split into separate task? (dependent on x, updating all v attributes)
for (UInt nodeIdx = 0; nodeIdx < mNumNetNodes; nodeIdx++)
for (UInt nodeIdx = 0; nodeIdx < mNumNetNodes; ++nodeIdx)
mNodes[nodeIdx]->mnaUpdateVoltage(mLeftSideVector);
if (!mIsInInitialization)
......@@ -621,14 +621,14 @@ void MnaSolver<VarType>::log(Real time, Int timeStepCount) {