DPsim
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DPsim::MnaSolverDirect< VarType > Class Template Reference

Solver class using Modified Nodal Analysis (MNA). More...

#include <MNASolverDirect.h>

Inheritance diagram for DPsim::MnaSolverDirect< VarType >:
[legend]
Collaboration diagram for DPsim::MnaSolverDirect< VarType >:
[legend]

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
 
- Public Member Functions inherited from DPsim::MnaSolver< VarType >
virtual ~MnaSolver ()
 Destructor.
 
virtual void initialize () override
 Calls subroutines to set up everything that is required before simulation. More...
 
virtual void setSystem (const CPS::SystemTopology &system) override
 
Matrix & leftSideVector ()
 
Matrix & rightSideVector ()
 
virtual CPS::Task::List getTasks () override
 Get tasks for scheduler.
 
- Public Member Functions inherited from DPsim::Solver
 Solver (String name, CPS::Logger::Level logLevel)
 
void setTimeStep (Real timeStep)
 
void doFrequencyParallelization (Bool freqParallel)
 
void doSystemMatrixRecomputation (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
 
- Public Attributes inherited from DPsim::MnaSolver< VarType >
CPS::Attribute< Matrix >::Ptr mLeftSideVector
 Solution vector of unknown quantities.
 
std::vector< CPS::Attribute< Matrix >::Ptr > mLeftSideVectorHarm
 Solution vector of unknown quantities (parallel frequencies)
 
- Public Attributes inherited from DPsim::Solver
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::TaskcreateSolveTaskRecomp () override
 Create a solve task for recomputation solver.
 
virtual void recomputeSystemMatrix (Real time)
 Recomputes systems matrix.
 
std::shared_ptr< CPS::TaskcreateSolveTask () override
 Create a solve task for this solver implementation.
 
std::shared_ptr< CPS::TaskcreateLogTask () override
 Create a solve task for this solver implementation.
 
std::shared_ptr< CPS::TaskcreateSolveTaskHarm (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< DirectLinearSolvercreateDirectSolverImplementation (CPS::Logger::Log mSLog)
 Returns a pointer to an object of type DirectLinearSolver.
 
void createEmptySystemMatrix ()
 Create system matrix.
 
void createEmptySystemMatrix ()
 Create system matrix.
 
- Protected Member Functions inherited from DPsim::MnaSolver< VarType >
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< DirectLinearSolvermDirectLinearSolverVariableSystemMatrix
 LU factorization of variable system matrix.
 
DirectLinearSolverImpl mImplementationInUse
 LU factorization indicator.
 
DirectLinearSolverConfiguration mConfigurationInUse
 LU factorization configuration.
 
- Protected Attributes inherited from DPsim::MnaSolver< VarType >
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< SwitchConfigurationmSwitchEvents
 Vector of switch times.
 
Int mLastLogTimeStep = 0
 Last simulation time step when log was updated.
 
std::shared_ptr< DataLoggermLeftVectorLog
 Left side vector logger.
 
std::shared_ptr< DataLoggermRightVectorLog
 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.
 
- Protected Attributes inherited from DPsim::Solver
String mName
 Name for logging.
 
CPS::Logger::Level mLogLevel
 Logging level.
 
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

- Public Types inherited from DPsim::Solver
enum  Behaviour { Initialization , Simulation }
 
enum class  Type { MNA , DAE , NRP }
 
typedef std::shared_ptr< SolverPtr
 
typedef std::vector< Ptr > List
 

Detailed Description

template<typename VarType>
class DPsim::MnaSolverDirect< VarType >

Solver class using Modified Nodal Analysis (MNA).

Definition at line 58 of file MNASolverDirect.h.

Constructor & Destructor Documentation

◆ MnaSolverDirect()

template<typename VarType >
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.

Member Data Documentation

◆ mIter

template<typename VarType >
int DPsim::MnaSolverDirect< VarType >::mIter = 0

SynGen Interface

Definition at line 178 of file MNASolverDirect.h.


The documentation for this class was generated from the following files: