IdealVoltageSource.h 1.58 KB
Newer Older
Viviane's avatar
Viviane committed
1
2
3
4
5
6
7
#ifndef IDEALVOLTAGESOURCE_H
#define IDEALVOLTAGESOURCE_H

#include "BaseComponent.h"

namespace DPsim {

Markus Mirz's avatar
merge    
Markus Mirz committed
8
9
10
11
12
	/// Ideal Voltage source model:
	/// This model uses modified nodal analysis to represent an ideal voltage source. 
	/// For a voltage source between nodes j and k, a new variable (current across the voltage source) is added to the left side vector
	/// as unkown and it is taken into account for the equation of node j as positve and for the equation of node k as negative. Moreover
	/// a new equation ej - ek = V is added to the problem.
Viviane's avatar
Viviane committed
13
	class IdealVoltageSource : public BaseComponent {
14

Viviane's avatar
Viviane committed
15
	protected:
16
17

		//  ### Ideal Voltage source parameters ###
18
19
		/// Complex voltage [V]
		Complex mVoltage;
20

Viviane's avatar
Viviane committed
21
22
23
24
25
26
		Real mVoltageAtSourcer;
		Real mVoltageAtSourcei;
		Real mVoltageAtDestr;
		Real mVoltageAtDesti;
		Real mCurrentr;
		Real mCurrenti;
Markus Mirz's avatar
merge    
Markus Mirz committed
27

28
		/// Number of voltage source (first, second...)
29
		int number;
Viviane's avatar
Viviane committed
30

31
	public:		
Viviane's avatar
Viviane committed
32
		IdealVoltageSource() { ; };
33
34

		/// define paramenters of the voltage source
35
		IdealVoltageSource(std::string name, int src, int dest, Complex voltage, int num);
Viviane's avatar
Viviane committed
36

37
		void init(Real om, Real dt) { }
Markus Mirz's avatar
merge    
Markus Mirz committed
38
		
39
		/// Inserts the current across the voltage source in the equations of node j and k and add the equantion ej - ek = V to the problem
40
		void applySystemMatrixStamp(SystemModel& system);
Markus Mirz's avatar
merge    
Markus Mirz committed
41
		
42
		/// Stamps voltage source to the current vector
43
		void applyRightSideVectorStamp(SystemModel& system);
Markus Mirz's avatar
merge    
Markus Mirz committed
44
		
45
		/// Stamps voltage source to the current vector
46
		void step(SystemModel& system, Real time);
Markus Mirz's avatar
merge    
Markus Mirz committed
47
		
48
		void postStep(SystemModel& system) { }
49

50
		virtual Complex getCurrent(SystemModel& system);
Viviane's avatar
Viviane committed
51
52
53
	};
}
#endif