A two-dimensional FE truss program 4M020: Design Tools Eindhoven University of Technology Introduction The Matlab program fem2d allows to model and analyze two-dimensional truss structures, where trusses are homogeneous and linear elastic. Deformation and rotations must be small, i.e. the behavior is geometrically linear. Model geometry, topology (connectivity), geometrical and material parameters and boundary conditions (prescribed displacements and point loads) must be available as input data. After reading this input, fem2d checks it and initializes some variables. Input data are stored in a data base. When the analysis is finished, output date are stored in the data base and various other data arrays. Save the file fem2d.tar in the directory fem and extract the tar-file. It is very convenient to make a text-file e.g. com.txt to save some Matlab commands which you can copy into the Matlab shell. In the following section an example input is presented, with explanatory comments. The program itself is explained in more detail in the last section. 2 Example input file As an example, the two-bar truss structure, shown in the figure below, will be modelled, loaded and analyzed. y 3 2 2 F x Both trusses have different geometrical and material properties, which are given in the table below.
2 truss a b cross-sectional area A 0 20 [mm 2 ] Young s modulus E 200 50 [GPa] Poisson s ratio ν 0.3 0.3 [-] Now lets see which Matlab commands do the job. Before starting, it might be wise to clear everything and close all figures. clear all; close all; First we give the coordinates of the nodes in the array crd0. Now we have to decide on the units and in this example we choose to model everything in mm. crd0 = [ 0 0; 00 0; 0 00/sqrt(3) ]; Then the connectivity of the elements is defined in the array lok. This array has a row for each element. The first column contains the element type, which is 9 for a truss. The second row is the element group number. Typically elements with the same properties are placed in one and the same group. Because our two elements indeed have different properties, they are placed in two different groups. The third and fourth column contain the first and second node of the element. lok = [ 9 2 ; 9 2 2 3 ]; Now we have to provide the geometrical and material properties in the array elda (element data). For each element group we have a row in elda. The first column contains a zero (0), which is not important for our use of fem2d. The second column contains the material identification number. For linear elastic material, which we will use here and also further in other cases, this number is (eleven). The third column contains the cross-sectional area (in mm 2 ). The fourth and fifth column are not used for our problems and always contain a zero (0). The sixth and seventh column contain Young s modulus and Poisson s ratio. So for our example we have : elda = [ 0 0 0 0 200000 0.3 0 20 0 0 50000 0.3 ]; Boundary conditions are prescribed nodal displacements and/or prescribed nodal forces. Prescribed nodal displacements are always needed to prevent rigid body motions. Prescribed displacements are provided in the array pp. For each prescribed displacement component we have one row. The first column contains the node, the second column contains the direction (either (= x = horizontal) or 2 (= y = vertical). The third column contains the value. For our example we have : pp = [ 0; 2 0; 3 0; 3 2 0; ]; The prescribed forces are given in the array pf. Again each prescribed force component is placed on a row, with the node in the first, the direction in the second and the value in the third column. For our example :
3 pf = [ 2 2-00 ]; That is about all. The input is complete and fem2d can be executed to analyze the behavior. fem2d; When the analysis is completed successfully, we want to see some results. First the nodal data, i.e. displacements and reaction forces. They are available in the array s MTp and Mfi. Rows contain nodal data : displacement and forces in the first ( = x = horizontal) and second (2 = y = vertical) directions. Just type the next commands in the Matlab shell. MTp Mfi Element data, like stress and strain, are available in the data base. This is a Matlab structure eda.eldac. For element e we find the date in the array eda(e).eldac. The relevant date can be found at the following locations : eda(e).eldac() = sine of angle between axis and -direction eda(e).eldac(2) = cosine of angle between axis and -direction eda(e).eldac(3) = length eda(e).eldac(4) = cross-sectional area eda(e).eldac(6) = linear axial strain eda(e).eldac(7) = axial stress eda(e).eldac() = axial stretch ratio eda(e).eldac(2) = radial stretch ratio eda(e).eldac(8) = axial force To see some results for our example just type the following in the Matlab shell : eda().eldac(6) eda().eldac(7) eda().eldac(8) eda(2).eldac(6) eda(2).eldac(7) eda(2).eldac(8) These values can ofcourse be stored and printed in various ways. The above input commands can also be put in one single input file, e.g. Ifem2d.m : clear all; close all; crd0 = [ 0 0; 00 0; 0 00/sqrt(2) ]; lok = [ 9 2 ; 9 2 2 3 ]; elda = [ 0 0 0 0 200000 0.3; 0 20 0 0 50000 0.3 ]; pp = [ 0; 2 0; 3 0; 3 2 0; ]; pf = [ 2 2-00 ];
4 3 The program fem2d The two-dimensional finite element program fem2d is not only suited to analyze truss structures. As we only use it for this purpose, the following explanation is confined to this use. It is recommended to look at the program listing, when reading the text. The program starts with a check of input variables and initialization. This is done in separate m-files. prog= fe2d ; checkinputn; daba; lcase; initialzero; After that the loop over all elements ne is started to make the system of equations. for e=:ne... end; % element loop e In this loop some data are extracted from the data base eda.elpa, which contains the element parameters. ety = element type egr = element group nenod = number of element nodes nedof = number of element degrees of freedom neip = number of element integration points The last variable is irrelevant for the truss element. Element nodal coordinates are also needed : ec0 = initial element nodal coordinates ec = current element nodal coordinates After initialization of element matrix ( em ) and force column ( ef ) to zero, the element stiffness matrix is made. Here we only show the part for the truss element ( ety = 9 ). [ML,V] = geomm(e,eda); l0 = eda(e).elda0(3); A0 = eda(e).elda0(4); E0 = eda(e).elda0(8); em = (A0/l0 * E0) * ML ; The m-file geomm is used to generate the array s ML and V. From the data base we extract the initial element length l0, cross-sectional area A0 and Young s modulus E0. The element stiffness matrix em is assembled into the structural stiffness matrix sm, using information on the connectivity, which is stored in the array lokvg, which finishes the element loop. Now that we have the left hand structural stiffness matrix sm, the right hand force column rs must be made from the prescribed nodal forces, which are contained in the array fe. The total system of equations is reduced by partitioning, which means that prescribed nodal displacements are taken into account. This is done with the m-file partit. The reduced equation system is solved and the solution is found in the column sol.
5 sol = inv(sm)*rs; From this solution array, the nodal displacements and new coordinates are extracted. To calculated element strains and stresses, we have to go into an element loop for the second time. Using the nodal displacements, various element values are calculated and stored in the data base. 4 Mesh plotting function Truss structures can be plotted in undeformed and deformed state with a Matlab function pmshn.m. The call to the function looks like : pmshn(option,lok,crd0,crd,eda) We recognize the arrays lok, crd0, crd and eda, respectively the location (connectivity) matrix, the coordinates in initial and current state and the element data base. The first argument is a column array with some options : option() = magfac : magnification factor option(2) = inimsh : -> plotting of initial mesh option(3) = nodpnt : -> plotting of nodal numbers option(4) = elmnrs : -> plotting of element numbers option(5:0) = 0 : values are not relevant for trusses So it will almost always be enough to use : option = [ 0 0 0 0 0 0 0 0]; pmshn(option,lok,crd0,crd,eda);