IdealTransformerDP.cpp 1.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** Ideal Transformer DP
*
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/

#include "IdealTransformerDP.h"

using namespace DPsim;

27
28
IdealTransformerDP::IdealTransformerDP(String name, Int node1, Int node2, Real ratioAbs, Real ratioPhase) : BaseComponent(name, node1, node2) {
	mNumVirtualNodes = 1;
29
30
	mVirtualNodes = { 0 };	
	mRatio = std::polar(ratioAbs, ratioPhase);
31
32
33
34
}

void IdealTransformerDP::applySystemMatrixStamp(SystemModel& system) {
	if (mNode1 >= 0) {
35
36
		system.setCompSystemMatrixElement(mNode1, mVirtualNodes[0], -1.0, 0);
		system.setCompSystemMatrixElement(mVirtualNodes[0], mNode1, 1.0, 0);
37
38
	}
	if (mNode2 >= 0) {
39
40
		system.setCompSystemMatrixElement(mNode2, mVirtualNodes[0], mRatio.real, mRatio.imag);
		system.setCompSystemMatrixElement(mVirtualNodes[0], mNode2, -mRatio.real, -mRatio.imag);
41
42
	}
}