Professional Documents
Culture Documents
FEM TRUSS Mathematica
FEM TRUSS Mathematica
CreatedBy='Mathematica 4.2'
Mathematica-Compatible Notebook
This notebook can be used with any Mathematica-compatible
application, such as Mathematica, MathReader or Publicon. The data
for the notebook starts with the line containing stars above.
To get the notebook into a Mathematica-compatible application, do
one of the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the
application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematicacompatible application, you must delete the line below containing
the word CacheID, otherwise Mathematica-compatible applications may
try to use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info@wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from
Wolfram Research.
*******************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[
(*NotebookOutlinePosition[
(* CellTagsIndexPosition[
(*WindowFrame->Normal*)
14076,
15153,
15109,
365]*)
399]*)
395]*)
Notebook[{
Cell["\<\
To ASEN 5007 students: upon downloading this Notebook, check it out \
by following this procedure.
1. Initialize by picking Kernel -> Evaluation -> Evaluate Initialization. \
This will
execute (compile) Cells 1-6, which are marked as initialization cells.
Verify that the output of the cells (produced by the test statements \
in blue) agree
with the course Notes. (This shortcut initialization procedure may have \
changed in Versions 7-8; check the Help index)
2. Pick Cell 7 by clicking mouse on interior of cell. Execute by pressing \
<Shift-Enter>
on a Windows PC, or <Enter> on Mac. Check answers agree with Notes \
(Chapter 4)
3. Repeat for Cell 8. Check answers agree with Notes (Chapter 4) \
\>", \
"Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
FontFamily->"Times New Roman",
FontSize->14,
Background->RGBColor[1, 0.719951, 0.200015]],
Cell["\<\
Cell 1: module to form element stiffness of two-dimensional \
two-node bar element in global coordinates.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"ElemStiff2DTwoNodeBar[{{x1_,y1_},{x2_,y2_}},{Em_,A_}] := Module[\n \
{c,s,dx=x2-x1,dy=y2-y1,L,Ke}, \n
L=Sqrt[dx^2+dy^2]; c=dx/L; s=dy/L;\n
\
Ke=(Em*A/L)* {{ c^2, c*s,-c^2,-c*s},\n
{ c*s, \
s^2,-s*c,-s^2},\n
{-c^2,-s*c, c^2, s*c},\n
\
{-s*c,-s^2, s*c, s^2}}; \n
Return[Ke]\n ];\n",
StyleBox["Ke= ElemStiff2DTwoNodeBar[{{0,0},{10,10}},{100,2*Sqrt[2]}];\n\
Print[\"Numerical Elem Stiff Matrix:\"]; Print[Ke//MatrixForm];\nKe= \
ElemStiff2DTwoNodeBar[{{0,0},{L,L}},{Em,A}];\nKe=Simplify[Ke,L>0];\n\
Print[\"Symbolic Elem Stiff Matrix:\"]; Print[Ke//MatrixForm];",
FontColor->RGBColor[0, 0, 1]]
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 2: module to merge two-node bar element stiffness into the \
master stiffness matrix.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"MergeElemIntoMasterStiff[Ke_,eftab_,Kin_]:=Module[ {i,j,ii,jj,K=Kin}, \n
For [i=1, i<=4, i++, ii=eftab[[i]];\n
For [j=i, j<=4, j++, \
jj=eftab[[j]];\n
K[[jj,ii]]=K[[ii,jj]]+=Ke[[i,j]] \n
]\n ]; \
Return[K]\n];
\n",
StyleBox["K=Table[0,{6},{6}];\nPrint[\"Initialized master stiffness matrix:\
\"];\nPrint[K//MatrixForm]\n\
Ke=ElemStiff2DTwoNodeBar[{{0,0},{10,10}},{100,2*Sqrt[2]}];\nPrint[\"Member \
stiffness matrix:\"]; Print[Ke//MatrixForm];\n\
K=MergeElemIntoMasterStiff[Ke,{1,2,5,6},K]; \nPrint[\"Master stiffness after \
member merge:\"];\nPrint[K//MatrixForm];",
FontColor->RGBColor[0, 0, 1]]
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 3: module to assemble master stiffness matrix of example \
truss.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"AssembleMasterStiffOfExampleTruss[]:= Module[{Ke,K=Table[0,{6},{6}]},\n
\
Ke=ElemStiff2DTwoNodeBar[{{0,0},{10,0}},{100,1}];\n
K= \
MergeElemIntoMasterStiff[Ke,{1,2,3,4},K]; \n
\
Ke=ElemStiff2DTwoNodeBar[{{10,0},{10,10}},{100,1/2}];\n
K= \
MergeElemIntoMasterStiff[Ke,{3,4,5,6},K];\n
\
Ke=ElemStiff2DTwoNodeBar[{{0,0},{10,10}},{100,2*Sqrt[2]}];\n
K= \
MergeElemIntoMasterStiff[Ke,{1,2,5,6},K]; \n
Return[K]\n ];
\n",
StyleBox["K=AssembleMasterStiffOfExampleTruss[];\nPrint[\"Master stiffness \
of example truss:\"]; Print[K//MatrixForm];",
FontColor->RGBColor[0, 0, 1]]
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 4: modules to apply homogeneous, single-freedom displacement \
BCs on master stiffness and forces.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"ModifiedMasterStiffForDBC[pdof_,K_] := Module[\n \
{i,j,k,nk=Length[K],np=Length[pdof],Kmod=K}, \n
For [k=1,k<=np,k++, \
i=pdof[[k]]; \n
For [j=1,j<=nk,j++, Kmod[[i,j]]=Kmod[[j,i]]=0];\n
Kmod[[i,i]]=1];\n Return[Kmod]\n];\n\
ModifiedMasterForcesForDBC[pdof_,f_] := Module[\n \
{i,k,np=Length[pdof],fmod=f}, \n
For [k=1,k<=np,k++, i=pdof[[k]]; \
fmod[[i]]=0];\n Return[fmod]\n];
\n",
StyleBox["K=Array[Kij,{6,6}]; Print[\"Assembled master stiffness:\"]; \n\
Print[K//MatrixForm];\nK=ModifiedMasterStiffForDBC[{1,2,4},K];\n\
Print[\"Master stiffness modified for displacement B.C.:\"];\n\
Print[K//MatrixForm];\nf=Array[fi,{6}]; Print[\"Force vector:\"]; Print[f];\n\
f=ModifiedMasterForcesForDBC[{1,2,4},f];\nPrint[\"Force vector modified for \
displacement B.C.:\"]; Print[f];",
FontColor->RGBColor[0, 0, 1]]
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 5: module to compute the internal force in a two-dimensional \
two-node bar element.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"IntForce2DTwoNodeBar[{{x1_,y1_},{x2_,y2_}},{Em_,A_},eftab_,u_]:= \n \
Module[ {c,s,dx=x2-x1,dy=y2-y1,L,ix,iy,jx,jy,ubar,e}, \n
\
L=Sqrt[dx^2+dy^2]; c=dx/L; s=dy/L; {ix,iy,jx,jy}=eftab;\n
\
ubar={c*u[[ix]]+s*u[[iy]],-s*u[[ix]]+c*u[[iy]],\n
\
c*u[[jx]]+s*u[[jy]],-s*u[[jx]]+c*u[[jy]]};\n
e=(ubar[[3]]-ubar[[1]])/L; \
Return[Em*A*e]\n];\n",
StyleBox["p=IntForce2DTwoNodeBar[{{0,0},{10,10}},{100,2*Sqrt[2]},\n
\
{1,2,5,6},{0,0,0,0,0.4,-0.2}];\nPrint[\"Member int force (numerical):\"]; \
Print[N[p]];\np=IntForce2DTwoNodeBar[{{0,0},{L,L}},{Em,A},\n
\
{1,2,5,6},{0,0,0,0,ux3,uy3}];\nPrint[\"Member int force (symbolic):\"]; \
Print[Simplify[p]];",
FontColor->RGBColor[0, 0, 1]]
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 6: module to get internal forces in members of example truss.\
\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"IntForcesOfExampleTruss[u_]:= Module[{f=Table[0,{3}]},\n \
f[[1]]=IntForce2DTwoNodeBar[{{0,0},{10,0}},{100,1},{1,2,3,4},u];\n \
f[[2]]=IntForce2DTwoNodeBar[{{10,0},{10,10}},{100,1/2},{3,4,5,6},u];\n \
f[[3]]=IntForce2DTwoNodeBar[{{0,0},{10,10}},{100,2*Sqrt[2]},\n
\
{1,2,5,6},u]; \n Return[f]\n];
\n",
StyleBox["f=IntForcesOfExampleTruss[{0,0,0,0,0.4,-0.2}];\nPrint[\"Internal \
member forces in example truss:\"];Print[N[f]",
FontColor->RGBColor[0, 0, 1]],
"];"
}], "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
InitializationCell->True,
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["Cell 7: driver program to analyze example truss numerically.", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell["\<\
f={0,0,0,0,2,1};
K=AssembleMasterStiffOfExampleTruss[];
Kmod=ModifiedMasterStiffForDBC[{1,2,4},K];
fmod=ModifiedMasterForcesForDBC[{1,2,4},f];
u=Simplify[Inverse[Kmod].fmod];
Print[\"Computed nodal displacements:\"]; Print[u];
f=Simplify[K.u];
Print[\"External node forces including reactions:\"]; Print[f];
p=Simplify[IntForcesOfExampleTruss[u]];
Print[\"Internal member forces:\"]; Print[p];\
\>", "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 8: driver program for analysis of example truss, leaving \
forces at node 3 symbolic.\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell["\<\
f={0,0,0,0,fx3,fy3};
K=AssembleMasterStiffOfExampleTruss[];
Kmod=ModifiedMasterStiffForDBC[{1,2,4},K];
fmod=ModifiedMasterForcesForDBC[{1,2,4},f];
u=Simplify[Inverse[Kmod].fmod];
Print[\"Computed nodal displacements:\"]; Print[u];
f=Simplify[K.u];
Print[\"External node forces including reactions:\"]; Print[f];
p=Simplify[IntForcesOfExampleTruss[u]];
Print[\"Internal member forces:\"]; Print[p];\
\>", "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["Cell 9: for Exercise 5.7.", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell["\<\
xynode={{0,0},{10,0},{10,10}}; elenod={{1,2},{2,3},{3,1}};
unode={{0,0},{0,0},{2/5,-1/5}}; amp=5; p={};
For [t=0,t<=1,t=t+1/5,
For [e=1,e<=Length[elenod],e++, {i,j}=elenod[[e]];
xyi=xynode[[i]];ui=unode[[i]];xyj=xynode[[j]];uj=unode[[j]];
p=AppendTo[p,Graphics[Line[{xyi+amp*t*ui,xyj+amp*t*uj}]]];
];
];
Show[p,Axes->False,AspectRatio->Automatic];\
\>", "Input",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[0, 1, 0]],
Cell["\<\
Cell 10: Making all truss properties symbolic (initialize *this \
cell only* then run driver of Cell 8)\
\>", "Text",
CellFrame->True,
CellMargins->{{11, 9}, {Inherited, Inherited}},
CellLabelMargins->{{7, Inherited}, {Inherited, Inherited}},
ImageRegion->{{-0, 1}, {0, 1}},
Background->RGBColor[1, 1, 0]],
Cell[TextData[{
"AssembleMasterStiffOfExampleTruss[]:= Module[{Ke,K=Table[0,{6},{6}]},\n
\
Ke=ElemStiff2DTwoNodeBar[{{0,0},{L,0}},{E1,A1}];\n
K= \
MergeElemIntoMasterStiff[Ke,{1,2,3,4},K]; \n
\
Ke=ElemStiff2DTwoNodeBar[{{L,0},{L,H}},{E2,A2}];\n
K= \
MergeElemIntoMasterStiff[Ke,{3,4,5,6},K];\n
\
Ke=ElemStiff2DTwoNodeBar[{{0,0},{L,H}},{E3,A3}];\n
K= \
MergeElemIntoMasterStiff[Ke,{1,2,5,6},K]; \n
K=Simplify[K,L>0&&H>0];\n
\
Return[K]\n ];
\n",
StyleBox["K=AssembleMasterStiffOfExampleTruss[];\nPrint[\"Master stiffness \
of all-symbolic truss:\"]; Print[K//MatrixForm];",
FontColor->RGBColor[0, 0, 1]],
"\n"
}], "Input",
CellFrame->True,
Cell[10472,
Cell[11092,
Cell[11408,
Cell[12032,
Cell[12275,
Cell[12880,
Cell[13209,
}
]
*)
265,
283,
293,
311,
318,
335,
345,
617,
313,
621,
240,
602,
326,
863,
(*******************************************************************
End of Mathematica Notebook file.
*******************************************************************)