DPsim
Loading...
Searching...
No Matches
MNASolverPlugin.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
13
14namespace DPsim {
15
16template <typename VarType>
17class MnaSolverPlugin : public MnaSolverDirect<VarType> {
18protected:
19 using Solver::mSLog;
22 void *mDlHandle;
23
25 void initialize() override;
26 void recomputeSystemMatrix(Real time) override;
27 void solve(Real time, Int timeStepCount) override;
28
29public:
30 MnaSolverPlugin(String pluginName, String name,
32 CPS::Logger::Level logLevel = CPS::Logger::Level::info);
33
34 virtual ~MnaSolverPlugin();
35
36 CPS::Task::List getTasks() override;
37
38 class SolveTask : public CPS::Task {
39 public:
41 : Task(solver.mName + ".Solve"), mSolver(solver) {
42
43 for (auto it : solver.mMNAComponents) {
44 if (it->getRightVector()->get().size() != 0)
45 mAttributeDependencies.push_back(it->getRightVector());
46 }
47 for (auto node : solver.mNodes) {
48 mModifiedAttributes.push_back(node->mVoltage);
49 }
50 mModifiedAttributes.push_back(solver.mLeftSideVector);
51 }
52
53 void execute(Real time, Int timeStepCount) {
54 mSolver.solve(time, timeStepCount);
55 }
56
57 private:
59 };
60
61 class LogTask : public CPS::Task {
62 public:
64 : Task(solver.mName + ".Log"), mSolver(solver) {
67 }
68
69 void execute(Real time, Int timeStepCount) {
70 mSolver.log(time, timeStepCount);
71 }
72
73 private:
75 };
76};
77
78} // namespace DPsim
spdlog::level::level_enum Level
Definition Logger.h:33
Tasks to be defined by every component.
Definition Task.h:25
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:53
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:52
Task()
Definition Task.h:30
std::vector< Ptr > List
Definition Task.h:28
std::string mName
Definition Task.h:51
MnaSolverDirect(String name, CPS::Domain domain=CPS::Domain::DP, CPS::Logger::Level logLevel=CPS::Logger::Level::info)
CPS::MNAInterface::List mMNAComponents
List of MNA components with static stamp into system matrix.
Definition MNASolver.h:70
CPS::Attribute< Matrix >::Ptr mLeftSideVector
Solution vector of unknown quantities.
Definition MNASolver.h:210
CPS::SimNode< VarType >::List mNodes
List of simulation nodes.
Definition MNASolver.h:66
LogTask(MnaSolverPlugin< VarType > &solver)
void execute(Real time, Int timeStepCount)
void execute(Real time, Int timeStepCount)
SolveTask(MnaSolverPlugin< VarType > &solver)
CPS::Task::List getTasks() override
Get tasks for scheduler.
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.
void initialize() override
Initialize cuSparse-library.
static CPS::AttributeBase::Ptr external
Definition Scheduler.h:63
CPS::Logger::Log mSLog
Logger.
Definition Solver.h:55
CPS::Real Real
Definition Definitions.h:18
CPS::String String
Definition Definitions.h:20
CPS::Int Int
Definition Definitions.h:22