-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbase_class_improved.hpp
More file actions
84 lines (62 loc) · 2.06 KB
/
base_class_improved.hpp
File metadata and controls
84 lines (62 loc) · 2.06 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
#ifndef base_class_hpp
#define base_class_hpp
#include <vector>
#include <string>
#include <cmath>
using namespace std;
class node;
//Base class just for inherited functionality so everything can use the same methods when iterating through arrays of components
class base_class
{
protected:
node* node1; //Used to tell which nodes this component is connected to
node* node2;
int name;
double value;
double prev_cv = 0; //Used for transient sims to store the previous voltage/current value
double tot_acc = 0;
char type;
public:
//Returns the nodes the component is connected to in a vector form
virtual vector<node*> return_nodes(){
vector<node*> temp{node1, node2};
return temp;
}
//Returns type of component
virtual char return_type(){
return type;
}
//Returns name of the current component
virtual int return_name(){
return name;
}
//Sets the previous value of current/voltage
virtual void set_prev_cv(double cv){
prev_cv = cv;
}
//Returns the previous value of current/voltage
virtual double return_prev_cv(){
return prev_cv;
}
//Returns current/voltage/resistance depending on subclass (Will be overwritten in the appropriate subclasses)
virtual double return_value(double t, bool final_loop_checker){
return 1;
}
virtual double return_tot_acc(){
return tot_acc;
}
virtual void set_tot_acc(double acc){
tot_acc = acc;
}
//Used for nonlinear components and will be overwritten. Function is here to allow access to them in the base_class vector
virtual base_class* return_Req(){
return this;
}
virtual base_class* return_Ieq(){
return this;
}
virtual base_class* return_Rl(){
return this;
}
};
#endif