User:Eml4500.f08.lulz.strack/hw5

MATLAB Code
The first part of the required MATLAB code debugs part of the two-bar truss system from Homework 2. The code is presented below for the corrected system representation and is called "TwoBarTrussSystemDebugged.m". It uses the same three functions (PlaneTrussElement.m, NodalSoln.m, PlaneTrussResults.m) defined in Homework 2. The only difference between "TwoBarTrussSystem.m" and "TwoBarTrussSystemDebugged.m" is Line 40 of code reproduced below the program.

The first part of the program defines the specifications of each bar and node including modulus of elasticity (e), cross-sectional area (A), and loading values (P). The "nodes" matrix defines the absolute locations of the three nodes. The "conn" matrix defines the global node numbers at the ends of each bar or element. Each row represents an element. As shown in the code, there are 2 sets of 2 numbers for the 2 nodes corresponding to each element. The "lmm" matrix represents the global degrees of freedom (dof) for each element. Each node has 2 dof's; therefore, each element has 4 corresponding dof's. Degrees of freedom are numbered from 1 to 6 where the first 2 correspond to the x and y direction of Global Node 1, the second 2 correspond to the x and y direction of Global Node 2, and the third 2 correspond to the x and y direction of Global Node 3. From all this data, the global stiffness matrix (K) is created. The displacements of the nodes are calculated by isolating the relevant parts of the global stiffness matrix, inverting them, and multiplying by the load array (R). Finally, the reactions (reactions) at each node are calculated by multiplying the displacement array (d) by the global stiffness matrix.

TwoBarTrussSystemDebugged.m
Line 40

Before

After

Command Window Output

>> TwoBarTrussSystemDebugged

k_local =

0.75       -0.75        -0.75         0.75

k =

0.5625     0.32476      -0.5625     -0.32476      0.32476       0.1875     -0.32476      -0.1875      -0.5625     -0.32476       0.5625      0.32476     -0.32476      -0.1875      0.32476       0.1875

k_local =

5   -5    -5     5

k =

2.5        -2.5         -2.5          2.5         -2.5          2.5          2.5         -2.5         -2.5          2.5          2.5         -2.5          2.5         -2.5         -2.5          2.5

K =

0.5625     0.32476      -0.5625     -0.32476            0            0      0.32476       0.1875     -0.32476      -0.1875            0            0      -0.5625     -0.32476       3.0625      -2.1752         -2.5          2.5     -0.32476      -0.1875      -2.1752       2.6875          2.5         -2.5            0            0         -2.5          2.5          2.5         -2.5            0            0          2.5         -2.5         -2.5          2.5

R =

0    0     0     7     0     0

d =

0           0        4.352       6.1271            0            0

reactions =

-4.4378     -2.5622       4.4378      -4.4378

results =

1.7081      5.1244       5.1244       0.6276        3.138        6.276

The displacement array (d) shows that Global Node 2 was displaced because it was the only unfixed node. The output also displays the reactions at the fixed nodes in the "reactions" matrix. The results matrix (results) shows the strain, stress, and axial force in each element. Homework 2, the results matrix changed from a 3x5 to a 3x3 matrix, showing that the bug was removed. Below are the tabular results of the output above. These values match the values computed using the statics method from Homework 2.

The next part of the MATLAB code constructs and loads a truss system composed of six bars. The code below represents Example 4.1 (SixBarTrussEx.m) on page 226 of the textbook. The code for this program is structured similarly to the code for the two-bar truss system. However, there are six elements and five nodes instead of two elements and three nodes.

There are two cases for this example. The original system (SixBarTrussEx.m), Case 1, is the code provided by textbook. Case 2 (SixBarTrussExModified.m) is the same system with a different modulus of elasticity for each element.

SixBarTrussEx.m (Case 1)
Command Window Output

>> SixBarTrussEx

K =

Columns 1 through 5

85355       35355       -50000            0            0        35355        35355            0            0            0       -50000            0        85355       -35355            0            0            0       -35355  1.0202e+005            0 0           0            0            0        71554            0            0            0            0       -35777            0            0            0            0            0            0            0            0       -66667            0       -35355       -35355       -35355        35355       -71554       -35355       -35355        35355       -35355        35777

Columns 6 through 10

