CurrentSource.cpp 710 Bytes
Newer Older
Markus Mirz's avatar
Markus Mirz committed
1
2
#include "CurrentSource.h"

3
4
using namespace DPsim;

5
6
7
CurrentSource::CurrentSource(std::string name, int src, int dest, Complex current) : BaseComponent(name, src, dest) {
	this->mCurrent = current;
	attrMap["current"] = {AttrComplex, &this->mCurrent};
Markus Mirz's avatar
Markus Mirz committed
8
9
};
	
10
void CurrentSource::applyRightSideVectorStamp(SystemModel& system) {
Georg Martin Reinke's avatar
Georg Martin Reinke committed
11
	if (mNode1 >= 0) {
12
		system.addCompToRightSideVector(mNode1, mCurrent.real(), mCurrent.imag());
Markus Mirz's avatar
Markus Mirz committed
13
	}
Georg Martin Reinke's avatar
Georg Martin Reinke committed
14
	if (mNode2 >= 0) {
15
		system.addCompToRightSideVector(mNode2, -mCurrent.real(), mCurrent.imag());
Markus Mirz's avatar
Markus Mirz committed
16
	}
Georg Martin Reinke's avatar
Georg Martin Reinke committed
17
18
19
20
21
}

void CurrentSource::step(SystemModel& system, Real time) {
	this->applyRightSideVectorStamp(system);
}
22
23

Complex CurrentSource::getCurrent(SystemModel &system) {
24
	return mCurrent;
25
}