Commit 044d46f3 authored by Markus Mirz's avatar Markus Mirz
Browse files

introducing new MNA solver class

parent e1adfcc0
......@@ -22,13 +22,14 @@
#include <iostream>
#include <list>
#include "DPsim.h"
#include "DPsim_MNA.h"
using namespace DPsim;
static int testCIMReader(std::list<String> filenames) {
Simulation sim("CIM", filenames, 50, 0.0001, 0.1, Logger::Level::DEBUG, SimulationType::DP);
MnaSimulation sim("CIM", filenames, 50, 0.0001, 0.1, SimulationType::DP, Logger::Level::DEBUG);
sim.run();
return 0;
}
......
......@@ -19,27 +19,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "DPsim.h"
#include "DPsim_MNA.h"
using namespace DPsim;
using namespace DPsim::Components::DP;
int main(int argc, char* argv[])
{
int main(int argc, char* argv[]) {
// Define simulation scenario
Real timeStep = 0.001;
Real omega = 2.0*M_PI*50.0;
Real finalTime = 0.3;
Real timeStep = 0.00001;
Real frequency = 50;
Real finalTime = 0.1;
String simName = "DP_IdealVS_RxLine1_" + std::to_string(timeStep);
Component::List comps = {
VoltageSource::make("v_1", 0, GND, Complex(10, 0)),
RxLine::make("Line_1", 0, 1, 0.1, 0.001),
Resistor::make("r_1", 1, GND, 20)
VoltageSource::make("v_1", GND, 0, Complex(100, 0), Logger::Level::DEBUG),
//RxLine::make("Line_1", 0, 1, 0.1, 0.001, Logger::Level::DEBUG),
Inductor::make("l_1", 0, 1, 0.001, Logger::Level::DEBUG),
Resistor::make("r_1", 1, GND, 1, Logger::Level::DEBUG)
};
Simulation sim(simName, comps, omega, timeStep, finalTime);
MnaSimulation sim(simName, comps, frequency, timeStep, finalTime, SimulationType::DP, Logger::Level::INFO);
sim.run();
return 0;
......
......@@ -2,7 +2,7 @@ add_library(dpsim
SystemModel.cpp
Utilities.cpp
Simulation.cpp
MNA_Simulation.cpp
MNA_Solver.cpp
FaultSimulation.cpp
SynGenSimulation.cpp
CPowerSystems/Source/Logger.cpp
......
#include "Simulation.h"
#include "CPowerSystems/Source/Components.h"
#include "CPowerSystems/Source/Logger.h"
#include "RealTimeSimulation.h"
#ifdef WITH_SHMEM
#include "CPowerSystems/Source/Interfaces/ShmemInterface.h"
#endif
\ No newline at end of file
#endif
#include "MNA_Solver.h"
#include "CPowerSystems/Source/Components.h"
#include "CPowerSystems/Source/Logger.h"
#ifdef WITH_SHMEM
#include "CPowerSystems/Source/Interfaces/ShmemInterface.h"
#endif
......@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "MNA_Simulation.h"
#include "MNA_Solver.h"
#include "CPowerSystems/Source/CIM/Reader.h"
using namespace DPsim;
......@@ -119,11 +119,11 @@ void MnaSimulation::initialize(Component::List newComponents) {
if (comp->getNode2() > maxNode)
maxNode = comp->getNode2();
}
if (mNodes[mSystemIndex].size() == 0) {
if (mNodes.size() == 0) {
// Create Nodes for all node indices
mNodes.push_back(Node::List(maxNode + 1, nullptr));
for (int node = 0; node < mNodes.size(); node++)
for (int node = 0; node <= mNodes.size(); node++)
mNodes[mSystemIndex][node] = std::make_shared<Node>(node);
for (auto comp : mComponents[mSystemIndex]) {
......@@ -197,6 +197,7 @@ void MnaSimulation::createEmptySystemMatrix() {
void MnaSimulation::addSystemTopology(Component::List newComponents) {
mComponents.push_back(newComponents);
mNodes.push_back(Node::List(mNumNodes, nullptr));
// It is assumed that the system size does not change
createEmptySystemMatrix();
......
......@@ -123,7 +123,7 @@ namespace DPsim {
public:
/// Creates system matrix according to
MnaSimulation(String name,
Component::List comps, Real om, Real dt, Real tf, SimulationType simType = SimulationType::DP,
Component::List comps, Real frequency, Real timeStep, Real finalTime, SimulationType simType = SimulationType::DP,
Logger::Level logLevel = Logger::Level::INFO, Int downSampleRate = 1);
/// Creates system matrix according to
MnaSimulation(String name,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment