DPsim
|
Solver class using Modified Nodal Analysis (MNA). More...
#include <MNASolverDirect.h>
Classes | |
class | LogTask |
class | SolveTask |
class | SolveTaskHarm |
class | SolveTaskRecomp |
Public Member Functions | |
MnaSolverDirect (String name, CPS::Domain domain=CPS::Domain::DP, CPS::Logger::Level logLevel=CPS::Logger::Level::info) | |
virtual | ~MnaSolverDirect ()=default |
Destructor. | |
void | setDirectLinearSolverImplementation (DirectLinearSolverImpl implementation) |
Sets the linear solver to "implementation" and creates an object. | |
void | setDirectLinearSolverConfiguration (DirectLinearSolverConfiguration &configuration) override |
Sets the linear solver configuration. | |
void | logLUTimes () override |
log LU decomposition times | |
![]() | |
virtual | ~MnaSolver () |
Destructor. | |
virtual void | initialize () override |
Calls subroutines to set up everything that is required before simulation. | |
virtual void | setSystem (const CPS::SystemTopology &system) override |
Matrix & | leftSideVector () |
Matrix & | rightSideVector () |
virtual CPS::Task::List | getTasks () override |
Get tasks for scheduler. | |
![]() | |
Solver (String name, CPS::Logger::Level logLevel) | |
void | setTimeStep (Real timeStep) |
void | doFrequencyParallelization (Bool freqParallel) |
void | doSystemMatrixRecomputation (Bool value) |
void | setLogSolveTimes (Bool value) |
void | doSteadyStateInit (Bool f) |
activate steady state initialization | |
void | setSteadStIniTimeLimit (Real v) |
set steady state initialization time limit | |
void | setSteadStIniAccLimit (Real v) |
set steady state initialization accuracy limit | |
virtual void | setSolverAndComponentBehaviour (Solver::Behaviour behaviour) |
set solver and component to initialization or simulation behaviour | |
void | doInitFromNodesAndTerminals (Bool f) |
activate powerflow initialization | |
void | setMaxNumberOfIterations (int maxIterations) |
Public Attributes | |
int | mIter = 0 |
![]() | |
CPS::Attribute< Matrix >::Ptr | mLeftSideVector |
Solution vector of unknown quantities. | |
std::vector< CPS::Attribute< Matrix >::Ptr > | mLeftSideVectorHarm |
Solution vector of unknown quantities (parallel frequencies) | |
![]() | |
int | mMaxIterations = 10 |
Protected Member Functions | |
void | createEmptySystemMatrix () override |
Create system matrix. | |
void | switchedMatrixEmpty (std::size_t index) override |
Sets all entries in the matrix with the given switch index to zero. | |
void | switchedMatrixEmpty (std::size_t swIdx, Int freqIdx) override |
Sets all entries in the matrix with the given switch index and frequency index to zero. | |
void | switchedMatrixStamp (std::size_t index, std::vector< std::shared_ptr< CPS::MNAInterface > > &comp) override |
Applies a component stamp to the matrix with the given switch index. | |
void | stampVariableSystemMatrix () override |
Stamps components into the variable system matrix. | |
void | solveWithSystemMatrixRecomputation (Real time, Int timeStepCount) override |
Solves the system with variable system matrix. | |
std::shared_ptr< CPS::Task > | createSolveTaskRecomp () override |
Create a solve task for recomputation solver. | |
virtual void | recomputeSystemMatrix (Real time) |
Recomputes systems matrix. | |
std::shared_ptr< CPS::Task > | createSolveTask () override |
Create a solve task for this solver implementation. | |
std::shared_ptr< CPS::Task > | createLogTask () override |
Create a solve task for this solver implementation. | |
std::shared_ptr< CPS::Task > | createSolveTaskHarm (UInt freqIdx) override |
Create a solve task for this solver implementation. | |
void | logSystemMatrices () override |
Logging of system matrices and source vector. | |
void | solve (Real time, Int timeStepCount) override |
Solves system for single frequency. | |
void | solveWithHarmonics (Real time, Int timeStepCount, Int freqIdx) override |
Solves system for multiple frequencies. | |
void | logSolveTime () |
Logging of the right-hand-side solution time. | |
void | logFactorizationTime () |
Logging of the LU factorization time. | |
void | logRecomputationTime () |
Logging of the LU refactorization time. | |
std::shared_ptr< DirectLinearSolver > | createDirectSolverImplementation (CPS::Logger::Log mSLog) |
Returns a pointer to an object of type DirectLinearSolver. | |
void | createEmptySystemMatrix () |
Create system matrix. | |
void | createEmptySystemMatrix () |
Create system matrix. | |
![]() | |
void | updateSwitchStatus () |
Collects the status of switches to select correct system matrix. | |
MnaSolver (String name, CPS::Domain domain=CPS::Domain::DP, CPS::Logger::Level logLevel=CPS::Logger::Level::info) | |
Constructor should not be called by users but by Simulation. | |
void | initializeComponents () |
Initialization of individual components. | |
virtual void | initializeSystem () |
Initialization of system matrices and source vector. | |
void | initializeSystemWithParallelFrequencies () |
Initialization of system matrices and source vector. | |
void | initializeSystemWithPrecomputedMatrices () |
Initialization of system matrices and source vector. | |
void | initializeSystemWithVariableMatrix () |
Initialization of system matrices and source vector. | |
void | identifyTopologyObjects () |
Identify Nodes and SimPowerComps and SimSignalComps. | |
void | assignMatrixNodeIndices () |
Assign simulation node index according to index in the vector. | |
void | collectVirtualNodes () |
void | steadyStateInitialization () |
void | createEmptyVectors () |
Create left and right side vector. | |
virtual void | switchedMatrixStamp (std::size_t swIdx, Int freqIdx, CPS::MNAInterface::List &components, CPS::MNASwitchInterface::List &switches) |
Applies a component and switch stamp to the matrix with the given switch index. | |
Bool | hasVariableComponentChanged () |
Checks whether the status of variable MNA elements have changed. | |
virtual void | log (Real time, Int timeStepCount) override |
Logs left and right vector. | |
void | initializeComponents () |
void | initializeComponents () |
void | createEmptyVectors () |
void | createEmptyVectors () |
Protected Attributes | |
std::unordered_map< std::bitset< SWITCH_NUM >, std::vector< SparseMatrix > > | mSwitchedMatrices |
Map of system matrices where the key is the bitset describing the switch states. | |
std::unordered_map< std::bitset< SWITCH_NUM >, std::vector< std::shared_ptr< DirectLinearSolver > > > | mDirectLinearSolvers |
Map of direct linear solvers related to the system matrices. | |
SparseMatrix | mBaseSystemMatrix |
System matrix including all static elements. | |
SparseMatrix | mVariableSystemMatrix |
System matrix including stamp of static and variable elements. | |
std::shared_ptr< DirectLinearSolver > | mDirectLinearSolverVariableSystemMatrix |
LU factorization of variable system matrix. | |
DirectLinearSolverImpl | mImplementationInUse |
LU factorization indicator. | |
DirectLinearSolverConfiguration | mConfigurationInUse |
LU factorization configuration. | |
![]() | |
CPS::Domain | mDomain |
Simulation domain, which can be dynamic phasor (DP) or EMT. | |
UInt | mNumNodes = 0 |
Number of network and virtual nodes, single line equivalent. | |
UInt | mNumNetNodes = 0 |
Number of network nodes, single line equivalent. | |
UInt | mNumVirtualNodes = 0 |
Number of virtual nodes, single line equivalent. | |
UInt | mNumMatrixNodeIndices = 0 |
Number of network and virtual nodes, considering individual phases. | |
UInt | mNumNetMatrixNodeIndices = 0 |
Number of network nodes, considering individual phases. | |
UInt | mNumVirtualMatrixNodeIndices = 0 |
Number of virtual nodes, considering individual phases. | |
UInt | mNumHarmMatrixNodeIndices = 0 |
Number of nodes, excluding the primary frequency. | |
UInt | mNumTotalMatrixNodeIndices = 0 |
Total number of network and virtual nodes, considering individual phases and additional frequencies. | |
std::vector< std::pair< UInt, UInt > > | mListVariableSystemMatrixEntries |
List of index pairs of varying matrix entries. | |
CPS::SystemTopology | mSystem |
System topology. | |
CPS::SimNode< VarType >::List | mNodes |
List of simulation nodes. | |
CPS::MNAInterface::List | mMNAComponents |
List of MNA components with static stamp into system matrix. | |
CPS::MNASwitchInterface::List | mSwitches |
CPS::MNAInterface::List | mMNAIntfSwitches |
List of switches if they must be accessed as MNAInterface objects. | |
CPS::SimSignalComp::List | mSimSignalComps |
List of signal type components that do not directly interact with the MNA solver. | |
std::bitset< SWITCH_NUM > | mCurrentSwitchStatus |
Current status of all switches encoded as bitset. | |
CPS::MNASyncGenInterface::List | mSyncGen |
List of synchronous generators that need iterate to solve the differential equations. | |
Matrix | mRightSideVector |
Source vector of known quantities. | |
std::vector< const Matrix * > | mRightVectorStamps |
List of all right side vector contributions. | |
std::vector< Matrix > | mRightSideVectorHarm |
Source vector of known quantities. | |
Int | mNumRecomputations = 0 |
Number of system matrix recomputations. | |
CPS::MNAVariableCompInterface::List | mVariableComps |
CPS::MNAInterface::List | mMNAIntfVariableComps |
List of variable components if they must be accessed as MNAInterface objects. | |
UInt | mSwitchTimeIndex = 0 |
Index of the next switching event. | |
std::vector< SwitchConfiguration > | mSwitchEvents |
Vector of switch times. | |
Int | mLastLogTimeStep = 0 |
Last simulation time step when log was updated. | |
std::shared_ptr< DataLogger > | mLeftVectorLog |
Left side vector logger. | |
std::shared_ptr< DataLogger > | mRightVectorLog |
Right side vector logger. | |
std::vector< Real > | mFactorizeTimes |
LU factorization measurements. | |
std::vector< Real > | mSolveTimes |
Right-hand side solution measurements. | |
std::vector< Real > | mRecomputationTimes |
LU refactorization measurements. | |
![]() | |
String | mName |
Name for logging. | |
CPS::Logger::Level | mLogLevel |
Logging level. | |
Bool | mLogSolveTimes = true |
Collect step time for logging. | |
CPS::Logger::Log | mSLog |
Logger. | |
Real | mTimeStep |
Time step for fixed step solvers. | |
Bool | mFrequencyParallel = false |
Activates parallelized computation of frequencies. | |
Real | mSteadStIniTimeLimit = 10 |
steady state initialization time limit | |
Real | mSteadStIniAccLimit = 0.0001 |
steady state initialization accuracy limit | |
Bool | mSteadyStateInit = false |
Activates steady state initialization. | |
Bool | mIsInInitialization = false |
Determines if solver is in initialization phase, which requires different behavior. | |
Bool | mInitFromNodesAndTerminals = true |
Bool | mSystemMatrixRecomputation = false |
Enable recomputation of system matrix during simulation. | |
Behaviour | mBehaviour = Solver::Behaviour::Simulation |
Solver behaviour initialization or simulation. | |
Additional Inherited Members | |
![]() | |
enum | Behaviour { Initialization , Simulation } |
enum class | Type { MNA , DAE , NRP } |
typedef std::shared_ptr< Solver > | Ptr |
typedef std::vector< Ptr > | List |
Solver class using Modified Nodal Analysis (MNA).
Definition at line 58 of file MNASolverDirect.h.
DPsim::MnaSolverDirect< VarType >::MnaSolverDirect | ( | String | name, |
CPS::Domain | domain = CPS::Domain::DP, | ||
CPS::Logger::Level | logLevel = CPS::Logger::Level::info ) |
Constructor should not be called by users but by Simulation sovlerImpl: choose the most advanced solver implementation available by default
Definition at line 18 of file MNASolverDirect.cpp.
|
protected |
Returns a pointer to an object of type DirectLinearSolver.
Definition at line 426 of file MNASolverDirect.cpp.
|
protectedvirtual |
Create system matrix.
Implements DPsim::MnaSolver< VarType >.
Definition at line 161 of file MNASolverDirect.cpp.
|
protectedvirtual |
Create system matrix.
Implements DPsim::MnaSolver< VarType >.
Definition at line 181 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Create system matrix.
Implements DPsim::MnaSolver< VarType >.
|
overrideprotectedvirtual |
Create a solve task for this solver implementation.
Implements DPsim::MnaSolver< VarType >.
Definition at line 229 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Create a solve task for this solver implementation.
Implements DPsim::MnaSolver< VarType >.
Definition at line 212 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Create a solve task for this solver implementation.
Implements DPsim::MnaSolver< VarType >.
Definition at line 223 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Create a solve task for recomputation solver.
Implements DPsim::MnaSolver< VarType >.
Definition at line 217 of file MNASolverDirect.cpp.
|
protected |
Logging of the LU factorization time.
Definition at line 396 of file MNASolverDirect.cpp.
|
overridevirtual |
log LU decomposition times
Reimplemented from DPsim::Solver.
Definition at line 374 of file MNASolverDirect.cpp.
|
protected |
Logging of the LU refactorization time.
Definition at line 403 of file MNASolverDirect.cpp.
|
protected |
Logging of the right-hand-side solution time.
Definition at line 380 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Logging of system matrices and source vector.
Implements DPsim::MnaSolver< VarType >.
Definition at line 334 of file MNASolverDirect.cpp.
|
protectedvirtual |
Recomputes systems matrix.
Reimplemented in DPsim::MnaSolverPlugin< VarType >.
Definition at line 138 of file MNASolverDirect.cpp.
|
overridevirtual |
Sets the linear solver configuration.
Reimplemented from DPsim::Solver.
Definition at line 461 of file MNASolverDirect.cpp.
void DPsim::MnaSolverDirect< VarType >::setDirectLinearSolverImplementation | ( | DirectLinearSolverImpl | implementation | ) |
Sets the linear solver to "implementation" and creates an object.
Definition at line 455 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Solves system for single frequency.
Implements DPsim::MnaSolver< VarType >.
Reimplemented in DPsim::MnaSolverPlugin< VarType >.
Definition at line 234 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Solves system for multiple frequencies.
Implements DPsim::MnaSolver< VarType >.
Definition at line 321 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Solves the system with variable system matrix.
Implements DPsim::MnaSolver< VarType >.
Definition at line 108 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Stamps components into the variable system matrix.
Implements DPsim::MnaSolver< VarType >.
Definition at line 57 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Sets all entries in the matrix with the given switch index to zero.
Implements DPsim::MnaSolver< VarType >.
Definition at line 25 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Sets all entries in the matrix with the given switch index and frequency index to zero.
Implements DPsim::MnaSolver< VarType >.
Definition at line 30 of file MNASolverDirect.cpp.
|
overrideprotectedvirtual |
Applies a component stamp to the matrix with the given switch index.
Implements DPsim::MnaSolver< VarType >.
Definition at line 36 of file MNASolverDirect.cpp.
|
protected |
System matrix including all static elements.
Definition at line 72 of file MNASolverDirect.h.
|
protected |
LU factorization configuration.
Definition at line 80 of file MNASolverDirect.h.
|
protected |
Map of direct linear solvers related to the system matrices.
Definition at line 68 of file MNASolverDirect.h.
|
protected |
LU factorization of variable system matrix.
Definition at line 76 of file MNASolverDirect.h.
|
protected |
LU factorization indicator.
Definition at line 78 of file MNASolverDirect.h.
int DPsim::MnaSolverDirect< VarType >::mIter = 0 |
Definition at line 178 of file MNASolverDirect.h.
|
protected |
Map of system matrices where the key is the bitset describing the switch states.
Definition at line 64 of file MNASolverDirect.h.
|
protected |
System matrix including stamp of static and variable elements.
Definition at line 74 of file MNASolverDirect.h.