0           0            0       -35355       -35355            0            0            0       -35355       -35355            0            0            0       -35355        35355            0            0       -66667        35355       -35355       -35777            0            0       -71554        35777        17889            0            0        35777       -17889            0        71554        35777       -71554       -35777            0        35777        84555       -35777       -17889        35777       -71554       -35777  2.1382e+005            0 -17889      -35777       -17889            0  1.0649e+005

R =

0           0        10000        17321            0            0            0            0            0            0

d =

0           0      0.21311      0.24998            0            0            0            0   -0.0060971     0.012242

reactions =

-10873     -217.27       874.27      -437.13      -1.7279       -16666

results =

5.3276e-005      10.655        10655 -4.6334e-006    -0.92669      -926.69 -4.8873e-006    -0.97746      -977.46 -8.3326e-005     -16.665       -16665 1.5363e-006     0.30727       307.27 -9.659e-009  -0.0019318      -1.9318

The displacement array (d) shows that Global Nodes 2 and 5 were displaced because these were the only unfixed nodes. The output also displays the reactions at the fixed nodes in the "reactions" matrix. The results matrix (results) show the strain, stress, and axial force in each element. Below are the tabular results of the output above.

To visualize the loaded and unloaded system, the following code graphs the system in its loaded and unloaded state. In order to be able to realize the direction of node movement, the unfixed node displacements have been magnified by the displacement magnification factor (m) of 3000. As shown, the original values from the displacement array (d(3), d(4), d(9), d(10)) above were used below to get the right proportions of the nodal displacements.

SixBarTrussDisplay.m
Command Window Output

>> SixBarTrussDisplay



The dashed red line represents the undeformed system shape. The solid blue line represents the deformed system shape. The abbreviations "GN" and "E" stand for Global Node and Element, respectively. Note only nodes 2 and 5 are displaced because they are unfixed.

The code below is the code for Case 2. Below the program are the line changes to the program for Case 1.

SixBarTrussExModified.m (Case 2)
Lines 2, 22, and 31

Before

After

Command Window Output

>> SixBarTrussExModified

K =

Columns 1 through 5

76391       38891       -37500            0            0        38891        38891            0            0            0       -37500            0        69320       -31820            0            0            0       -31820        98486            0            0            0            0            0        71554            0            0            0            0       -35777            0            0            0            0            0            0            0            0       -66667            0       -38891       -38891       -31820        31820       -71554       -38891       -38891        31820       -31820        35777

Columns 6 through 10

0           0            0       -38891       -38891            0            0            0       -38891       -38891            0            0            0       -31820        31820            0            0       -66667        31820       -31820       -35777            0            0       -71554        35777        17889            0            0        35777       -17889            0        89443        44721       -89443       -44721            0        44721        89027       -44721       -22361        35777       -89443       -44721  2.3171e+005        16015 -17889      -44721       -22361        16015  1.1096e+005

R =

0           0        10000        17321            0            0            0            0            0            0

d =

0           0      0.26485      0.26083            0            0            0            0   0.00063864    -0.001246

reactions =

-9908.3      23.619      -90.274       45.137      -1.4008       -17389

results =

6.6213e-005      9.9319       9931.9 5.347e-007    0.096245       96.245 5.0465e-007     0.10093       100.93 -8.6943e-005     -17.389       -17389 -1.5183e-007   -0.033402      -33.402 -6.2645e-009  -0.0015661      -1.5661

The displacement array (d) shows that Global Nodes 2 and 5 were displaced because these were the only unfixed nodes. The output also displays the reactions at the fixed nodes in the "reactions" matrix. The results matrix (results) show the strain, stress, and axial force in each element. Below are the tabular results of the output above.

To visualize the loaded and unloaded system, the following code graphs the system in its unloaded state and loaded states for Cases 1 and 2. For this display, the magnification factor was changed to 10000. Also, the labels have been removed for the global nodes and elements. The displacement array for Case 1 was changed from "d" to "d1". For Case 2, a new array was created called "d2" using the values in the displacement array from the output above.

SixBarTrussDisplayModified.m
Command Window Output

>> SixBarTrussDisplayModified



The dashed red line represents the undeformed system shape. The solid blue line represents the deformed system shape for Case 1. The dotted black line represents the deformed system shape for Case 2.

The next part of the MATLAB code constructs and loads a three dimensional truss system composed of three bars. The code below represents Example 4.2 (ThreeBarSpaceTrussEx.m) on page 230 of the textbook. The code for this program is structured similarly to the code for the two previous systems. However, this system is a space system where displacement and reactions are measured in three dimensions.

