forked from Anton788/New_Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mags_and_coils.h
247 lines (191 loc) · 6.03 KB
/
Mags_and_coils.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#pragma once
#include <cstdio>
#include <iostream>
#include <math.h>
#include <vecters.h>
#include <Gas.h>
#include <vector>
using namespace std;
#define π 3.14159265358979323846
#define μ (1.25663706 / 1000000 )
typedef struct Field_cell
{
vecter Mag_vec;
} Field_cell;
class Field_2D {
public:
void *magnit;
vector<vector<Field_cell>> cells;
int size_x, size_y;
double mult;
Field_2D() {};
Field_2D(size_t size_x, size_t size_y):
size_x(size_x),
size_y(size_y),
cells(size_x, vector<Field_cell>(size_y))
{}
void show_field(int cherez_n);
double Flow_X_flat(double distance, int diametr);
};
class Electromagnet {
public:
double diametr;
double radius;
double height;
double diametr_SI;
double height_SI;
double convert_to_SI;
vecter position;
vecter position_SI;
vecter force_on;
//vecter direction;
//vecter speed;
Field_2D Mag_field;
Electromagnet();
Electromagnet(int destiny_of_mag_pixels, double _diametr,
double _height, vecter _position);
void show_field(int cherez_n);
};
class Magnet : public Electromagnet {
double strength;
public:
int sight;
double weight;
vecter speed_SI;
vecter speed;
vecter accel;
Gas* left;
Gas* right;
Magnet();
Magnet(int destiny_of_mag_pixels, double _strength, double _diametr, double _weight,
double _height, vecter _position, vecter _speed, int _sight);
void relocate(double dtime);
void Set_Field2D_Conf(int prec_H, int prec_R, int _size_x, int _size_y);
vecter Mag_Mag_Force(Magnet mag, int H_prec);
};
class Coil : public Electromagnet {
double flow[2];
int turns;
public:
double current;
double voltage;
double resist;
Coil();
Coil(int destiny_of_mag_pixels, double _current, double _diametr,
double _height, vecter _position, int _turns);
void Set_Field2D_Conf(int prec_R, int _size_x, int _size_y); /* USE FIELD MULTIPLYIER (CURRENT) TO CALCULATE REAL FIELD*/ /*FOR NORMAL PRECISION MANY TURNS NEEDED*/
double flow_X_from_mag(Electromagnet& magnit);
double set_voltage(double dtime);
vecter Force_from_coil(Magnet mag);
};
class Coil_System {
int coil_num;
vector<Coil*> coils;
vector<vector<double>> inductive_coupling;
Coil_System();
Coil_System(int num_of_coils, Coil coil1, ...);
int set_coupling(); // returns 1 if coupling calculated correctly, else 0
void update(double dtime);
};
double Flow_X_flat(Electromagnet mag, double distance, int diametr);
double Flow_X_flat(Field_2D field, double distance, int diametr);
//struct Coil {
// double diametr, radius, height, flow[2], current, voltage, resist;
// double diametr_SI, height_SI, convert_to_SI;
// vecter position, position_SI, force_on;
// Field_2D Mag_field;
// int turns;
// vecter direction;
// Coil();
// Coil(int destiny_of_mag_pixels, double _current, double _diametr,
// double _height, vecter _position, int _turns);
// double flow_X_from_mag(Magnet& magnit);
// vecter Force_from_coil(Magnet mag);
//};
//struct Magnet
//{
// double strength, diametr, radius, weight, height;
// double diametr_SI, height_SI, convert_to_SI;
//
// vecter position, position_SI, speed, speed_SI, accel, force_on;
// Field_2D Mag_field;
// vecter direction;
// Gas* left;
// Gas* right;
// int sight;
// void relocate(double dtime);
// Magnet();
// /*Magnet(int destiny_of_mag_pixels)
// {
// convert_to_SI = destiny_of_mag_pixels;
// position.x_proj = position.y_proj = position.z_proj = speed.x_proj =
// speed.y_proj = speed.z_proj = weight =
// direction.x_proj = direction.y_proj = direction.z_proj =
// force_on.x_proj = force_on.x_proj = force_on.x_proj =
// accel.x_proj = accel.y_proj = accel.y_proj = 0;
// cout << "Height: ";
// cin >> height_SI;
// height = height_SI*convert_to_SI;
// cout << "Diametr: ";
// cin >> diametr_SI;
// diametr = diametr_SI*convert_to_SI;
// cout << "Magnet strength: ";
// cin >> strength;
// strength = strength / convert_to_SI / 4 / π;
// cout << "Sight to X axis(1 or -1): ";
// cin >> sight;
// Mag_field.magnit = this;
// radius=diametr/2;
// }*/
// Magnet(int destiny_of_mag_pixels, double _strength, double _diametr, double _weight,
// double _height, vecter _position, vecter _speed, int _sight);
// void show_field(int cherez_n);
// /*void Set_Field2D_Conf()
// {
// int x, y, z, h, angle, prec_H, prec_R;
// double len;
// cout << "Height precision:";
// cin >> prec_H;
// cout << "Radial precision:";
// cin >> prec_R;
// cout << "X size of field: ";
// cin >> Mag_field.size_x;
// cout << "Y size of field: ";
// cin >> Mag_field.size_y;
// Mag_field.magnit = this;
// Mag_field.mult = 1;
// Mag_field.cells = (Field_cell**)malloc((Mag_field.size_x ) * sizeof(Field_cell*));
// for (int i = 0; i < (Mag_field.size_x ); i++)
// {
// Mag_field.cells[i] = (Field_cell*)malloc((Mag_field.size_y ) * sizeof(Field_cell));
// }
// vecter radius, tmp, koltso, cur;
// koltso.set(0, diametr / 2, 0);
// cur.set(0, 0, (strength / prec_H * height) * (π * diametr / prec_R));
// for (x = 0; x < Mag_field.size_x; x++)
// {
// for (y = 0; y < Mag_field.size_y; y++)
// {
// tmp.set(x, y, 0);
// Mag_field.cells[x][y].Mag_vec.set(0, 0, 0);
// for (h = -prec_H / 2; h < prec_H / 2; h++)
// {
// koltso.x_proj = h * height / prec_H;
// for (angle = 0; angle < prec_R; angle++)
// {
// radius = tmp - Vec_Rotate_X(koltso, π * 2 / prec_R * angle);
// len = radius.len();
// Mag_field.cells[x][y].Mag_vec += ((radius * Vec_Rotate_X(cur, π * 2 / prec_R * angle))* (1 / len / len / len));
// }
// }
// Mag_field.cells[x][y].Mag_vec = Mag_field.cells[x][y].Mag_vec*sight*μ*convert_to_SI;
// Mag_field.cells[x][y].Mag_vec.z_proj = 0;
// }
// }
// cout << "Field configuration is installed " << endl;
//
// }*/
// void Set_Field2D_Conf(int prec_H, int prec_R, int _size_x, int _size_y);
// vecter Mag_Mag_Force(Magnet mag, int H_prec);
//
//};