-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRotMagWidthOptim.m
172 lines (120 loc) · 3.07 KB
/
RotMagWidthOptim.m
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
%==========================================
% Title: Parameteroptimierung elektrischer Maschinen mit Genetischen Algorithmen
% Author: Omar Askour
% Date: WS20/21
%=========================================
%----- Prameter outside the for loop helps to get all graphs in one diagram
n=20;
s=0.5;
torq=[];
theta=[];
widtdAng=[];
Mtorq= [];
ripple= [];
x2=31.30;
x1=31.35;
vol=[];
%-------------------------
for i=1:s:n
fname = sprintf('MagWidth%2.1f.fem', 44-i);
openfemm
opendocument(fname);
mi_saveas('test.fem');
%----- Prameter inside the for loop helps to get every single graph separately
%
% torq=[];
% theta=[];
% widtdAng=[];
% Mtorq= [];
% % ripple= [];
% x2=31.30;
% x1=31.35;
%-----------------------
mi_selectsegment(0,31.326);
mi_selectsegment(31.326,0);
mi_deleteselected;
iphase=5;
tic
for k=0:30
theta_akt = k;
theta_pre = k-1;
phi_q = 0;
x_akt=x2*cosd(theta_akt);
y_akt=x2*sind(theta_akt);
x_pre=x2*cosd(theta_pre);
y_pre=x2*sind(theta_pre);
mi_modifycircprop('A',1,iphase*cosd(4*(theta_akt+phi_q)));
mi_modifycircprop('B',1,iphase*cosd(4*(theta_akt-120)+phi_q));
mi_modifycircprop('C',1,iphase*cosd(4*(theta_akt-240)+phi_q));
mi_selectgroup(1);
mi_moverotate(0,0,theta_akt);
%%--- x(-)y(+)
mi_addarc(0,x1,-y_akt,x_akt,theta_akt,1);
mi_addarc(x1,0,x_akt,y_akt,theta_akt,1);
mi_selectarcsegment(-y_akt,x_akt);
mi_selectarcsegment(x_akt,y_akt);
mi_setarcsegmentprop(1, 'arcgap', 0, 1);
mi_clearselected();
mi_analyze();
mi_loadsolution;
mo_groupselectblock(1);
torq=[torq , mo_blockintegral(22)];
theta=[theta,theta_akt];
mi_selectarcsegment(x_pre,y_pre);
mi_selectarcsegment(-y_pre,x_pre);
mi_deleteselectedarcsegments;
mi_selectgroup(1);
mi_moverotate(0,0,-theta_akt);
end
% %--- get single graph
% figure
% %
% plot(theta,torq);
% % hold off
% xlabel('angle, °');
% % xlim([5 27])
% ylabel('Torque');
% title(sprintf('torque depends to Angle (Magnet width= %2.2f)', 35-i));
%savefig(sprintf('Magwisth_rotation%2.2f.fem', i));
widtdAng=[widtdAng,44-i];
vol=[vol,mo_blockintegral(10)];
Mtorq=[Mtorq, mean(torq)];
ripple= (max(torq)- min(torq))/ 2*Mtorq;
mi_addsegment(0,x2,0,x1);
mi_addsegment(x2,0,x1,0);
end
toc
disp(sprintf(' mean torque= %d ',Mtorq));
disp(sprintf(' ripple = %d ',ripple));
figure
plot(theta,torq,'w');
xlabel('angle, °');
xlim([1 30])
ylabel('Torque');
title('torque depends to Angle (global)');
figure
plot(theta,torq,'r');
xlabel('angle, °');
xlim([1 30])
ylabel('Torque');
title('torque depends to Angle (global)');
%
figure
plot(widtdAng,Mtorq);
xlabel('Magnet Breite (Kreissegment)[°]');
% xlim([5 27])
ylabel('mittlere Drehmoment [N.m]');
title('mittlere Drehmoment abhängig von Magnet Breite ');
%
figure
% axis auto
plot(widtdAng,vol)
xlabel('Magnet width');
%xlim([5 27])
ylabel('volume');
title('volume depends on Magnet width');
% plot(widtdAng,ripple);
% xlabel('Magnet thickness');
% % xlim([5 27])
% ylabel('ripple');
% title('ripple depends on Magnet width');