assemble global stiffness matrix
144 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%Hello, I want to assemble global stiffness matrix of 3 element connected each other to get stiffness matrix of whole structure, but could not figure it out how to write a function. Can you please help me out.
%Igonoring shear deformation, the element stiffness matrix in local
%coordination for element 1
clc;
clear;
close;
%syms A;
%syms R;
syms E
syms I
syms R
syms phi real;
E = 1;
I_z = 1;
E_Iz = E*I_z;
L = R; %R
%A = 1;
A = 100000000000;
K1 = A*E/L;
K2 = 12*E*I_z/L^3;
K3= 6*E*I_z/L^2;
K4 = 4*E*I_z/L;
K5 = 2*E*I_z/L;
% for element 1
Ke_1_local = [K1 0 0 -K1 0 0;
0 K2 K3 0 -K2 K3;
0 K3 K4 0 -K3 K5;
-K1 0 0 K1 0 0;
0 -K2 -K3 0 K2 -K3;
0 K3 K5 0 -K3 K4 ];
% transformation matrix Gamma
Phi = 90;
gamma_1 = [cosd(Phi) sind(Phi) 0 0 0 0;
-sind(Phi) cosd(Phi) 0 0 0 0;
0 0 1 0 0 0 ;
0 0 0 cosd(Phi) sind(Phi) 0;
0 0 0 -sind(Phi) cosd(Phi) 0;
0 0 0 0 0 1];
%element stiffness matrix in global coordinate
Ke_1_global = gamma_1'.*Ke_1_local.*gamma_1;
%For arch
%Element 2
phi_1 = 0;
phi_2 = pi/2;
%equillibrium matrix
phi2 = [-1 0 0;
0 -1 0;
-R*(sin(phi_2)-sin(phi_1)) R*(cos(phi_1)-cos(phi_2)) -1];
%flexibility matrix
Q_b = @(phi) [-R*(sin(phi)-sin(phi_1)) R*(cos(phi_1)-cos(phi)) -1];
d2 = @(phi) (Q_b(phi)'.*Q_b(phi))./E_Iz;
d2_phi = d2(Phi);
d2_int = int(d2_phi, 1e-8, pi/2);
d_3 = vpa(d2_int);
%Siffness matrix
Kff_3 = inv(d_3);
Kfs_3 = inv(d_3)*phi2';
Ksf_3 = phi2*inv(d_3);
Kss_3 = phi2*inv(d_3)*phi2';
K_2_global = round([Kff_3 Kfs_3; Ksf_3 Kss_3], 2);
%Element3
phi_1 = pi/2;
phi_2 = 3*pi/4;
%equillibrium matrix
phi2 = [-1 0 0;
0 -1 0;
-R*(sin(phi_2)-sin(phi_1)) R*(cos(phi_1)-cos(phi_2)) -1];
%flexibility matrix
Q_b = @(phi) [-R*(sin(phi)-sin(phi_1)) R*(cos(phi_1)-cos(phi)) -1];
d3 = @(phi) (Q_b(phi)'.*Q_b(phi))./E_Iz;
d3_phi = d3(Phi);
d3_int = int(d3_phi, phi_1, phi_2);
d_3 = vpa(d3_int);
%Siffness matrix
Kff_3 = inv(d_3);
Kfs_3 = inv(d_3)*phi2';
Ksf_3 = phi2*inv(d_3);
Kss_3= phi2*inv(d_3)*phi2';
K_3_global = round([Kff_3 Kfs_3; Ksf_3 Kss_3], 2);
%assemble local stiffness matrix
connect = {[1 2], [2,3]; [3,4]};
nele = 3; %number of element
ndof = 3; %number of dof perelement
0 commentaires
Réponses (1)
Ayush
le 8 Sep 2023
Dear Milan,
I understand that your intent is to construct the global stiffness matrix for a structure comprising of three interconnected elements, aiming to obtain the stiffness matrix for the entire structure by implementing a function.
I attempted to execute the provided code on my system, but encountered an error that states:
```
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in MLAnswers6_w3 (line 80)
connect = {[1 2], [2,3]; [3,4]};
```
However, to assemble the global stiffness matrix for the structure with three interconnected elements, the following steps can be followed:
1. Initialize the global stiffness matrix, denoted as “K_global”, as a matrix of zeros with dimensions “(ndof*nele) x (ndof*nele)”.
2. For each element, compute its global stiffness matrix, denoted as “K_element_global”, by utilizing the transformation matrix gamma and the element stiffness matrix “Ke_local”.
3. Transpose the gamma matrix and multiply it with “Ke_local”.
4. Multiply the resulting matrix with “gamma”.
5. Assemble the local stiffness matrices into the global stiffness matrix.
6. For each element, determine the corresponding degrees of freedom (DOFs) in the global stiffness matrix.
7. Add the local stiffness matrix to the appropriate locations within the global stiffness matrix.
Example code to achieve the described steps:
function K_global = assembleGlobalStiffnessMatrix(nele, ndof, Ke_local, gamma)
K_global = zeros(ndof*nele);
for element = 1:nele
% Calculate the global stiffness matrix for the current element
Ke_element_global = gamma' * Ke_local * gamma;
% Identify the corresponding DOFs in the global stiffness matrix
dofs = (element-1)*ndof + 1 : element*ndof;
% Assemble the local stiffness matrix into the global stiffness matrix
K_global(dofs, dofs) = K_global(dofs, dofs) + Ke_element_global;
end
end
% Call the function to assemble the global stiffness matrix
K_global = assembleGlobalStiffnessMatrix(nele, ndof, Ke_1_local, gamma_1);
% Add the stiffness matrices of the remaining elements
K_global = K_global + K_2_global + K_3_global;
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!