{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Plot" -1 13 1 {CSTYLE "" -1 -1 " Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 } } {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4974 "restart:\n# Finte \+ Element Truss Analysis Program\n#\n#********** GIVE THE NAME OF THE IN PUTFILE IN THE LINE BELOW ***********\n# Use fronts lash/ in place of backslash\\ \n# Enclose the name \+ in single backquotes`\n# End the line wit a col on:\n#\ninfilename:=\n`D:/Documents and Settings/blume/Desktop/tutoria l.inp.txt`:\n#\n#*************************** THEN HIT RETURN ********* ****************** \n# \n#******************************************** ***************************\n# load plotting and linear algebra map le packages\n#\nwith(plots):with(linalg):with(plottools):\n#\n# define an output file name\n#\nlifn:=length(infilename):\noutfilename:=cat(s ubstring(infilename,1..lifn-8),`.out.txt`):\n#\n# ================= Re ad data from the input file ==================\n#\n infile:=fopen( infilename,READ):\n#\n# Title:\n#\nruntitle := readline(infile):\n# \n# No. nodes and nodal coordinates\n#\nnnode := fscanf(infile,`%d` )[1]:\n coord := array(1..nnode,1..2):\n for i from 1 to nnode do \n coord[i,1] := fscanf(infile,`%f`)[1]:\n coord[i,2] := f scanf(infile,`%f`)[1]:\n od:\n#\n# No. elements connectivity, a nd material data.\n# connect[i,1] and connect[i,2] hold the two joint numbers for the\n# ith member. connect[i,3] holds EA for that member \n#\n nelem := fscanf(infile,`%d`)[1]:\n connect := a rray(1..nelem,1..3):\n for i from 1 to nelem do\n for j from 1 to 2 do\n connect[i,j] := fscanf(infile,`%d`)[1]:\n \+ od:\n connect[i,3] := fscanf(infile,`%e`)[1]:\n od:\n\n#\n# \+ No. degrees of freedom with prescribed displacements; prescribed \n # displacements\n# \n nfix := fscanf(infile,`%d`)[1]:\n fixnode s := array(1..nfix,1..3):\n for i from 1 to nfix do\n#\n# fixnode s[i,1] holds the number of the ith fixed node\n# fixnodes[i,2] holds t he direction (1 or 2) \n# fixnodes[i,3] holds the valus of the prescri bed displacement\n#\n fixnodes[i,1] := fscanf(infile,`%d`)[1]:\n fixnodes[i,2] := fscanf(infile,`%d`)[1]:\n fixnodes[i,3] \+ := fscanf(infile,`%e`)[1]:\n od:\n#\n# No. loaded nodes, with \+ the loads\n#\n nload := fscanf(infile,`%d`)[1]:\n loads := array (1..nload,1..3):\n#\n# Node number of ith loaded node is in loads[i ,1]\n# F1 and F2 for the ith loaded node are in loads[i,2] and load s[i,3]\n#\n for i from 1 to nload do\n loads[i,1] := fsc anf(infile,`%d`)[1]:\n loads[i,2] := fscanf(infile,`%e`)[1]:\n loads[i,3] := fscanf(infile,`%e`)[1]:\n od:\n fclose (infile):\n#\n#********************************GRAPHICS*************** *********************************\n#\n# Plot the undeformed mesh\n# \nelplot:=[seq([[coord[connect[i,1],1],coord[connect[i,1],2]],\n \+ [coord[connect[i,2],1],coord[connect[i,2],2]]], \+ i=1..nelem)]:\npnodes:=textplot(\{seq([coord[nn,1],co ord[nn,2],convert(nn,string)],nn=1..nnode)\},\n font=[TIMES,BOLD ,16]):\npels:=textplot(\{seq([(coord[connect[ne,1],1]+coord[connect[ne ,2],1])/2,\n (coord[connect[ne,1],2]+coord[connect [ne,2],2])/2,convert(ne,string)],\n ne=1..nelem) \},font=[HELVETICA,12]):\npm:=plot(elplot,axesfont=[TIMES,ROMAN,6],\nc olor=magenta,labelfont=[TIMES,ROMAN,12], titlefont=[TIMES,ROMAN,14],ti tle=cat(runtitle,`: Mesh`),\nthickness=3,labels=[`x1`,`x2`],scaling=co nstrained):\ndisplay(pm,pnodes,pels); \n#\n# Plot loads and BC\n#\n# \+ Scale the load vector by max element length*max load magnitude*.2\n# \nmaxlength:= max(seq(sqrt((coord[connect[ie,1],1]-coord[connect[ie,2] ,1])^2+\n (coord[connect[ie,1],2]-coord[connect[ie,2],2])^2),ie=1. .nelem)):\nmaxf:=max(seq(sqrt(loads[ii,2]^2+loads[ii,3]^2),ii=1..nload )):\nloadscale:=0.2*maxlength/(maxf+0.00001*maxlength):\n#\n# graphics of laod vectors\n#\nloadarrows:=seq(arrow([coord[loads[il,1],1],coord [loads[il,1],2]], [coord[loads[il,1],1]+loadscale*loads[il,2] ,coord[loads[il,1],2]+loadscale*loads[il,3]],\n .02 , .1, .3, color=green),il=1..nload):\n#\n# Scale the displacement arro ws by max element length*max presc. displacement*.2\n#\nmaxd:=max(seq( abs(fixnodes[ii,3]),ii=1..nfix)):\nbcscale:=0.2*maxlength/(maxd+0.0000 1*maxlength):\n\n#\n# graphics of BC vectors\n#\nbcarrows:=seq(arrow( \n [coord[fixnodes[il,1],1]-(2-fixnodes[il,2])*(fixnodes[il,3 ]+.05*maxlength),\n coord[fixnodes[il,1],2]-(fixnodes[il,2]- 1)*(fixnodes[il,3]+.05*maxlength)],\n [coord[fixnodes[il,1], 1],coord[fixnodes[il,1],2]],.01,.03,1-bcscale*fixnodes[il,3], \+ color=blue),il=1..nfix):\n#\n# graphics of load la bels\n#\nplls:=textplot(\{seq([(coord[loads[il,1],1]+loadscale*loads[i l,2]/2,coord[loads[il,1],2]+loadscale*loads[il,3]/2,convert(evalf(sqrt (loads[il,2]^2+loads[il,3]^2),3),string))],\n il= 1..nload)\},font=[HELVETICA,12]):\n#\ndisplay(plls,pm,bcarrows,loadarr ows,title=cat(runtitle,`: Load and BC`));\n#\n#*********************** *********END OF GRAPHICS***********************************\n#" }} {PARA 13 "" 1 "" {GLPLOT2D 320 320 320 {PLOTDATA 2 "60-%'CURVESG6%7$7$ $\"\"!F)F(7$$\"3i************pq!#=F+-%'COLOURG6&%$RGBG$\"*++++\"!\")F( F2-%*THICKNESSG6#\"\"$-F$6%7$F*7$$\"3#*************49!#,)*z%) !#5Q%1.006\"-%%FONTG6$%*HELVETICAG\"#7-%'CURVESG6%7$7$$\"\"!F:F97$$\"3 i************pq!#=F<-%'COLOURG6&%$RGBG$\"*++++\"!\")F9FC-%*THICKNESSG6 #\"\"$-F56%7$F;7$$\"3#*************49!# " 0 "" {MPLTEXT 1 0 7008 "#\n#================ ELEMENT STIF FNESS MATRIX ===================\n#\nelstif := proc (xa,ya,xb,yb,EA) \+ \n local elstif, nx, ny, length;\n#\n# Define the element lengt h and direction vector \n#\n length := sqrt((xa-xb)*(xa-xb)+(ya-yb)* (ya-yb));\n# \n nx := (xb-xa)/length;\n ny := (yb-ya)/length;\n \+ \n#\n# Define the element stiffness\n#\n elstif := evalm((EA /length)*array(1..4,1..4,\n [[nx*nx,nx*ny,-nx*nx,-nx*n y],\n [ny*nx,ny*ny,-ny*nx,-ny*ny],\n \+ [-nx*nx,-nx*ny,nx*nx,nx*ny],\n [-ny*nx,-ny*ny,ny*nx, ny*ny]]));\nend:\n#\n#===========Assemble the global stiffness matrix= =============\n#\nStif := array(1..2*nnode,1..2*nnode):\n for i from 1 to 2*nnode do\n for j from 1 to 2*nnode do\n Stif[i,j] := 0.0:\n od:\n od:\n#\n# Loop over all the elements\n#\nfor lm n from 1 to nelem do\n#\n# Set up the stiffness for the current elem ent\n#\n a := connect[lmn,1]:\n b := connect[lmn,2]:\n EA := \+ connect[lmn,3]:\n k := array(1..4,1..4):\n k:=elstif(coord[a,1], coord[a,2],coord[b,1],coord[b,2],EA):\n#\n# Add the current element \+ stiffness to the global stiffness\n#\n for i from 1 to 2 do\n \+ for ii from 1 to 2 do\n for j from 1 to 2 do\n for jj \+ from 1 to 2 do\n rw := 2*(connect[lmn,i]-1)+ii:\n \+ cl := 2*(connect[lmn,j]-1)+jj: \n Stif[rw,cl] := S tif[rw,cl] + k[2*(i-1)+ii,2*(j-1)+jj]:\n od:\n od:\n od:\n od:\n od:\n#\n# ==================== Assemble global residual vector ============\n#\n# Define the residual\n#\n resi d := array(1..2*nnode):\n for i from 1 to 2*nnode do\n resid[i ] := 0.:\n od:\n#\n# Loop loaded noads\n#\n for i from 1 to nl oad do\n a := loads[i,1]:\n f1 := loads[i,2]:\n f2 := l oads[i,3]:\n resid[2*a-1] := resid[2*a-1] + f1:\n resid[2*a] := resid[2*a] + f2:\n od:\n#\n# Modify the global stiffness a nd residual to include constraints\n#\n for i from 1 to nfix do\n \+ rw := 2*fixnodes[i,1]+fixnodes[i,2]-2:\n for j from 1 to 2* nnode do\n resid[j] := resid[j] - Stif[j,rw]*fixnodes[i,3]:\n \+ Stif[rw,j] := 0:\n Stif[j,rw] := 0:\n od;\n \+ Stif[rw,rw] := 1.0:\n resid[rw] := fixnodes[i,3]:\n od:\n #\n# ================== Solve the FEM equations ===================\n# \nu := linsolve(Stif,resid):\n#\n# Define a procedure to calculate the element strains\n#\nelstrain := proc (xa,ya,xb,yb,uax,uay,ubx,uby ) \n local elstrain, nx, ny, length, uel;\n#\n# length and direct ion vector for the element\n#\nlength := sqrt((xa-xb)*(xa-xb)+(ya-yb)* (ya-yb));\n# \n nx := (xb-xa)/length;\n ny := (yb-ya)/length;\n# \n# Element displacement vector\n#\n uel := array(1..4,[uax,uay, ubx,uby]);\n#\n# Element strains\n#\n elstrain := ((ubx-uax)*nx+ (uby-uay)*ny)/length;\nend:\n# \n# compute element forces and st rains:\n#\nfor lmn from 1 to nelem do\n a := connect[lmn,1]:\n \+ b := connect[lmn,2]:\n EA := connect[lmn,3]:\n xa := coor d[a,1]:\n ya := coord[a,2]:\n xb := coord[b,1]:\n yb := coord[b,2]:\n uxa := u[2*a-1]:\n uya := u[2*a]:\n uxb \+ := u[2*b-1]:\n uyb := u[2*b]:\n Strain[lmn] := elstrain(xa,y a,xb,yb,uxa,uya,uxb,uyb):\n Force[lmn]:=EA*Strain[lmn]; \n od: \n# \n#********************************GRAPHICS******************* **********************\n# \n#=====Plot the deformed mesh===\n#\n#= ====Displacements are scaled by 0.1*maximum displacement*maximum eleme nt length\n# \nmaxu:=max(seq(abs(u[ii]),ii=1..2*nnode)):\nplotscale :=0.1*maxlength/maxu:\nprint(`Displacements scaled by:`,plotscale);\n# \ndcoord:=array(1..nnode,1..2): \n for a from 1 to nnode do\n \+ xa := coord[a,1]:\n ya := coord[a,2]:\n uxa := u[2*a-1]:\n \+ uya := u[2*a]:\n dcoord[a,1]:=xa+plotscale*uxa:\n dcoord [a,2]:=ya+plotscale*uya:\n od:\ndefplot:=[seq([[dcoord[connect[i,1] ,1],dcoord[connect[i,1],2]],\n [dcoord[connect[i,2],1],dco ord[connect[i,2],2]]], i=1..nelem)]:\n #\npd:=plot(defplot,axesfont=[TIMES,ROMAN,10],\ncolor=green,labelfont= [TIMES,ROMAN,14], titlefont=[TIMES,BOLD,16],title=`Truss Mesh`,\nthick ness=3,labels=[`x1`,`x2`],scaling=constrained,title=cat(runtitle, `: D eformation`)): \n#\ndloadarrows:=seq(arrow([dcoord[loads[il,1],1],dcoo rd[loads[il,1],2]],\n [dcoord[loads[il,1],1]+loadscale*loads[ il,2],dcoord[loads[il,1],2]+loadscale*loads[il,3]],\n \+ .02, .1, .3, color=green),il=1..nload):\n#\n# Scale the bc vector b y max element length*max presc. displacement*.2\n#\nmaxd:=max(seq(abs( fixnodes[ii,3]),ii=1..nfix)):\nbcscale:=0.2*maxlength/(maxd+0.00001*ma xlength):\n\n#\n# graphics of bc\n#\ndbcarrows:=seq(arrow(\n \+ [dcoord[fixnodes[il,1],1]-(2-fixnodes[il,2])*(fixnodes[il,3]+.05*maxle ngth),\n dcoord[fixnodes[il,1],2]-(fixnodes[il,2]-1)*(fixnod es[il,3]+.05*maxlength)],\n [dcoord[fixnodes[il,1],1],dcoord [fixnodes[il,1],2]],.01,.03,1-bcscale*fixnodes[il,3], \+ color=blue),il=1..nfix):\n#\ndisplay(pd,pm,dbcarrows,dload arrows);\n#\n#====Display element forces graphically\n#\n#\npforce:=te xtplot(\{seq([(coord[connect[ne,1],1]+coord[connect[ne,2],1])/2,(coord [connect[ne,1],2]+coord[connect[ne,2],2])/2,convert(evalf(Force[ne],3) ,string)],ne=1..nelem)\},font=[HELVETICA,14]):\n#\ndisplay(\{pm,pnodes ,pforce\},titlefont=[TIMES,BOLD,16],title=cat(runtitle,`: Forces`),\nt hickness=3,scaling=constrained,axes=none);\n#\n#********************** ********** END OF GRAPHICS ***********************************\n#\n#\n # Print nodal displacements, element strains and forces\n#\noutfile :=fopen(outfilename,WRITE):\n#\nfprintf(outfile, `%s\\n`,runtitle):\nf printf(outfile,`%s %3d %3d\\n` ,`Number of Nodes and Elements:`,nnode, nelem):\nfprintf(outfile,`%s\\n`,`Node# x1 x2`):\n for i fro m 1 to nnode do\n fprintf(outfile,`%5d %9.4f %9.4f\\n`,\n \+ i,coord[i,1],coord[i,2]):\n od:\nfprintf(outfile,`%s\\n`, `El# Node 1 Node 2 EA`):\n for i from 1 to nelem do\n fp rintf(outfile,`%4d %10d %10d %9.4f\\n`,\n i,connect[ i,1],connect[i,2],connect[i,3]):\n od:\nfprintf(outfile,`%s\\n`,`Fix ed Node# DOF Value`):\n for i from 1 to nfix do\n fprintf(out file,`%9d %12d %10.4f\\n`,\n fixnodes[i,1],fixnodes[i ,2],fixnodes[i,3]):\n od:\nfprintf(outfile,`%s\\n`,`Loaded Node# \+ P1 P2`):\n for i from 1 to nload do\n fprintf(outfile,`%9 d %13.4f %9.4f\\n`,\n loads[i,1],loads[i,2],loads[i,3 ]):\n od:\nfprintf(outfile,`%s\\n`,` `):\nfprintf(outfile,`%s\\n`,`* ********************************`):\nfprintf(outfile,`%s\\n`,` `):\nfp rintf(outfile,`%s\\n`,`Nodal Displacements:`):\nfprintf(outfile,`%s\\n `,` Node u1 u2`):\n for i from 1 to nnode do\n fprintf (outfile,`%3d %8.4f %8.4f\\n`,i,u[2*i-1],u[2*i]):\n od:\nfprintf(out file,`%s\\n`,`Strains and Forces:`):\nfprintf(outfile,`%s\\n`,`Element Strain Force`):\n for i from 1 to nelem do\n fprintf(out file,`%3d %9.4f %9.4f\\n`,i,Strain[i],Force[i]):\n od:\nfclose(outfi le):\nprint(`End`);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$%9Displacements ~scaled~by:G$\"+`F'F0F7-F$6%7$F'7$$\"3i******** ****pqF-FI-F16&F3F4F(F4F7-F$6%7$FH7$$\"3#*************49FAF(FKF7-F$6%7 $FPF'FKF7-%)POLYGONSG6&7&7$$!++++]q!#6$!+++++]!#77$Fen$\"+++++]FjnF[oF Z7%7$Fen$\"+++++:FgnF'7$Fen$!+++++:Fgn-F16&F3F(F(F4-%&STYLEG6#%,PATCHN OGRIDG-F$6#7*FZF[oF[oF_oF'FboFZFZ-FW6&7&7$F\\oFen7$FhnFenFbpFap7%7$Fco FenF'7$F`oFenFeoFgo-F$6#7*FapFbpFbpFdpF'FepFapFap-FW6&7&7$$\"+RMOT8!\" *Fen7$$\"+RMOJ8F_qFenF`qF\\q7%7$$\"+RMO@8F_qFen7$$\"+RMOO8F_qF(7$$\"+R MO^8F_qFenFeoFgo-F$6#7*F\\qF`qF`qFdqFgqFjqF\\qF\\q-FW6&7&7$$\"+,DL/o!# 5$\"+******z%)Ffr7$$\"+,DL/mFfrFgr7$Fjr$\"+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "2 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }