plane truss analysis by a cas · macsyma (born at mit ai lab in 1968, restricted access by dod...

30
Introduction to FEM 4 Plane Truss Analysis by a CAS IFEM Ch 4 – Slide 1

Upload: hoanglien

Post on 11-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

4Plane Truss

Analysisby a CAS

IFEM Ch 4 – Slide 1

Page 2: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Computer Algebra Systems: What Are They?

Computer tools to help humans solve math problems

Especially: algebra and calculus

Why do humans need help?

IFEM Ch 4 – Slide 2

Page 3: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

The Three Big Ma's in Order of Appearance

Macsyma (born at MIT AI Lab in 1968, restricted access by DoD

until late 1980s, died 1999, continued as free source)

Maple (1982)

Mathematica (1994)

Matlab is not a CAS but has a Symbolic Toolbox (ST)("Ma" in Matlab stands for Matrix, not Math)

And a host of minor players: Mathcad, MuPAD, etcMatlab ST uses MuPAD after 2008 (before that, Maple)(Maple is powerful, but the Matlab interface was ugly)

IFEM Ch 4 – Slide 3

Page 4: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Why Mathematica?

Implemented on many platforms (Maple is primarily used under Unix, no Mac version)Support severall programming models Imperative, object, functionalPublication quality graphicsGood documentation & many application booksProgramming facilitiesPublication quality graphicsGood documentation & many application booksFree to students amd faculty

Inefficient in floating-point computations by orders of magnitude compared to, say, Fortran or CList data structures may be difficult for beginners

Strong points

Weak points

IFEM Ch 4 – Slide 4

Page 5: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Mathematica vs. Matlab Coverage

MATHEMATICA

MATLABsans MuPAD

Toolbox

Symboliccalculations

Exact numericcalculations

Floating-point(a.k.a. inexact) numeric

calculations

Floating-point(a.k.a. inexact) numeric

calculations

Source code: C++ Source code: Fortran

IFEM Ch 4 – Slide 5

Page 6: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Popularity Contest by Number of "Hits" on www3.addall.com Book Search Engine (Sep 2017)

books in printMacsyma 2 Maple 20 Mathematica 108 Matlab 110MuPAD 7

Other languages: C++ 102, Java 107, Python 113, HTML 101, Fortran 53, Lisp 51

IFEM Ch 4 – Slide 6

Page 7: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Last Major Releases of Mathematica

Version 2.2 1995 Version 3.0 1997Version 4.0 1999, 4.1 2001, 4.2 2002Version 5.0 2003, 5.1 2004, 5.2 2005Version 6.0 2007Version 7.0 2009Version 8.0 2011Version 9.0 2012Version 10.0 2014Version 11.0 2017

IFEM Ch 4 – Slide 7

Page 8: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Eligibility: students, faculty, staff and departments of all CU campusesPlatforms: Mac OSX, Windows, Linux, Solaris, AIX, HP-UX

How to Get It

1) Download and install software as per instructions at http://oit.colorado.edu/software-hardware/site-licenses/mathematicaor contact the Site Licensing office: [email protected], 303-492-8995

2) Register your copy online at http://register.wolfram.com/ usingcampus license number L2437-5121 plus your computer MathID number.Be sure to use your CU mail address.

3) A password (unique to your computer) will be forwarded to you viaemail from Site Licensing

ITS Support

Question & tech support problems: send email to [email protected] hands-on workshops are available for those new to the software,click on Workshops on the Web page given above.Details (for example: what is a MathID?) about licensing & support are posted at the above web site.

IFEM Ch 4 – Slide 8

Page 9: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Mathematica Programming Model

UI is interpretative: input-outputTwo programs: Front-end and KernelFiles are cell-organizedEvery action is done by a function e.g. For and If are functions

Two data structures: atoms and lists

IFEM Ch 4 – Slide 9

Page 10: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Hot Areas in Computation(Starting salaries in 6 figures)

Superfast (GPU based) graphicsBig dataAI and roboticsBioinformaticsLarge scale networking and securityMultimedia

Several of these, notably AI, rely on list data structures

IFEM Ch 4 – Slide 10

Page 11: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Lists in Mathematica

A list is a sequence of objects separated by commasand delimited by curly braces:

mylist = {obj-1, obj-2, ... obj-n}

Objects can be atoms (numbers, symbols,character strings, sound records, etc), or lists.

Thus a list may contain sublists, which may containsub-sub-lists, ... ad infinitum.

IFEM Ch 4 – Slide 11

Page 12: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

List Examples

Arrays are lists of objects of the same type. Examples:

A 6-vector of integers: v= {1,2,3,4,5,6}

A 4 x 2 matrix of floating-point numbers: A = {{0.1,0.2,0.3,0.4}, {0.5,0.6,0.7,0.8}}

A 2 x 2 x 2 array of symbols: S = {{{a1,a2},{a3,a4}},{{a5,a6},{a7,a8}}}

IFEM Ch 4 – Slide 12

Page 13: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

More Complicated List Examples

A graphic object: p = {plotcommand1,plotcommand2, ... plotcommand-n}

A silent movie: Metropolis={setup,frame-1,....frame-n,finish}

A movie with sound:

ET={setup,frame-1,sound-1,....frame-n,sound-n,finish}

IFEM Ch 4 – Slide 13

Page 14: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

A Mathematica File (called Notebook) is a Sequence of Cells of Different Types. Three Common Types Are:

Integration example

f[x_,α_,β_]:=(1+β*x^2)/(1+α*x+x^2);F=Integrate[f[x,-1,2],{x,0,5}]; F=Simplify[F]; Print[F]; Print[N[F]]; F=NIntegrate[f[x,-1,2],{x,0,5}]; Print["F=",F//InputForm];

13.0445F=13.044522437723455

Input Cell

Text Cell

Print Output Cell10 + Log[21]

IFEM Ch 4 – Slide 14

Page 15: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEMContinuation of Last Slide, Showing a Plot CellFa=Integrate[f[z,a,b],{z,0,5}]; Fa=Simplify[Fa]; Print["Fa=",Fa]; Plot3D[Fa,{a,-1.5,1.5},{b,-10,10},ViewPoint->{-1,-1,1}];Fa=FullSimplify[Fa]; (* very slow but you get *) Print["Fa=",Fa];

-1

0

1

-10

-5

0

5

10-50

0

50

-1

0

1

12

Print Output after Simplify[ ..]

Print Output after FullSimplify[ .. ]

Plot Output Cell

Input Cell

Fa=5b - a b Log[26+5a] -

(2 + (-2 + a2) b) (Log[1- ]- Log[1+ ] - Log[1- ]+ Log[1+ ])4-a24-a2 4-a2 4-a2

a a (10+a)(10+a)

4 - a 22

4 - a 22

4 - a 2

4 - a 2

4 - a 2 4 - a 2 4 - a 2

4 - a 2 4 - a 2

4 - a 2

4 - a 24 - a 2

Fa= (10 4-a 2 b - a 4-a2 b Log[26+5a] - (2+(-2+a2) b) Log[1- ] +

2 Log[1 + ] - 2 b Log[1 + ] + a2 b Log[1 + ] +

2 Log[ ] - 2 b Log[ ] + a2 b Log[ ] -

2 Log[ ] + 2 b Log[ ] - a2 b Log[ ])

1

a

a

a a

-10 - a + 4-a2

10 + a + 4-a2 10 + a + 4-a2 10 + a + 4-a2

-10 - a + 4-a2-10 - a + 4-a2

IFEM Ch 4 – Slide 15

Page 16: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Notebook Cells Are Color CodedHere Are My Conventions

Background:

Strong yellow: text cell Light green: input cell White or light yellow output cell Sahara user instruction cell (first cell of a complicated posted NB)

Text color in input (green BG) cells: Black normal code Blue test code Red debug code - often commented out

IFEM Ch 4 – Slide 16

Page 17: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Plane Truss Program Configuration

Built-in Equation Solver

Derived inChapter 2

User preparedscript

Element Library Pre- and Postprocessing Utilities

Printing PlottingBar Element Stiffness

Bar InternalForce

Application ofSupport BCs

Problem Driver

StiffnessAssembler

Internal Force Recovery

IFEM Ch 4 – Slide 17

Page 18: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Plane Truss Program Module Names

Cell 6:PrintPlaneTrussNodeCoordinatesPrintPlaneTrussElementDataPrintPlaneTrussFreedomActivityPrintPlaneTrussNodeDisplacementsPrintPlaneTrussNodeForcesPrintNodeTrussIntForcesPrintPlaneTrussStresses

Cell 1: PlaneBarStiffness

Cell 4:PlaneBarIntForce

Built in Equation Solver

Print Plot

Cell 3:AppliedForceVectorModifiedMasterStiffnessModifiedNodeForcePrescDispBCTagsPrescDispBCVals

Cells 10 & higher: Driver Scripts

User preparedscripts

Cell 2:PlaneTrussMasterSttiffness

Cell 5: PlaneTrussIntForcesPlaneTrussStresses

Pre- and Postprocessing Utilities

Processing

Cells 7,8,9:PlotPlaneTrussElementsPlotPlaneTrussElementsAndNodesPlotPlaneTrussDeformedShapePlotPlaneTrussStressesLineColor

IFEM Ch 4 – Slide 18

Page 19: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Module to Form Element Stiffness Matrix of Plane Bar

Numerical Elem Stiff Matrix:

Symb Elem Stiff Matrix:

10 10 -10 -10-10 10 -10 -10-10 -10 10 10-10 -10 10 10

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

A Em 2 2 L

- -

- -

- -

- -

1 1 -1 -1-1 1 -1 -1-1 -1 1 1-1 -1 1 1

= *

PlaneBarStiffness[{{x1_,y1_},{x2_,y2_}},Em_,A_]:= Module[ {c,s,x21=x2-x1,y21=y2-y1,LLe,Le,Ke}, LLe=x21^2+y21^2; Le=PowerExpand[Sqrt[LLe]]; c=x21/Le; s=y21/Le; Ke=(Em*A/Le)*{{ c^2, c*s,-c^2,-c*s},

{ c*s, s^2,-s*c,-s^2}, {-c^2,-s*c, c^2, s*c}, {-s*c,-s^2, s*c, s^2}};

Return[Ke]];

Ke= PlaneBarStiffness[{{0,0},{10,10}},100,2*Sqrt[2]];Print["Numerical Elem Stiff Matrix: ",Ke//MatrixForm];ClearAll[Em,A,L]; Ke= PlaneBarStiffness[{{0,0},{L,L}},Em,A];Ke=Simplify[Ke,L>0]; fac=Em*A/(2*Sqrt[2]*L); Kesc=Simplify[Ke/fac];Print["Symb Elem Stiff Matrix: ",Ke//MatrixForm, " = ",fac,"*",Kesc//MatrixForm];

IFEM Ch 4 – Slide 19

Page 20: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Plane Truss Master Stiffness Assembler

Master stiffness of example truss:

20 10 −10 0 −10 −1010 10 0 0 −10 −10

−10 0 10 0 0 0

0 0 0 5 0 −5−10 −10 0 0 10 10

−10 −10 0 −5 10 15

PlaneTrussMasterStiffness[nodxyz_,elenod_,elemat_,elefab_]:= Module[{numele=Length[elenod],numnod=Length[nodxyz],e,eft, ni,nj,ncoor,Em,A,Ke,K}, K=Table[0,{2*numnod},{2*numnod}]; For [e=1,e<=numele,e++, {ni,nj}=elenod[[e]]; eft={2*ni-1,2*ni,2*nj-1,2*nj}; ncoor={nodxyz[[ni]],nodxyz[[nj]]}; Em=elemat[[e]]; A=elefab[[e]]; Ke=PlaneBarStiffness[ncoor,Em,A]; For [i=1,i<=4,i++, ii=eft[[i]];

For [j=i,j<=4,j++, jj=eft[[j]]; K[[jj,ii]]=K[[ii,jj]]+=Ke[[i,j]]; ];

]; ]; Return[K]];

nodxyz={{0,0},{10,0},{10,10}}; elenod={{1,2},{2,3},{1,3}};elemat={100,100,100}; elefab={1,1/2,2*Sqrt[2]}; K=PlaneTrussMasterStiffness[nodxyz,elenod,elemat,elefab];Print["Master stiffness of example truss: ",K//MatrixForm];

IFEM Ch 4 – Slide 20

Page 21: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEMModules to Modify Master Stiffness & Forces for Displacement BC

AppliedForceVector[nodtag_,nodval_]:= Module[{i,ftag,fval, numdof,f}, {ftag,fval}={Flatten[nodtag],Flatten[nodval]}; numdof=Length[ftag]; f=Table[0,{numdof}]; For [i=1,i<=numdof,i++, If [ftag[[i]]==0, f[[i]]=fval[[i]]]]; Return[f]];

ModifiedMasterStiffness[nodtag_,K_] := Module[ {i,j,k,n=Length[K],pdof,np,Kmod=K}, pdof=PrescDispDOFTags[nodtag]; np=Length[pdof]; For [k=1,k<=np,k++, i=pdof[[k]]; For [j=1,j<=n,j++, Kmod[[i,j]]=Kmod[[j,i]]=0]; Kmod[[i,i]]=1]; Return[Kmod]];

ModifiedNodeForces[nodtag_,nodval_,K_,f_]:= Module[ {i,j,k,n=Length[K],pdof,pval,np,d,c,fmod=f}, pdof=PrescDispDOFTags[nodtag]; np=Length[pdof]; pval=PrescDispDOFValues[nodtag,nodval]; c=Table[1,{n}]; For [k=1,k<=np,k++, i=pdof[[k]]; c[[i]]=0]; For [k=1,k<=np,k++, i=pdof[[k]]; d=pval[[k]]; fmod[[i]]=d; If [d==0, Continue[]]; For [j=1,j<=n,j++, fmod[[j]]-=K[[i,j]]*c[[j]]*d]; ]; Return[fmod]];

Auxiliary modules PrescDispDOFTags and PrescDispDOFValuesnot listed for lack of space. See Figure 4.9 of Notes.

IFEM Ch 4 – Slide 21

Page 22: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Testing Apply-Displacement-BC Modules

K before BC:

K11 K22 K13 K14 K15 K16K12 K22 K23 K24 K25 K26K13 K23 K33 K34 K35 K36K14 K24 K34 K44 K45 K46K15 K25 K35 K45 K55 K56K16 K26 K36 K46 K56 K66

f before BC:{0, 0, 0, 0, 2, 1}

K modified for BC:

nodtag={{1,1},{0,1},{0,0}}; nodval={{-1,2},{0,3},{2,1}};K={{K11,K12,K13,K14,K15,K16},{K12,K22,K23,K24,K25,K26}, {K13,K23,K33,K34,K35,K36},{K14,K24,K34,K44,K45,K46}, {K15,K25,K35,K45,K55,K56},{K16,K26,K36,K46,K56,K66}};Print["K before BC:",K//MatrixForm];f=AppliedForceVector[nodtag,nodval];Print["f before BC:",f]; Kmod=ModifiedMasterStiffness[nodtag,K];Print["K modified for BC:",Kmod//MatrixForm];fmod=ModifiedNodeForces[nodtag,nodval,K,f];Print["f modified for BC:",fmod];

1 0 0 0 0 00 1 0 0 0 00 0 K33 0 K35 K360 0 0 1 0 00 0 K35 0 K55 K560 0 K36 0 K56 K66

f modified for BC:{-1, 2, K13 - 2 K23 - 3 K34, 3, 2 + K15 - 2 K25 - 3 K45, 1 + K16 - 2 K26 - 3 K46}

IFEM Ch 4 – Slide 22

Page 23: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Module that Computes Internal Force in Plane Bar Element

Bar int force (numerical): 2.82843

Bar int force (symbolic): - A Em (ux1 - ux3 + uy1 - uy3)

2L

PlaneBarIntForce[{{x1_,y1_},{x2_,y2_}},Em_,A_,ue_]:= Module[ {x21=x2-x1,y21=y2-y1,dux,duy,LLe,pe}, LLe=x21^2+y21^2; dux=ue[[3]]-ue[[1]]; duy=ue[[4]]-ue[[2]]; pe=(Em*A/LLe)*(x21*dux+y21*duy); Return[pe]];

pe=PlaneBarIntForce[{{0,0},{10,10}},100,2*Sqrt[2],{0,0,0.4,-0.2}];Print["Bar int force (numerical): ",pe]; ClearAll[Em,A,L,ux1,uy1,ux3,uy3];pe=PlaneBarIntForce[{{0,0},{L,L}},Em,A,{ux1,uy1,ux3,uy3}];Print["Bar int force (symbolic): ",Simplify[pe]];

IFEM Ch 4 – Slide 23

Page 24: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEMModules to Compute Bar Internal Forces

and Stresses in a Plane Truss

Internal bar forces in example truss: {0., -1, 2.82843}

Bar stresses in example truss: {0., -2., 1.}

PlaneTrussIntForces[nodxyz_,elenod_,elemat_,elefab_,noddis_]:= Module[{numele=Length[elenod],e,ni,nj,encoor,Em,A,ue,elefor}, elefor=Table[0,{numele}]; For [e=1,e<=numele,e++, {ni,nj}=elenod[[e]];

encoor={nodxyz[[ni]],nodxyz[[nj]]}; Em=elemat[[e]]; A=elefab[[e]]; ue=Flatten[{noddis[[ni]],noddis[[nj]]}]; elefor[[e]]=PlaneBarIntForce[encoor,Em,A,ue];

]; Return[elefor]];

PlaneTrussStresses[elefab_,elefor_]:= Module[ {numele=Length[elefab],e,elesig}, elesig=Table[0,{numele}]; For [e=1,e<=numele,e++, elesig[[e]]=elefor[[e]]/elefab[[e]] ]; Return[elesig]];

nodxyz={{0,0},{10,0},{10,10}}; elenod={{1,2},{2,3},{1,3}};elemat={100,100,100}; elefab={1,1/2,2*Sqrt[2]}; noddis={{0,0},{0,0},{0.4,-0.2}};elefor=PlaneTrussIntForces[nodxyz,elenod,elemat,elefab,noddis];Print["Internal bar forces in example truss: ",N[elefor]];elesig=PlaneTrussStresses[elefab,elefor];Print["Bar stresses in example truss: ",N[elesig]];

IFEM Ch 4 – Slide 24

Page 25: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEMDriver To Analyze Example Truss with All-Numerical Data

ClearAll[a,Em,A1,A2,A3,fx2,fx3,fy3]; a=10; Em=100; A1=1; A2=1/2; A3=2*Sqrt[2]; fx2=0; fx3=2; fy3=1;nodxyz={{0,0},{a,0},{a,a}}; elenod={{1,2},{2,3},{1,3}};elemat={Em,Em,Em}; elefab=N[{A1,A2,A3}];nodtag={{1,1},{0,1},{0,0}}; nodval={{0,0},{fx2,0},{fx3,fy3}};PrintPlaneTrussNodeCoordinates[nodxyz,"Node coords of example truss:",{6,4}];PrintPlaneTrussElementData[elenod,elemat,elefab,"Element data of example truss:"{7,4}]; PrintPlaneTrussFreedomActivity[nodtag,nodval,"DOF activity of example truss:",{}];aspect=1.0; imgsiz=250; box={{0-d,0-d},{a+d,0-d},{a+d,a+d},{0-d,a+d}}/.d->.5; labels={{True,0.02,-1.5,1.5},{True,0.04},{"Times",12,"Plain","Italic"}};PlotPlaneTrussElementsAndNodes[nodxyz,elenod,"Example truss elems & nodes:", {aspect,imgsiz,labels}];K=PlaneTrussMasterStiffness[nodxyz,elenod,elemat,elefab];f=AppliedForceVector[nodtag,nodval];Kmod=ModifiedMasterStiffness[nodtag,K];Print["K=",K//MatrixForm," Kmod=",Kmod//MatrixForm];fmod=ModifiedNodeForces[nodtag,nodval,K,f];Print["f=",f//MatrixForm," fmod=",fmod//MatrixForm];u=Simplify[LinearSolve[Kmod,fmod]]; u=Chop[u]; noddis=Partition[u,2];PrintPlaneTrussNodeDisplacements[noddis,"Example truss node displacements:",{10,6}];box={{0-d,0-d},{a+d,0-d},{a+d,a+d},{0-d,a+d}}/.d->1; PlotPlaneTrussDeformedShape[nodxyz,elenod,noddis,{0,1,2},box,"Example truss"<> " orig & 2 deformed shapes",{aspect,imgsiz,{"red","blue","green"}}]; f=Simplify[K.u]; nodfor=Partition[f,2];PrintPlaneTrussNodeForces[nodfor,"Example truss node forces w/ reactions:",{10,6}];elefor=PlaneTrussIntForces[nodxyz,elenod,elemat,elefab,noddis];elesig=PlaneTrussStresses[elefab,elefor]; {elefor,elesig}=Chop[{elefor,elesig}];PrintPlaneTrussElemForcesAndStresses[elefor,elesig,"Example truss elem"<>

" forces & stresses:",{7,4}];box={{0-d,0-d},{a+d,0-d},{a+d,a+d},{0-d,a+d}}/.d->.5; PlotPlaneTrussStresses[nodxyz,elenod,elesig,1,box, "Example truss elem stresses",{aspect,imgsiz,labels}];

IFEM Ch 4 – Slide 25

Page 26: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Result From All-Numeric-Data Analysis

Node coords of example truss:

node x−coor y−coor1 0.0000 0.00002 10.0000 0.00003 10.0000 10.0000

Element data of example truss:

elem nodes modulus area1 {1, 2} 100.0000 1.00002 {2, 3} 100.0000 0.50003 {1, 3} 100.0000 2.8284

DOF activity of example truss:

node x−tag y−tag x−value y−value1 1 1 0 02 0 1 0 03 0 0 2 1

Example truss elems & nodes:

1

23

1 2

3

K=

20. 10. −10. 0 −10. −10.10. 10. 0 0 −10. −10.

−10. 0 10. 0 0 0

0 0 0 5. 0 −5.−10. −10. 0 0 10. 10.

−10. −10. 0 −5. 10. 15.

Kmod=

1 0 0 0 0 0

0 1 0 0 0 0

0 0 10. 0 0 0

0 0 0 1 0 0

0 0 0 0 10. 10.

0 0 0 0 10. 15.

f

0

0

0

0

2

1

fmod=

0

0

0

0

2

1

Example truss node displacements:

node x−displ y−displ1 0.000000 0.0000002 0.000000 0.0000003 0.400000 −0.200000

Example truss orig & 2 deformed shapes

Example truss node forces w reactions:

node x−force y−force1 −2.000000 −2.0000002 0.000000 1.0000003 2.000000 1.000000

Example truss elem forces & stresses:

elem axial force axial stress1 0.0000 0.00002 −1.0000 −2.00003 2.8284 1.0000

Example truss elem stresses

(Output cells rearranged in 3 columns to fit slide)

IFEM Ch 4 – Slide 26

Page 27: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Example Truss Analyzed With Symbolic Forces(Shorter Driver Because Plot Commands Removed)

ClearAll[fx2,fx3,fy3];nodxyz={{0,0},{10,0},{10,10}}; elenod={{1,2},{2,3},{1,3}};elemat={100,100,100}; elefab={1,1/2,2*Sqrt[2]}; nodtag={{1,1},{0,1},{0,0}}; nodval={{0,0},{fx2,0},{fx3,fy3}};Print["Node coord of example truss:",nodxyz];Print["Element data of example truss:",{elenod,elemat,elefab}];Print["DOF activity of example truss:",{nodtag,nodval}];K=PlaneTrussMasterStiffness[nodxyz,elenod,elemat,elefab];f=AppliedForceVector[nodtag,nodval];Kmod=ModifiedMasterStiffness[nodtag,K];fmod=ModifiedNodeForces[nodtag,nodval,K,f];u=Simplify[LinearSolve[Kmod,fmod]]; noddis=Partition[u,2]; Print["Computed node displacements:",u];f=Simplify[K.u]; nodfor=Partition[f,2];Print["Node forces including reactions:",f];elefor=PlaneTrussIntForces[nodxyz,elenod,elemat,elefab,noddis];elesig=PlaneTrussStresses[elefab,elefor];Print["Elem forces: ",elefor]; Print["Elem stresses: ",elesig];

Node coord of example truss:{{0, 0}, {10, 0}, {10, 10}}

Element data of example truss:{{{1, 2}, {2, 3}, {1, 3}, {100, 100, 100}, {1, , 2 2 }}

DOF activity of example truss:{{{1, 1},{0, 1}, {0, 0}}, {{0, 0}, {fx2, 0}, {fx3, fy3}}}

Computed node displacements: {0, 0, , 0, (3 fx3 - 2 fy3), (-fx3 + fy3)}

Node forces including reactions:{-fx2 - fx3, -fx3, fx2, fx3 - fy3, fx3, fy3}

Element forces: {fx2, -fx3 + fy3, (3 fx3 - 2 fy3 + 2 (-fx3 + fy3))}

Elem stresses: {fx2, 2 (-fx3 + fy3), (3 fx3 - 2 fy3 + 2(-fx3 + fy3))}

12

12

110

15

fx210

2

IFEM Ch 4 – Slide 27

Page 28: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEMDriver to Analyze Example Truss with All-Symbolic Data

Node coord of example truss:{{0, 0}, {a, 0}, {a, b}}

Element data of example truss: {{{1, 2}, {2, 3}, {1, 3}}, {Em, Em, Em}, {A1, A2, A3}}

DOF activity of example truss:{{1,1}, {0, 1}, {0, 0}}, {{0, 0}, {fx2, 0}, {fx3,fy3}}}

Computed node displacements:

{0, 0, , 0, , }

Elem forces: { fx2,- + fy3, }

Elem stresses: { , , }

a fx2 A2 (a + b ) fx3 + A3 b (b fx3 - a fy3) b (-b fx3 + a fy3)

b fx3 a + b fx3

b fx3fx2 + fy3 a + b fx3

A1 Em a A2 A3 Em a A2 Em

a a

a A1 A2 a A3

2

3/22 2

2

22

2

2

-

ClearAll[fx2,fx3,fy3,a,b,A1,A2,A3,Em];nodxyz={{0,0},{a,0},{a,b}}; elenod={{1,2},{2,3},{1,3}};elemat={Em,Em,Em}; elefab={A1,A2,A3}; nodtag={{1,1},{0,1},{0,0}}; nodval={{0,0},{fx2,0},{fx3,fy3}};Print["Node coord of example truss:",nodxyz];Print["Element data of example truss:",{elenod,elemat,elefab}];Print["DOF activity of example truss:",{nodtag,nodval}];K=PlaneTrussMasterStiffness[nodxyz,elenod,elemat,elefab];K=Simplify[K,a>0&&b>0];f=AppliedForceVector[nodtag,nodval];Kmod=ModifiedMasterStiffness[nodtag,K];fmod=ModifiedNodeForces[nodtag,nodval,K,f];u=Simplify[LinearSolve[Kmod,fmod],a>0&&b>0]; noddis=Partition[u,2]; Print["Computed node displacements:",u];f=Simplify[K.u,a>0&&b>0]; nodfor=Partition[f,2];Print["Node forces including reactions:",f];elefor=PlaneTrussIntForces[nodxyz,elenod,elemat,elefab,noddis];elefor=Simplify[elefor,a>0&&b>0];elesig=PlaneTrussStresses[elefab,elefor]; elesig=Simplify[elesig,a>0&&b>0];Print["Elem forces: ",elefor]; Print["Elem stresses: ",elesig];

IFEM Ch 4 – Slide 28

Page 29: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

5-Member Plane Truss For Homework #2

����

��

��

1 2

4

3(1) (2)

(3) (4)(5)

P

2a

b

x

y

Same E for all members

Members (3),(4) and (5) have equal cross-section areas, and so do (1) and (2). The former are twice the areas of the latter.

IFEM Ch 4 – Slide 29

Page 30: Plane Truss Analysis by a CAS · Macsyma (born at MIT AI Lab in 1968, restricted access by DoD until late 1980s, died 1999, continued as free source) ... Two programs: Front-end and

Introduction to FEM

Member Stress Plot for 5-Member Plane Truss

Truss member stresses

Red: tension, blue: compression

IFEM Ch 4 – Slide 30