CapacitorDP.h 2.69 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
/** Capacitor
 *
 * @file
 * @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/>.
 *********************************************************************************/

24
#pragma once
Markus Mirz's avatar
Markus Mirz committed
25
26
27

#include <iostream>

28
#include "BaseComponent.h"
Markus Mirz's avatar
Markus Mirz committed
29

30

Markus Mirz's avatar
merge    
Markus Mirz committed
31
namespace DPsim {
Steffen Vogel's avatar
Steffen Vogel committed
32

33
34
35
36
	/// Capacitor model:
	/// The capacitor is represented by a DC equivalent circuit which corresponds to one iteration of the trapezoidal integration method.
	/// The equivalent DC circuit is a resistance in paralel with a current source. The resistance is constant for a defined time step and system
	///frequency and the current source changes for each iteration.
37
	class Capacitor : public BaseComponent {
Markus Mirz's avatar
Markus Mirz committed
38
	protected:
39
		/// Capacitance [F]
40
		Real capacitance;
Markus Mirz's avatar
Markus Mirz committed
41
		/// Real part of the voltage across the capacitor [V]
42
		Real deltavr;
Markus Mirz's avatar
Markus Mirz committed
43
		/// Imaginary part of the voltage across the capacitor [V]
44
		Real deltavi;
45
		/// Real and imaginary part of the current through the capacitor [A]
46
47
		Real currr;
		Real curri;
Steffen Vogel's avatar
Steffen Vogel committed
48
		///Real and imaginary part of the DC equivalent current source [A]
49
50
		Real cureqr;
		Real cureqi;
Steffen Vogel's avatar
Steffen Vogel committed
51

52
53
		Real mGcr;
		Real mGci;
Markus Mirz's avatar
Markus Mirz committed
54
55
56
57


	public:
		Capacitor() { };
58
59

		/// define capacitor name, conected nodes and capacitance
60
		Capacitor(String name, Int src, Int dest, Real capacitance);
Markus Mirz's avatar
Markus Mirz committed
61

Markus Mirz's avatar
merge    
Markus Mirz committed
62
		/// initializes variables detalvr, deltavi, currr, curri, cureqr and curreqi
63
		void init(Real om, Real dt);
Steffen Vogel's avatar
Steffen Vogel committed
64

65
		/// Stamps DC equivalent resistance to the conductance matrix
66
		void applySystemMatrixStamp(SystemModel& system);
Steffen Vogel's avatar
Steffen Vogel committed
67

68
		/// Stamps DC equivalent current source to the current vector
69
		void applyRightSideVectorStamp(SystemModel& system) { }
Steffen Vogel's avatar
Steffen Vogel committed
70

71
		/// calculates the value of the current source for one time step and apply it to the current vector
72
		void step(SystemModel& system, Real time);
Steffen Vogel's avatar
Steffen Vogel committed
73

74
		/// Recalculates variables detalvr, deltavi, currr and curri based on the simulation results of one time step
75
		void postStep(SystemModel& system);
76
77
78

		/// Return current from the previous step
		Complex getCurrent(SystemModel& system);
Markus Mirz's avatar
Markus Mirz committed
79
	};
80
}