-
Notifications
You must be signed in to change notification settings - Fork 2
/
Qij_calc.m
80 lines (68 loc) · 2.49 KB
/
Qij_calc.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
function [fval] = Qij_Calc (n)
%%%% - make sure that the Normx value is that which corresponds to the n
%%%% ply value and nothing else
%clc
%n=5;
for Low=1:n; %Lower bound that is dependent on the number of plys issued by GA in Composite_Optimization script
LowB(1,Low)=-90;%min ply angle is -90 degrees
end
for High=1:n; %upper bound that is dependent on the number of plys issued by GA in Composite_Optimization script
UpB(1,High)=90;%max ply angle is 90 deg
end
LB=LowB;
UB=UpB;
%%
options=gaoptimset('PopulationSize',30,'Generations',20);
[x,fval,population,scores] = ga(@Objectivefcn,n,[],[],[],[],LB,UB,[],options);
function [fval] = Objectivefcn(x)
x=-x*100;
% for j=1:n
% if x(j)>90
% x(j)=90
% else if x(j)>=67.5
% x(j)=90;
% else if x(j)>=22.5
% x(j)=45;
% else if x(j)< 22.5
% x(j)=0;
% else if x(j)<=-22.5
% x(j)=-45;
% else if x(j)<=-67.5
% x(j)=-90;
% else x(j)<-90
% x(j)=-90;
% end
% end
% end
% end
% end
% end
% end
NormF = Force(x,n);
%pause(1)
NormX = NormF(1);
%pause(1)
NormY = NormF(2);
%pause(1)
Shear = NormF(3);
%pause(1)
fval=-1*(NormX+NormY+Shear);
%clc;
NormFo = [NormF(1);NormF(2);NormF(3)];
Momn = [NormF(4);NormF(5);NormF(6)];
fid = fopen('D:\Users\Jeff\Documents\School Documents\Graduate - Mechanical\Composites\Project\Optimization Code\Orientation.txt', 'w');
fprintf(fid,'\n%d\n',x);
fclose(fid);
fid = fopen('D:\Users\Jeff\Documents\School Documents\Graduate - Mechanical\Composites\Project\Optimization Code\Maximized_Force.txt', 'w');
fprintf(fid,'\n%s\n',NormFo);
fclose(fid);
fid = fopen('D:\Users\Jeff\Documents\School Documents\Graduate - Mechanical\Composites\Project\Optimization Code\Maximized_Moments.txt', 'w');
fprintf(fid,'\n%s\n',Momn);
fclose(fid);
clc;
end
x;
fval;
population;
scores;
end