Force = [0 0 0 0 0 0 0 0 0 0 -1000 0 0 -1000 0 0 -1000 0 0-1000 0 0 0 0 0 0 0 0 0 0]';
alphaA = [pi/2 pi/2 0 0 0 0 0 0 -pi/2];
alphaB = [pi/2 0 0 0 0 0 0 -pi/2 -pi/2];
dX = [240 240 240 240 240 240 240 240 240];
dY = [0 -240 0 0 0 0 0 -240 0];
syms L x A E G Ay Iz real
fuq_straight = [1/(A*E) 0 0;
fux_straight = HxB_T*fuq_straight*HxB;
fBA_straight = int(fux_straight, x, 0, L);
kB_straight = eval(inv(fBA_straight));
syms L1 x A1 E G Ay1 Iz1 real
fuq_column = [1/(A1*E) 0 0;
fux_column = HxB_Tc*fuq_column*HxBc;
fBA_column = int(fux_column, x, 0, L1);
kB_column = eval(inv(fBA_column));
syms alpha theta r E G A Ay Iz real
lambda_QB = lambda_QB_T';
fux = TQB_T * fuq * TQB.*r;
fBA_curved = int(fux, alpha, 0, theta);
kB_curved = eval(inv(fBA_curved));
KKG = zeros(nnodes*ndofn,nnodes*ndofn);
KG = zeros(2*ndofn,2*ndofn);
TAB = [ cos(angle) sin(angle) 0;
-r*(1-cos(angle)) r*sin(angle) 1];
disp(['element= ',num2str(ii)])
KG(1:3,1:3) = lA*HAB*kB_straight*HAB'*lA';
KG(4:6,1:3) = -lB*kB_straight*HAB'*lA';
KG(1:3,4:6) = -lA*HAB*kB_straight*lB';
KG(4:6,4:6) = lB*kB_straight*lB';
KG(1:3,1:3) = lA*HAB*kB_column*HAB'*lA';
KG(4:6,1:3) = -lB*kB_column*HAB'*lA';
KG(1:3,4:6) = -lA*HAB*kB_column*lB';
KG(4:6,4:6) = lB*kB_column*lB';
KG(1:3,1:3) = lA*TAB*kB_curved*TAB'*lA';
KG(4:6,1:3) = -lB*kB_curved*TAB'*lA';
KG(1:3,4:6) = -lA*TAB*kB_curved*lB';
KG(4:6,4:6) = lB*kB_curved*lB';
AA = node1*3-2 : node1*3;
BB = node2*3-2 : node2*3;
KKG(AA,AA) = KKG(AA,AA) + KG(1:3,1:3);
KKG(BB,AA) = KKG(BB,AA) + KG(4:6,1:3);
KKG(AA,BB) = KKG(AA,BB) + KG(1:3,4:6);
KKG(BB,BB) = KKG(BB,BB) + KG(4:6,4:6);
Force([1:3,28:30],:) = [];
KK = KKG([1,3:6,10:12,16:19,21],[1,3:6,10:12,16:19,21]);
ux = displ([4,7,10,13,16,19,22,25]);
uy = displ([11,14,17,20]);
phi = displ([6,9,12,15,18,21,24]);
disp([' Node ' ' ux [in] ' 'uy [in] ' 'phi [rad]'])
disp([[2;4;6;7] , ux , [0;uy;0] , phi])
displALL_x = [ux(1),ux(2),0,ux(3),0,ux(4),ux(5)];
displALL_y = [0,uy(1),0,uy(2),0,uy(3),0];
n_coord = [000 120 120 195 270 270 390;...
035 075 000 085 000 075 035].*12;
figure(1), plot(xcoord,ycoord,'ks')
plot(xcoord + scale.*displALL_x , ycoord + scale.*displALL_y,'ro')
legend('undeformed nodes','deformed nodes')