EMT_Ph3_Transformer.h 3.83 KB
Newer Older
1
2
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
 *                     EONERC, RWTH Aachen University
Markus Mirz's avatar
Markus Mirz committed
3
 *
4
5
6
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
Markus Mirz's avatar
Markus Mirz committed
7
8
9
10
 *********************************************************************************/

#pragma once

11
#include <cps/SimPowerComp.h>
Markus Mirz's avatar
Markus Mirz committed
12
13
#include <cps/Solver/MNAInterface.h>
#include <cps/EMT/EMT_Ph3_Inductor.h>
14
#include <cps/EMT/EMT_Ph3_Resistor.h>
Markus Mirz's avatar
Markus Mirz committed
15
16
17
18
19
20
21
#include <cps/Base/Base_Ph3_Transformer.h>

namespace CPS {
	namespace EMT {
		namespace Ph3 {
			/// Transformer that includes an inductance and resistance
			class Transformer :
Markus Mirz's avatar
Markus Mirz committed
22
				public SimPowerComp<Real>,
Markus Mirz's avatar
Markus Mirz committed
23
24
25
26
27
28
29
30
31
				public MNAInterface,
				public SharedFactory<Transformer>,
				public Base::Ph3::Transformer {
			private:
				/// Internal inductor to model losses
				std::shared_ptr<EMT::Ph3::Inductor> mSubInductor;
				/// Internal parallel resistance as snubber
				std::shared_ptr<EMT::Ph3::Resistor> mSubSnubResistor;
				std::shared_ptr<EMT::Ph3::Resistor> mSubResistor;
32
33
34
35
36
37

				/// Snubber resistance added on the low voltage side
				Matrix mSnubberResistance;

				/// Boolean for considering resistive losses with sub resistor
				Bool mWithResistiveLosses;
Markus Mirz's avatar
Markus Mirz committed
38
39
40
			public:
				/// Defines UID, name and logging level
				Transformer(String uid, String name,
41
					Logger::Level logLevel = Logger::Level::off, Bool withResistiveLosses = false);
Markus Mirz's avatar
Markus Mirz committed
42
43
44
45
				/// Defines name and logging level
				Transformer(String name, Logger::Level logLevel = Logger::Level::off)
					: Transformer(name, name, logLevel) { }

Markus Mirz's avatar
Markus Mirz committed
46
				SimPowerComp<Real>::Ptr clone(String name);
Markus Mirz's avatar
Markus Mirz committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

				// #### General ####
				/// Defines component parameters
				void setParameters(Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance);
				/// Initializes component from power flow data
				void initializeFromPowerflow(Real frequency);

				// #### MNA section ####
				/// Initializes internal variables of the component
				void mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector);
				/// Stamps system matrix
				void mnaApplySystemMatrixStamp(Matrix& systemMatrix);
				/// Stamps right side (source) vector
				void mnaApplyRightSideVectorStamp(Matrix& rightVector);
				/// Updates internal current variable of the component
				void mnaUpdateCurrent(const Matrix& leftVector);
				/// Updates internal voltage variable of the component
				void mnaUpdateVoltage(const Matrix& leftVector);

				class MnaPreStep : public Task {
				public:
					MnaPreStep(Transformer& transformer) :
						Task(transformer.mName + ".MnaPreStep"), mTransformer(transformer) {
						mAttributeDependencies.push_back(transformer.mSubSnubResistor->attribute("right_vector"));
						mAttributeDependencies.push_back(transformer.mSubInductor->attribute("right_vector"));
						if (transformer.mSubResistor)
							mAttributeDependencies.push_back(transformer.mSubResistor->attribute("right_vector"));
						mModifiedAttributes.push_back(transformer.attribute("right_vector"));
					}

					void execute(Real time, Int timeStepCount);

				private:
					Transformer& mTransformer;
				};


				class MnaPostStep : public Task {
				public:
					MnaPostStep(Transformer& transformer, Attribute<Matrix>::Ptr leftVector) :
						Task(transformer.mName + ".MnaPostStep"), mTransformer(transformer), mLeftVector(leftVector) {
						mAttributeDependencies.push_back(transformer.mSubInductor->attribute("i_intf"));
						mAttributeDependencies.push_back(leftVector);
						mModifiedAttributes.push_back(transformer.attribute("i_intf"));
						mModifiedAttributes.push_back(transformer.attribute("v_intf"));
					}

					void execute(Real time, Int timeStepCount);

				private:
					Transformer& mTransformer;
					Attribute<Matrix>::Ptr mLeftVector;
				};
			};
		}
	}
}