请帮助这个5元素的代码有位移,应变和应力0

6视图(30天)
% ................................................................%为有限元分析MATLAB代码% ENGT5258:信托设计使用有限元方法%弗朗西斯·蒂埃里Fonkui De Montfort大学宽松外衣% 2016年12月
清晰;关闭所有;clc;% %设置输入参数桁架组装% x, y坐标的节点每个节点= (0.8 0;0 0;0 0.8;0.8 - 0.8,1.55 - 0.8);%注意,因为我们定义E = 1 = 1,我们将具有相同的应力、应变值%桁架构件材料的杨氏模量E = 210 * 10 ^ 9;%的横截面区域每个桁架成员= 0.1914;%第一个节点,第二个节点,E,每个元素的值元素= [1 2 E; 3 2 E; 3 4 E; 4 1 E; 4 2 E; 4 5 E; 5 1 E];%确定的节点数量nnode =长度(节点);%确定nelem的元素数量=(元素,1)大小; %% Initialise Stiffness, Displacement, Force, Strain and Stress Vectors % Initialise Stiffness matrix, i.e size of K_global = number of nodes X number of degrees of freedom K_global = zeros(2*nnode,2*nnode); % Initialise Displacements, i.e. u1, v1, u2, v2, u3, v3, u4, v4, u5, v5, % u6, v6, u7, v7, u8, v8, u9, v9, u10 and v10 U = zeros(2*nnode, 1); % Initialise Force vector, i.e. fx1, fy1, fx2, fy2, fx3, fy3, fx4, fy4, % fx5, fy5, fx6, fy6, fx7, fy7, fx8, fy8, fx9, fy9, fx10 and fy10 F = zeros(2*nnode, 1); % Initialise Elemental Strain vector, i.e. strain1 and strain2 strain = zeros(nelem,1); % Initialise Elemental Stress vector, i,e. stress1, stress2 stress= zeros(nelem,1); %% Apply Boundary Conditions % Define number of Degrees Of Freedom i.e. u1, v1, u2, v2, u3, v3, u4, v4, % u5, v5, u6, v6, u7, v7, u8, v8, u9, v9, u10, v10 active_DOF = 1:2*nnode; % Assign zero for known Displacments i.e Degrees Of Freedom, for example, u1=v1=u3=v3=0 active_DOF([5 6 7 8]) = []; % Apply known forces to force vector, i.e. fxy = -10 F(5) = -10; %% Compute elemental stiffness matrix and perform assembly for p = 1:nelem %Determine DOF for each element DOFs = [2*Elements(p, 1)-1, 2*Elements(p, 1), 2*Elements(p, 2)-1, 2*Elements(p, 2)]; % Assign x and y coordinate for each element X1 = Nodes(Elements(p,1), 1); Y1 = Nodes(Elements(p,1), 2); X2 = Nodes(Elements(p,2), 1); Y2 = Nodes(Elements(p,2), 2); % Calculate length of the element L = sqrt((X2-X1)^2+(Y2-Y1)^2); % Determine cos theta and sin theta for the transformation matrix cos_theta=(X2-X1)/L; sin_theta = (Y2-Y1)/L; % Assign Youngs modulus for each element E = Elements(p,3); % Assign Cross-sectional area of each element A = Elements(p,4); % Compute elemental stiffness matrix for each element k_element = (E*A/L)*[cos_theta^2 cos_theta*sin_theta -cos_theta^2 -cos_theta*sin_theta; cos_theta*sin_theta sin_theta^2 -cos_theta*sin_theta -sin_theta^2; -cos_theta^2 -cos_theta*sin_theta cos_theta^2 cos_theta*sin_theta; -cos_theta*sin_theta -sin_theta^2 cos_theta*sin_theta sin_theta^2]; % Assemble each element to obtain global stiffness matrix K_global(DOFs,DOFs) = K_global(DOFs,DOFs) + k_element; end
% %求出节点位移只有active_DOFive自由度,Ks和力量U (active_DOF) = K_global (active_DOF active_DOF) \ F (active_DOF);
% %计算元素应变和应力对q = 1: nelem %确定为每个元素景深自由度=(2 *元素(q, 1) 1, 2 *元素(q, 1), 2 *元素(q, 2) 1, 2 *元素(q, 2)];%为每个元素分配x和y坐标X1 =节点(元素(q, 1), 1);日元=节点(元素(q, 1), 2);(q, 2 X2 =节点(元素),1);Y2 =节点(元素(q, 2), 2);%计算元素的长度L =√(X2-X1) ^ 2 + (Y2-Y1) ^ 2);%确定cosθ和变换矩阵cos_theta sinθ= (X2-X1) / L;sin_theta = (Y2-Y1) / L;%的变换矩阵来计算轴向位移的节点位移t = [cos_theta sin_theta 0 0;0 0 cos_theta sin_theta]; % calculate axial displacements for each element d = t*U(DOFs); % Compute Strain strain(q) = (d(2) - d(1))/L; % Compute Stress stress(q)= Elements(q, 3)*strain(q); end %% Display the results disp('Global Stiffness Matrix, K_global=');disp(K_global); disp('Computed Nodal Displacements, U=');disp(U); disp('Computed Strains for all elements, strain=');disp(strain); disp('Computed Stresses for all elements, stress =');disp(stress);
请帮助这个5元素的代码有位移,应变和应力0

答案(0)

类别

找到更多的在应力和应变帮助中心文件交换

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!