├── .gitattributes ├── fem ├── K.mat ├── PStresses.m ├── RF.mat ├── RF11.mat ├── RF22.mat ├── assemble.m ├── fem_functions.m ├── fem_main.m ├── sigma.mat ├── stiffness.m ├── strain.mat ├── stress.mat ├── stressandstrain.m └── u.mat ├── matlab 有限元源程序 ├── BeamAssemble.m ├── BeamElementForces.m ├── BeamElementMomentDiagram.m ├── BeamElementShearDiagram.m ├── BeamElementStiffness.m ├── BilinearQuadAssemble.m ├── BilinearQuadElementArea.m ├── BilinearQuadElementPStresses.m ├── BilinearQuadElementStiffness.m ├── BilinearQuadElementStiffness2.m ├── BilinearQuadElementStresses.m ├── GridAssemble.m ├── GridElementForces.m ├── GridElementLength.m ├── GridElementStiffness.m ├── LinearBarAssemble.m ├── LinearBarElementForces.m ├── LinearBarElementStiffness.m ├── LinearBarElementStresses.m ├── LinearTriangleAssemble.m ├── LinearTriangleElementArea.m ├── LinearTriangleElementPStresses.m ├── LinearTriangleElementStiffness.m ├── LinearTriangleElementStresses.m ├── PlaneFrameAssemble.m ├── PlaneFrameElementAxialDiagram.m ├── PlaneFrameElementForces.m ├── PlaneFrameElementLength.m ├── PlaneFrameElementMomentDiagram.m ├── PlaneFrameElementShearDiagram.m ├── PlaneFrameElementStiffness.m ├── PlaneFrameInclinedSupport.m ├── PlaneTrussAssemble.m ├── PlaneTrussElementForce.m ├── PlaneTrussElementLength.m ├── PlaneTrussElementStiffness.m ├── PlaneTrussElementStress.m ├── PlaneTrussInclinedSupport.m ├── QuadTriangleAssemble.m ├── QuadTriangleElementArea.m ├── QuadTriangleElementPStresses.m ├── QuadTriangleElementStiffness.m ├── QuadTriangleElementStresses.m ├── QuadraticBarAssemble.m ├── QuadraticBarElementForces.m ├── QuadraticBarElementStiffness.m ├── QuadraticBarElementStresses.m ├── QuadraticQuadAssemble.m ├── QuadraticQuadElementArea.m ├── QuadraticQuadElementPStresses.m ├── QuadraticQuadElementStiffness.m ├── QuadraticQuadElementStresses.m ├── SpaceFrameAssemble.m ├── SpaceFrameElementAxialDiagram.m ├── SpaceFrameElementForces.m ├── SpaceFrameElementLength.m ├── SpaceFrameElementMomentYDiagram.m ├── SpaceFrameElementMomentZDiagram.m ├── SpaceFrameElementShearYDiagram.m ├── SpaceFrameElementShearZDiagram.m ├── SpaceFrameElementStiffness.m ├── SpaceFrameElementTorsionDiagram.m ├── SpaceTrussAssemble.m ├── SpaceTrussElementForce.m ├── SpaceTrussElementLength.m ├── SpaceTrussElementStiffness.m ├── SpaceTrussElementStress.m ├── SpringAssemble.m ├── SpringElementForces.m ├── SpringElementStiffness.m ├── TetrahedronAssemble.m ├── TetrahedronElementPStresses.m ├── TetrahedronElementStiffness.m ├── TetrahedronElementStresses.m └── TetrahedronElementVolume.m └── readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /fem/K.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/K.mat -------------------------------------------------------------------------------- /fem/PStresses.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/PStresses.m -------------------------------------------------------------------------------- /fem/RF.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/RF.mat -------------------------------------------------------------------------------- /fem/RF11.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/RF11.mat -------------------------------------------------------------------------------- /fem/RF22.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/RF22.mat -------------------------------------------------------------------------------- /fem/assemble.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/assemble.m -------------------------------------------------------------------------------- /fem/fem_functions.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/fem_functions.m -------------------------------------------------------------------------------- /fem/fem_main.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/fem_main.m -------------------------------------------------------------------------------- /fem/sigma.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/sigma.mat -------------------------------------------------------------------------------- /fem/stiffness.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/stiffness.m -------------------------------------------------------------------------------- /fem/strain.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/strain.mat -------------------------------------------------------------------------------- /fem/stress.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/stress.mat -------------------------------------------------------------------------------- /fem/stressandstrain.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/stressandstrain.m -------------------------------------------------------------------------------- /fem/u.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timeflies1113/FEM_MATLAB/da0b9b30619cf5af8ba565eee64d228b72a30193/fem/u.mat -------------------------------------------------------------------------------- /matlab 有限元源程序/BeamAssemble.m: -------------------------------------------------------------------------------- 1 | function y = BeamAssemble(K,k,i,j) 2 | %BeamAssemble This function assembles the element stiffness 3 | % matrix k of the beam element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 9 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 10 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 11 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 12 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 13 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 14 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 15 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 16 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 17 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 18 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 19 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 20 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 21 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 22 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 23 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 24 | y = K; 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BeamElementForces.m: -------------------------------------------------------------------------------- 1 | function y = BeamElementForces(k,u) 2 | %BeamElementForces This function returns the element nodal force 3 | % vector given the element stiffness matrix k 4 | % and the element nodal displacement vector u. 5 | y = k * u; 6 | 7 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BeamElementMomentDiagram.m: -------------------------------------------------------------------------------- 1 | function y = BeamElementMomentDiagram(f, L) 2 | %BeamElementMomentDiagram This function plots the bending moment 3 | % diagram for the beam element with nodal 4 | % force vector f and length L. 5 | x = [0 ; L]; 6 | z = [-f(2) ; f(4)]; 7 | hold on; 8 | title('Bending Moment Diagram'); 9 | plot(x,z); 10 | y1 = [0 ; 0]; 11 | plot(x,y1,'k') 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BeamElementShearDiagram.m: -------------------------------------------------------------------------------- 1 | function y = BeamElementShearDiagram(f, L) 2 | %BeamElementShearDiagram This function plots the shear force 3 | % diagram for the beam element with nodal 4 | % force vector f and length L. 5 | x = [0 ; L]; 6 | z = [f(1) ; -f(3)]; 7 | hold on; 8 | title('Shear Force Diagram'); 9 | plot(x,z); 10 | y1 = [0 ; 0]; 11 | plot(x,y1,'k') 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BeamElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = BeamElementStiffness(E,I,L) 2 | %BeamElementStiffness This function returns the element 3 | % stiffness matrix for a beam 4 | % element with modulus of elasticity E, 5 | % moment of inertia I, and length L. 6 | % The size of the element stiffness 7 | % matrix is 4 x 4. 8 | y = E*I/(L*L*L)*[12 6*L -12 6*L ; 6*L 4*L*L -6*L 2*L*L ; 9 | -12 -6*L 12 -6*L ; 6*L 2*L*L -6*L 4*L*L]; 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadAssemble.m: -------------------------------------------------------------------------------- 1 | function y = BilinearQuadAssemble(K,k,i,j,m,n) 2 | %BilinearQuadAssemble This function assembles the element 3 | % stiffness matrix k of the bilinear 4 | % quadrilateral element with nodes i, j, 5 | % m, and n into the global stiffness 6 | % matrix K. 7 | % This function returns the global stiffness 8 | % matrix K after the element stiffness matrix 9 | % k is assembled. 10 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 11 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 12 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 13 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 14 | K(2*i-1,2*m-1) = K(2*i-1,2*m-1) + k(1,5); 15 | K(2*i-1,2*m) = K(2*i-1,2*m) + k(1,6); 16 | K(2*i-1,2*n-1) = K(2*i-1,2*n-1) + k(1,7); 17 | K(2*i-1,2*n) = K(2*i-1,2*n) + k(1,8); 18 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 19 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 20 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 21 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 22 | K(2*i,2*m-1) = K(2*i,2*m-1) + k(2,5); 23 | K(2*i,2*m) = K(2*i,2*m) + k(2,6); 24 | K(2*i,2*n-1) = K(2*i,2*n-1) + k(2,7); 25 | K(2*i,2*n) = K(2*i,2*n) + k(2,8); 26 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 27 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 28 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 29 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 30 | K(2*j-1,2*m-1) = K(2*j-1,2*m-1) + k(3,5); 31 | K(2*j-1,2*m) = K(2*j-1,2*m) + k(3,6); 32 | K(2*j-1,2*n-1) = K(2*j-1,2*n-1) + k(3,7); 33 | K(2*j-1,2*n) = K(2*j-1,2*n) + k(3,8); 34 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 35 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 36 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 37 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 38 | K(2*j,2*m-1) = K(2*j,2*m-1) + k(4,5); 39 | K(2*j,2*m) = K(2*j,2*m) + k(4,6); 40 | K(2*j,2*n-1) = K(2*j,2*n-1) + k(4,7); 41 | K(2*j,2*n) = K(2*j,2*n) + k(4,8); 42 | K(2*m-1,2*i-1) = K(2*m-1,2*i-1) + k(5,1); 43 | K(2*m-1,2*i) = K(2*m-1,2*i) + k(5,2); 44 | K(2*m-1,2*j-1) = K(2*m-1,2*j-1) + k(5,3); 45 | K(2*m-1,2*j) = K(2*m-1,2*j) + k(5,4); 46 | K(2*m-1,2*m-1) = K(2*m-1,2*m-1) + k(5,5); 47 | K(2*m-1,2*m) = K(2*m-1,2*m) + k(5,6); 48 | K(2*m-1,2*n-1) = K(2*m-1,2*n-1) + k(5,7); 49 | K(2*m-1,2*n) = K(2*m-1,2*n) + k(5,8); 50 | K(2*m,2*i-1) = K(2*m,2*i-1) + k(6,1); 51 | K(2*m,2*i) = K(2*m,2*i) + k(6,2); 52 | K(2*m,2*j-1) = K(2*m,2*j-1) + k(6,3); 53 | K(2*m,2*j) = K(2*m,2*j) + k(6,4); 54 | K(2*m,2*m-1) = K(2*m,2*m-1) + k(6,5); 55 | K(2*m,2*m) = K(2*m,2*m) + k(6,6); 56 | K(2*m,2*n-1) = K(2*m,2*n-1) + k(6,7); 57 | K(2*m,2*n) = K(2*m,2*n) + k(6,8); 58 | K(2*n-1,2*i-1) = K(2*n-1,2*i-1) + k(7,1); 59 | K(2*n-1,2*i) = K(2*n-1,2*i) + k(7,2); 60 | K(2*n-1,2*j-1) = K(2*n-1,2*j-1) + k(7,3); 61 | K(2*n-1,2*j) = K(2*n-1,2*j) + k(7,4); 62 | K(2*n-1,2*m-1) = K(2*n-1,2*m-1) + k(7,5); 63 | K(2*n-1,2*m) = K(2*n-1,2*m) + k(7,6); 64 | K(2*n-1,2*n-1) = K(2*n-1,2*n-1) + k(7,7); 65 | K(2*n-1,2*n) = K(2*n-1,2*n) + k(7,8); 66 | K(2*n,2*i-1) = K(2*n,2*i-1) + k(8,1); 67 | K(2*n,2*i) = K(2*n,2*i) + k(8,2); 68 | K(2*n,2*j-1) = K(2*n,2*j-1) + k(8,3); 69 | K(2*n,2*j) = K(2*n,2*j) + k(8,4); 70 | K(2*n,2*m-1) = K(2*n,2*m-1) + k(8,5); 71 | K(2*n,2*m) = K(2*n,2*m) + k(8,6); 72 | K(2*n,2*n-1) = K(2*n,2*n-1) + k(8,7); 73 | K(2*n,2*n) = K(2*n,2*n) + k(8,8); 74 | y = K; 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadElementArea.m: -------------------------------------------------------------------------------- 1 | function y = BilinearQuadElementArea(x1,y1,x2,y2,x3,y3,x4,y4) 2 | %BilinearQuadElementArea This function returns the area 3 | % of the bilinear quadrilateral 4 | % element whose first node has 5 | % coordinates (x1,y1), second 6 | % node has coordinates (x2,y2), 7 | % third node has coordinates 8 | % (x3,y3), and fourth node has 9 | % coordinates (x4,y4) . 10 | yfirst = (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2; 11 | ysecond = (x1*(y3-y4) + x3*(y4-y1) + x4*(y1-y3))/2; 12 | y = yfirst + ysecond; 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadElementPStresses.m: -------------------------------------------------------------------------------- 1 | function y = BilinearQuadElementPStresses(sigma) 2 | %BilinearQuadElementPStresses This function returns the element 3 | % principal stresses and their 4 | % angle given the element 5 | % stress vector. 6 | R = (sigma(1) + sigma(2))/2; 7 | Q = ((sigma(1) - sigma(2))/2)^2 + sigma(3)*sigma(3); 8 | M = 2*sigma(3)/(sigma(1) - sigma(2)); 9 | s1 = R + sqrt(Q); 10 | s2 = R - sqrt(Q); 11 | theta = (atan(M)/2)*180/pi; 12 | y = [s1 ; s2 ; theta]; 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadElementStiffness.m: -------------------------------------------------------------------------------- 1 | function w = BilinearQuadElementStiffness(E,NU,h,x1,y1,x2,y2,x3,y3,x4,y4,p) 2 | %BilinearQuadElementStiffness This function returns the element 3 | % stiffness matrix for a bilinear 4 | % quadrilateral element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, thickness h, coordinates of 7 | % node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), coordinates of 9 | % node 3 (x3,y3), and coordinates of 10 | % node 4 (x4,y4). Use p = 1 for cases 11 | % of plane stress, and p = 2 for 12 | % cases of plane strain. 13 | % The size of the element 14 | % stiffness matrix is 8 x 8. 15 | syms s t; 16 | a = (y1*(s-1)+y2*(-1-s)+y3*(1+s)+y4*(1-s))/4; 17 | b = (y1*(t-1)+y2*(1-t)+y3*(1+t)+y4*(-1-t))/4; 18 | c = (x1*(t-1)+x2*(1-t)+x3*(1+t)+x4*(-1-t))/4; 19 | d = (x1*(s-1)+x2*(-1-s)+x3*(1+s)+x4*(1-s))/4; 20 | B1 = [a*(t-1)/4-b*(s-1)/4 0 ; 0 c*(s-1)/4-d*(t-1)/4 ; 21 | c*(s-1)/4-d*(t-1)/4 a*(t-1)/4-b*(s-1)/4]; 22 | B2 = [a*(1-t)/4-b*(-1-s)/4 0 ; 0 c*(-1-s)/4-d*(1-t)/4 ; 23 | c*(-1-s)/4-d*(1-t)/4 a*(1-t)/4-b*(-1-s)/4]; 24 | B3 = [a*(t+1)/4-b*(s+1)/4 0 ; 0 c*(s+1)/4-d*(t+1)/4 ; 25 | c*(s+1)/4-d*(t+1)/4 a*(t+1)/4-b*(s+1)/4]; 26 | B4 = [a*(-1-t)/4-b*(1-s)/4 0 ; 0 c*(1-s)/4-d*(-1-t)/4 ; 27 | c*(1-s)/4-d*(-1-t)/4 a*(-1-t)/4-b*(1-s)/4]; 28 | Bfirst = [B1 B2 B3 B4]; 29 | Jfirst = [0 1-t t-s s-1 ; t-1 0 s+1 -s-t ; 30 | s-t -s-1 0 t+1 ; 1-s s+t -t-1 0]; 31 | J = [x1 x2 x3 x4]*Jfirst*[y1 ; y2 ; y3 ; y4]/8; 32 | B = Bfirst/J; 33 | if p == 1 34 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 35 | elseif p == 2 36 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 37 | end 38 | BD = J*transpose(B)*D*B; 39 | r = int(int(BD, t, -1, 1), s, -1, 1); 40 | z = h*r; 41 | w = double(z); 42 | 43 | 44 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadElementStiffness2.m: -------------------------------------------------------------------------------- 1 | function w = BilinearQuadElementStiffness2(E,NU,h,x1,y1,x2,y2,x3,y3,x4,y4,p) 2 | %BilinearQuadElementStiffness This function returns the element 3 | % stiffness matrix for a bilinear 4 | % quadrilateral element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, thickness h, coordinates of 7 | % node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), coordinates of 9 | % node 3 (x3,y3), and coordinates of 10 | % node 4 (x4,y4). Use p = 1 for cases 11 | % of plane stress, and p = 2 for 12 | % cases of plane strain. 13 | % The size of the element 14 | % stiffness matrix is 8 x 8. 15 | syms s t; 16 | N1 = (1-s)*(1-t)/4; 17 | N2 = (1+s)*(1-t)/4; 18 | N3 = (1+s)*(1+t)/4; 19 | N4 = (1-s)*(1+t)/4; 20 | x = N1*x1 + N2*x2 + N3*x3 + N4*x4; 21 | y = N1*y1 + N2*y2 + N3*y3 + N4*y4; 22 | xs = diff(x,s); 23 | xt = diff(x,t); 24 | ys = diff(y,s); 25 | yt = diff(y,t); 26 | J = xs*yt - ys*xt; 27 | N1s = diff(N1,s); 28 | N2s = diff(N2,s); 29 | N3s = diff(N3,s); 30 | N4s = diff(N4,s); 31 | N1t = diff(N1,t); 32 | N2t = diff(N2,t); 33 | N3t = diff(N3,t); 34 | N4t = diff(N4,t); 35 | B11 = yt*N1s - ys*N1t; 36 | B12 = 0; 37 | B13 = yt*N2s - ys*N2t; 38 | B14 = 0; 39 | B15 = yt*N3s - ys*N3t; 40 | B16 = 0; 41 | B17 = yt*N4s - ys*N4t; 42 | B18 = 0; 43 | B21 = 0; 44 | B22 = xs*N1t - xt*N1s; 45 | B23 = 0; 46 | B24 = xs*N2t - xt*N2s; 47 | B25 = 0; 48 | B26 = xs*N3t - xt*N3s; 49 | B27 = 0; 50 | B28 = xs*N4t - xt*N4s; 51 | B31 = xs*N1t - xt*N1s; 52 | B32 = yt*N1s - ys*N1t; 53 | B33 = xs*N2t - xt*N2s; 54 | B34 = yt*N2s - ys*N2t; 55 | B35 = xs*N3t - xt*N3s; 56 | B36 = yt*N3s - ys*N3t; 57 | B37 = xs*N4t - xt*N4s; 58 | B38 = yt*N4s - ys*N4t; 59 | B = [B11 B12 B13 B14 B15 B16 B17 B18 ; 60 | B21 B22 B23 B24 B25 B26 B27 B28 ; 61 | B31 B32 B33 B34 B35 B36 B37 B38]; 62 | if p == 1 63 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 64 | elseif p == 2 65 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 66 | end 67 | BD = transpose(B)*D*B/J; 68 | r = int(int(BD, t, -1, 1), s, -1, 1); 69 | z = h*r; 70 | w = double(z); 71 | 72 | 73 | -------------------------------------------------------------------------------- /matlab 有限元源程序/BilinearQuadElementStresses.m: -------------------------------------------------------------------------------- 1 | function w = BilinearQuadElementStresses(E,NU,x1,y1,x2,y2,x3,y3,x4,y4,p,u) 2 | %BilinearQuadElementStresses This function returns the element 3 | % stress vector for a bilinear 4 | % quadrilateral element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, coordinates of 7 | % node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), coordinates of 9 | % node 3 (x3,y3), and coordinates of 10 | % node 4 (x4,y4). Use p = 1 for cases 11 | % of plane stress, and p = 2 for 12 | % cases of plane strain. 13 | syms s t; 14 | a = (y1*(s-1)+y2*(-1-s)+y3*(1+s)+y4*(1-s))/4; 15 | b = (y1*(t-1)+y2*(1-t)+y3*(1+t)+y4*(-1-t))/4; 16 | c = (x1*(t-1)+x2*(1-t)+x3*(1+t)+x4*(-1-t))/4; 17 | d = (x1*(s-1)+x2*(-1-s)+x3*(1+s)+x4*(1-s))/4; 18 | B1 = [a*(t-1)/4-b*(s-1)/4 0 ; 0 c*(s-1)/4-d*(t-1)/4 ; 19 | c*(s-1)/4-d*(t-1)/4 a*(t-1)/4-b*(s-1)/4]; 20 | B2 = [a*(1-t)/4-b*(-1-s)/4 0 ; 0 c*(-1-s)/4-d*(1-t)/4 ; 21 | c*(-1-s)/4-d*(1-t)/4 a*(1-t)/4-b*(-1-s)/4]; 22 | B3 = [a*(t+1)/4-b*(s+1)/4 0 ; 0 c*(s+1)/4-d*(t+1)/4 ; 23 | c*(s+1)/4-d*(t+1)/4 a*(t+1)/4-b*(s+1)/4]; 24 | B4 = [a*(-1-t)/4-b*(1-s)/4 0 ; 0 c*(1-s)/4-d*(-1-t)/4 ; 25 | c*(1-s)/4-d*(-1-t)/4 a*(-1-t)/4-b*(1-s)/4]; 26 | Bfirst = [B1 B2 B3 B4]; 27 | Jfirst = [0 1-t t-s s-1 ; t-1 0 s+1 -s-t ; 28 | s-t -s-1 0 t+1 ; 1-s s+t -t-1 0]; 29 | J = [x1 x2 x3 x4]*Jfirst*[y1 ; y2 ; y3 ; y4]/8; 30 | B = Bfirst/J; 31 | if p == 1 32 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 33 | elseif p == 2 34 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 35 | end 36 | w = D*B*u 37 | % 38 | % We also calculate the stresses at the centroid of the element 39 | % 40 | wcent = subs(w, {s,t}, {0,0}); 41 | w = double(wcent); 42 | 43 | 44 | -------------------------------------------------------------------------------- /matlab 有限元源程序/GridAssemble.m: -------------------------------------------------------------------------------- 1 | function y = GridAssemble(K,k,i,j) 2 | %GridAssemble This function assembles the element stiffness 3 | % matrix k of the grid element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(3*i-2,3*i-2) = K(3*i-2,3*i-2) + k(1,1); 9 | K(3*i-2,3*i-1) = K(3*i-2,3*i-1) + k(1,2); 10 | K(3*i-2,3*i) = K(3*i-2,3*i) + k(1,3); 11 | K(3*i-2,3*j-2) = K(3*i-2,3*j-2) + k(1,4); 12 | K(3*i-2,3*j-1) = K(3*i-2,3*j-1) + k(1,5); 13 | K(3*i-2,3*j) = K(3*i-2,3*j) + k(1,6); 14 | K(3*i-1,3*i-2) = K(3*i-1,3*i-2) + k(2,1); 15 | K(3*i-1,3*i-1) = K(3*i-1,3*i-1) + k(2,2); 16 | K(3*i-1,3*i) = K(3*i-1,3*i) + k(2,3); 17 | K(3*i-1,3*j-2) = K(3*i-1,3*j-2) + k(2,4); 18 | K(3*i-1,3*j-1) = K(3*i-1,3*j-1) + k(2,5); 19 | K(3*i-1,3*j) = K(3*i-1,3*j) + k(2,6); 20 | K(3*i,3*i-2) = K(3*i,3*i-2) + k(3,1); 21 | K(3*i,3*i-1) = K(3*i,3*i-1) + k(3,2); 22 | K(3*i,3*i) = K(3*i,3*i) + k(3,3); 23 | K(3*i,3*j-2) = K(3*i,3*j-2) + k(3,4); 24 | K(3*i,3*j-1) = K(3*i,3*j-1) + k(3,5); 25 | K(3*i,3*j) = K(3*i,3*j) + k(3,6); 26 | K(3*j-2,3*i-2) = K(3*j-2,3*i-2) + k(4,1); 27 | K(3*j-2,3*i-1) = K(3*j-2,3*i-1) + k(4,2); 28 | K(3*j-2,3*i) = K(3*j-2,3*i) + k(4,3); 29 | K(3*j-2,3*j-2) = K(3*j-2,3*j-2) + k(4,4); 30 | K(3*j-2,3*j-1) = K(3*j-2,3*j-1) + k(4,5); 31 | K(3*j-2,3*j) = K(3*j-2,3*j) + k(4,6); 32 | K(3*j-1,3*i-2) = K(3*j-1,3*i-2) + k(5,1); 33 | K(3*j-1,3*i-1) = K(3*j-1,3*i-1) + k(5,2); 34 | K(3*j-1,3*i) = K(3*j-1,3*i) + k(5,3); 35 | K(3*j-1,3*j-2) = K(3*j-1,3*j-2) + k(5,4); 36 | K(3*j-1,3*j-1) = K(3*j-1,3*j-1) + k(5,5); 37 | K(3*j-1,3*j) = K(3*j-1,3*j) + k(5,6); 38 | K(3*j,3*i-2) = K(3*j,3*i-2) + k(6,1); 39 | K(3*j,3*i-1) = K(3*j,3*i-1) + k(6,2); 40 | K(3*j,3*i) = K(3*j,3*i) + k(6,3); 41 | K(3*j,3*j-2) = K(3*j,3*j-2) + k(6,4); 42 | K(3*j,3*j-1) = K(3*j,3*j-1) + k(6,5); 43 | K(3*j,3*j) = K(3*j,3*j) + k(6,6); 44 | y = K; 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /matlab 有限元源程序/GridElementForces.m: -------------------------------------------------------------------------------- 1 | function y = GridElementForces(E,G,I,J,L,theta,u) 2 | %GridElementForces This function returns the element force 3 | % vector given the modulus of elasticity E, 4 | % the shear modulus of elasticity G, the 5 | % moment of inertia I, the torsional constant J, 6 | % the length L, the angle theta (in degrees), 7 | % and the element nodal displacement vector u. 8 | x = theta*pi/180; 9 | C = cos(x); 10 | S = sin(x); 11 | w1 = 12*E*I/(L*L*L); 12 | w2 = 6*E*I/(L*L); 13 | w3 = G*J/L; 14 | w4 = 4*E*I/L; 15 | w5 = 2*E*I/L; 16 | kprime = [w1 0 w2 -w1 0 w2 ; 0 w3 0 0 -w3 0 ; 17 | w2 0 w4 -w2 0 w5 ; -w1 0 -w2 w1 0 -w2 ; 18 | 0 -w3 0 0 w3 0 ; w2 0 w5 -w2 0 w4]; 19 | R = [1 0 0 0 0 0 ; 0 C S 0 0 0 ; 0 -S C 0 0 0 ; 20 | 0 0 0 1 0 0 ; 0 0 0 0 C S ; 0 0 0 0 -S C]; 21 | y = kprime*R* u; 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /matlab 有限元源程序/GridElementLength.m: -------------------------------------------------------------------------------- 1 | function y = GridElementLength(x1,y1,x2,y2) 2 | %GridElementLength This function returns the length of the 3 | % grid element whose first node has 4 | % coordinates (x1,y1) and second node has 5 | % coordinates (x2,y2). 6 | y = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /matlab 有限元源程序/GridElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = GridElementStiffness(E,G,I,J,L,theta) 2 | %GridElementStiffness This function returns the element 3 | % stiffness matrix for a grid 4 | % element with modulus of elasticity E, 5 | % shear modulus of elasticity G, moment of 6 | % inertia I, torsional constant J, length L, 7 | % and angle theta (in degrees). 8 | % The size of the element stiffness 9 | % matrix is 6 x 6. 10 | x = theta*pi/180; 11 | C = cos(x); 12 | S = sin(x); 13 | w1 = 12*E*I/(L*L*L); 14 | w2 = 6*E*I/(L*L); 15 | w3 = G*J/L; 16 | w4 = 4*E*I/L; 17 | w5 = 2*E*I/L; 18 | kprime = [w1 0 w2 -w1 0 w2 ; 0 w3 0 0 -w3 0 ; 19 | w2 0 w4 -w2 0 w5 ; -w1 0 -w2 w1 0 -w2 ; 20 | 0 -w3 0 0 w3 0 ; w2 0 w5 -w2 0 w4]; 21 | R = [1 0 0 0 0 0 ; 0 C S 0 0 0 ; 0 -S C 0 0 0 ; 22 | 0 0 0 1 0 0 ; 0 0 0 0 C S ; 0 0 0 0 -S C]; 23 | y = R'*kprime*R; 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearBarAssemble.m: -------------------------------------------------------------------------------- 1 | function y = LinearBarAssemble(K,k,i,j) 2 | %LinearBarAssemble This function assembles the element stiffness 3 | % matrix k of the linear bar with nodes i and j 4 | % into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(i,i) = K(i,i) + k(1,1); 9 | K(i,j) = K(i,j) + k(1,2); 10 | K(j,i) = K(j,i) + k(2,1); 11 | K(j,j) = K(j,j) + k(2,2); 12 | y = K; 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearBarElementForces.m: -------------------------------------------------------------------------------- 1 | function y = LinearBarElementForces(k,u) 2 | %LinearBarElementForces This function returns the element nodal 3 | % force vector given the element stiffness 4 | % matrix k and the element nodal displacement 5 | % vector u. 6 | y = k * u; 7 | 8 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearBarElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = LinearBarElementStiffness(E,A,L) 2 | %LinearBarElementStiffness This function returns the element 3 | % stiffness matrix for a linear bar with 4 | % modulus of elasticity E, cross-sectional 5 | % area A, and length L. The size of the 6 | % element stiffness matrix is 2 x 2. 7 | y = [E*A/L -E*A/L ; -E*A/L E*A/L]; 8 | 9 | 10 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearBarElementStresses.m: -------------------------------------------------------------------------------- 1 | function y = LinearBarElementStresses(k, u, A) 2 | %LinearBarElementStresses This function returns the element nodal 3 | % stress vector given the element stiffness 4 | % matrix k, the element nodal displacement 5 | % vector u, and the cross-sectional area A. 6 | y = k * u/A; 7 | 8 | 9 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearTriangleAssemble.m: -------------------------------------------------------------------------------- 1 | function y = LinearTriangleAssemble(K,k,i,j,m) 2 | %LinearTriangleAssemble This function assembles the element 3 | % stiffness matrix k of the linear 4 | % triangular element with nodes i, j, 5 | % and m into the global stiffness matrix K. 6 | % This function returns the global stiffness 7 | % matrix K after the element stiffness matrix 8 | % k is assembled. 9 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 10 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 11 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 12 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 13 | K(2*i-1,2*m-1) = K(2*i-1,2*m-1) + k(1,5); 14 | K(2*i-1,2*m) = K(2*i-1,2*m) + k(1,6); 15 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 16 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 17 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 18 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 19 | K(2*i,2*m-1) = K(2*i,2*m-1) + k(2,5); 20 | K(2*i,2*m) = K(2*i,2*m) + k(2,6); 21 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 22 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 23 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 24 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 25 | K(2*j-1,2*m-1) = K(2*j-1,2*m-1) + k(3,5); 26 | K(2*j-1,2*m) = K(2*j-1,2*m) + k(3,6); 27 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 28 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 29 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 30 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 31 | K(2*j,2*m-1) = K(2*j,2*m-1) + k(4,5); 32 | K(2*j,2*m) = K(2*j,2*m) + k(4,6); 33 | K(2*m-1,2*i-1) = K(2*m-1,2*i-1) + k(5,1); 34 | K(2*m-1,2*i) = K(2*m-1,2*i) + k(5,2); 35 | K(2*m-1,2*j-1) = K(2*m-1,2*j-1) + k(5,3); 36 | K(2*m-1,2*j) = K(2*m-1,2*j) + k(5,4); 37 | K(2*m-1,2*m-1) = K(2*m-1,2*m-1) + k(5,5); 38 | K(2*m-1,2*m) = K(2*m-1,2*m) + k(5,6); 39 | K(2*m,2*i-1) = K(2*m,2*i-1) + k(6,1); 40 | K(2*m,2*i) = K(2*m,2*i) + k(6,2); 41 | K(2*m,2*j-1) = K(2*m,2*j-1) + k(6,3); 42 | K(2*m,2*j) = K(2*m,2*j) + k(6,4); 43 | K(2*m,2*m-1) = K(2*m,2*m-1) + k(6,5); 44 | K(2*m,2*m) = K(2*m,2*m) + k(6,6); 45 | y = K; 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearTriangleElementArea.m: -------------------------------------------------------------------------------- 1 | function y = LinearTriangleElementArea(xi,yi,xj,yj,xm,ym) 2 | %LinearTriangleElementArea This function returns the area of the 3 | % linear triangular element whose first 4 | % node has coordinates (xi,yi), second 5 | % node has coordinates (xj,yj), and 6 | % third node has coordinates (xm,ym). 7 | y = (xi*(yj-ym) + xj*(ym-yi) + xm*(yi-yj))/2; 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearTriangleElementPStresses.m: -------------------------------------------------------------------------------- 1 | function y = LinearTriangleElementPStresses(sigma) 2 | %LinearTriangleElementPStresses This function returns the element 3 | % principal stresses and their 4 | % angle given the element 5 | % stress vector. 6 | R = (sigma(1) + sigma(2))/2; 7 | Q = ((sigma(1) - sigma(2))/2)^2 + sigma(3)*sigma(3); 8 | M = 2*sigma(3)/(sigma(1) - sigma(2)); 9 | s1 = R + sqrt(Q); 10 | s2 = R - sqrt(Q); 11 | theta = (atan(M)/2)*180/pi; 12 | y = [s1 ; s2 ; theta]; 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearTriangleElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = LinearTriangleElementStiffness(E,NU,t,xi,yi,xj,yj,xm,ym,p) 2 | %LinearTriangleElementStiffness This function returns the element 3 | % stiffness matrix for a linear 4 | % triangular element with modulus of 5 | % elasticity E, Poisson's ratio NU, 6 | % thickness t, coordinates of the 7 | % first node (xi,yi), coordinates of 8 | % the second node (xj,yj), and 9 | % coordinates of the third node 10 | % (xm,ym). Use p = 1 for cases of 11 | % plane stress, and p = 2 for cases 12 | % of plane strain. 13 | % The size of the element stiffness 14 | % matrix is 6 x 6. 15 | A = (xi*(yj-ym) + xj*(ym-yi) + xm*(yi-yj))/2; 16 | betai = yj-ym; 17 | betaj = ym-yi; 18 | betam = yi-yj; 19 | gammai = xm-xj; 20 | gammaj = xi-xm; 21 | gammam = xj-xi; 22 | B = [betai 0 betaj 0 betam 0 ; 23 | 0 gammai 0 gammaj 0 gammam ; 24 | gammai betai gammaj betaj gammam betam]/(2*A); 25 | if p == 1 26 | D = (E/(1-NU*NU))*[1 NU 0 ; NU 1 0 ; 0 0 (1-NU)/2]; 27 | elseif p == 2 28 | D = (E/(1+NU)/(1-2*NU))*[1-NU NU 0 ; NU 1-NU 0 ; 0 0 (1-2*NU)/2]; 29 | end 30 | y = t*A*B'*D*B; 31 | 32 | -------------------------------------------------------------------------------- /matlab 有限元源程序/LinearTriangleElementStresses.m: -------------------------------------------------------------------------------- 1 | function y = LinearTriangleElementStresses(E,NU,t,xi,yi,xj,yj,xm,ym,p,u) 2 | %LinearTriangleElementStresses This function returns the element 3 | % stress vector for a linear 4 | % triangular element with modulus of 5 | % elasticity E, Poisson's ratio NU, 6 | % thickness t, coordinates of the 7 | % first node (xi,yi), coordinates of 8 | % the second node (xj,yj), 9 | % coordinates of the third node 10 | % (xm,ym), and element displacement 11 | % vector u. Use p = 1 for cases of 12 | % plane stress, and p = 2 for cases 13 | % of plane strain. 14 | % The size of the element stress 15 | % vector is 3 x 1. 16 | A = (xi*(yj-ym) + xj*(ym-yi) + xm*(yi-yj))/2; 17 | betai = yj-ym; 18 | betaj = ym-yi; 19 | betam = yi-yj; 20 | gammai = xm-xj; 21 | gammaj = xi-xm; 22 | gammam = xj-xi; 23 | B = [betai 0 betaj 0 betam 0 ; 24 | 0 gammai 0 gammaj 0 gammam ; 25 | gammai betai gammaj betaj gammam betam]/(2*A); 26 | if p == 1 27 | D = (E/(1-NU*NU))*[1 NU 0 ; NU 1 0 ; 0 0 (1-NU)/2]; 28 | elseif p == 2 29 | D = (E/(1+NU)/(1-2*NU))*[1-NU NU 0 ; NU 1-NU 0 ; 0 0 (1-2*NU)/2]; 30 | end 31 | y = D*B*u; 32 | 33 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameAssemble.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameAssemble(K,k,i,j) 2 | %PlaneFrameAssemble This function assembles the element stiffness 3 | % matrix k of the plane frame element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(3*i-2,3*i-2) = K(3*i-2,3*i-2) + k(1,1); 9 | K(3*i-2,3*i-1) = K(3*i-2,3*i-1) + k(1,2); 10 | K(3*i-2,3*i) = K(3*i-2,3*i) + k(1,3); 11 | K(3*i-2,3*j-2) = K(3*i-2,3*j-2) + k(1,4); 12 | K(3*i-2,3*j-1) = K(3*i-2,3*j-1) + k(1,5); 13 | K(3*i-2,3*j) = K(3*i-2,3*j) + k(1,6); 14 | K(3*i-1,3*i-2) = K(3*i-1,3*i-2) + k(2,1); 15 | K(3*i-1,3*i-1) = K(3*i-1,3*i-1) + k(2,2); 16 | K(3*i-1,3*i) = K(3*i-1,3*i) + k(2,3); 17 | K(3*i-1,3*j-2) = K(3*i-1,3*j-2) + k(2,4); 18 | K(3*i-1,3*j-1) = K(3*i-1,3*j-1) + k(2,5); 19 | K(3*i-1,3*j) = K(3*i-1,3*j) + k(2,6); 20 | K(3*i,3*i-2) = K(3*i,3*i-2) + k(3,1); 21 | K(3*i,3*i-1) = K(3*i,3*i-1) + k(3,2); 22 | K(3*i,3*i) = K(3*i,3*i) + k(3,3); 23 | K(3*i,3*j-2) = K(3*i,3*j-2) + k(3,4); 24 | K(3*i,3*j-1) = K(3*i,3*j-1) + k(3,5); 25 | K(3*i,3*j) = K(3*i,3*j) + k(3,6); 26 | K(3*j-2,3*i-2) = K(3*j-2,3*i-2) + k(4,1); 27 | K(3*j-2,3*i-1) = K(3*j-2,3*i-1) + k(4,2); 28 | K(3*j-2,3*i) = K(3*j-2,3*i) + k(4,3); 29 | K(3*j-2,3*j-2) = K(3*j-2,3*j-2) + k(4,4); 30 | K(3*j-2,3*j-1) = K(3*j-2,3*j-1) + k(4,5); 31 | K(3*j-2,3*j) = K(3*j-2,3*j) + k(4,6); 32 | K(3*j-1,3*i-2) = K(3*j-1,3*i-2) + k(5,1); 33 | K(3*j-1,3*i-1) = K(3*j-1,3*i-1) + k(5,2); 34 | K(3*j-1,3*i) = K(3*j-1,3*i) + k(5,3); 35 | K(3*j-1,3*j-2) = K(3*j-1,3*j-2) + k(5,4); 36 | K(3*j-1,3*j-1) = K(3*j-1,3*j-1) + k(5,5); 37 | K(3*j-1,3*j) = K(3*j-1,3*j) + k(5,6); 38 | K(3*j,3*i-2) = K(3*j,3*i-2) + k(6,1); 39 | K(3*j,3*i-1) = K(3*j,3*i-1) + k(6,2); 40 | K(3*j,3*i) = K(3*j,3*i) + k(6,3); 41 | K(3*j,3*j-2) = K(3*j,3*j-2) + k(6,4); 42 | K(3*j,3*j-1) = K(3*j,3*j-1) + k(6,5); 43 | K(3*j,3*j) = K(3*j,3*j) + k(6,6); 44 | y = K; 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementAxialDiagram.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementAxialDiagram(f, L) 2 | %PlaneFrameElementAxialDiagram This function plots the axial force 3 | % diagram for the plane frame element 4 | % with nodal force vector f and length 5 | % L. 6 | x = [0 ; L]; 7 | z = [-f(1) ; f(4)]; 8 | hold on; 9 | title('Axial Force Diagram'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementForces.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementForces(E,A,I,L,theta,u) 2 | %PlaneFrameElementForces This function returns the element force 3 | % vector given the modulus of elasticity E, 4 | % the cross-sectional area A, the moment of 5 | % inertia I, the length L, the angle theta 6 | % (in degrees), and the element nodal 7 | % displacement vector u. 8 | x = theta * pi/180; 9 | C = cos(x); 10 | S = sin(x); 11 | w1 = E*A/L; 12 | w2 = 12*E*I/(L*L*L); 13 | w3 = 6*E*I/(L*L); 14 | w4 = 4*E*I/L; 15 | w5 = 2*E*I/L; 16 | kprime = [w1 0 0 -w1 0 0 ; 0 w2 w3 0 -w2 w3 ; 17 | 0 w3 w4 0 -w3 w5 ; -w1 0 0 w1 0 0 ; 18 | 0 -w2 -w3 0 w2 -w3 ; 0 w3 w5 0 -w3 w4]; 19 | T = [C S 0 0 0 0 ; -S C 0 0 0 0 ; 0 0 1 0 0 0 ; 20 | 0 0 0 C S 0 ; 0 0 0 -S C 0 ; 0 0 0 0 0 1]; 21 | y = kprime*T* u; 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementLength.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementLength(x1,y1,x2,y2) 2 | %PlaneFrameElementLength This function returns the length of the 3 | % plane frame element whose first node has 4 | % coordinates (x1,y1) and second node has 5 | % coordinates (x2,y2). 6 | y = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementMomentDiagram.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementMomentDiagram(f, L) 2 | %PlaneFrameElementMomentDiagram This function plots the bending 3 | % moment diagram for the plane frame 4 | % element with nodal force vector f 5 | % and length L. 6 | x = [0 ; L]; 7 | z = [-f(3) ; f(6)]; 8 | hold on; 9 | title('Bending Moment Diagram'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementShearDiagram.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementShearDiagram(f, L) 2 | %PlaneFrameElementShearDiagram This function plots the shear force 3 | % diagram for the plane frame element 4 | % with nodal force vector f and length 5 | % L. 6 | x = [0 ; L]; 7 | z = [f(2) ; -f(5)]; 8 | hold on; 9 | title('Shear Force Diagram'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameElementStiffness(E,A,I,L,theta) 2 | %PlaneFrameElementStiffness This function returns the element 3 | % stiffness matrix for a plane frame 4 | % element with modulus of elasticity E, 5 | % cross-sectional area A, moment of 6 | % inertia I, length L, and angle 7 | % theta (in degrees). 8 | % The size of the element stiffness 9 | % matrix is 6 x 6. 10 | x = theta*pi/180; 11 | C = cos(x); 12 | S = sin(x); 13 | w1 = A*C*C + 12*I*S*S/(L*L); 14 | w2 = A*S*S + 12*I*C*C/(L*L); 15 | w3 = (A-12*I/(L*L))*C*S; 16 | w4 = 6*I*S/L; 17 | w5 = 6*I*C/L; 18 | y = E/L*[w1 w3 -w4 -w1 -w3 -w4 ; w3 w2 w5 -w3 -w2 w5 ; 19 | -w4 w5 4*I w4 -w5 2*I ; -w1 -w3 w4 w1 w3 w4 ; 20 | -w3 -w2 -w5 w3 w2 -w5 ; -w4 w5 2*I w4 -w5 4*I]; 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneFrameInclinedSupport.m: -------------------------------------------------------------------------------- 1 | function y = PlaneFrameInclinedSupport(T,i,alpha) 2 | %PlaneFrameInclinedSupport This function calculates the 3 | % tranformation matrix T of the inclined 4 | % support at node i with angle of 5 | % inclination alpha (in degrees). 6 | x = alpha*pi/180; 7 | T(3*i-2,3*i-2) = cos(x); 8 | T(3*i-2,3*i-1) = sin(x); 9 | T(3*i-2,3*i) = 0; 10 | T(3*i-1,3*i-2) = -sin(x); 11 | T(3*i-1,3*i-1) = cos(x); 12 | T(3*i-1,3*i) = 0; 13 | T(3*i,3*i-2) = 0; 14 | T(3*i,3*i-1) = 0; 15 | T(3*i,3*i) = 1; 16 | y = T; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussAssemble.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussAssemble(K,k,i,j) 2 | %PlaneTrussAssemble This function assembles the element stiffness 3 | % matrix k of the plane truss element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 9 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 10 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 11 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 12 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 13 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 14 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 15 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 16 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 17 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 18 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 19 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 20 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 21 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 22 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 23 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 24 | y = K; 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussElementForce.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussElementForce(E,A,L,theta,u) 2 | %PlaneTrussElementForce This function returns the element force 3 | % given the modulus of elasticity E, the 4 | % cross-sectional area A, the length L, 5 | % the angle theta (in degrees), and the 6 | % element nodal displacement vector u. 7 | x = theta * pi/180; 8 | C = cos(x); 9 | S = sin(x); 10 | y = E*A/L*[-C -S C S]* u; 11 | 12 | 13 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussElementLength.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussElementLength(x1,y1,x2,y2) 2 | %PlaneTrussElementLength This function returns the length of the 3 | % plane truss element whose first node has 4 | % coordinates (x1,y1) and second node has 5 | % coordinates (x2,y2). 6 | y = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)); 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussElementStiffness(E,A,L, theta) 2 | %PlaneTrussElementStiffness This function returns the element 3 | % stiffness matrix for a plane truss 4 | % element with modulus of elasticity E, 5 | % cross-sectional area A, length L, and 6 | % angle theta (in degrees). 7 | % The size of the element stiffness 8 | % matrix is 4 x 4. 9 | x = theta*pi/180; 10 | C = cos(x); 11 | S = sin(x); 12 | y = E*A/L*[C*C C*S -C*C -C*S ; C*S S*S -C*S -S*S ; 13 | -C*C -C*S C*C C*S ; -C*S -S*S C*S S*S]; 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussElementStress.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussElementStress(E,L,theta,u) 2 | %PlaneTrussElementStress This function returns the element stress 3 | % given the modulus of elasticity E, the 4 | % the length L, the angle theta (in 5 | % degrees), and the element nodal 6 | % displacement vector u. 7 | x = theta * pi/180; 8 | C = cos(x); 9 | S = sin(x); 10 | y = E/L*[-C -S C S]* u; 11 | 12 | 13 | -------------------------------------------------------------------------------- /matlab 有限元源程序/PlaneTrussInclinedSupport.m: -------------------------------------------------------------------------------- 1 | function y = PlaneTrussInclinedSupport(T,i,alpha) 2 | %PlaneTrussInclinedSupport This function calculates the 3 | % tranformation matrix T of the inclined 4 | % support at node i with angle of 5 | % inclination alpha (in degrees). 6 | x = alpha*pi/180; 7 | T(2*i-1,2*i-1) = cos(x); 8 | T(2*i-1,2*i) = sin(x); 9 | T(2*i,2*i-1) = -sin(x) ; 10 | T(2*i,2*i) = cos(x); 11 | y = T; 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadTriangleAssemble.m: -------------------------------------------------------------------------------- 1 | function y = QuadTriangleAssemble(K,k,i,j,m,p,q,r) 2 | %QuadTriangleAssemble This function assembles the element 3 | % stiffness matrix k of the quadratic 4 | % triangular element with nodes i, j, 5 | % m, p, q, and r into the global 6 | % stiffness matrix K. 7 | % This function returns the global 8 | % stiffness matrix K after the element 9 | % stiffness matrix k is assembled. 10 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 11 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 12 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 13 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 14 | K(2*i-1,2*m-1) = K(2*i-1,2*m-1) + k(1,5); 15 | K(2*i-1,2*m) = K(2*i-1,2*m) + k(1,6); 16 | K(2*i-1,2*p-1) = K(2*i-1,2*p-1) + k(1,7); 17 | K(2*i-1,2*p) = K(2*i-1,2*p) + k(1,8); 18 | K(2*i-1,2*q-1) = K(2*i-1,2*q-1) + k(1,9); 19 | K(2*i-1,2*q) = K(2*i-1,2*q) + k(1,10); 20 | K(2*i-1,2*r-1) = K(2*i-1,2*r-1) + k(1,11); 21 | K(2*i-1,2*r) = K(2*i-1,2*r) + k(1,12); 22 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 23 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 24 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 25 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 26 | K(2*i,2*m-1) = K(2*i,2*m-1) + k(2,5); 27 | K(2*i,2*m) = K(2*i,2*m) + k(2,6); 28 | K(2*i,2*p-1) = K(2*i,2*p-1) + k(2,7); 29 | K(2*i,2*p) = K(2*i,2*p) + k(2,8); 30 | K(2*i,2*q-1) = K(2*i,2*q-1) + k(2,9); 31 | K(2*i,2*q) = K(2*i,2*q) + k(2,10); 32 | K(2*i,2*r-1) = K(2*i,2*r-1) + k(2,11); 33 | K(2*i,2*r) = K(2*i,2*r) + k(2,12); 34 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 35 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 36 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 37 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 38 | K(2*j-1,2*m-1) = K(2*j-1,2*m-1) + k(3,5); 39 | K(2*j-1,2*m) = K(2*j-1,2*m) + k(3,6); 40 | K(2*j-1,2*p-1) = K(2*j-1,2*p-1) + k(3,7); 41 | K(2*j-1,2*p) = K(2*j-1,2*p) + k(3,8); 42 | K(2*j-1,2*q-1) = K(2*j-1,2*q-1) + k(3,9); 43 | K(2*j-1,2*q) = K(2*j-1,2*q) + k(3,10); 44 | K(2*j-1,2*r-1) = K(2*j-1,2*r-1) + k(3,11); 45 | K(2*j-1,2*r) = K(2*j-1,2*r) + k(3,12); 46 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 47 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 48 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 49 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 50 | K(2*j,2*m-1) = K(2*j,2*m-1) + k(4,5); 51 | K(2*j,2*m) = K(2*j,2*m) + k(4,6); 52 | K(2*j,2*p-1) = K(2*j,2*p-1) + k(4,7); 53 | K(2*j,2*p) = K(2*j,2*p) + k(4,8); 54 | K(2*j,2*q-1) = K(2*j,2*q-1) + k(4,9); 55 | K(2*j,2*q) = K(2*j,2*q) + k(4,10); 56 | K(2*j,2*r-1) = K(2*j,2*r-1) + k(4,11); 57 | K(2*j,2*r) = K(2*j,2*r) + k(4,12); 58 | K(2*m-1,2*i-1) = K(2*m-1,2*i-1) + k(5,1); 59 | K(2*m-1,2*i) = K(2*m-1,2*i) + k(5,2); 60 | K(2*m-1,2*j-1) = K(2*m-1,2*j-1) + k(5,3); 61 | K(2*m-1,2*j) = K(2*m-1,2*j) + k(5,4); 62 | K(2*m-1,2*m-1) = K(2*m-1,2*m-1) + k(5,5); 63 | K(2*m-1,2*m) = K(2*m-1,2*m) + k(5,6); 64 | K(2*m-1,2*p-1) = K(2*m-1,2*p-1) + k(5,7); 65 | K(2*m-1,2*p) = K(2*m-1,2*p) + k(5,8); 66 | K(2*m-1,2*q-1) = K(2*m-1,2*q-1) + k(5,9); 67 | K(2*m-1,2*q) = K(2*m-1,2*q) + k(5,10); 68 | K(2*m-1,2*r-1) = K(2*m-1,2*r-1) + k(5,11); 69 | K(2*m-1,2*r) = K(2*m-1,2*r) + k(5,12); 70 | K(2*m,2*i-1) = K(2*m,2*i-1) + k(6,1); 71 | K(2*m,2*i) = K(2*m,2*i) + k(6,2); 72 | K(2*m,2*j-1) = K(2*m,2*j-1) + k(6,3); 73 | K(2*m,2*j) = K(2*m,2*j) + k(6,4); 74 | K(2*m,2*m-1) = K(2*m,2*m-1) + k(6,5); 75 | K(2*m,2*m) = K(2*m,2*m) + k(6,6); 76 | K(2*m,2*p-1) = K(2*m,2*p-1) + k(6,7); 77 | K(2*m,2*p) = K(2*m,2*p) + k(6,8); 78 | K(2*m,2*q-1) = K(2*m,2*q-1) + k(6,9); 79 | K(2*m,2*q) = K(2*m,2*q) + k(6,10); 80 | K(2*m,2*r-1) = K(2*m,2*r-1) + k(6,11); 81 | K(2*m,2*r) = K(2*m,2*r) + k(6,12); 82 | K(2*p-1,2*i-1) = K(2*p-1,2*i-1) + k(7,1); 83 | K(2*p-1,2*i) = K(2*p-1,2*i) + k(7,2); 84 | K(2*p-1,2*j-1) = K(2*p-1,2*j-1) + k(7,3); 85 | K(2*p-1,2*j) = K(2*p-1,2*j) + k(7,4); 86 | K(2*p-1,2*m-1) = K(2*p-1,2*m-1) + k(7,5); 87 | K(2*p-1,2*m) = K(2*p-1,2*m) + k(7,6); 88 | K(2*p-1,2*p-1) = K(2*p-1,2*p-1) + k(7,7); 89 | K(2*p-1,2*p) = K(2*p-1,2*p) + k(7,8); 90 | K(2*p-1,2*q-1) = K(2*p-1,2*q-1) + k(7,9); 91 | K(2*p-1,2*q) = K(2*p-1,2*q) + k(7,10); 92 | K(2*p-1,2*r-1) = K(2*p-1,2*r-1) + k(7,11); 93 | K(2*p-1,2*r) = K(2*p-1,2*r) + k(7,12); 94 | K(2*p,2*i-1) = K(2*p,2*i-1) + k(8,1); 95 | K(2*p,2*i) = K(2*p,2*i) + k(8,2); 96 | K(2*p,2*j-1) = K(2*p,2*j-1) + k(8,3); 97 | K(2*p,2*j) = K(2*p,2*j) + k(8,4); 98 | K(2*p,2*m-1) = K(2*p,2*m-1) + k(8,5); 99 | K(2*p,2*m) = K(2*p,2*m) + k(8,6); 100 | K(2*p,2*p-1) = K(2*p,2*p-1) + k(8,7); 101 | K(2*p,2*p) = K(2*p,2*p) + k(8,8); 102 | K(2*p,2*q-1) = K(2*p,2*q-1) + k(8,9); 103 | K(2*p,2*q) = K(2*p,2*q) + k(8,10); 104 | K(2*p,2*r-1) = K(2*p,2*r-1) + k(8,11); 105 | K(2*p,2*r) = K(2*p,2*r) + k(8,12); 106 | K(2*q-1,2*i-1) = K(2*q-1,2*i-1) + k(9,1); 107 | K(2*q-1,2*i) = K(2*q-1,2*i) + k(9,2); 108 | K(2*q-1,2*j-1) = K(2*q-1,2*j-1) + k(9,3); 109 | K(2*q-1,2*j) = K(2*q-1,2*j) + k(9,4); 110 | K(2*q-1,2*m-1) = K(2*q-1,2*m-1) + k(9,5); 111 | K(2*q-1,2*m) = K(2*q-1,2*m) + k(9,6); 112 | K(2*q-1,2*p-1) = K(2*q-1,2*p-1) + k(9,7); 113 | K(2*q-1,2*p) = K(2*q-1,2*p) + k(9,8); 114 | K(2*q-1,2*q-1) = K(2*q-1,2*q-1) + k(9,9); 115 | K(2*q-1,2*q) = K(2*q-1,2*q) + k(9,10); 116 | K(2*q-1,2*r-1) = K(2*q-1,2*r-1) + k(9,11); 117 | K(2*q-1,2*r) = K(2*q-1,2*r) + k(9,12); 118 | K(2*q,2*i-1) = K(2*q,2*i-1) + k(10,1); 119 | K(2*q,2*i) = K(2*q,2*i) + k(10,2); 120 | K(2*q,2*j-1) = K(2*q,2*j-1) + k(10,3); 121 | K(2*q,2*j) = K(2*q,2*j) + k(10,4); 122 | K(2*q,2*m-1) = K(2*q,2*m-1) + k(10,5); 123 | K(2*q,2*m) = K(2*q,2*m) + k(10,6); 124 | K(2*q,2*p-1) = K(2*q,2*p-1) + k(10,7); 125 | K(2*q,2*p) = K(2*q,2*p) + k(10,8); 126 | K(2*q,2*q-1) = K(2*q,2*q-1) + k(10,9); 127 | K(2*q,2*q) = K(2*q,2*q) + k(10,10); 128 | K(2*q,2*r-1) = K(2*q,2*r-1) + k(10,11); 129 | K(2*q,2*r) = K(2*q,2*r) + k(10,12); 130 | K(2*r-1,2*i-1) = K(2*r-1,2*i-1) + k(11,1); 131 | K(2*r-1,2*i) = K(2*r-1,2*i) + k(11,2); 132 | K(2*r-1,2*j-1) = K(2*r-1,2*j-1) + k(11,3); 133 | K(2*r-1,2*j) = K(2*r-1,2*j) + k(11,4); 134 | K(2*r-1,2*m-1) = K(2*r-1,2*m-1) + k(11,5); 135 | K(2*r-1,2*m) = K(2*r-1,2*m) + k(11,6); 136 | K(2*r-1,2*p-1) = K(2*r-1,2*p-1) + k(11,7); 137 | K(2*r-1,2*p) = K(2*r-1,2*p) + k(11,8); 138 | K(2*r-1,2*q-1) = K(2*r-1,2*q-1) + k(11,9); 139 | K(2*r-1,2*q) = K(2*r-1,2*q) + k(11,10); 140 | K(2*r-1,2*r-1) = K(2*r-1,2*r-1) + k(11,11); 141 | K(2*r-1,2*r) = K(2*r-1,2*r) + k(11,12); 142 | K(2*r,2*i-1) = K(2*r,2*i-1) + k(12,1); 143 | K(2*r,2*i) = K(2*r,2*i) + k(12,2); 144 | K(2*r,2*j-1) = K(2*r,2*j-1) + k(12,3); 145 | K(2*r,2*j) = K(2*r,2*j) + k(12,4); 146 | K(2*r,2*m-1) = K(2*r,2*m-1) + k(12,5); 147 | K(2*r,2*m) = K(2*r,2*m) + k(12,6); 148 | K(2*r,2*p-1) = K(2*r,2*p-1) + k(12,7); 149 | K(2*r,2*p) = K(2*r,2*p) + k(12,8); 150 | K(2*r,2*q-1) = K(2*r,2*q-1) + k(12,9); 151 | K(2*r,2*q) = K(2*r,2*q) + k(12,10); 152 | K(2*r,2*r-1) = K(2*r,2*r-1) + k(12,11); 153 | K(2*r,2*r) = K(2*r,2*r) + k(12,12); 154 | y = K; 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadTriangleElementArea.m: -------------------------------------------------------------------------------- 1 | function y = QuadTriangleElementArea(x1,y1,x2,y2,x3,y3) 2 | %QuadTriangleElementArea This function returns the area of the 3 | % quadratic triangular element whose first 4 | % node has coordinates (x1,y1), second 5 | % node has coordinates (x2,y2), and 6 | % third node has coordinates (x3,y3). 7 | y = (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2; 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadTriangleElementPStresses.m: -------------------------------------------------------------------------------- 1 | function y = QuadTriangleElementPStresses(sigma) 2 | %QuadTriangleElementPStresses This function returns the element 3 | % principal stresses and their 4 | % angle given the element 5 | % stress vector. 6 | R = (sigma(1) + sigma(2))/2; 7 | Q = ((sigma(1) - sigma(2))/2)^2 + sigma(3)*sigma(3); 8 | M = 2*sigma(3)/(sigma(1) - sigma(2)); 9 | s1 = R + sqrt(Q); 10 | s2 = R - sqrt(Q); 11 | theta = (atan(M)/2)*180/pi; 12 | y = [s1 ; s2 ; theta]; 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadTriangleElementStiffness.m: -------------------------------------------------------------------------------- 1 | function w = QuadTriangleElementStiffness(E,NU,t,x1,y1,x2,y2,x3,y3,p) 2 | %QuadTriangleElementStiffness This function returns the element 3 | % stiffness matrix for a quadratic 4 | % triangular element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, thickness t, coordinates of 7 | % the node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), and 9 | % coordinates of node 3 10 | % (x3,y3). Use p = 1 for cases of 11 | % plane stress, and p = 2 for 12 | % cases of plane strain. 13 | % The size of the element 14 | % stiffness matrix is 12 x 12. 15 | syms x y; 16 | x4 = (x1 + x2)/2; 17 | y4 = (y1 + y2)/2; 18 | x5 = (x2 + x3)/2; 19 | y5 = (y2 + y3)/2; 20 | x6 = (x1 + x3)/2; 21 | y6 = (y1 + y3)/2; 22 | x21 = x2 - x1; 23 | y21 = y2 - y1; 24 | x23 = x2 - x3; 25 | y23 = y2 - y3; 26 | x46 = x4 - x6; 27 | y46 = y4 - y6; 28 | x13 = x1 - x3; 29 | y13 = y1 - y3; 30 | x16 = x1 - x6; 31 | y16 = y1 - y6; 32 | x31 = x3 - x1; 33 | y31 = y3 - y1; 34 | x54 = x5 - x4; 35 | y54 = y5 - y4; 36 | x24 = x2 - x4; 37 | y24 = y2 - y4; 38 | x56 = x5 - x6; 39 | y56 = y5 - y6; 40 | x36 = x3 - x6; 41 | y36 = y3 - y6; 42 | x41 = x4 - x1; 43 | y41 = y4 - y1; 44 | x43 = x4 - x3; 45 | y43 = y4 - y3; 46 | x51 = x5 - x1; 47 | y51 = y5 - y1; 48 | x61 = x6 - x1; 49 | y61 = y6 - y1; 50 | x63 = x6 - x3; 51 | y63 = y6 - y3; 52 | N1 = (x23*(y-y3)-y23*(x-x3))*(x46*(y-y6)-y46*(x-x6))/((x23*y13-y23*x13)*(x46*y16-y46*x16)); 53 | N2 = (x31*(y-y1)-y31*(x-x1))*(x54*(y-y4)-y54*(x-x4))/((x31*y21-y31*x21)*(x54*y24-y54*x24)); 54 | N3 = (x21*(y-y1)-y21*(x-x1))*(x56*(y-y6)-y56*(x-x6))/((x21*y31-y21*x31)*(x56*y36-y56*x36)); 55 | N4 = (x31*(y-y1)-y31*(x-x1))*(x23*(y-y3)-y23*(x-x3))/((x31*y41-y31*x41)*(x23*y43-y23*x43)); 56 | N5 = (x31*(y-y1)-y31*(x-x1))*(x21*(y-y1)-y21*(x-x1))/((x31*y51-y31*x51)*(x21*y51-y21*x51)); 57 | N6 = (x21*(y-y1)-y21*(x-x1))*(x23*(y-y3)-y23*(x-x3))/((x21*y61-y21*x61)*(x23*y63-y23*x63)); 58 | N1x = diff(N1,x); 59 | N1y = diff(N1,y); 60 | N2x = diff(N2,x); 61 | N2y = diff(N2,y); 62 | N3x = diff(N3,x); 63 | N3y = diff(N3,y); 64 | N4x = diff(N4,x); 65 | N4y = diff(N4,y); 66 | N5x = diff(N5,x); 67 | N5y = diff(N5,y); 68 | N6x = diff(N6,x); 69 | N6y = diff(N6,y); 70 | B = [N1x, 0, N2x, 0, N3x, 0, N4x, 0, N5x, 0, N6x, 0 ; 71 | 0, N1y, 0, N2y, 0, N3y, 0, N4y, 0, N5y, 0, N6y; 72 | N1y, N1x, N2y, N2x, N3y, N3x, N4y, N4x, N5y, N5x, N6y, N6x]; 73 | if p == 1 74 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 75 | elseif p == 2 76 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 77 | end 78 | BD = transpose(B)*D*B; 79 | l1 = y1 + (x-x1)*(y2-y1)/(x2-x1); 80 | l2 = y1 + (x-x1)*(y3-y1)/(x3-x1); 81 | l3 = y2 + (x-x2)*(y3-y2)/(x3-x2); 82 | r1 = int(int(BD, y, l1, l2), x, x1, x3); 83 | r2 = int(int(BD, y, l1, l3), x, x3, x2); 84 | z = t*(r1+r2); 85 | w = double(z); 86 | 87 | 88 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadTriangleElementStresses.m: -------------------------------------------------------------------------------- 1 | function w = QuadTriangleElementSresses(E,NU,t,x1,y1,x2,y2,x3,y3,p,u) 2 | %QuadTriangleElementStresses This function returns the element 3 | % stresses for a quadratic 4 | % triangular element with modulus of 5 | % elasticity E, Poisson's ratio NU, 6 | % thickness t, coordinates of the 7 | % node 1 (x1,y1), coordinates of 8 | % node 2 (x2,y2), 9 | % coordinates of node 3 10 | % (x3,y3), and element displacement 11 | % vector u. Use p = 1 for cases of 12 | % plane stress, and p = 2 for cases 13 | % of plane strain. 14 | % The size of the element stiffness 15 | % matrix is 12 x 12. 16 | syms x y; 17 | x4 = (x1 + x2)/2; 18 | y4 = (y1 + y2)/2; 19 | x5 = (x2 + x3)/2; 20 | y5 = (y2 + y3)/2; 21 | x6 = (x1 + x3)/2; 22 | y6 = (y1 + y3)/2; 23 | x21 = x2 - x1; 24 | y21 = y2 - y1; 25 | x23 = x2 - x3; 26 | y23 = y2 - y3; 27 | x46 = x4 - x6; 28 | y46 = y4 - y6; 29 | x13 = x1 - x3; 30 | y13 = y1 - y3; 31 | x16 = x1 - x6; 32 | y16 = y1 - y6; 33 | x31 = x3 - x1; 34 | y31 = y3 - y1; 35 | x54 = x5 - x4; 36 | y54 = y5 - y4; 37 | x24 = x2 - x4; 38 | y24 = y2 - y4; 39 | x56 = x5 - x6; 40 | y56 = y5 - y6; 41 | x36 = x3 - x6; 42 | y36 = y3 - y6; 43 | x41 = x4 - x1; 44 | y41 = y4 - y1; 45 | x43 = x4 - x3; 46 | y43 = y4 - y3; 47 | x51 = x5 - x1; 48 | y51 = y5 - y1; 49 | x61 = x6 - x1; 50 | y61 = y6 - y1; 51 | x63 = x6 - x3; 52 | y63 = y6 - y3; 53 | N1 = (x23*(y-y3)-y23*(x-x3))*(x46*(y-y6)-y46*(x-x6))/((x23*y13-y23*x13)*(x46*y16-y46*x16)); 54 | N2 = (x31*(y-y1)-y31*(x-x1))*(x54*(y-y4)-y54*(x-x4))/((x31*y21-y31*x21)*(x54*y24-y54*x24)); 55 | N3 = (x21*(y-y1)-y21*(x-x1))*(x56*(y-y6)-y56*(x-x6))/((x21*y31-y21*x31)*(x56*y36-y56*x36)); 56 | N4 = (x31*(y-y1)-y31*(x-x1))*(x23*(y-y3)-y23*(x-x3))/((x31*y41-y31*x41)*(x23*y43-y23*x43)); 57 | N5 = (x31*(y-y1)-y31*(x-x1))*(x21*(y-y1)-y21*(x-x1))/((x31*y51-y31*x51)*(x21*y51-y21*x51)); 58 | N6 = (x21*(y-y1)-y21*(x-x1))*(x23*(y-y3)-y23*(x-x3))/((x21*y61-y21*x61)*(x23*y63-y23*x63)); 59 | N1x = diff(N1,x); 60 | N1y = diff(N1,y); 61 | N2x = diff(N2,x); 62 | N2y = diff(N2,y); 63 | N3x = diff(N3,x); 64 | N3y = diff(N3,y); 65 | N4x = diff(N4,x); 66 | N4y = diff(N4,y); 67 | N5x = diff(N5,x); 68 | N5y = diff(N5,y); 69 | N6x = diff(N6,x); 70 | N6y = diff(N6,y); 71 | B = [N1x, 0, N2x, 0, N3x, 0, N4x, 0, N5x, 0, N6x, 0 ; 72 | 0, N1y, 0, N2y, 0, N3y, 0, N4y, 0, N5y, 0, N6y; 73 | N1y, N1x, N2y, N2x, N3y, N3x, N4y, N4x, N5y, N5x, N6y, N6x]; 74 | if p == 1 75 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 76 | elseif p == 2 77 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 78 | end 79 | w = D*B*u 80 | % 81 | % We also calculate the stresses at the centroid of the element 82 | % 83 | xcent = (x1 + x2 + x3)/3; 84 | ycent = (y1 + y2 + y3)/3; 85 | wcent = subs(w, {x,y}, {xcent,ycent}); 86 | w = double(wcent); 87 | 88 | 89 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticBarAssemble.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticBarAssemble(K,k,i,j,m) 2 | %QuadraticBarAssemble This function assembles the element stiffness 3 | % matrix k of the quadratic bar with nodes i, j 4 | % and m into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(i,i) = K(i,i) + k(1,1); 9 | K(i,j) = K(i,j) + k(1,2); 10 | K(i,m) = K(i,m) + k(1,3); 11 | K(j,i) = K(j,i) + k(2,1); 12 | K(j,j) = K(j,j) + k(2,2); 13 | K(j,m) = K(j,m) + k(2,3); 14 | K(m,i) = K(m,i) + k(3,1); 15 | K(m,j) = K(m,j) + k(3,2); 16 | K(m,m) = K(m,m) + k(3,3); 17 | y = K; 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticBarElementForces.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticBarElementForces(k,u) 2 | %QuadraticBarElementForces This function returns the element nodal 3 | % force vector given the element stiffness 4 | % matrix k and the element nodal 5 | % displacement vector u. 6 | y = k * u; 7 | 8 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticBarElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticBarElementStiffness(E,A,L) 2 | %QuadraticBarElementStiffness This function returns the element 3 | % stiffness matrix for a quadratic bar 4 | % with modulus of elasticity E, 5 | % cross-sectional area A, and length L. 6 | % The size of the element stiffness 7 | % matrix is 3 x 3. 8 | y = E*A/(3*L)*[7 1 -8 ; 1 7 -8 ; -8 -8 16]; 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticBarElementStresses.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticBarElementStresses(k, u, A) 2 | %QuadraticBarElementStresses This function returns the element 3 | % nodal stress vector given the element 4 | % stiffness matrix k, the element nodal 5 | % displacement vector u, and the 6 | % cross-sectional area A. 7 | y = k * u/A; 8 | 9 | 10 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticQuadAssemble.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticQuadAssemble(K,k,i,j,m,p,q,r,s,t) 2 | %QuadraticQuadAssemble This function assembles the element 3 | % stiffness matrix k of the quadratic 4 | % quadrilateral element with nodes i, j, 5 | % m, p, q, r, s, and t into the global 6 | % stiffness matrix K. 7 | % This function returns the global 8 | % stiffness matrix K after the element 9 | % stiffness matrix k is assembled. 10 | K(2*i-1,2*i-1) = K(2*i-1,2*i-1) + k(1,1); 11 | K(2*i-1,2*i) = K(2*i-1,2*i) + k(1,2); 12 | K(2*i-1,2*j-1) = K(2*i-1,2*j-1) + k(1,3); 13 | K(2*i-1,2*j) = K(2*i-1,2*j) + k(1,4); 14 | K(2*i-1,2*m-1) = K(2*i-1,2*m-1) + k(1,5); 15 | K(2*i-1,2*m) = K(2*i-1,2*m) + k(1,6); 16 | K(2*i-1,2*p-1) = K(2*i-1,2*p-1) + k(1,7); 17 | K(2*i-1,2*p) = K(2*i-1,2*p) + k(1,8); 18 | K(2*i-1,2*q-1) = K(2*i-1,2*q-1) + k(1,9); 19 | K(2*i-1,2*q) = K(2*i-1,2*q) + k(1,10); 20 | K(2*i-1,2*r-1) = K(2*i-1,2*r-1) + k(1,11); 21 | K(2*i-1,2*r) = K(2*i-1,2*r) + k(1,12); 22 | K(2*i-1,2*s-1) = K(2*i-1,2*s-1) + k(1,13); 23 | K(2*i-1,2*s) = K(2*i-1,2*s) + k(1,14); 24 | K(2*i-1,2*t-1) = K(2*i-1,2*t-1) + k(1,15); 25 | K(2*i-1,2*t) = K(2*i-1,2*t) + k(1,16); 26 | K(2*i,2*i-1) = K(2*i,2*i-1) + k(2,1); 27 | K(2*i,2*i) = K(2*i,2*i) + k(2,2); 28 | K(2*i,2*j-1) = K(2*i,2*j-1) + k(2,3); 29 | K(2*i,2*j) = K(2*i,2*j) + k(2,4); 30 | K(2*i,2*m-1) = K(2*i,2*m-1) + k(2,5); 31 | K(2*i,2*m) = K(2*i,2*m) + k(2,6); 32 | K(2*i,2*p-1) = K(2*i,2*p-1) + k(2,7); 33 | K(2*i,2*p) = K(2*i,2*p) + k(2,8); 34 | K(2*i,2*q-1) = K(2*i,2*q-1) + k(2,9); 35 | K(2*i,2*q) = K(2*i,2*q) + k(2,10); 36 | K(2*i,2*r-1) = K(2*i,2*r-1) + k(2,11); 37 | K(2*i,2*r) = K(2*i,2*r) + k(2,12); 38 | K(2*i,2*s-1) = K(2*i,2*s-1) + k(2,13); 39 | K(2*i,2*s) = K(2*i,2*s) + k(2,14); 40 | K(2*i,2*t-1) = K(2*i,2*t-1) + k(2,15); 41 | K(2*i,2*t) = K(2*i,2*t) + k(2,16); 42 | K(2*j-1,2*i-1) = K(2*j-1,2*i-1) + k(3,1); 43 | K(2*j-1,2*i) = K(2*j-1,2*i) + k(3,2); 44 | K(2*j-1,2*j-1) = K(2*j-1,2*j-1) + k(3,3); 45 | K(2*j-1,2*j) = K(2*j-1,2*j) + k(3,4); 46 | K(2*j-1,2*m-1) = K(2*j-1,2*m-1) + k(3,5); 47 | K(2*j-1,2*m) = K(2*j-1,2*m) + k(3,6); 48 | K(2*j-1,2*p-1) = K(2*j-1,2*p-1) + k(3,7); 49 | K(2*j-1,2*p) = K(2*j-1,2*p) + k(3,8); 50 | K(2*j-1,2*q-1) = K(2*j-1,2*q-1) + k(3,9); 51 | K(2*j-1,2*q) = K(2*j-1,2*q) + k(3,10); 52 | K(2*j-1,2*r-1) = K(2*j-1,2*r-1) + k(3,11); 53 | K(2*j-1,2*r) = K(2*j-1,2*r) + k(3,12); 54 | K(2*j-1,2*s-1) = K(2*j-1,2*s-1) + k(3,13); 55 | K(2*j-1,2*s) = K(2*j-1,2*s) + k(3,14); 56 | K(2*j-1,2*t-1) = K(2*j-1,2*t-1) + k(3,15); 57 | K(2*j-1,2*t) = K(2*j-1,2*t) + k(3,16); 58 | K(2*j,2*i-1) = K(2*j,2*i-1) + k(4,1); 59 | K(2*j,2*i) = K(2*j,2*i) + k(4,2); 60 | K(2*j,2*j-1) = K(2*j,2*j-1) + k(4,3); 61 | K(2*j,2*j) = K(2*j,2*j) + k(4,4); 62 | K(2*j,2*m-1) = K(2*j,2*m-1) + k(4,5); 63 | K(2*j,2*m) = K(2*j,2*m) + k(4,6); 64 | K(2*j,2*p-1) = K(2*j,2*p-1) + k(4,7); 65 | K(2*j,2*p) = K(2*j,2*p) + k(4,8); 66 | K(2*j,2*q-1) = K(2*j,2*q-1) + k(4,9); 67 | K(2*j,2*q) = K(2*j,2*q) + k(4,10); 68 | K(2*j,2*r-1) = K(2*j,2*r-1) + k(4,11); 69 | K(2*j,2*r) = K(2*j,2*r) + k(4,12); 70 | K(2*j,2*s-1) = K(2*j,2*s-1) + k(4,13); 71 | K(2*j,2*s) = K(2*j,2*s) + k(4,14); 72 | K(2*j,2*t-1) = K(2*j,2*t-1) + k(4,15); 73 | K(2*j,2*t) = K(2*j,2*t) + k(4,16); 74 | K(2*m-1,2*i-1) = K(2*m-1,2*i-1) + k(5,1); 75 | K(2*m-1,2*i) = K(2*m-1,2*i) + k(5,2); 76 | K(2*m-1,2*j-1) = K(2*m-1,2*j-1) + k(5,3); 77 | K(2*m-1,2*j) = K(2*m-1,2*j) + k(5,4); 78 | K(2*m-1,2*m-1) = K(2*m-1,2*m-1) + k(5,5); 79 | K(2*m-1,2*m) = K(2*m-1,2*m) + k(5,6); 80 | K(2*m-1,2*p-1) = K(2*m-1,2*p-1) + k(5,7); 81 | K(2*m-1,2*p) = K(2*m-1,2*p) + k(5,8); 82 | K(2*m-1,2*q-1) = K(2*m-1,2*q-1) + k(5,9); 83 | K(2*m-1,2*q) = K(2*m-1,2*q) + k(5,10); 84 | K(2*m-1,2*r-1) = K(2*m-1,2*r-1) + k(5,11); 85 | K(2*m-1,2*r) = K(2*m-1,2*r) + k(5,12); 86 | K(2*m-1,2*s-1) = K(2*m-1,2*s-1) + k(5,13); 87 | K(2*m-1,2*s) = K(2*m-1,2*s) + k(5,14); 88 | K(2*m-1,2*t-1) = K(2*m-1,2*t-1) + k(5,15); 89 | K(2*m-1,2*t) = K(2*m-1,2*t) + k(5,16); 90 | K(2*m,2*i-1) = K(2*m,2*i-1) + k(6,1); 91 | K(2*m,2*i) = K(2*m,2*i) + k(6,2); 92 | K(2*m,2*j-1) = K(2*m,2*j-1) + k(6,3); 93 | K(2*m,2*j) = K(2*m,2*j) + k(6,4); 94 | K(2*m,2*m-1) = K(2*m,2*m-1) + k(6,5); 95 | K(2*m,2*m) = K(2*m,2*m) + k(6,6); 96 | K(2*m,2*p-1) = K(2*m,2*p-1) + k(6,7); 97 | K(2*m,2*p) = K(2*m,2*p) + k(6,8); 98 | K(2*m,2*q-1) = K(2*m,2*q-1) + k(6,9); 99 | K(2*m,2*q) = K(2*m,2*q) + k(6,10); 100 | K(2*m,2*r-1) = K(2*m,2*r-1) + k(6,11); 101 | K(2*m,2*r) = K(2*m,2*r) + k(6,12); 102 | K(2*m,2*s-1) = K(2*m,2*s-1) + k(6,13); 103 | K(2*m,2*s) = K(2*m,2*s) + k(6,14); 104 | K(2*m,2*t-1) = K(2*m,2*t-1) + k(6,15); 105 | K(2*m,2*t) = K(2*m,2*t) + k(6,16); 106 | K(2*p-1,2*i-1) = K(2*p-1,2*i-1) + k(7,1); 107 | K(2*p-1,2*i) = K(2*p-1,2*i) + k(7,2); 108 | K(2*p-1,2*j-1) = K(2*p-1,2*j-1) + k(7,3); 109 | K(2*p-1,2*j) = K(2*p-1,2*j) + k(7,4); 110 | K(2*p-1,2*m-1) = K(2*p-1,2*m-1) + k(7,5); 111 | K(2*p-1,2*m) = K(2*p-1,2*m) + k(7,6); 112 | K(2*p-1,2*p-1) = K(2*p-1,2*p-1) + k(7,7); 113 | K(2*p-1,2*p) = K(2*p-1,2*p) + k(7,8); 114 | K(2*p-1,2*q-1) = K(2*p-1,2*q-1) + k(7,9); 115 | K(2*p-1,2*q) = K(2*p-1,2*q) + k(7,10); 116 | K(2*p-1,2*r-1) = K(2*p-1,2*r-1) + k(7,11); 117 | K(2*p-1,2*r) = K(2*p-1,2*r) + k(7,12); 118 | K(2*p-1,2*s-1) = K(2*p-1,2*s-1) + k(7,13); 119 | K(2*p-1,2*s) = K(2*p-1,2*s) + k(7,14); 120 | K(2*p-1,2*t-1) = K(2*p-1,2*t-1) + k(7,15); 121 | K(2*p-1,2*t) = K(2*p-1,2*t) + k(7,16); 122 | K(2*p,2*i-1) = K(2*p,2*i-1) + k(8,1); 123 | K(2*p,2*i) = K(2*p,2*i) + k(8,2); 124 | K(2*p,2*j-1) = K(2*p,2*j-1) + k(8,3); 125 | K(2*p,2*j) = K(2*p,2*j) + k(8,4); 126 | K(2*p,2*m-1) = K(2*p,2*m-1) + k(8,5); 127 | K(2*p,2*m) = K(2*p,2*m) + k(8,6); 128 | K(2*p,2*p-1) = K(2*p,2*p-1) + k(8,7); 129 | K(2*p,2*p) = K(2*p,2*p) + k(8,8); 130 | K(2*p,2*q-1) = K(2*p,2*q-1) + k(8,9); 131 | K(2*p,2*q) = K(2*p,2*q) + k(8,10); 132 | K(2*p,2*r-1) = K(2*p,2*r-1) + k(8,11); 133 | K(2*p,2*r) = K(2*p,2*r) + k(8,12); 134 | K(2*p,2*s-1) = K(2*p,2*s-1) + k(8,13); 135 | K(2*p,2*s) = K(2*p,2*s) + k(8,14); 136 | K(2*p,2*t-1) = K(2*p,2*t-1) + k(8,15); 137 | K(2*p,2*t) = K(2*p,2*t) + k(8,16); 138 | K(2*q-1,2*i-1) = K(2*q-1,2*i-1) + k(9,1); 139 | K(2*q-1,2*i) = K(2*q-1,2*i) + k(9,2); 140 | K(2*q-1,2*j-1) = K(2*q-1,2*j-1) + k(9,3); 141 | K(2*q-1,2*j) = K(2*q-1,2*j) + k(9,4); 142 | K(2*q-1,2*m-1) = K(2*q-1,2*m-1) + k(9,5); 143 | K(2*q-1,2*m) = K(2*q-1,2*m) + k(9,6); 144 | K(2*q-1,2*p-1) = K(2*q-1,2*p-1) + k(9,7); 145 | K(2*q-1,2*p) = K(2*q-1,2*p) + k(9,8); 146 | K(2*q-1,2*q-1) = K(2*q-1,2*q-1) + k(9,9); 147 | K(2*q-1,2*q) = K(2*q-1,2*q) + k(9,10); 148 | K(2*q-1,2*r-1) = K(2*q-1,2*r-1) + k(9,11); 149 | K(2*q-1,2*r) = K(2*q-1,2*r) + k(9,12); 150 | K(2*q-1,2*s-1) = K(2*q-1,2*s-1) + k(9,13); 151 | K(2*q-1,2*s) = K(2*q-1,2*s) + k(9,14); 152 | K(2*q-1,2*t-1) = K(2*q-1,2*t-1) + k(9,15); 153 | K(2*q-1,2*t) = K(2*q-1,2*t) + k(9,16); 154 | K(2*q,2*i-1) = K(2*q,2*i-1) + k(10,1); 155 | K(2*q,2*i) = K(2*q,2*i) + k(10,2); 156 | K(2*q,2*j-1) = K(2*q,2*j-1) + k(10,3); 157 | K(2*q,2*j) = K(2*q,2*j) + k(10,4); 158 | K(2*q,2*m-1) = K(2*q,2*m-1) + k(10,5); 159 | K(2*q,2*m) = K(2*q,2*m) + k(10,6); 160 | K(2*q,2*p-1) = K(2*q,2*p-1) + k(10,7); 161 | K(2*q,2*p) = K(2*q,2*p) + k(10,8); 162 | K(2*q,2*q-1) = K(2*q,2*q-1) + k(10,9); 163 | K(2*q,2*q) = K(2*q,2*q) + k(10,10); 164 | K(2*q,2*r-1) = K(2*q,2*r-1) + k(10,11); 165 | K(2*q,2*r) = K(2*q,2*r) + k(10,12); 166 | K(2*q,2*s-1) = K(2*q,2*s-1) + k(10,13); 167 | K(2*q,2*s) = K(2*q,2*s) + k(10,14); 168 | K(2*q,2*t-1) = K(2*q,2*t-1) + k(10,15); 169 | K(2*q,2*t) = K(2*q,2*t) + k(10,16); 170 | K(2*r-1,2*i-1) = K(2*r-1,2*i-1) + k(11,1); 171 | K(2*r-1,2*i) = K(2*r-1,2*i) + k(11,2); 172 | K(2*r-1,2*j-1) = K(2*r-1,2*j-1) + k(11,3); 173 | K(2*r-1,2*j) = K(2*r-1,2*j) + k(11,4); 174 | K(2*r-1,2*m-1) = K(2*r-1,2*m-1) + k(11,5); 175 | K(2*r-1,2*m) = K(2*r-1,2*m) + k(11,6); 176 | K(2*r-1,2*p-1) = K(2*r-1,2*p-1) + k(11,7); 177 | K(2*r-1,2*p) = K(2*r-1,2*p) + k(11,8); 178 | K(2*r-1,2*q-1) = K(2*r-1,2*q-1) + k(11,9); 179 | K(2*r-1,2*q) = K(2*r-1,2*q) + k(11,10); 180 | K(2*r-1,2*r-1) = K(2*r-1,2*r-1) + k(11,11); 181 | K(2*r-1,2*r) = K(2*r-1,2*r) + k(11,12); 182 | K(2*r-1,2*s-1) = K(2*r-1,2*s-1) + k(11,13); 183 | K(2*r-1,2*s) = K(2*r-1,2*s) + k(11,14); 184 | K(2*r-1,2*t-1) = K(2*r-1,2*t-1) + k(11,15); 185 | K(2*r-1,2*t) = K(2*r-1,2*t) + k(11,16); 186 | K(2*r,2*i-1) = K(2*r,2*i-1) + k(12,1); 187 | K(2*r,2*i) = K(2*r,2*i) + k(12,2); 188 | K(2*r,2*j-1) = K(2*r,2*j-1) + k(12,3); 189 | K(2*r,2*j) = K(2*r,2*j) + k(12,4); 190 | K(2*r,2*m-1) = K(2*r,2*m-1) + k(12,5); 191 | K(2*r,2*m) = K(2*r,2*m) + k(12,6); 192 | K(2*r,2*p-1) = K(2*r,2*p-1) + k(12,7); 193 | K(2*r,2*p) = K(2*r,2*p) + k(12,8); 194 | K(2*r,2*q-1) = K(2*r,2*q-1) + k(12,9); 195 | K(2*r,2*q) = K(2*r,2*q) + k(12,10); 196 | K(2*r,2*r-1) = K(2*r,2*r-1) + k(12,11); 197 | K(2*r,2*r) = K(2*r,2*r) + k(12,12); 198 | K(2*r,2*s-1) = K(2*r,2*s-1) + k(12,13); 199 | K(2*r,2*s) = K(2*r,2*s) + k(12,14); 200 | K(2*r,2*t-1) = K(2*r,2*t-1) + k(12,15); 201 | K(2*r,2*t) = K(2*r,2*t) + k(12,16); 202 | K(2*s-1,2*i-1) = K(2*s-1,2*i-1) + k(13,1); 203 | K(2*s-1,2*i) = K(2*s-1,2*i) + k(13,2); 204 | K(2*s-1,2*j-1) = K(2*s-1,2*j-1) + k(13,3); 205 | K(2*s-1,2*j) = K(2*s-1,2*j) + k(13,4); 206 | K(2*s-1,2*m-1) = K(2*s-1,2*m-1) + k(13,5); 207 | K(2*s-1,2*m) = K(2*s-1,2*m) + k(13,6); 208 | K(2*s-1,2*p-1) = K(2*s-1,2*p-1) + k(13,7); 209 | K(2*s-1,2*p) = K(2*s-1,2*p) + k(13,8); 210 | K(2*s-1,2*q-1) = K(2*s-1,2*q-1) + k(13,9); 211 | K(2*s-1,2*q) = K(2*s-1,2*q) + k(13,10); 212 | K(2*s-1,2*r-1) = K(2*s-1,2*r-1) + k(13,11); 213 | K(2*s-1,2*r) = K(2*s-1,2*r) + k(13,12); 214 | K(2*s-1,2*s-1) = K(2*s-1,2*s-1) + k(13,13); 215 | K(2*s-1,2*s) = K(2*s-1,2*s) + k(13,14); 216 | K(2*s-1,2*t-1) = K(2*s-1,2*t-1) + k(13,15); 217 | K(2*s-1,2*t) = K(2*s-1,2*t) + k(13,16); 218 | K(2*s,2*i-1) = K(2*s,2*i-1) + k(14,1); 219 | K(2*s,2*i) = K(2*s,2*i) + k(14,2); 220 | K(2*s,2*j-1) = K(2*s,2*j-1) + k(14,3); 221 | K(2*s,2*j) = K(2*s,2*j) + k(14,4); 222 | K(2*s,2*m-1) = K(2*s,2*m-1) + k(14,5); 223 | K(2*s,2*m) = K(2*s,2*m) + k(14,6); 224 | K(2*s,2*p-1) = K(2*s,2*p-1) + k(14,7); 225 | K(2*s,2*p) = K(2*s,2*p) + k(14,8); 226 | K(2*s,2*q-1) = K(2*s,2*q-1) + k(14,9); 227 | K(2*s,2*q) = K(2*s,2*q) + k(14,10); 228 | K(2*s,2*r-1) = K(2*s,2*r-1) + k(14,11); 229 | K(2*s,2*r) = K(2*s,2*r) + k(14,12); 230 | K(2*s,2*s-1) = K(2*s,2*s-1) + k(14,13); 231 | K(2*s,2*s) = K(2*s,2*s) + k(14,14); 232 | K(2*s,2*t-1) = K(2*s,2*t-1) + k(14,15); 233 | K(2*s,2*t) = K(2*s,2*t) + k(14,16); 234 | K(2*t-1,2*i-1) = K(2*t-1,2*i-1) + k(15,1); 235 | K(2*t-1,2*i) = K(2*t-1,2*i) + k(15,2); 236 | K(2*t-1,2*j-1) = K(2*t-1,2*j-1) + k(15,3); 237 | K(2*t-1,2*j) = K(2*t-1,2*j) + k(15,4); 238 | K(2*t-1,2*m-1) = K(2*t-1,2*m-1) + k(15,5); 239 | K(2*t-1,2*m) = K(2*t-1,2*m) + k(15,6); 240 | K(2*t-1,2*p-1) = K(2*t-1,2*p-1) + k(15,7); 241 | K(2*t-1,2*p) = K(2*t-1,2*p) + k(15,8); 242 | K(2*t-1,2*q-1) = K(2*t-1,2*q-1) + k(15,9); 243 | K(2*t-1,2*q) = K(2*t-1,2*q) + k(15,10); 244 | K(2*t-1,2*r-1) = K(2*t-1,2*r-1) + k(15,11); 245 | K(2*t-1,2*r) = K(2*t-1,2*r) + k(15,12); 246 | K(2*t-1,2*s-1) = K(2*t-1,2*s-1) + k(15,13); 247 | K(2*t-1,2*s) = K(2*t-1,2*s) + k(15,14); 248 | K(2*t-1,2*t-1) = K(2*t-1,2*t-1) + k(15,15); 249 | K(2*t-1,2*t) = K(2*t-1,2*t) + k(15,16); 250 | K(2*t,2*i-1) = K(2*t,2*i-1) + k(16,1); 251 | K(2*t,2*i) = K(2*t,2*i) + k(16,2); 252 | K(2*t,2*j-1) = K(2*t,2*j-1) + k(16,3); 253 | K(2*t,2*j) = K(2*t,2*j) + k(16,4); 254 | K(2*t,2*m-1) = K(2*t,2*m-1) + k(16,5); 255 | K(2*t,2*m) = K(2*t,2*m) + k(16,6); 256 | K(2*t,2*p-1) = K(2*t,2*p-1) + k(16,7); 257 | K(2*t,2*p) = K(2*t,2*p) + k(16,8); 258 | K(2*t,2*q-1) = K(2*t,2*q-1) + k(16,9); 259 | K(2*t,2*q) = K(2*t,2*q) + k(16,10); 260 | K(2*t,2*r-1) = K(2*t,2*r-1) + k(16,11); 261 | K(2*t,2*r) = K(2*t,2*r) + k(16,12); 262 | K(2*t,2*s-1) = K(2*t,2*s-1) + k(16,13); 263 | K(2*t,2*s) = K(2*t,2*s) + k(16,14); 264 | K(2*t,2*t-1) = K(2*t,2*t-1) + k(16,15); 265 | K(2*t,2*t) = K(2*t,2*t) + k(16,16); 266 | y = K; 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticQuadElementArea.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticQuadElementArea(x1,y1,x2,y2,x3,y3,x4,y4) 2 | %QuadraticQuadElementArea This function returns the area 3 | % of the quadratic quadrilateral 4 | % element whose first node has 5 | % coordinates (x1,y1), second 6 | % node has coordinates (x2,y2), 7 | % third node has coordinates 8 | % (x3,y3), and fourth node has 9 | % coordinates (x4,y4) . 10 | yfirst = (x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2))/2; 11 | ysecond = (x1*(y3-y4) + x3*(y4-y1) + x4*(y1-y3))/2; 12 | y = yfirst + ysecond; 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticQuadElementPStresses.m: -------------------------------------------------------------------------------- 1 | function y = QuadraticQuadElementPStresses(sigma) 2 | %QuadraticQuadElementPStresses This function returns the element 3 | % principal stresses and their 4 | % angle given the element 5 | % stress vector. 6 | R = (sigma(1) + sigma(2))/2; 7 | Q = ((sigma(1) - sigma(2))/2)^2 + sigma(3)*sigma(3); 8 | M = 2*sigma(3)/(sigma(1) - sigma(2)); 9 | s1 = R + sqrt(Q); 10 | s2 = R - sqrt(Q); 11 | theta = (atan(M)/2)*180/pi; 12 | y = [s1 ; s2 ; theta]; 13 | 14 | 15 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticQuadElementStiffness.m: -------------------------------------------------------------------------------- 1 | function w = QuadraticQuadElementStiffness(E,NU,h,x1,y1,x2,y2,x3,y3,x4,y4,p) 2 | %QuadraticQuadElementStiffness This function returns the element 3 | % stiffness matrix for a quadratic 4 | % quadrilateral element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, thickness h, coordinates of 7 | % node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), coordinates of 9 | % node 3 (x3,y3), and coordinates of 10 | % node 4 (x4,y4). Use p = 1 for cases 11 | % of plane stress, and p = 2 for 12 | % cases of plane strain. 13 | % The size of the element 14 | % stiffness matrix is 16 x 16. 15 | syms s t; 16 | x5 = (x1 + x2)/2; 17 | x6 = (x2 + x3)/2; 18 | x7 = (x3 + x4)/2; 19 | x8 = (x4 + x1)/2; 20 | y5 = (y1 + y2)/2; 21 | y6 = (y2 + y3)/2; 22 | y7 = (y3 + y4)/2; 23 | y8 = (y4 + y1)/2; 24 | N1 = (1-s)*(1-t)*(-s-t-1)/4; 25 | N2 = (1+s)*(1-t)*(s-t-1)/4; 26 | N3 = (1+s)*(1+t)*(s+t-1)/4; 27 | N4 = (1-s)*(1+t)*(-s+t-1)/4; 28 | N5 = (1-t)*(1+s)*(1-s)/2; 29 | N6 = (1+s)*(1+t)*(1-t)/2; 30 | N7 = (1+t)*(1+s)*(1-s)/2; 31 | N8 = (1-s)*(1+t)*(1-t)/2; 32 | x = N1*x1 + N2*x2 + N3*x3 + N4*x4 + N5*x5 + N6*x6 + N7*x7 + N8*x8; 33 | y = N1*y1 + N2*y2 + N3*y3 + N4*y4 + N5*y5 + N6*y6 + N7*y7 + N8*y8; 34 | xs = diff(x,s); 35 | xt = diff(x,t); 36 | ys = diff(y,s); 37 | yt = diff(y,t); 38 | J = xs*yt - ys*xt; 39 | N1s = diff(N1,s); 40 | N2s = diff(N2,s); 41 | N3s = diff(N3,s); 42 | N4s = diff(N4,s); 43 | N5s = diff(N5,s); 44 | N6s = diff(N6,s); 45 | N7s = diff(N7,s); 46 | N8s = diff(N8,s); 47 | N1t = diff(N1,t); 48 | N2t = diff(N2,t); 49 | N3t = diff(N3,t); 50 | N4t = diff(N4,t); 51 | N5t = diff(N5,t); 52 | N6t = diff(N6,t); 53 | N7t = diff(N7,t); 54 | N8t = diff(N8,t); 55 | B11 = yt*N1s - ys*N1t; 56 | B12 = 0; 57 | B13 = yt*N2s - ys*N2t; 58 | B14 = 0; 59 | B15 = yt*N3s - ys*N3t; 60 | B16 = 0; 61 | B17 = yt*N4s - ys*N4t; 62 | B18 = 0; 63 | B19 = yt*N5s - ys*N5t; 64 | B110 = 0; 65 | B111 = yt*N6s - ys*N6t; 66 | B112 = 0; 67 | B113 = yt*N7s - ys*N7t; 68 | B114 = 0; 69 | B115 = yt*N8s - ys*N8t; 70 | B116 = 0; 71 | B21 = 0; 72 | B22 = xs*N1t - xt*N1s; 73 | B23 = 0; 74 | B24 = xs*N2t - xt*N2s; 75 | B25 = 0; 76 | B26 = xs*N3t - xt*N3s; 77 | B27 = 0; 78 | B28 = xs*N4t - xt*N4s; 79 | B29 = 0; 80 | B210 = xs*N5t - xt*N5s; 81 | B211 = 0; 82 | B212 = xs*N6t - xt*N6s; 83 | B213 = 0; 84 | B214 = xs*N7t - xt*N7s; 85 | B215 = 0; 86 | B216 = xs*N8t - xt*N8s; 87 | B31 = xs*N1t - xt*N1s; 88 | B32 = yt*N1s - ys*N1t; 89 | B33 = xs*N2t - xt*N2s; 90 | B34 = yt*N2s - ys*N2t; 91 | B35 = xs*N3t - xt*N3s; 92 | B36 = yt*N3s - ys*N3t; 93 | B37 = xs*N4t - xt*N4s; 94 | B38 = yt*N4s - ys*N4t; 95 | B39 = xs*N5t - xt*N5s; 96 | B310 = yt*N5s - ys*N5t; 97 | B311 = xs*N6t - xt*N6s; 98 | B312 = yt*N6s - ys*N6t; 99 | B313 = xs*N7t - xt*N7s; 100 | B314 = yt*N7s - ys*N7t; 101 | B315 = xs*N8t - xt*N8s; 102 | B316 = yt*N8s - ys*N8t; 103 | % The expression of B below is not divided by J - it is adjusted for later 104 | % in the calculation of BD below. 105 | B = [B11 B12 B13 B14 B15 B16 B17 B18 B19 B110 B111 B112 B113 B114 B115 B116; 106 | B21 B22 B23 B24 B25 B26 B27 B28 B29 B210 B211 B212 B213 B214 B215 B216; 107 | B31 B32 B33 B34 B35 B36 B37 B38 B39 B310 B311 B312 B313 B314 B315 B316]; 108 | if p == 1 109 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 110 | elseif p == 2 111 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 112 | end 113 | Bnew = simplify(B); 114 | Jnew = simplify(J); 115 | BD = transpose(Bnew)*D*Bnew/Jnew; 116 | r = int(int(BD, t, -1, 1), s, -1, 1); 117 | z = h*r; 118 | w = double(z); 119 | 120 | 121 | -------------------------------------------------------------------------------- /matlab 有限元源程序/QuadraticQuadElementStresses.m: -------------------------------------------------------------------------------- 1 | function w = QuadraticQuadElementSresses(E,NU,x1,y1,x2,y2,x3,y3,x4,y4,p,u) 2 | %QuadraticQuadElementStresses This function returns the element 3 | % stress vector for a quadratic 4 | % quadrilateral element with modulus 5 | % of elasticity E, Poisson's ratio 6 | % NU, coordinates of 7 | % node 1 (x1,y1), coordinates 8 | % of node 2 (x2,y2), coordinates of 9 | % node 3 (x3,y3), coordinates of 10 | % node 4 (x4,y4), and element 11 | % displacement vector u. 12 | % Use p = 1 for cases 13 | % of plane stress, and p = 2 for 14 | % cases of plane strain. 15 | syms s t; 16 | x5 = (x1 + x2)/2; 17 | x6 = (x2 + x3)/2; 18 | x7 = (x3 + x4)/2; 19 | x8 = (x4 + x1)/2; 20 | y5 = (y1 + y2)/2; 21 | y6 = (y2 + y3)/2; 22 | y7 = (y3 + y4)/2; 23 | y8 = (y4 + y1)/2; 24 | N1 = (1-s)*(1-t)*(-s-t-1)/4; 25 | N2 = (1+s)*(1-t)*(s-t-1)/4; 26 | N3 = (1+s)*(1+t)*(s+t-1)/4; 27 | N4 = (1-s)*(1+t)*(-s+t-1)/4; 28 | N5 = (1-t)*(1+s)*(1-s)/2; 29 | N6 = (1+s)*(1+t)*(1-t)/2; 30 | N7 = (1+t)*(1+s)*(1-s)/2; 31 | N8 = (1-s)*(1+t)*(1-t)/2; 32 | x = N1*x1 + N2*x2 + N3*x3 + N4*x4 + N5*x5 + N6*x6 + N7*x7 + N8*x8; 33 | y = N1*y1 + N2*y2 + N3*y3 + N4*y4 + N5*y5 + N6*y6 + N7*y7 + N8*y8; 34 | xs = diff(x,s); 35 | xt = diff(x,t); 36 | ys = diff(y,s); 37 | yt = diff(y,t); 38 | J = xs*yt - ys*xt; 39 | N1s = diff(N1,s); 40 | N2s = diff(N2,s); 41 | N3s = diff(N3,s); 42 | N4s = diff(N4,s); 43 | N5s = diff(N5,s); 44 | N6s = diff(N6,s); 45 | N7s = diff(N7,s); 46 | N8s = diff(N8,s); 47 | N1t = diff(N1,t); 48 | N2t = diff(N2,t); 49 | N3t = diff(N3,t); 50 | N4t = diff(N4,t); 51 | N5t = diff(N5,t); 52 | N6t = diff(N6,t); 53 | N7t = diff(N7,t); 54 | N8t = diff(N8,t); 55 | B11 = yt*N1s - ys*N1t; 56 | B12 = 0; 57 | B13 = yt*N2s - ys*N2t; 58 | B14 = 0; 59 | B15 = yt*N3s - ys*N3t; 60 | B16 = 0; 61 | B17 = yt*N4s - ys*N4t; 62 | B18 = 0; 63 | B19 = yt*N5s - ys*N5t; 64 | B110 = 0; 65 | B111 = yt*N6s - ys*N6t; 66 | B112 = 0; 67 | B113 = yt*N7s - ys*N7t; 68 | B114 = 0; 69 | B115 = yt*N8s - ys*N8t; 70 | B116 = 0; 71 | B21 = 0; 72 | B22 = xs*N1t - xt*N1s; 73 | B23 = 0; 74 | B24 = xs*N2t - xt*N2s; 75 | B25 = 0; 76 | B26 = xs*N3t - xt*N3s; 77 | B27 = 0; 78 | B28 = xs*N4t - xt*N4s; 79 | B29 = 0; 80 | B210 = xs*N5t - xt*N5s; 81 | B211 = 0; 82 | B212 = xs*N6t - xt*N6s; 83 | B213 = 0; 84 | B214 = xs*N7t - xt*N7s; 85 | B215 = 0; 86 | B216 = xs*N8t - xt*N8s; 87 | B31 = xs*N1t - xt*N1s; 88 | B32 = yt*N1s - ys*N1t; 89 | B33 = xs*N2t - xt*N2s; 90 | B34 = yt*N2s - ys*N2t; 91 | B35 = xs*N3t - xt*N3s; 92 | B36 = yt*N3s - ys*N3t; 93 | B37 = xs*N4t - xt*N4s; 94 | B38 = yt*N4s - ys*N4t; 95 | B39 = xs*N5t - xt*N5s; 96 | B310 = yt*N5s - ys*N5t; 97 | B311 = xs*N6t - xt*N6s; 98 | B312 = yt*N6s - ys*N6t; 99 | B313 = xs*N7t - xt*N7s; 100 | B314 = yt*N7s - ys*N7t; 101 | B315 = xs*N8t - xt*N8s; 102 | B316 = yt*N8s - ys*N8t; 103 | Jnew = simplify(J); 104 | B = [B11 B12 B13 B14 B15 B16 B17 B18 B19 B110 B111 B112 B113 B114 B115 B116; 105 | B21 B22 B23 B24 B25 B26 B27 B28 B29 B210 B211 B212 B213 B214 B215 B216; 106 | B31 B32 B33 B34 B35 B36 B37 B38 B39 B310 B311 B312 B313 B314 B315 B316]/Jnew; 107 | if p == 1 108 | D = (E/(1-NU*NU))*[1, NU, 0 ; NU, 1, 0 ; 0, 0, (1-NU)/2]; 109 | elseif p == 2 110 | D = (E/(1+NU)/(1-2*NU))*[1-NU, NU, 0 ; NU, 1-NU, 0 ; 0, 0, (1-2*NU)/2]; 111 | end 112 | Bnew = simplify(B); 113 | w = D*Bnew*u 114 | % 115 | % We also calculate the stresses at the centroid of the element 116 | % 117 | wcent = subs(w, {s,t}, {0,0}); 118 | w = double(wcent); 119 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameAssemble.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameAssemble(K,k,i,j) 2 | %SpaceFrameAssemble This function assembles the element stiffness 3 | % matrix k of the space frame element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(6*i-5,6*i-5) = K(6*i-5,6*i-5) + k(1,1); 9 | K(6*i-5,6*i-4) = K(6*i-5,6*i-4) + k(1,2); 10 | K(6*i-5,6*i-3) = K(6*i-5,6*i-3) + k(1,3); 11 | K(6*i-5,6*i-2) = K(6*i-5,6*i-2) + k(1,4); 12 | K(6*i-5,6*i-1) = K(6*i-5,6*i-1) + k(1,5); 13 | K(6*i-5,6*i) = K(6*i-5,6*i) + k(1,6); 14 | K(6*i-5,6*j-5) = K(6*i-5,6*j-5) + k(1,7); 15 | K(6*i-5,6*j-4) = K(6*i-5,6*j-4) + k(1,8); 16 | K(6*i-5,6*j-3) = K(6*i-5,6*j-3) + k(1,9); 17 | K(6*i-5,6*j-2) = K(6*i-5,6*j-2) + k(1,10); 18 | K(6*i-5,6*j-1) = K(6*i-5,6*j-1) + k(1,11); 19 | K(6*i-5,6*j) = K(6*i-5,6*j) + k(1,12); 20 | K(6*i-4,6*i-5) = K(6*i-4,6*i-5) + k(2,1); 21 | K(6*i-4,6*i-4) = K(6*i-4,6*i-4) + k(2,2); 22 | K(6*i-4,6*i-3) = K(6*i-4,6*i-3) + k(2,3); 23 | K(6*i-4,6*i-2) = K(6*i-4,6*i-2) + k(2,4); 24 | K(6*i-4,6*i-1) = K(6*i-4,6*i-1) + k(2,5); 25 | K(6*i-4,6*i) = K(6*i-4,6*i) + k(2,6); 26 | K(6*i-4,6*j-5) = K(6*i-4,6*j-5) + k(2,7); 27 | K(6*i-4,6*j-4) = K(6*i-4,6*j-4) + k(2,8); 28 | K(6*i-4,6*j-3) = K(6*i-4,6*j-3) + k(2,9); 29 | K(6*i-4,6*j-2) = K(6*i-4,6*j-2) + k(2,10); 30 | K(6*i-4,6*j-1) = K(6*i-4,6*j-1) + k(2,11); 31 | K(6*i-4,6*j) = K(6*i-4,6*j) + k(2,12); 32 | K(6*i-3,6*i-5) = K(6*i-3,6*i-5) + k(3,1); 33 | K(6*i-3,6*i-4) = K(6*i-3,6*i-4) + k(3,2); 34 | K(6*i-3,6*i-3) = K(6*i-3,6*i-3) + k(3,3); 35 | K(6*i-3,6*i-2) = K(6*i-3,6*i-2) + k(3,4); 36 | K(6*i-3,6*i-1) = K(6*i-3,6*i-1) + k(3,5); 37 | K(6*i-3,6*i) = K(6*i-3,6*i) + k(3,6); 38 | K(6*i-3,6*j-5) = K(6*i-3,6*j-5) + k(3,7); 39 | K(6*i-3,6*j-4) = K(6*i-3,6*j-4) + k(3,8); 40 | K(6*i-3,6*j-3) = K(6*i-3,6*j-3) + k(3,9); 41 | K(6*i-3,6*j-2) = K(6*i-3,6*j-2) + k(3,10); 42 | K(6*i-3,6*j-1) = K(6*i-3,6*j-1) + k(3,11); 43 | K(6*i-3,6*j) = K(6*i-3,6*j) + k(3,12); 44 | K(6*i-2,6*i-5) = K(6*i-2,6*i-5) + k(4,1); 45 | K(6*i-2,6*i-4) = K(6*i-2,6*i-4) + k(4,2); 46 | K(6*i-2,6*i-3) = K(6*i-2,6*i-3) + k(4,3); 47 | K(6*i-2,6*i-2) = K(6*i-2,6*i-2) + k(4,4); 48 | K(6*i-2,6*i-1) = K(6*i-2,6*i-1) + k(4,5); 49 | K(6*i-2,6*i) = K(6*i-2,6*i) + k(4,6); 50 | K(6*i-2,6*j-5) = K(6*i-2,6*j-5) + k(4,7); 51 | K(6*i-2,6*j-4) = K(6*i-2,6*j-4) + k(4,8); 52 | K(6*i-2,6*j-3) = K(6*i-2,6*j-3) + k(4,9); 53 | K(6*i-2,6*j-2) = K(6*i-2,6*j-2) + k(4,10); 54 | K(6*i-2,6*j-1) = K(6*i-2,6*j-1) + k(4,11); 55 | K(6*i-2,6*j) = K(6*i-2,6*j) + k(4,12); 56 | K(6*i-1,6*i-5) = K(6*i-1,6*i-5) + k(5,1); 57 | K(6*i-1,6*i-4) = K(6*i-1,6*i-4) + k(5,2); 58 | K(6*i-1,6*i-3) = K(6*i-1,6*i-3) + k(5,3); 59 | K(6*i-1,6*i-2) = K(6*i-1,6*i-2) + k(5,4); 60 | K(6*i-1,6*i-1) = K(6*i-1,6*i-1) + k(5,5); 61 | K(6*i-1,6*i) = K(6*i-1,6*i) + k(5,6); 62 | K(6*i-1,6*j-5) = K(6*i-1,6*j-5) + k(5,7); 63 | K(6*i-1,6*j-4) = K(6*i-1,6*j-4) + k(5,8); 64 | K(6*i-1,6*j-3) = K(6*i-1,6*j-3) + k(5,9); 65 | K(6*i-1,6*j-2) = K(6*i-1,6*j-2) + k(5,10); 66 | K(6*i-1,6*j-1) = K(6*i-1,6*j-1) + k(5,11); 67 | K(6*i-1,6*j) = K(6*i-1,6*j) + k(5,12); 68 | K(6*i,6*i-5) = K(6*i,6*i-5) + k(6,1); 69 | K(6*i,6*i-4) = K(6*i,6*i-4) + k(6,2); 70 | K(6*i,6*i-3) = K(6*i,6*i-3) + k(6,3); 71 | K(6*i,6*i-2) = K(6*i,6*i-2) + k(6,4); 72 | K(6*i,6*i-1) = K(6*i,6*i-1) + k(6,5); 73 | K(6*i,6*i) = K(6*i,6*i) + k(6,6); 74 | K(6*i,6*j-5) = K(6*i,6*j-5) + k(6,7); 75 | K(6*i,6*j-4) = K(6*i,6*j-4) + k(6,8); 76 | K(6*i,6*j-3) = K(6*i,6*j-3) + k(6,9); 77 | K(6*i,6*j-2) = K(6*i,6*j-2) + k(6,10); 78 | K(6*i,6*j-1) = K(6*i,6*j-1) + k(6,11); 79 | K(6*i,6*j) = K(6*i,6*j) + k(6,12); 80 | K(6*j-5,6*i-5) = K(6*j-5,6*i-5) + k(7,1); 81 | K(6*j-5,6*i-4) = K(6*j-5,6*i-4) + k(7,2); 82 | K(6*j-5,6*i-3) = K(6*j-5,6*i-3) + k(7,3); 83 | K(6*j-5,6*i-2) = K(6*j-5,6*i-2) + k(7,4); 84 | K(6*j-5,6*i-1) = K(6*j-5,6*i-1) + k(7,5); 85 | K(6*j-5,6*i) = K(6*j-5,6*i) + k(7,6); 86 | K(6*j-5,6*j-5) = K(6*j-5,6*j-5) + k(7,7); 87 | K(6*j-5,6*j-4) = K(6*j-5,6*j-4) + k(7,8); 88 | K(6*j-5,6*j-3) = K(6*j-5,6*j-3) + k(7,9); 89 | K(6*j-5,6*j-2) = K(6*j-5,6*j-2) + k(7,10); 90 | K(6*j-5,6*j-1) = K(6*j-5,6*j-1) + k(7,11); 91 | K(6*j-5,6*j) = K(6*j-5,6*j) + k(7,12); 92 | K(6*j-4,6*i-5) = K(6*j-4,6*i-5) + k(8,1); 93 | K(6*j-4,6*i-4) = K(6*j-4,6*i-4) + k(8,2); 94 | K(6*j-4,6*i-3) = K(6*j-4,6*i-3) + k(8,3); 95 | K(6*j-4,6*i-2) = K(6*j-4,6*i-2) + k(8,4); 96 | K(6*j-4,6*i-1) = K(6*j-4,6*i-1) + k(8,5); 97 | K(6*j-4,6*i) = K(6*j-4,6*i) + k(8,6); 98 | K(6*j-4,6*j-5) = K(6*j-4,6*j-5) + k(8,7); 99 | K(6*j-4,6*j-4) = K(6*j-4,6*j-4) + k(8,8); 100 | K(6*j-4,6*j-3) = K(6*j-4,6*j-3) + k(8,9); 101 | K(6*j-4,6*j-2) = K(6*j-4,6*j-2) + k(8,10); 102 | K(6*j-4,6*j-1) = K(6*j-4,6*j-1) + k(8,11); 103 | K(6*j-4,6*j) = K(6*j-4,6*j) + k(8,12); 104 | K(6*j-3,6*i-5) = K(6*j-3,6*i-5) + k(9,1); 105 | K(6*j-3,6*i-4) = K(6*j-3,6*i-4) + k(9,2); 106 | K(6*j-3,6*i-3) = K(6*j-3,6*i-3) + k(9,3); 107 | K(6*j-3,6*i-2) = K(6*j-3,6*i-2) + k(9,4); 108 | K(6*j-3,6*i-1) = K(6*j-3,6*i-1) + k(9,5); 109 | K(6*j-3,6*i) = K(6*j-3,6*i) + k(9,6); 110 | K(6*j-3,6*j-5) = K(6*j-3,6*j-5) + k(9,7); 111 | K(6*j-3,6*j-4) = K(6*j-3,6*j-4) + k(9,8); 112 | K(6*j-3,6*j-3) = K(6*j-3,6*j-3) + k(9,9); 113 | K(6*j-3,6*j-2) = K(6*j-3,6*j-2) + k(9,10); 114 | K(6*j-3,6*j-1) = K(6*j-3,6*j-1) + k(9,11); 115 | K(6*j-3,6*j) = K(6*j-3,6*j) + k(9,12); 116 | K(6*j-2,6*i-5) = K(6*j-2,6*i-5) + k(10,1); 117 | K(6*j-2,6*i-4) = K(6*j-2,6*i-4) + k(10,2); 118 | K(6*j-2,6*i-3) = K(6*j-2,6*i-3) + k(10,3); 119 | K(6*j-2,6*i-2) = K(6*j-2,6*i-2) + k(10,4); 120 | K(6*j-2,6*i-1) = K(6*j-2,6*i-1) + k(10,5); 121 | K(6*j-2,6*i) = K(6*j-2,6*i) + k(10,6); 122 | K(6*j-2,6*j-5) = K(6*j-2,6*j-5) + k(10,7); 123 | K(6*j-2,6*j-4) = K(6*j-2,6*j-4) + k(10,8); 124 | K(6*j-2,6*j-3) = K(6*j-2,6*j-3) + k(10,9); 125 | K(6*j-2,6*j-2) = K(6*j-2,6*j-2) + k(10,10); 126 | K(6*j-2,6*j-1) = K(6*j-2,6*j-1) + k(10,11); 127 | K(6*j-2,6*j) = K(6*j-2,6*j) + k(10,12); 128 | K(6*j-1,6*i-5) = K(6*j-1,6*i-5) + k(11,1); 129 | K(6*j-1,6*i-4) = K(6*j-1,6*i-4) + k(11,2); 130 | K(6*j-1,6*i-3) = K(6*j-1,6*i-3) + k(11,3); 131 | K(6*j-1,6*i-2) = K(6*j-1,6*i-2) + k(11,4); 132 | K(6*j-1,6*i-1) = K(6*j-1,6*i-1) + k(11,5); 133 | K(6*j-1,6*i) = K(6*j-1,6*i) + k(11,6); 134 | K(6*j-1,6*j-5) = K(6*j-1,6*j-5) + k(11,7); 135 | K(6*j-1,6*j-4) = K(6*j-1,6*j-4) + k(11,8); 136 | K(6*j-1,6*j-3) = K(6*j-1,6*j-3) + k(11,9); 137 | K(6*j-1,6*j-2) = K(6*j-1,6*j-2) + k(11,10); 138 | K(6*j-1,6*j-1) = K(6*j-1,6*j-1) + k(11,11); 139 | K(6*j-1,6*j) = K(6*j-1,6*j) + k(11,12); 140 | K(6*j,6*i-5) = K(6*j,6*i-5) + k(12,1); 141 | K(6*j,6*i-4) = K(6*j,6*i-4) + k(12,2); 142 | K(6*j,6*i-3) = K(6*j,6*i-3) + k(12,3); 143 | K(6*j,6*i-2) = K(6*j,6*i-2) + k(12,4); 144 | K(6*j,6*i-1) = K(6*j,6*i-1) + k(12,5); 145 | K(6*j,6*i) = K(6*j,6*i) + k(12,6); 146 | K(6*j,6*j-5) = K(6*j,6*j-5) + k(12,7); 147 | K(6*j,6*j-4) = K(6*j,6*j-4) + k(12,8); 148 | K(6*j,6*j-3) = K(6*j,6*j-3) + k(12,9); 149 | K(6*j,6*j-2) = K(6*j,6*j-2) + k(12,10); 150 | K(6*j,6*j-1) = K(6*j,6*j-1) + k(12,11); 151 | K(6*j,6*j) = K(6*j,6*j) + k(12,12); 152 | y = K; 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementAxialDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementAxialDiagram(f, L) 2 | %SpaceFrameElementAxialDiagram This function plots the axial force 3 | % diagram for the space frame element 4 | % with nodal force vector f and length 5 | % L. 6 | x = [0 ; L]; 7 | z = [-f(1) ; f(7)]; 8 | hold on; 9 | title('Axial Force Diagram'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementForces.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementForces(E,G,A,Iy,Iz,J,x1,y1,z1,x2,y2,z2,u) 2 | %SpaceFrameElementForces This function returns the element force 3 | % vector given the modulus of elasticity E, 4 | % the shear modulus of elasticity G, the 5 | % cross-sectional area A, moments of inertia 6 | % Iy and Iz, the torsional constant J, 7 | % the coordinates (x1,y1,z1) of the first 8 | % node, the coordinates (x2,y2,z2) of the 9 | % second node, and the element nodal 10 | % displacement vector u. 11 | L = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)); 12 | w1 = E*A/L; 13 | w2 = 12*E*Iz/(L*L*L); 14 | w3 = 6*E*Iz/(L*L); 15 | w4 = 4*E*Iz/L; 16 | w5 = 2*E*Iz/L; 17 | w6 = 12*E*Iy/(L*L*L); 18 | w7 = 6*E*Iy/(L*L); 19 | w8 = 4*E*Iy/L; 20 | w9 = 2*E*Iy/L; 21 | w10 = G*J/L; 22 | kprime = [w1 0 0 0 0 0 -w1 0 0 0 0 0 ; 23 | 0 w2 0 0 0 w3 0 -w2 0 0 0 w3 ; 24 | 0 0 w6 0 -w7 0 0 0 -w6 0 -w7 0 ; 25 | 0 0 0 w10 0 0 0 0 0 -w10 0 0 ; 26 | 0 0 -w7 0 w8 0 0 0 w7 0 w9 0 ; 27 | 0 w3 0 0 0 w4 0 -w3 0 0 0 w5 ; 28 | -w1 0 0 0 0 0 w1 0 0 0 0 0 ; 29 | 0 -w2 0 0 0 -w3 0 w2 0 0 0 -w3 ; 30 | 0 0 -w6 0 w7 0 0 0 w6 0 w7 0 ; 31 | 0 0 0 -w10 0 0 0 0 0 w10 0 0 ; 32 | 0 0 -w7 0 w9 0 0 0 w7 0 w8 0 ; 33 | 0 w3 0 0 0 w5 0 -w3 0 0 0 w4]; 34 | if x1 == x2 & y1 == y2 35 | if z2 > z1 36 | Lambda = [0 0 1 ; 0 1 0 ; -1 0 0]; 37 | else 38 | Lambda = [0 0 -1 ; 0 1 0 ; 1 0 0]; 39 | end 40 | else 41 | CXx = (x2-x1)/L; 42 | CYx = (y2-y1)/L; 43 | CZx = (z2-z1)/L; 44 | D = sqrt(CXx*CXx + CYx*CYx); 45 | CXy = -CYx/D; 46 | CYy = CXx/D; 47 | CZy = 0; 48 | CXz = -CXx*CZx/D; 49 | CYz = -CYx*CZx/D; 50 | CZz = D; 51 | Lambda = [CXx CYx CZx ; CXy CYy CZy ; CXz CYz CZz]; 52 | end 53 | R = [Lambda zeros(3) zeros(3) zeros(3) ; 54 | zeros(3) Lambda zeros(3) zeros(3) ; 55 | zeros(3) zeros(3) Lambda zeros(3) ; 56 | zeros(3) zeros(3) zeros(3) Lambda]; 57 | y = kprime*R* u; 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementLength.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementLength(x1,y1,z1,x2,y2,z2) 2 | %SpaceFrameElementLength This function returns the length of the 3 | % space frame element whose first node has 4 | % coordinates (x1,y1,z1) and second node has 5 | % coordinates (x2,y2,z2). 6 | y = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)); 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementMomentYDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementMomentYDiagram(f, L) 2 | %SpaceFrameElementMomentYDiagram This function plots the bending 3 | % moment diagram for the space frame 4 | % element with nodal force vector f 5 | % and length L. 6 | x = [0 ; L]; 7 | z = [f(5) ; -f(11)]; 8 | hold on; 9 | title('Bending Moment Diagram along Y Axis'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementMomentZDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementMomentZDiagram(f, L) 2 | %SpaceFrameElementMomentZDiagram This function plots the bending 3 | % moment diagram for the space frame 4 | % element with nodal force vector f 5 | % and length L. 6 | x = [0 ; L]; 7 | z = [f(6) ; -f(12)]; 8 | hold on; 9 | title('Bending Moment Diagram along Z Axis'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementShearYDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementShearYDiagram(f, L) 2 | %SpaceFrameElementShearYDiagram This function plots the shear force 3 | % diagram for the space frame element 4 | % with nodal force vector f and 5 | % length L. 6 | x = [0 ; L]; 7 | z = [f(2) ; -f(8)]; 8 | hold on; 9 | title('Shear Force Diagram in Y Direction'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementShearZDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementShearZDiagram(f, L) 2 | %SpaceFrameElementShearZDiagram This function plots the shear force 3 | % diagram for the space frame element 4 | % with nodal force vector f and 5 | % length L. 6 | x = [0 ; L]; 7 | z = [f(3) ; -f(9)]; 8 | hold on; 9 | title('Shear Force Diagram in Z Direction'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementStiffness(E,G,A,Iy,Iz,J,x1,y1,z1,x2,y2,z2) 2 | %SpaceFrameElementStiffness This function returns the element 3 | % stiffness matrix for a space frame 4 | % element with modulus of elasticity E, 5 | % shear modulus of elasticity G, cross- 6 | % sectional area A, moments of inertia 7 | % Iy and Iz, torsional constant J, 8 | % coordinates (x1,y1,z1) for the first 9 | % node and coordinates (x2,y2,z2) for the 10 | % second node. 11 | % The size of the element stiffness 12 | % matrix is 12 x 12. 13 | L = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)); 14 | w1 = E*A/L; 15 | w2 = 12*E*Iz/(L*L*L); 16 | w3 = 6*E*Iz/(L*L); 17 | w4 = 4*E*Iz/L; 18 | w5 = 2*E*Iz/L; 19 | w6 = 12*E*Iy/(L*L*L); 20 | w7 = 6*E*Iy/(L*L); 21 | w8 = 4*E*Iy/L; 22 | w9 = 2*E*Iy/L; 23 | w10 = G*J/L; 24 | kprime = [w1 0 0 0 0 0 -w1 0 0 0 0 0 ; 25 | 0 w2 0 0 0 w3 0 -w2 0 0 0 w3 ; 26 | 0 0 w6 0 -w7 0 0 0 -w6 0 -w7 0 ; 27 | 0 0 0 w10 0 0 0 0 0 -w10 0 0 ; 28 | 0 0 -w7 0 w8 0 0 0 w7 0 w9 0 ; 29 | 0 w3 0 0 0 w4 0 -w3 0 0 0 w5 ; 30 | -w1 0 0 0 0 0 w1 0 0 0 0 0 ; 31 | 0 -w2 0 0 0 -w3 0 w2 0 0 0 -w3 ; 32 | 0 0 -w6 0 w7 0 0 0 w6 0 w7 0 ; 33 | 0 0 0 -w10 0 0 0 0 0 w10 0 0 ; 34 | 0 0 -w7 0 w9 0 0 0 w7 0 w8 0 ; 35 | 0 w3 0 0 0 w5 0 -w3 0 0 0 w4]; 36 | if x1 == x2 & y1 == y2 37 | if z2 > z1 38 | Lambda = [0 0 1 ; 0 1 0 ; -1 0 0]; 39 | else 40 | Lambda = [0 0 -1 ; 0 1 0 ; 1 0 0]; 41 | end 42 | else 43 | CXx = (x2-x1)/L; 44 | CYx = (y2-y1)/L; 45 | CZx = (z2-z1)/L; 46 | D = sqrt(CXx*CXx + CYx*CYx); 47 | CXy = -CYx/D; 48 | CYy = CXx/D; 49 | CZy = 0; 50 | CXz = -CXx*CZx/D; 51 | CYz = -CYx*CZx/D; 52 | CZz = D; 53 | Lambda = [CXx CYx CZx ; CXy CYy CZy ; CXz CYz CZz]; 54 | end 55 | R = [Lambda zeros(3) zeros(3) zeros(3) ; 56 | zeros(3) Lambda zeros(3) zeros(3) ; 57 | zeros(3) zeros(3) Lambda zeros(3) ; 58 | zeros(3) zeros(3) zeros(3) Lambda]; 59 | y = R'*kprime*R; 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceFrameElementTorsionDiagram.m: -------------------------------------------------------------------------------- 1 | function y = SpaceFrameElementTorsionDiagram(f, L) 2 | %SpaceFrameElementTorsionDiagram This function plots the torsion 3 | % diagram for the space frame 4 | % element with nodal force vector f 5 | % and length L. 6 | x = [0 ; L]; 7 | z = [f(4) ; -f(10)]; 8 | hold on; 9 | title('Torsion Diagram'); 10 | plot(x,z); 11 | y1 = [0 ; 0]; 12 | plot(x,y1,'k') 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceTrussAssemble.m: -------------------------------------------------------------------------------- 1 | function y = SpaceTrussAssemble(K,k,i,j) 2 | %SpaceTrussAssemble This function assembles the element stiffness 3 | % matrix k of the space truss element with nodes 4 | % i and j into the global stiffness matrix K. 5 | % This function returns the global stiffness 6 | % matrix K after the element stiffness matrix 7 | % k is assembled. 8 | K(3*i-2,3*i-2) = K(3*i-2,3*i-2) + k(1,1); 9 | K(3*i-2,3*i-1) = K(3*i-2,3*i-1) + k(1,2); 10 | K(3*i-2,3*i) = K(3*i-2,3*i) + k(1,3); 11 | K(3*i-2,3*j-2) = K(3*i-2,3*j-2) + k(1,4); 12 | K(3*i-2,3*j-1) = K(3*i-2,3*j-1) + k(1,5); 13 | K(3*i-2,3*j) = K(3*i-2,3*j) + k(1,6); 14 | K(3*i-1,3*i-2) = K(3*i-1,3*i-2) + k(2,1); 15 | K(3*i-1,3*i-1) = K(3*i-1,3*i-1) + k(2,2); 16 | K(3*i-1,3*i) = K(3*i-1,3*i) + k(2,3); 17 | K(3*i-1,3*j-2) = K(3*i-1,3*j-2) + k(2,4); 18 | K(3*i-1,3*j-1) = K(3*i-1,3*j-1) + k(2,5); 19 | K(3*i-1,3*j) = K(3*i-1,3*j) + k(2,6); 20 | K(3*i,3*i-2) = K(3*i,3*i-2) + k(3,1); 21 | K(3*i,3*i-1) = K(3*i,3*i-1) + k(3,2); 22 | K(3*i,3*i) = K(3*i,3*i) + k(3,3); 23 | K(3*i,3*j-2) = K(3*i,3*j-2) + k(3,4); 24 | K(3*i,3*j-1) = K(3*i,3*j-1) + k(3,5); 25 | K(3*i,3*j) = K(3*i,3*j) + k(3,6); 26 | K(3*j-2,3*i-2) = K(3*j-2,3*i-2) + k(4,1); 27 | K(3*j-2,3*i-1) = K(3*j-2,3*i-1) + k(4,2); 28 | K(3*j-2,3*i) = K(3*j-2,3*i) + k(4,3); 29 | K(3*j-2,3*j-2) = K(3*j-2,3*j-2) + k(4,4); 30 | K(3*j-2,3*j-1) = K(3*j-2,3*j-1) + k(4,5); 31 | K(3*j-2,3*j) = K(3*j-2,3*j) + k(4,6); 32 | K(3*j-1,3*i-2) = K(3*j-1,3*i-2) + k(5,1); 33 | K(3*j-1,3*i-1) = K(3*j-1,3*i-1) + k(5,2); 34 | K(3*j-1,3*i) = K(3*j-1,3*i) + k(5,3); 35 | K(3*j-1,3*j-2) = K(3*j-1,3*j-2) + k(5,4); 36 | K(3*j-1,3*j-1) = K(3*j-1,3*j-1) + k(5,5); 37 | K(3*j-1,3*j) = K(3*j-1,3*j) + k(5,6); 38 | K(3*j,3*i-2) = K(3*j,3*i-2) + k(6,1); 39 | K(3*j,3*i-1) = K(3*j,3*i-1) + k(6,2); 40 | K(3*j,3*i) = K(3*j,3*i) + k(6,3); 41 | K(3*j,3*j-2) = K(3*j,3*j-2) + k(6,4); 42 | K(3*j,3*j-1) = K(3*j,3*j-1) + k(6,5); 43 | K(3*j,3*j) = K(3*j,3*j) + k(6,6); 44 | y = K; 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceTrussElementForce.m: -------------------------------------------------------------------------------- 1 | function y = SpaceTrussElementForce(E,A,L,thetax,thetay,thetaz,u) 2 | %SpaceTrussElementForce This function returns the element force 3 | % given the modulus of elasticity E, the 4 | % cross-sectional area A, the length L, 5 | % the angles thetax, thetay, thetaz 6 | % (in degrees), and the element nodal 7 | % displacement vector u. 8 | x = thetax * pi/180; 9 | w = thetay * pi/180; 10 | v = thetaz * pi/180; 11 | Cx = cos(x); 12 | Cy = cos(w); 13 | Cz = cos(v); 14 | y = E*A/L*[-Cx -Cy -Cz Cx Cy Cz]*u; 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceTrussElementLength.m: -------------------------------------------------------------------------------- 1 | function y = SpaceTrussElementLength(x1,y1,z1,x2,y2,z2) 2 | %SpaceTrussElementLength This function returns the length of the 3 | % space truss element whose first node has 4 | % coordinates (x1,y1,z1) and second node has 5 | % coordinates (x2,y2,z2). 6 | y = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)); 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceTrussElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = SpaceTrussElementStiffness(E,A,L,thetax,thetay,thetaz) 2 | %SpaceTrussElementStiffness This function returns the element 3 | % stiffness matrix for a space truss 4 | % element with modulus of elasticity E, 5 | % cross-sectional area A, length L, and 6 | % angles thetax, thetay, thetaz 7 | % (in degrees). The size of the element 8 | % stiffness matrix is 6 x 6. 9 | x = thetax*pi/180; 10 | u = thetay*pi/180; 11 | v = thetaz*pi/180; 12 | Cx = cos(x); 13 | Cy = cos(u); 14 | Cz = cos(v); 15 | w = [Cx*Cx Cx*Cy Cx*Cz ; Cy*Cx Cy*Cy Cy*Cz ; Cz*Cx Cz*Cy Cz*Cz]; 16 | y = E*A/L*[w -w ; -w w]; 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpaceTrussElementStress.m: -------------------------------------------------------------------------------- 1 | function y = SpaceTrussElementStress(E,L,thetax,thetay,thetaz,u) 2 | %SpaceTrussElementStress This function returns the element stress 3 | % given the modulus of elasticity E, the 4 | % length L, the angles thetax, thetay, 5 | % thetaz (in degrees), and the element 6 | % nodal displacement vector u. 7 | x = thetax * pi/180; 8 | w = thetay * pi/180; 9 | v = thetaz * pi/180; 10 | Cx = cos(x); 11 | Cy = cos(w); 12 | Cz = cos(v); 13 | y = E/L*[-Cx -Cy -Cz Cx Cy Cz]*u; 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpringAssemble.m: -------------------------------------------------------------------------------- 1 | function y = SpringAssemble(K,k,i,j) 2 | %SpringAssemble This function assembles the element stiffness 3 | % matrix k of the spring with nodes i and j into the 4 | % global stiffness matrix K. 5 | % This function returns the global stiffness matrix K 6 | % after the element stiffness matrix k is assembled. 7 | K(i,i) = K(i,i) + k(1,1); 8 | K(i,j) = K(i,j) + k(1,2); 9 | K(j,i) = K(j,i) + k(2,1); 10 | K(j,j) = K(j,j) + k(2,2); 11 | y = K; 12 | 13 | 14 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpringElementForces.m: -------------------------------------------------------------------------------- 1 | function y = SpringElementForces(k,u) 2 | %SpringElementForces This function returns the element nodal force 3 | % vector given the element stiffness matrix k 4 | % and the element nodal displacement vector u. 5 | y = k * u; 6 | 7 | -------------------------------------------------------------------------------- /matlab 有限元源程序/SpringElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = SpringElementStiffness(k) 2 | %SpringElementStiffness This function returns the element stiffness 3 | % matrix for a spring with stiffness k. 4 | % The size of the element stiffness matrix 5 | % is 2 x 2. 6 | y = [k -k ; -k k]; 7 | 8 | -------------------------------------------------------------------------------- /matlab 有限元源程序/TetrahedronAssemble.m: -------------------------------------------------------------------------------- 1 | function y = TetrahedronAssemble(K,k,i,j,m,n) 2 | %TetrahedronAssemble This function assembles the element stiffness 3 | % matrix k of the linear tetrahedral (solid) 4 | % element with nodes i, j, m, and n into the 5 | % global stiffness matrix K. 6 | % This function returns the global stiffness 7 | % matrix K after the element stiffness matrix 8 | % k is assembled. 9 | K(3*i-2,3*i-2) = K(3*i-2,3*i-2) + k(1,1); 10 | K(3*i-2,3*i-1) = K(3*i-2,3*i-1) + k(1,2); 11 | K(3*i-2,3*i) = K(3*i-2,3*i) + k(1,3); 12 | K(3*i-2,3*j-2) = K(3*i-2,3*j-2) + k(1,4); 13 | K(3*i-2,3*j-1) = K(3*i-2,3*j-1) + k(1,5); 14 | K(3*i-2,3*j) = K(3*i-2,3*j) + k(1,6); 15 | K(3*i-2,3*m-2) = K(3*i-2,3*m-2) + k(1,7); 16 | K(3*i-2,3*m-1) = K(3*i-2,3*m-1) + k(1,8); 17 | K(3*i-2,3*m) = K(3*i-2,3*m) + k(1,9); 18 | K(3*i-2,3*n-2) = K(3*i-2,3*n-2) + k(1,10); 19 | K(3*i-2,3*n-1) = K(3*i-2,3*n-1) + k(1,11); 20 | K(3*i-2,3*n) = K(3*i-2,3*n) + k(1,12); 21 | K(3*i-1,3*i-2) = K(3*i-1,3*i-2) + k(2,1); 22 | K(3*i-1,3*i-1) = K(3*i-1,3*i-1) + k(2,2); 23 | K(3*i-1,3*i) = K(3*i-1,3*i) + k(2,3); 24 | K(3*i-1,3*j-2) = K(3*i-1,3*j-2) + k(2,4); 25 | K(3*i-1,3*j-1) = K(3*i-1,3*j-1) + k(2,5); 26 | K(3*i-1,3*j) = K(3*i-1,3*j) + k(2,6); 27 | K(3*i-1,3*m-2) = K(3*i-1,3*m-2) + k(2,7); 28 | K(3*i-1,3*m-1) = K(3*i-1,3*m-1) + k(2,8); 29 | K(3*i-1,3*m) = K(3*i-1,3*m) + k(2,9); 30 | K(3*i-1,3*n-2) = K(3*i-1,3*n-2) + k(2,10); 31 | K(3*i-1,3*n-1) = K(3*i-1,3*n-1) + k(2,11); 32 | K(3*i-1,3*n) = K(3*i-1,3*n) + k(2,12); 33 | K(3*i,3*i-2) = K(3*i,3*i-2) + k(3,1); 34 | K(3*i,3*i-1) = K(3*i,3*i-1) + k(3,2); 35 | K(3*i,3*i) = K(3*i,3*i) + k(3,3); 36 | K(3*i,3*j-2) = K(3*i,3*j-2) + k(3,4); 37 | K(3*i,3*j-1) = K(3*i,3*j-1) + k(3,5); 38 | K(3*i,3*j) = K(3*i,3*j) + k(3,6); 39 | K(3*i,3*m-2) = K(3*i,3*m-2) + k(3,7); 40 | K(3*i,3*m-1) = K(3*i,3*m-1) + k(3,8); 41 | K(3*i,3*m) = K(3*i,3*m) + k(3,9); 42 | K(3*i,3*n-2) = K(3*i,3*n-2) + k(3,10); 43 | K(3*i,3*n-1) = K(3*i,3*n-1) + k(3,11); 44 | K(3*i,3*n) = K(3*i,3*n) + k(3,12); 45 | K(3*j-2,3*i-2) = K(3*j-2,3*i-2) + k(4,1); 46 | K(3*j-2,3*i-1) = K(3*j-2,3*i-1) + k(4,2); 47 | K(3*j-2,3*i) = K(3*j-2,3*i) + k(4,3); 48 | K(3*j-2,3*j-2) = K(3*j-2,3*j-2) + k(4,4); 49 | K(3*j-2,3*j-1) = K(3*j-2,3*j-1) + k(4,5); 50 | K(3*j-2,3*j) = K(3*j-2,3*j) + k(4,6); 51 | K(3*j-2,3*m-2) = K(3*j-2,3*m-2) + k(4,7); 52 | K(3*j-2,3*m-1) = K(3*j-2,3*m-1) + k(4,8); 53 | K(3*j-2,3*m) = K(3*j-2,3*m) + k(4,9); 54 | K(3*j-2,3*n-2) = K(3*j-2,3*n-2) + k(4,10); 55 | K(3*j-2,3*n-1) = K(3*j-2,3*n-1) + k(4,11); 56 | K(3*j-2,3*n) = K(3*j-2,3*n) + k(4,12); 57 | K(3*j-1,3*i-2) = K(3*j-1,3*i-2) + k(5,1); 58 | K(3*j-1,3*i-1) = K(3*j-1,3*i-1) + k(5,2); 59 | K(3*j-1,3*i) = K(3*j-1,3*i) + k(5,3); 60 | K(3*j-1,3*j-2) = K(3*j-1,3*j-2) + k(5,4); 61 | K(3*j-1,3*j-1) = K(3*j-1,3*j-1) + k(5,5); 62 | K(3*j-1,3*j) = K(3*j-1,3*j) + k(5,6); 63 | K(3*j-1,3*m-2) = K(3*j-1,3*m-2) + k(5,7); 64 | K(3*j-1,3*m-1) = K(3*j-1,3*m-1) + k(5,8); 65 | K(3*j-1,3*m) = K(3*j-1,3*m) + k(5,9); 66 | K(3*j-1,3*n-2) = K(3*j-1,3*n-2) + k(5,10); 67 | K(3*j-1,3*n-1) = K(3*j-1,3*n-1) + k(5,11); 68 | K(3*j-1,3*n) = K(3*j-1,3*n) + k(5,12); 69 | K(3*j,3*i-2) = K(3*j,3*i-2) + k(6,1); 70 | K(3*j,3*i-1) = K(3*j,3*i-1) + k(6,2); 71 | K(3*j,3*i) = K(3*j,3*i) + k(6,3); 72 | K(3*j,3*j-2) = K(3*j,3*j-2) + k(6,4); 73 | K(3*j,3*j-1) = K(3*j,3*j-1) + k(6,5); 74 | K(3*j,3*j) = K(3*j,3*j) + k(6,6); 75 | K(3*j,3*m-2) = K(3*j,3*m-2) + k(6,7); 76 | K(3*j,3*m-1) = K(3*j,3*m-1) + k(6,8); 77 | K(3*j,3*m) = K(3*j,3*m) + k(6,9); 78 | K(3*j,3*n-2) = K(3*j,3*n-2) + k(6,10); 79 | K(3*j,3*n-1) = K(3*j,3*n-1) + k(6,11); 80 | K(3*j,3*n) = K(3*j,3*n) + k(6,12); 81 | K(3*m-2,3*i-2) = K(3*m-2,3*i-2) + k(7,1); 82 | K(3*m-2,3*i-1) = K(3*m-2,3*i-1) + k(7,2); 83 | K(3*m-2,3*i) = K(3*m-2,3*i) + k(7,3); 84 | K(3*m-2,3*j-2) = K(3*m-2,3*j-2) + k(7,4); 85 | K(3*m-2,3*j-1) = K(3*m-2,3*j-1) + k(7,5); 86 | K(3*m-2,3*j) = K(3*m-2,3*j) + k(7,6); 87 | K(3*m-2,3*m-2) = K(3*m-2,3*m-2) + k(7,7); 88 | K(3*m-2,3*m-1) = K(3*m-2,3*m-1) + k(7,8); 89 | K(3*m-2,3*m) = K(3*m-2,3*m) + k(7,9); 90 | K(3*m-2,3*n-2) = K(3*m-2,3*n-2) + k(7,10); 91 | K(3*m-2,3*n-1) = K(3*m-2,3*n-1) + k(7,11); 92 | K(3*m-2,3*n) = K(3*m-2,3*n) + k(7,12); 93 | K(3*m-1,3*i-2) = K(3*m-1,3*i-2) + k(8,1); 94 | K(3*m-1,3*i-1) = K(3*m-1,3*i-1) + k(8,2); 95 | K(3*m-1,3*i) = K(3*m-1,3*i) + k(8,3); 96 | K(3*m-1,3*j-2) = K(3*m-1,3*j-2) + k(8,4); 97 | K(3*m-1,3*j-1) = K(3*m-1,3*j-1) + k(8,5); 98 | K(3*m-1,3*j) = K(3*m-1,3*j) + k(8,6); 99 | K(3*m-1,3*m-2) = K(3*m-1,3*m-2) + k(8,7); 100 | K(3*m-1,3*m-1) = K(3*m-1,3*m-1) + k(8,8); 101 | K(3*m-1,3*m) = K(3*m-1,3*m) + k(8,9); 102 | K(3*m-1,3*n-2) = K(3*m-1,3*n-2) + k(8,10); 103 | K(3*m-1,3*n-1) = K(3*m-1,3*n-1) + k(8,11); 104 | K(3*m-1,3*n) = K(3*m-1,3*n) + k(8,12); 105 | K(3*m,3*i-2) = K(3*m,3*i-2) + k(9,1); 106 | K(3*m,3*i-1) = K(3*m,3*i-1) + k(9,2); 107 | K(3*m,3*i) = K(3*m,3*i) + k(9,3); 108 | K(3*m,3*j-2) = K(3*m,3*j-2) + k(9,4); 109 | K(3*m,3*j-1) = K(3*m,3*j-1) + k(9,5); 110 | K(3*m,3*j) = K(3*m,3*j) + k(9,6); 111 | K(3*m,3*m-2) = K(3*m,3*m-2) + k(9,7); 112 | K(3*m,3*m-1) = K(3*m,3*m-1) + k(9,8); 113 | K(3*m,3*m) = K(3*m,3*m) + k(9,9); 114 | K(3*m,3*n-2) = K(3*m,3*n-2) + k(9,10); 115 | K(3*m,3*n-1) = K(3*m,3*n-1) + k(9,11); 116 | K(3*m,3*n) = K(3*m,3*n) + k(9,12); 117 | K(3*n-2,3*i-2) = K(3*n-2,3*i-2) + k(10,1); 118 | K(3*n-2,3*i-1) = K(3*n-2,3*i-1) + k(10,2); 119 | K(3*n-2,3*i) = K(3*n-2,3*i) + k(10,3); 120 | K(3*n-2,3*j-2) = K(3*n-2,3*j-2) + k(10,4); 121 | K(3*n-2,3*j-1) = K(3*n-2,3*j-1) + k(10,5); 122 | K(3*n-2,3*j) = K(3*n-2,3*j) + k(10,6); 123 | K(3*n-2,3*m-2) = K(3*n-2,3*m-2) + k(10,7); 124 | K(3*n-2,3*m-1) = K(3*n-2,3*m-1) + k(10,8); 125 | K(3*n-2,3*m) = K(3*n-2,3*m) + k(10,9); 126 | K(3*n-2,3*n-2) = K(3*n-2,3*n-2) + k(10,10); 127 | K(3*n-2,3*n-1) = K(3*n-2,3*n-1) + k(10,11); 128 | K(3*n-2,3*n) = K(3*n-2,3*n) + k(10,12); 129 | K(3*n-1,3*i-2) = K(3*n-1,3*i-2) + k(11,1); 130 | K(3*n-1,3*i-1) = K(3*n-1,3*i-1) + k(11,2); 131 | K(3*n-1,3*i) = K(3*n-1,3*i) + k(11,3); 132 | K(3*n-1,3*j-2) = K(3*n-1,3*j-2) + k(11,4); 133 | K(3*n-1,3*j-1) = K(3*n-1,3*j-1) + k(11,5); 134 | K(3*n-1,3*j) = K(3*n-1,3*j) + k(11,6); 135 | K(3*n-1,3*m-2) = K(3*n-1,3*m-2) + k(11,7); 136 | K(3*n-1,3*m-1) = K(3*n-1,3*m-1) + k(11,8); 137 | K(3*n-1,3*m) = K(3*n-1,3*m) + k(11,9); 138 | K(3*n-1,3*n-2) = K(3*n-1,3*n-2) + k(11,10); 139 | K(3*n-1,3*n-1) = K(3*n-1,3*n-1) + k(11,11); 140 | K(3*n-1,3*n) = K(3*n-1,3*n) + k(11,12); 141 | K(3*n,3*i-2) = K(3*n,3*i-2) + k(12,1); 142 | K(3*n,3*i-1) = K(3*n,3*i-1) + k(12,2); 143 | K(3*n,3*i) = K(3*n,3*i) + k(12,3); 144 | K(3*n,3*j-2) = K(3*n,3*j-2) + k(12,4); 145 | K(3*n,3*j-1) = K(3*n,3*j-1) + k(12,5); 146 | K(3*n,3*j) = K(3*n,3*j) + k(12,6); 147 | K(3*n,3*m-2) = K(3*n,3*m-2) + k(12,7); 148 | K(3*n,3*m-1) = K(3*n,3*m-1) + k(12,8); 149 | K(3*n,3*m) = K(3*n,3*m) + k(12,9); 150 | K(3*n,3*n-2) = K(3*n,3*n-2) + k(12,10); 151 | K(3*n,3*n-1) = K(3*n,3*n-1) + k(12,11); 152 | K(3*n,3*n) = K(3*n,3*n) + k(12,12); 153 | y = K; 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /matlab 有限元源程序/TetrahedronElementPStresses.m: -------------------------------------------------------------------------------- 1 | function y = TetrahedronElementPStresses(sigma) 2 | %TetrahedronElementPStresses This function returns the three 3 | % principal stresses for the element 4 | % given the element stress vector. 5 | % The principal angles are not returned. 6 | s1 = sigma(1) + sigma(2) + sigma(3); 7 | s2 = sigma(1)*sigma(2) + sigma(1)*sigma(3) + sigma(2)*sigma(3) - sigma(4)*sigma(4) -sigma(5)*sigma(5) -sigma(6)*sigma(6); 8 | ms3 = [sigma(1) sigma(4) sigma(6) ; sigma(4) sigma(2) sigma(5) ; sigma(6) sigma(5) sigma(3)]; 9 | s3 = det(ms3); 10 | y = [s1 ; s2 ; s3]; 11 | 12 | 13 | -------------------------------------------------------------------------------- /matlab 有限元源程序/TetrahedronElementStiffness.m: -------------------------------------------------------------------------------- 1 | function y = TetrahedronElementStiffness(E,NU,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4) 2 | %TetrahedronElementStiffness This function returns the element 3 | % stiffness matrix for a linear 4 | % tetrahedral (solid) element with 5 | % modulus of elasticity E, 6 | % Poisson's ratio NU, coordinates 7 | % of the first node (x1,y1,z1), 8 | % coordinates of the second node 9 | % (x2,y2,z2), coordinates of the 10 | % third node (x3,y3,z3), and 11 | % coordinates of the fourth node 12 | % (x4,y4,z4). 13 | % The size of the element stiffness 14 | % matrix is 12 x 12. 15 | xyz = [1 x1 y1 z1 ; 1 x2 y2 z2 ; 1 x3 y3 z3 ; 1 x4 y4 z4]; 16 | V = det(xyz)/6; 17 | mbeta1 = [1 y2 z2 ; 1 y3 z3 ; 1 y4 z4]; 18 | mbeta2 = [1 y1 z1 ; 1 y3 z3 ; 1 y4 z4]; 19 | mbeta3 = [1 y1 z1 ; 1 y2 z2 ; 1 y4 z4]; 20 | mbeta4 = [1 y1 z1 ; 1 y2 z2 ; 1 y3 z3]; 21 | mgamma1 = [1 x2 z2 ; 1 x3 z3 ; 1 x4 z4]; 22 | mgamma2 = [1 x1 z1 ; 1 x3 z3 ; 1 x4 z4]; 23 | mgamma3 = [1 x1 z1 ; 1 x2 z2 ; 1 x4 z4]; 24 | mgamma4 = [1 x1 z1 ; 1 x2 z2 ; 1 x3 z3]; 25 | mdelta1 = [1 x2 y2 ; 1 x3 y3 ; 1 x4 y4]; 26 | mdelta2 = [1 x1 y1 ; 1 x3 y3 ; 1 x4 y4]; 27 | mdelta3 = [1 x1 y1 ; 1 x2 y2 ; 1 x4 y4]; 28 | mdelta4 = [1 x1 y1 ; 1 x2 y2 ; 1 x3 y3]; 29 | beta1 = -1*det(mbeta1); 30 | beta2 = det(mbeta2); 31 | beta3 = -1*det(mbeta3); 32 | beta4 = det(mbeta4); 33 | gamma1 = det(mgamma1); 34 | gamma2 = -1*det(mgamma2); 35 | gamma3 = det(mgamma3); 36 | gamma4 = -1*det(mgamma4); 37 | delta1 = -1*det(mdelta1); 38 | delta2 = det(mdelta2); 39 | delta3 = -1*det(mdelta3); 40 | delta4 = det(mdelta4); 41 | B1 = [beta1 0 0 ; 0 gamma1 0 ; 0 0 delta1 ; 42 | gamma1 beta1 0 ; 0 delta1 gamma1 ; delta1 0 beta1]; 43 | B2 = [beta2 0 0 ; 0 gamma2 0 ; 0 0 delta2 ; 44 | gamma2 beta2 0 ; 0 delta2 gamma2 ; delta2 0 beta2]; 45 | B3 = [beta3 0 0 ; 0 gamma3 0 ; 0 0 delta3 ; 46 | gamma3 beta3 0 ; 0 delta3 gamma3 ; delta3 0 beta3]; 47 | B4 = [beta4 0 0 ; 0 gamma4 0 ; 0 0 delta4 ; 48 | gamma4 beta4 0 ; 0 delta4 gamma4 ; delta4 0 beta4]; 49 | B = [B1 B2 B3 B4]/(6*V); 50 | D = (E/((1+NU)*(1-2*NU)))*[1-NU NU NU 0 0 0 ; NU 1-NU NU 0 0 0 ; NU NU 1-NU 0 0 0 ; 51 | 0 0 0 (1-2*NU)/2 0 0 ; 0 0 0 0 (1-2*NU)/2 0 ; 0 0 0 0 0 (1-2*NU)/2]; 52 | y = V*B'*D*B; 53 | 54 | -------------------------------------------------------------------------------- /matlab 有限元源程序/TetrahedronElementStresses.m: -------------------------------------------------------------------------------- 1 | function y = TetrahedronElementStresses(E,NU,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,u) 2 | %TetrahedronElementStresses This function returns the element 3 | % stress vector for a linear 4 | % tetrahedral (solid) element with 5 | % modulus of elasticity E, 6 | % Poisson's ratio NU, coordinates 7 | % of the first node (x1,y1,z1), 8 | % coordinates of the second node 9 | % (x2,y2,z2), coordinates of the 10 | % third node (x3,y3,z3), 11 | % coordinates of the fourth node 12 | % (x4,y4,z4), and element displacement 13 | % vector u. 14 | % The size of the element stress 15 | % vector is 6 x 1. 16 | xyz = [1 x1 y1 z1 ; 1 x2 y2 z2 ; 1 x3 y3 z3 ; 1 x4 y4 z4]; 17 | V = det(xyz)/6; 18 | mbeta1 = [1 y2 z2 ; 1 y3 z3 ; 1 y4 z4]; 19 | mbeta2 = [1 y1 z1 ; 1 y3 z3 ; 1 y4 z4]; 20 | mbeta3 = [1 y1 z1 ; 1 y2 z2 ; 1 y4 z4]; 21 | mbeta4 = [1 y1 z1 ; 1 y2 z2 ; 1 y3 z3]; 22 | mgamma1 = [1 x2 z2 ; 1 x3 z3 ; 1 x4 z4]; 23 | mgamma2 = [1 x1 z1 ; 1 x3 z3 ; 1 x4 z4]; 24 | mgamma3 = [1 x1 z1 ; 1 x2 z2 ; 1 x4 z4]; 25 | mgamma4 = [1 x1 z1 ; 1 x2 z2 ; 1 x3 z3]; 26 | mdelta1 = [1 x2 y2 ; 1 x3 y3 ; 1 x4 y4]; 27 | mdelta2 = [1 x1 y1 ; 1 x3 y3 ; 1 x4 y4]; 28 | mdelta3 = [1 x1 y1 ; 1 x2 y2 ; 1 x4 y4]; 29 | mdelta4 = [1 x1 y1 ; 1 x2 y2 ; 1 x3 y3]; 30 | beta1 = -1*det(mbeta1); 31 | beta2 = det(mbeta2); 32 | beta3 = -1*det(mbeta3); 33 | beta4 = det(mbeta4); 34 | gamma1 = det(mgamma1); 35 | gamma2 = -1*det(mgamma2); 36 | gamma3 = det(mgamma3); 37 | gamma4 = -1*det(mgamma4); 38 | delta1 = -1*det(mdelta1); 39 | delta2 = det(mdelta2); 40 | delta3 = -1*det(mdelta3); 41 | delta4 = det(mdelta4); 42 | B1 = [beta1 0 0 ; 0 gamma1 0 ; 0 0 delta1 ; 43 | gamma1 beta1 0 ; 0 delta1 gamma1 ; delta1 0 beta1]; 44 | B2 = [beta2 0 0 ; 0 gamma2 0 ; 0 0 delta2 ; 45 | gamma2 beta2 0 ; 0 delta2 gamma2 ; delta2 0 beta2]; 46 | B3 = [beta3 0 0 ; 0 gamma3 0 ; 0 0 delta3 ; 47 | gamma3 beta3 0 ; 0 delta3 gamma3 ; delta3 0 beta3]; 48 | B4 = [beta4 0 0 ; 0 gamma4 0 ; 0 0 delta4 ; 49 | gamma4 beta4 0 ; 0 delta4 gamma4 ; delta4 0 beta4]; 50 | B = [B1 B2 B3 B4]/(6*V); 51 | D = (E/((1+NU)*(1-2*NU)))*[1-NU NU NU 0 0 0 ; NU 1-NU NU 0 0 0 ; NU NU 1-NU 0 0 0 ; 52 | 0 0 0 (1-2*NU)/2 0 0 ; 0 0 0 0 (1-2*NU)/2 0 ; 0 0 0 0 0 (1-2*NU)/2]; 53 | y = D*B*u; 54 | 55 | -------------------------------------------------------------------------------- /matlab 有限元源程序/TetrahedronElementVolume.m: -------------------------------------------------------------------------------- 1 | function y = TetrahedronElementVolume(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4) 2 | %TetrahedronElementVolume This function returns the volume 3 | % of the linear tetrahedral element 4 | % whose first node has coordinates 5 | % (x1,y1,z1), second node has 6 | % coordinates (x2,y2,z2), third node 7 | % has coordinates (x3,y3,z3), and 8 | % fourth node has coordiantes 9 | % (x4,y4,z4). 10 | xyz = [1 x1 y1 z1 ; 1 x2 y2 z2 ; 1 x3 y3 z3 ; 1 x4 y4 z4]; 11 | y = det(xyz)/6; 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # matlab实现简单FEM有限元分析 2 | 3 | ## 1.文件介绍 4 | 5 | -matlab有限元源程序文件夹:中存储某教材的源程序,包括一系列函数; 6 | 7 | -fem文件夹:实现一个简单机构的有限元分析代码。 8 | 9 | ## 2.运行 10 | 11 | 运行fem文件夹中的fem_main.m文件 12 | 13 | ## 3.结果: 14 | 15 | - K.mat:矩阵 16 | - RF.mat/RF11.mat/RF22.mat:反力 17 | - strain.mat:应变 18 | - stress.amt:应力 19 | - u.mat:位移 20 | 21 | --------------------------------------------------------------------------------