LinearResistorEMT.cpp 778 Bytes
Newer Older
1
2
3
4
#include "LinearResistorEMT.h"

using namespace DPsim;

5
6
LinearResistorEMT::LinearResistorEMT(std::string name, int src, int dest, Real resistance) : BaseComponent(name, src, dest) {
	this->mResistance = resistance;
7
	attrMap["resistance"] = {AttrReal, &this->mResistance};
8
9
}

10
void LinearResistorEMT::applySystemMatrixStamp(SystemModel& system) {
11
	this->mConductance = 1.0 / mResistance;
12
13
	// Set diagonal entries
	if (mNode1 >= 0) {
14
		system.addRealToSystemMatrix(mNode1, mNode1, mConductance);
15
16
	}
	if (mNode2 >= 0) {
17
		system.addRealToSystemMatrix(mNode2, mNode2, mConductance);
18
19
20
	}
	// Set off diagonal entries
	if (mNode1 >= 0 && mNode2 >= 0) {
21
22
		system.addRealToSystemMatrix(mNode1, mNode2, -mConductance);
		system.addRealToSystemMatrix(mNode2, mNode1, -mConductance);
23
24
25
26
	}
}