19template <
typename VarType>
37 CPS::Logger::Level::debug);
38 SPDLOG_LOGGER_INFO(log, str);
41template <
typename VarType>
65 if (
mPlugin->lu_decomp(&matrix) != 0) {
66 SPDLOG_LOGGER_ERROR(this->
mSLog,
"error recomputing decomposition");
75 std::vector<SparseMatrix> hMat;
79 "System-matrix recomputation is not supported by MNA solver plugins.");
82 nnz = hMat[0].nonZeros();
89 if ((
mDlHandle = dlopen(pluginFileName.c_str(), RTLD_NOW)) ==
nullptr) {
90 SPDLOG_LOGGER_ERROR(this->
mSLog,
"error opening dynamic library {}: {}",
98 SPDLOG_LOGGER_ERROR(this->
mSLog,
"error reading symbol from library {}: {}",
104 SPDLOG_LOGGER_ERROR(this->
mSLog,
"error getting plugin class");
111 .values = hMat[0].valuePtr(),
112 .rowIndex = hMat[0].outerIndexPtr(),
113 .colIndex = hMat[0].innerIndexPtr(),
118 if (
mPlugin->init(&matrix) != 0) {
119 SPDLOG_LOGGER_ERROR(this->
mSLog,
"error initializing plugin");
128 for (
auto task : comp->mnaTasks()) {
132 for (
auto node : this->
mNodes) {
133 for (
auto task : node->mnaTasks())
138 for (
auto task : comp->getTasks()) {
147template <
typename VarType>
161 (
double *)this->leftSideVector().data());
spdlog::level::level_enum Level
std::shared_ptr< spdlog::logger > Log
static Log get(const std::string &name, Level filelevel=Level::info, Level clilevel=Level::off)
SparseMatrix mVariableSystemMatrix
System matrix including stamp of static and variable elements.
SparseMatrix mBaseSystemMatrix
System matrix including all static elements.
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.
MnaSolverDirect(String name, CPS::Domain domain=CPS::Domain::DP, CPS::Logger::Level logLevel=CPS::Logger::Level::info)
Matrix mRightSideVector
Source vector of known quantities.
virtual void initialize() override
Calls subroutines to set up everything that is required before simulation.
CPS::MNAInterface::List mMNAIntfVariableComps
List of variable components if they must be accessed as MNAInterface objects.
UInt mNumNetNodes
Number of network nodes, single line equivalent.
CPS::MNAInterface::List mMNAIntfSwitches
List of switches if they must be accessed as MNAInterface objects.
std::vector< const Matrix * > mRightVectorStamps
List of all right side vector contributions.
void updateSwitchStatus()
Collects the status of switches to select correct system matrix.
Int mNumRecomputations
Number of system matrix recomputations.
CPS::MNAInterface::List mMNAComponents
List of MNA components with static stamp into system matrix.
CPS::Attribute< Matrix >::Ptr mLeftSideVector
Solution vector of unknown quantities.
CPS::SimSignalComp::List mSimSignalComps
List of signal type components that do not directly interact with the MNA solver.
CPS::SimNode< VarType >::List mNodes
List of simulation nodes.
CPS::Task::List getTasks() override
Get tasks for scheduler.
CPS::Logger::Log mSLog
Logger.
struct dpsim_mna_plugin * mPlugin
void solve(Real time, Int timeStepCount) override
Solves system for single frequency.
MnaSolverPlugin(String pluginName, String name, CPS::Domain domain=CPS::Domain::DP, CPS::Logger::Level logLevel=CPS::Logger::Level::info)
void recomputeSystemMatrix(Real time) override
Recomputes systems matrix.
virtual ~MnaSolverPlugin()
void initialize() override
Initialize cuSparse-library.
Bool mSystemMatrixRecomputationEnabled
Effective system-matrix recomputation setting used by the solver.
Bool mIsInInitialization
Determines if solver is in initialization phase, which requires different behavior.
struct dpsim_mna_plugin * get_mna_plugin(const char *name)
void pluginLogger(const char *str)