The format of the array "conn" doesn't change. On the other hand, the number of columns in "nodes" and "lmm" increase because the matrices are accommodating for movement in the Z-direction.

This program utilizes two new functions: "SpaceTrussElement.m" and "SpaceTrussResults.m". These are displayed below the program.

SpaceTrussResults.m
Command Window Output

>> ThreeBarSpaceTrussEx

K =

Columns 1 through 6

1459.7      2919.3      -3040.9            0            0            0       2919.3       5838.6      -6081.9            0            0            0      -3040.9      -6081.9       6335.3            0            0            0            0            0            0       3566.7      -3566.7       4953.8            0            0            0      -3566.7       3566.7      -4953.8            0            0            0       4953.8      -4953.8       6880.3            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0      -1459.7      -2919.3       3040.9      -3566.7       3566.7      -4953.8      -2919.3      -5838.6       6081.9       3566.7      -3566.7       4953.8       3040.9       6081.9      -6335.3      -4953.8       4953.8      -6880.3

Columns 7 through 12

0           0            0      -1459.7      -2919.3       3040.9            0            0            0      -2919.3      -5838.6       6081.9            0            0            0       3040.9       6081.9      -6335.3            0            0            0      -3566.7       3566.7      -4953.8            0            0            0       3566.7      -3566.7       4953.8            0            0            0      -4953.8       4953.8      -6880.3            0            0            0            0            0            0            0            0            0            0            0            0            0            0        60000            0            0       -60000            0            0            0       5026.4      -647.45       1912.9            0            0            0      -647.45       9405.4       -11036            0            0       -60000       1912.9       -11036        73216

d =

0           0            0            0            0            0            0            0            0     -0.18705       -2.592      -0.3858

reactions =

6666.7       13333       -13889      -6666.7       6666.7      -9259.3            0            0        23148

results =

0.00050936      101.87        20375   0.00033036       66.072        13214   -0.0001929       -38.58       -23148

The displacement array (d) shows that Global Node 4 was displaced because it was the only unfixed node. The output also displays the reactions at the fixed nodes in the "reactions" matrix. The results matrix (results) show the strain, stress, and axial force in each element. Below are the tabular results of the output above.

This problem is statically determinate. Because the system occupies a three-dimensional space, there exists three equations for equilibrium in the x, y, and z directions. There are also three unknown variables which are the axial forces reacting at Global Node 4 to accommodate the loading force (P).

The relationship between axial forces and directional forces is governed by the following equations.

The place holder "n" represents the nth Global Node or Element. The three equilibrium equations are shown below using the directional forces derived above.

When the equations for the directional forces are substituted into the above equations, the new equations only have the three axial forces as unknowns. The coefficients of these axial forces make up the matrix "F" in the following code. The "L" array defines the lengths of the three elements. The "R" array is the loading at Global Node 4 by force P in the negative Y-direction. The program below simultaneously solves the system of equations to determine the axial forces in the elements.

ThreeBarSpaceTrussStatics.m
Command Window Output

>> ThreeBarSpaceTrussStatics

L =

2.9339      2.8543            2

R =

0      20000           0

F =

0.32721     -0.5045            0      0.65441       0.5045            0     -0.68168     -0.70069           -1

axial_forces =

20375       13214       -23148

The axial forces produced using the statics method matches exactly to the values obtained in the table above for the FEA method. This proves that the system is statically determinate.

To visualize the loaded and unloaded system, the following code graphs the system in its loaded and unloaded state. In order to be able to realize the direction of node movement, the unfixed node displacements have been magnified by the displacement magnification factor (m) of 300. As shown, the original values from the displacement array (d(10), d(11), d(12)) above were used below to get the right proportions of the nodal displacements.

ThreeBarSpaceTrussDisplay.m
Command Window Output

>> ThreeBarSpaceTrussDisplay



The dashed red line represents the undeformed system shape. The solid blue line represents the deformed system shape. The abbreviations "GN" and "E" stand for Global Node and Element, respectively. Note only node 4 is displaced because it is unfixed. This view is a perspective view as if the observer was looking at the system from the global location (-2,-2,3).

The next three view are views along each axis (X, Y, Z), respectively. Line 27 from "ThreeBarTrussDisplay.m" was modified as shown below for each plot. The only other changes to the code were locations of the "GN" and "E" labels which are trivial.

Line 27

Before

After View along X-axis:

View along Y-axis:

View along Z-axis: