DPsim
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DPsim::MnaSolver< VarType > Class Template Referenceabstract

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

#include <MNASolver.h>

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

Public Member Functions

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
 
virtual void setDirectLinearSolverConfiguration (DirectLinearSolverConfiguration &)
 set direct linear solver configuration (only available in MNA for now)
 
virtual void logLUTimes ()
 log LU decomposition times, if applicable
 
void setMaxNumberOfIterations (int maxIterations)
 

Public Attributes

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 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 createEmptySystemMatrix ()=0
 Create system matrix.
 
virtual void switchedMatrixEmpty (std::size_t index)=0
 Sets all entries in the matrix with the given switch index to zero.
 
virtual void switchedMatrixEmpty (std::size_t swIdx, Int freqIdx)=0
 Sets all entries in the matrix with the given switch index and frequency index to zero.
 
virtual void switchedMatrixStamp (std::size_t index, std::vector< std::shared_ptr< CPS::MNAInterface >> &comp)=0
 Applies a component stamp to the matrix with the given switch index.
 
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 stampVariableSystemMatrix ()=0
 Stamps components into the variable system matrix.
 
virtual void solveWithSystemMatrixRecomputation (Real time, Int timeStepCount)=0
 Solves the system with variable system matrix.
 
virtual std::shared_ptr< CPS::TaskcreateSolveTaskRecomp ()=0
 Create a solve task for recomputation solver.
 
virtual void logSystemMatrices ()=0
 Logging of system matrices and source vector.
 
virtual std::shared_ptr< CPS::TaskcreateSolveTask ()=0
 Create a solve task for this solver implementation.
 
virtual std::shared_ptr< CPS::TaskcreateLogTask ()=0
 Create a solve task for this solver implementation.
 
virtual std::shared_ptr< CPS::TaskcreateSolveTaskHarm (UInt freqIdx)=0
 Create a solve task for this solver implementation.
 
virtual void solve (Real time, Int timeStepCount)=0
 Solves system for single frequency.
 
virtual void solveWithHarmonics (Real time, Int timeStepCount, Int freqIdx)=0
 Solves system for multiple frequencies.
 
virtual void log (Real time, Int timeStepCount) override
 Logs left and right vector.
 
void initializeComponents ()
 
void initializeComponents ()
 
void createEmptyVectors ()
 
void createEmptyVectors ()
 

Protected Attributes

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::MnaSolver< VarType >

Solver class using Modified Nodal Analysis (MNA).

Definition at line 38 of file MNASolver.h.

Member Function Documentation

◆ collectVirtualNodes()

template<typename VarType >
void DPsim::MnaSolver< VarType >::collectVirtualNodes
protected

Collects virtual nodes inside components. The MNA algorithm handles these nodes in the same way as network nodes.

Definition at line 422 of file MNASolver.cpp.

◆ initialize()

template<typename VarType >
void DPsim::MnaSolver< VarType >::initialize
overridevirtual

Calls subroutines to set up everything that is required before simulation.

FIXME: This is kinda ugly... At least we should somehow unify mLeftSideVector and mLeftSideVectorHarm.

Reimplemented from DPsim::Solver.

Reimplemented in DPsim::MnaSolverPlugin< VarType >.

Definition at line 35 of file MNASolver.cpp.

Member Data Documentation

◆ mSwitches

template<typename VarType >
CPS::MNASwitchInterface::List DPsim::MnaSolver< VarType >::mSwitches
protected

List of switches that stamp differently depending on their state and indicate the solver to choose a different system matrix

Definition at line 72 of file MNASolver.h.

◆ mVariableComps

template<typename VarType >
CPS::MNAVariableCompInterface::List DPsim::MnaSolver< VarType >::mVariableComps
protected

List of components that indicate the solver to recompute the system matrix depending on their state

Definition at line 96 of file MNASolver.h.


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