EMT_Ph3_Transformer.h 4.16 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

				// #### General ####
				/// Defines component parameters
				void setParameters(Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance);
				/// Initializes component from power flow data
Markus Mirz's avatar
Markus Mirz committed
52
				void initializeFromNodesAndTerminals(Real frequency);
Markus Mirz's avatar
Markus Mirz committed
53
54
55
56
57
58
59
60
61
62
63
64

				// #### 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);
65
66
67
68
69
70
71
72
				/// MNA pre step operations
				void mnaPreStep(Real time, Int timeStepCount);
				/// MNA post step operations
				void mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
				/// Add MNA pre step dependencies
				void mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes);
				/// Add MNA post step dependencies
				void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
Markus Mirz's avatar
Markus Mirz committed
73
74
75
76
77

				class MnaPreStep : public Task {
				public:
					MnaPreStep(Transformer& transformer) :
						Task(transformer.mName + ".MnaPreStep"), mTransformer(transformer) {
78
							mTransformer.mnaAddPreStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes);
Markus Mirz's avatar
Markus Mirz committed
79
					}
80
					void execute(Real time, Int timeStepCount) { mTransformer.mnaPreStep(time, timeStepCount); };
Markus Mirz's avatar
Markus Mirz committed
81
82
83
84
85
86
87
88
89
				private:
					Transformer& mTransformer;
				};


				class MnaPostStep : public Task {
				public:
					MnaPostStep(Transformer& transformer, Attribute<Matrix>::Ptr leftVector) :
						Task(transformer.mName + ".MnaPostStep"), mTransformer(transformer), mLeftVector(leftVector) {
90
							mTransformer.mnaAddPostStepDependencies(mPrevStepDependencies, mAttributeDependencies, mModifiedAttributes, mLeftVector);
Markus Mirz's avatar
Markus Mirz committed
91
					}
92
					void execute(Real time, Int timeStepCount) { mTransformer.mnaPostStep(time, timeStepCount, mLeftVector); };
Markus Mirz's avatar
Markus Mirz committed
93
94
95
96
97
98
99
100
101

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