平面三角形单元有限元程序设计

合集下载

Fortran语言编写弹性力学平面问题3节点三角形单元或4节点等参单元的有限元程序

Fortran语言编写弹性力学平面问题3节点三角形单元或4节点等参单元的有限元程序

Fortran语言编写弹性力学平面问题3节点三角形单元或4节点等参单元的有限元程序:c--------------------------------------------------------------------------c.....FEA2DP---A finite element analysis program for2D elastic problemscc Tangent matrix is stored with varioud band methodc This program is used to demonstrte the usage of vrious bandc Storage schem of symmetric and unsymmetric tangent matrixcc Wang shunjinc At chongqing vniversity(06/06/2013)c-------------------------------------------------------------------------program FEA2DPcc a(1)-a(n1-1):x(ndm,nummnp);a(n1)-a(n2-1):f(ndf,numnp)c a(n2)-a(n3-1):b(neq);a(n3)-a(n4-1):ad(neq)c a(n4)-a(n5-1):al(nad);a(n5)-a(n6-1):nu(nad)cc ia(1)-ia(n1-1):ix(nen1,numel);ia(n1)-ia(n2-1):id(ndf,numnp)c ia(n2)-ia(n3-1):jd((ndf*numnp);ia(n3)-ia(n4-1):idl(nen*numel*ndf)cimplicit real*8(a-h,o-z)dimension a(100000),ia(1000)character*80headcommon/cdata/numnp,numel,nummat,nen,neqcommon/sdata/ndf,ndm,nen1,nstcommon/iofile/ior,iowcnmaxm=100000imaxm=1000ior=1iow=2cc Open files for data input and outputcopen(ior,file='input.dat',form='formatted')open(iow,file='output.dat')cc.....Read titlecread(ior,'(a)')headwrite(iow,'(a)')headcc.....Read and print control informationcc numnp:number of nodesc numel:number of elementsc nummat:number of material typesc nload:number of loadsc ndm:number of coordinats of each nodec ndf:number of degrees of freedomc nen:number of nodes in each elementcread(ior,'(7i5)')numnp,numel,nummat,nload,ndm,ndf,nenwrite(iow,2000)numnp,numel,nummat,nload,ndm,ndf,nen cc.....Set poiters for allocation of data arrayscnen1=nen+4nst=nen*ndfnneq=ndf*numnpcn1=ndm*numnp+1n2=n1+ndf*numnp+1ci1=nen1*numel+1i2=i1+ndf*numnp+1i3=i2+ndf*numnp+1i4=i3+numel*nen*ndf+1cc.....Call mesh input subroutine to read all mesh dataccall pmesh(a(1),a(n1),ia(1),ia(i1),ndf,ndm,nen1,nload)cpute profileccall profil(ia(i2),ia(i3),ia(i1),ia(1),ndf,nen1,nad)cn3=n2+neq+1n4=n3+neq+1n5=n4+nad+1n6=n5+nad+1cc The lengthes of real and integer arrayscwrite(iow,2222)n6,i4cc The lengthes of array exceeds the limitationcif(n6>nmaxm.or.i4>imaxm)thenif(n6>nmaxm)write(iow,3333)n6,nmaxmif(i4>nmaxm)write(iow,4444)i4,imaxmstopend ifctute and aseemble element arraysccall assem(nad,ia(1),ia(i1),ia(i2),a(1),a(n2),a(n3),1a(n4),a(n5))cc Form load vectorccall pload(ia(i1),a(n1),a(n2),nneq,neq)cc.....Triangular decomposition of a matrix stored in profile formccall datri(ndf,numnp,ia(i2),neq,nad,.false.,a(n3),a(n5),a(n5))cc For unsymmtric tangent matirxc Call datri(ndf,numnp,ia(i2),neq,nad,.true.,a(n3),a(n4),a(n5))cc Solve equationsccall dasol(ndf,numnp,a(n2),ia(i2),neq,nad,aengy,a(n3),a(n5),a(n5)) cc For unsymmetric tangent matrixc Call dasol(ndf,numnp,a(n2),ia(i2),neq,nad,aengy,a(n3),a(n5),a(n5)) cc Output nodal displacementsccall prtdis(ia(i1),a(n2),ndf,numnp,neq)cc.....Close input and output files;destroy temporary disk filescclose(ior)close(iow)cc.....Input/output formatsc1000format(20a4)2000format(//x5x,'number of nodal points=',i6/15x,'number of elements=',i6/25x,'number of material sets=',i6/35x,'number of nodal loads=',i6/45x,'dimension of coordinate space=',i6/55x,'degree of freedoms/node=',i6/65x,'nodes per element(maximum)=',i6)2222format(//,10x,'the lengthe of real array is',i10,/,110x,'the lengthe of integer array is',i10)3333format(//,10x,'the lengthe of real array',i10,'exceed the',1'maximun value',i10)4444format(//,10x,'the lengthe of integer array',i10,'exceed the',1'maximun value',i10)cstopendccsubroutine pmesh(x,f,ix,id,ndf,ndm,nen1,nload)cc......Data input routine for mesh descriprioncimplicit real*8(a-h,o-z)dimension x(ndm,numnp),f(ndf,numnp),id(ndf,numnp),ix(nen1,numel)common/bdata/head(20)common/cdata/numnp,numel,nummat,nen,neqcommon/mater/ee,xnu,itypecommon/iofile/ior,iowcc.....Input constrain codes and nodal coordinate datacc id(k,j):constrain code of kth degree of freedom of node j,=0:free,=1:fixed c x(k,j):kth coordinate of node jcdo i=1,numnpread(ior,'(3i5,2f10.4)')j,(id(k,j),k=1,ndm),(x(k,j),k=1,ndm) end docwrite(iow,'(//17hnodal coordinates,/)')do i=1,numnpwrite(iow,'(3i5,2f10.4)')i,(id(k,i),k=1,ndm),(x(k,i),k=1,ndm) end docc.....element data inputcc ix(k,j):global node number of kth node in element jcdo i=1,numelread(ior,'(9i5)')j,(ix(k,j),k=1,nen)end docwrite(iow,'(//,18helement definition,/)')do i=1,numelwrite(iow,'(9i5)')j,(ix(k,j),k=1,nen)end docc.....Material data inputcc ee:young's modulus,xnu:poisson ratioc itype:type of problem,=1,:plane stress,=2:plane strain,=3:axi-symmetric cread(ior,'(2f10.4,i5)')ee,xnu,itypewrite(iow,'(//,19hmateial properties,/)')write(iow,'(2(e10.4,5x),i5)')ee,xnu,itypecc.....force/disp data inputcc f(k,j):concentrate load at node j in k directioncf=0.0d0do i=1,nloadread(ior,'(i5,2f10.4)')j,(f(k,j),k=1,ndf)end docwrite(iow,'(//,20happlied nodal forces,/)')do i=1,nloadwrite(iow,'(i5,2f10.4)')j,(f(k,j),k=1,ndf)end docreturncc format statementsc2000format('mesh1>',$)3000format(1x,'**warning**element connections necessary'1'to use block in macro program')4000format('**current problem valies**'/i6,'nodes,',1i5,'elmts,',i3,'matls,',i2,'dims,',i2,'dof/node,',2i3,'nodes/elmt')endccsubroutine assem(nad,ix,id,jd,x,b,ad,al,au)cc Call element subroutine and assemble global tangent matrixcimplicit real*8(a-h,o-z)dimension ilx(nen),xl(ndf,nen),ld(ndf,nen),s(nst,nst),p(nst)dimension ix(nen1,numel),id(ndf,numnp),jd(ndf*numnp)dimension x(ndm,numnp),b(neq),ad(neq),al(nad),au(nad)common/cdata/numnp,numel,nummat,nen,neqcommon/sdata/ndf,ndm,nen1,nstcnel=nencc elenment loopcdo320n=1,numels=0.0d0!element stiffness matrixp=0.0d0!nodal forcene=ndo310i=1,nenilx(i)=ix(i,ne)!current element definitiondo k=1,ndmxl(k,i)=x(k,ilx(i))!nodal coords in current elementend dokk=ilx(i)do k=1,ndfld(k,i)=id(k,kk)!equation numbersend do310continuecc Call element libccall elmt01(xl,ilx,s,p,ndf,ndm,nst)cc Asemmble tangent matrix and load vector if neededccall dasbly(ndf,nad,s,p,ld,jd,nst,b,ad,al,au)c320continue!end element loopcreturnendccsubroutine dasbly(ndf,nad,s,p,ld,jp,ns,b,ad,al,au)cc.....Assemble the symmetric or unsymmetric arrays for'dasol'cimplicit real*8(a-h,o-z)c logical alfl,aufl,bfldimension ad(neq),al(nad),au(nad)dimension ld(ns),jp(ndf*numnp),b(neq),s(ns,ns),p(ns)common/cdata/numnp,numel,nummat,nen,neqcommon/iofile/ior,iowcc alfl=true:for unsymmetric matirx assemblec alfl=false:for symmetric matirx assemblec s:element stiffness matrixc p:load or internal force vectorc ad:diagonal elementsc au:upper triangle elementsc al:lower triangle elementsc jp:pointer to last element in each row/column of al/au respectivec ld:equation numbers of each freedom degree in an element(get from id) cc.....Loop through the rows to perform the assemblycdo200i=1,nsii=ld(i)if(ii.gt.0)thenc if(aufl)then!assemble stiffness matrixcc.....Loop through the columns to perform the assemblycdo100j=1,nsif(ld(j).eq.ii)thenad(ii)=ad(ii)+s(i,j)elseif(ld(j).gt.ii)thenjc=ld(j)jj=ii+jp(jc)-jc+1au(jj)=au(jj)+s(i,j)c if(alfl)al(jj)=al(jj)+s(j,i)!unsymmetricendif100continueendifc if(bfl)b(ii)=b(ii)+p(i)!assemble nodal forcec endif200continuecreturnendccsubroutine dasol(ndf,numnp,b,jp,neq,nad,energy,ad,al,au)cc.....Solution of symmetric equations in profile formc.....Coeficient matrix must be decomposed into its triangularc.....Factor using datri beforce using dasol.cc jp:pointer to last element in each row/column of al/au respecive ccimplicit real*8(a-h,o-z)dimension ad(neq),al(nad),au(nad)dimension b(neq),jp(ndf*numnp)common/iofile/ior,iowdata zero/0.0d0/cc.....Find the first nonzero entry in the ring hand sidecdo is=1,neqif(b(is).ne.zero)go to200end dowrite(iow,2000)returnc200if(is.lt.neq)thencc.....Reduce the right hand sidecdo300j=is+1,neqjr=jp(j-1)jh=jp(j)-jrif(jh.gt.0)thenb(j)=b(j)-dot(al(jr+1),b(j-jh),jh)end if300continueend ifcc.....Multiply inverse of diagonal elementscenergy=zerodo400j=is,neqbd=b(j)b(j)=b(j)*ad(j)energy=energy+bd*b(j)400continuecc.....backsubstitutioncif(neq.gt.1)thendo500j=neq,2,-1jr=jp(j-1)jh=jp(j)-jrif(jh.gt.0)thencall saxpb(au(jr+1),b(j-jh),-b(j),jh,b(j-jh))end if500continueend ifcreturnc2000format('**dasol warning1**zero right-hand-side vector') endccsubroutine datest(au,jh,daval)cc.....test for rankcimplicit real*8(a-h,o-z)dimension au(jh)cdaval=0.0d0cdo j=1,jhdaval=daval+abs(au(j))end docreturnendccsubroutine datri(ndf,numnp,jp,neq,nad,flg,ad,al,au)cc.....Triangular decomposiontion of a matrix stored in profile form cimplicit real*8(a-h,o-z)logical flgdimension jp(ndf*numnp),ad(neq),al(nad),au(nad)common/iofile/ior,iowcc.....n.b.tol should be set to approximate half-word precision.cdata zero,one/0.0d0,1.0d0/,tol/0.5d-07/cc.....Set initial values for contditioning checkcdimx=zerodimn=zerocdo j=1,neqdimn=max(dimn,abs(ad(j)))end dodfig=zerocc.....Loop through the columns to perform the triangular decomposition cjd=1do200j=1,neqjr=jd+1jd=jp(j)jh=jd-jrif(jh.gt.0)thenis=j-jhie=j-1cc.....If diagonal is zeor compute a norm for singularity testcif(ad(j).eq.zero)call datest(au(jr),jh,daval)do100i=is,iejr=jr+1id=jp(i)ih=min(id-jp(i-1),i-is+1)if(ih.gt.0)thenjrh=jr-ihidh=id-ih+1au(jr)=au(jr)-dot(au(jrh),al(idh),ih)if(flg)al(jr)=al(jr)-dot(al(jrh),au(idh),ih)end if100continueend ifcc.....Reduce the diagonalcif(jh.ge.0)thendd=ad(j)jr=jd-jhjrh=j-jh-1call dredu(al(jr),au(jr),ad(jrh),jh+1,flg,ad(j))cc.....Check for possible errors and print warningscif(abs(ad(j)).lt.tol*abs(dd))write(iow,2000)jif(dd.lt.zero.and.ad(j).gt.zero)write(iow,2001)jif(dd.gt.zero.and.ad(j).lt.zero)write(iow,2001)jif(ad(j).eq.zero)write(iow,2002)jif(dd.eq.zero.and.jh.gt.0)thenif(abs(ad(j)).lt.tol*daval)write(iow,2003)jendifendifcc.....Stroe reciprocal of diagonal,compute condition checkscif(ad(j).ne.zero)thendimx=max(dimx,abs(ad(j)))dimn=min(dimn,abs(ad(j)))dfig=max(dfig,abs(dd/ad(j)))ad(j)=one/ad(j)end if200continuecc.....Print conditioning informationcdd=zeroif(dimn.ne.zero)dd=dimx/dimnifig=dlog10(dfig)+0.6write(iow,2004)dimx,dimn,dd,ifigcreturncc.....formatsc2000format('**datri warning1**loss of at least7digits in', 1'reducing diagonal of equation',i5)2001format('**datri warning2**sign of changed when', 1'reducing equation',i5)2002format('**datri warning3**reduced diagonal is zero zeri for', 1'equation',i5)2003format('**datri warning4**rank failure ffo zero unreduced', 1'diagonal in equation',i5)2004format(//'conditon check:d-max',e11.4,';d-min',e11.4, 1';ratio',e11.4/'maximim no.diagonal digits lost:',i3) 2005format('cond ck:dmax',1p1e9.2,';dmin',1p1e9.2,1';ratio',1p1e9.2)endccsubroutine dredu(al,au,ad,jh,flg,dj)cc.....Reduce diagonal element in triangular decompositioncimplicit real*8(a-h,o-z)logical flgdimension al(jh),au(jh),ad(jh)cdo j=1,jhud=au(j)*ad(j)dj=dj-al(j)*udau(j)=udend docc.....Finish computation of column of al for unsymmetric matricescif(flg)thendo j=1,jhal(j)=al(j)*ad(j)end doend ifcreturnendccsubroutine profil(jd,idl,id,ix,ndf,nen1,nad)cpute profile of global arrayscimplicit real*8(a-h,o-z)dimension jd(ndf*numnp),idl(numel*nen*ndf),id(ndf,numnp),1ix(nen1,numel)common/cdata/numnp,numel,nummat,nen,neqcommon/frdata/maxfcommon/iofile/ior,iowcc jd:column hight(address of diagonal elements)c id:boudary condition codes before this bubroutine's runningc id:equation numbers in global array(excluded restrained nodes)after running c idl:element strech orderc nad:total number of non-zero elements except diagonal elementsc in global tangent matrixcc.....Set up the equation numberscneq=0cdo10k=1,numnpdo10n=1,ndfj=id(n,k)if(j.eq.0)thenneq=neq+1id(n,k)=neqelseid(n,k)=0endif10continuecpute column heightsccall pconsi(jd,neq,0)cdo50n=1,numelmm=0nad=0do30i=1,nenii=iabs(ix(i,n))if(ii.gt.0)thendo20j=1,ndfjj=id(j,ii)if(jj.gt.0)thenif(mm.eq.0)mm=jjmm=min(mm,jj)nad=nad+1idl(nad)=jjendif20continueend if30continueif(nad.gt.0)thendo40i=1,nadii=idl(i)jj=jd(ii)jd(ii)=max(jj,ii-mm)40continueendif50continuecpute diagongal pointers for profilecnad=0jd(1)=0if(neq.gt.1)thendo60n=2,neqjd(n)=jd(n)+jd(n-1)60continuenad=jd(neq)end ifcc.....Set element search order to sequentialcdo70n=1,numelidl(n)=n70continuecc.....equation summarycmaxf=0mm=0if(neq.gt.0)mm=(nad+neq)/neqwrite(iow,2001)neq,numnp,mm,numel,nad,nummatcreturnc2001format(5x,'neq=',i5,5x,'numnp=',i5,5x,'mm=',i5,/5x, 1'numel=',i5,5x,'nad=',i5,5x,'nummat=',i5/) endcsubroutine saxpb(a,b,x,n,c)cc.....Vector times scalar added to second vectorcimplicit real*8(a-h,o-z)dimension a(n),b(n),c(n)cdo k=1,nc(k)=a(k)*x+b(k)end docreturnendcsubroutine pconsi(iv,nn,ic)cc.....Zero integer arraycdimension iv(nn)cdo n=1,nniv(n)=icend docreturnendcsubroutine elmt01(xl,ilx,s,p,ndf,ndm,nst)cc.....plane linear elastic element routinec ityp=1:plane stressc=2:plane strainc=3:axisymmetriccimplicit real*8(a-h,o-z)dimension xl(ndm,nen),ilx(nen),sigr(6)dimension d(18),s(nst,nst),p(nst),shp(3,9),sg(16),tg(16),wg(16)character wd(3)*12common/cdata/numnp,numel,nummat,nen,neqcommon/mater/ee,xnu,itypecommon/iofile/ior,iowdata wd/'plane stress','plane strain','axisymmetric'/cc xl(ndm,nen):coords of each node in current elementc ilx(nen):element definition of current elementc d(18):materials propertiesc s(nst,nst):element stiffness matrixc p(ns):nodal force and internal forcec shp(3,9):shape function and its derivativesc sg(16),tg(16),wg(16):weight coefficients of guass intergtation c l,k:integration pointscl=2k=2e=eenel=nencc d(14):thickness;d(11),d(12):body forcesc.....Set material patameter type and flagscityp=max(1,min(ityp,3))j=min(ityp,2)cd(1)=e*(1.+(1-j)*xnu)/(1.+xnu)/(1.-j*xnu)d(2)=xnu*d(1)/(1.+(1-j)*xnu)d(3)=e/2./(1.+xnu)d(13)=d(2)*(j-1)if((d(14).le.0.0d0).or.ityp.ge.2)d(14)=1.0d(15)=itypd(16)=ed(17)=xnud(18)=-xnu/el=min(4,max(1,l))k=min(4,max(1,k))d(5)=ld(6)=kc d(9)=t0c d(10)=e*alp/(1.-j*xnu)lint=0cwrite(iow,2000)wd(ityp),d(16),d(17),d(4),l,k,d(14),1d(11),d(12)cc.....stiffness/residual computationcl=kcc Compute cordinates and weights of integtation pointc`sg,tg:cootds;wg=wp*wqcif(l*l.ne.lint)call pguass(l,lint,sg,tg,wg)cpute integrals of shape functionscdo340l=1,lintcc Compute shape function and their derivatives to local and global coordinate systemccall shape(sg(l),tg(l),xl,shp,xsj,ndm,nen,ilx,.false.)cc Compute global coordinates of integration pointscxx=0.0yy=0.0do j=1,nenxx=xx+shp(3,j)*xl(1,j)yy=yy+shp(3,j)*xl(2,j)end doxsj=xsj*wg(l)*d(14)!xsj+|j|(sp,tq)*wp*wq*tcpute jacobian correction for plane stress and strain problemscif(ityp.le.2)thendv=xsjxsj=0.0zz=0.0c sigr4=-d(11)*dv!d(11)body forceelsecc For anisymmetric problemcdv=xsj*xx*3.1415926*2.zz=1./xxc sigr4=sigr(4)*xsj-d(11)*dvendifj1=1cc.....Loop over rowscdo330j=1,nelw11=shp(1,j)*dvw12=shp(2,j)*dvw22=shp(3,j)*xsjw22=shp(3,j)*dv*zzccpute the internal forces out of balancecc p(j1)=p(j1)-(shp(1,j)*sigr(1)+shp(2,j)*sigr(2))*dvc1-shp(3,j)*sigr4c p(j1+1)=p(j1+1)-(shp(1,j)*sigr(2)+shp(2,j)*sigr(3))*dvc1+d(12)*shp(3,j)*dv!d(12)body force cc.....Loop over columns(symmetry noted)c Compute stiffness matrixck1=j1a11=d(1)*w11+d(2)*w22a21=d(2)*w11+d(1)*w22a31=d(2)*(w11+w22)a41=d(3)*w12a12=d(2)*w12a32=d(1)*w12a42=d(3)*w11do320k=j,nelw11=shp(1,k)w12=shp(2,k)w22=shp(3,k)*zzs(j1,k1)=s(j1,k1)+w11*a11+w22*a21+w12*a41s(j1+1,k1)=s(j1+1,k1)+(w11+w22)*a12+w12*a42s(j1,k1+1)=s(j1,k1+1)+w12*a31+w11*a41s(j1+1,k1+1)=s(j1+1,k1+1)+w12*a32+w11*a42k1=k1+ndf320continuej1=ndf+j1330continue340continuecc.....Make stiffness symmetriccdo360j=1,nstdo360k=j,nsts(k,j)=s(j,k)360continuecreturncc.....Formats for input-outputc1000format(3f10.0,3i10)1001format(8f10.0)2000format(/5x,a12,'linear elastic element'//110x,'modulus',e18.5/10x,'poission ratio',f8.5/10x,'density',e18.5/ 210x,'guass ptr/dir',i3/10x,'stress pts',i6/10x,'thickness',e16.5/310x,'1-gravity',e16.5/10x,'2-gtavity',e16.5/10x,'alpha',e20.5/410x,'base temp',e16.5/)2001format(5x,'element stresses'//'elmt1-coord',2x,'11-stress',2x, 1'12-stress',2x,'22-stress',2x,'33-stress',3x,'1-coord',2x,3x,2'2-stress'/'matl2-coord',2x,'11-strain',2x,'12-strain'2x,3'22-strain',2x,'33-strain',6x,'angle'/39('-'))2002format(i4,0p1f9.3,1p6e11.3/i4,0p1f9.3,1p4e11.3,0p1f11.2/) 5000format('input:e,nu,rho,pts/stiff,pts/stre',1',type(1=stress,2=strain,3=axism)',/3x,'>',$)5001format('input:thickness,1-body force,1-body force,alpha,' 1,'temp-base'/3x,'>',$)endcsubroutine shape(ss,tt,xl,shp,xsj,ndm,nel,ilx,flg)cc.....Shape function routine for two dimension elementscimplicit real*8(a-h,o-z)logical flgdimension xl(ndm,nel),s(4),t(4),x(nel)dimension shp(3,nel),xs(2,2),sx(2,2)data s/-0.5d0,0.5d0,0.5d0,-0.5d0/,1t/-0.5d0,-0.5d0,0.5d0,0.5d0/cc.....Form4-node quatrilateral shape functionscc nel:nuber of nodes per elementcdo100i=1,4shp(3,i)=(0.5+s(i)*ss)*(0.5+t(i)*tt)shp(1,i)=s(i)*(0.5+t(i)*tt)shp(2,i)=t(i)*(0.5+s(i)*ss)100continuecc.....Form triangge bu adding their and fourth together for triangle element cif(nel.eq.3)thendo i=1,3shp(i,3)=shp(i,3)+shp(i,4)enddoendifcc.....Add quatratic terms if necessary for element with more than4nodes cif(nel.gt.4)call shap2(ss,tt,shp,ilx,nel)cc.....Construct jacobian and its inversecdo125i=1,2do125j=1,2xs(i,j)=0.0do120k=1,nelxs(i,j)=xs(i,j)+xl(i,k)*shp(j,k)120continue125continuecc xsj:determinate of jacob matrixcxsj=xs(1,1)*xs(2,2)-xs(1,2)*xs(2,1)cif(flg)returnc flg=false:form global derivativescif(xsj.le.0.0d0)xsj=1.0sx(1,1)=xs(2,2)/xsjsx(2,2)=xs(1,1)/xsjsx(1,2)=-xs(1,2)/xsjsx(2,1)=-xs(2,1)/xsjcc....Form global derivativescdo130i=1,neltp=shp(1,i)*sx(1,1)+shp(2,i)*sx(2,1)shp(2,i)=shp(1,i)*sx(1,2)+shp(2,i)*sx(2,2)shp(1,i)=tp130continuecreturnendcsubroutine shap2(s,t,shp,ilx,nel)cc....Add quadtatic function as necessarycimplicit real*8(a-h,o-z)dimension shp(3,9),ilx(nel)cs2=(1.-s*s)/2.t2=(1.-t*t)/2.do100i=5,9do100j=1,3shp(j,i)=0.0100continuecc.....Midsize nodes(serenipity)cif(ilx(5).eq.0)go to101shp(1,5)=-s*(1.-t)shp(2,5)=-s2shp(3,5)=s2*(1.-t)101if(nel.lt.6)go to107if(ilx(6).eq.0)go to102shp(1,6)=t2shp(2,6)=-t*(1.+s)shp(3,6)=t2*(1.+s)102if(nel.lt.7)go to107if(ilx(7).eq.0)go to103shp(1,7)=-s*(1.+t)shp(2,7)=s2shp(3,7)=s2*(1.+t)103if(nel.lt.8)go to107if(ilx(8).eq.0)go to104shp(1,8)=-t2shp(2,8)=-t*(1.-s)shp(3,8)=t2*(1.-s)cc.....Interior node(lagragian)c104if(nel.lt.9)go to107if(ilx(9).eq.0)go to107shp(1,9)=-4.*s*t2shp(2,9)=-4.*t*s2shp(3,9)=4.*s2*t2cc.....Correct edge nodes for interior node(lagrangian) cdo106j=1,3do105i=1,4105shp(j,i)=shp(j,i)-0.25*shp(j,9)do106i=5,8106if(ilx(i).ne.0)shp(j,i)=shp(j,i)-.5*shp(j,9)cc.....Correct corner nodes for presense of midsize nodes c107do108i=1,4k=mod(i+2,4)+5l=i+4do108j=1,3108shp(j,i)=shp(j,i)-0.5*(shp(j,k)+shp(j,l))returnendcsubroutine pguass(l,lint,r,z,w)cc.....Guass points and weights for two dimensionscimplicit real*8(a-h,o-z)dimension lr(9),lz(9),lw(9),r(16),z(16),w(16)c common/eldtat/dm,n,ma,mct,iel,neldata lr/-1,1,1,-1,0,1,0,-1,0/,lz/-1,-1,1,1,-1,0,1,0,0/data lw/4*25,4*40,64/cc lint:number of integration pointsc r,z:coordinates of integration pointsc w:wp*wq,product of the two weightsclint=l*lcc.....1x1integerationc1r(1)=0.z(1)=0.w(1)=4.creturncc.....2x2integerationc2g=1.0/sqrt(3.d0)do i=1,4r(i)=g*lr(i)z(i)=g*lz(i)w(i)=1.end docreturncc.....3x3integerationc3g=sqrt(0.60d0)h=1.0/81.0d0cdo i=1,9r(i)=g*lr(i)z(i)=g*lz(i)w(i)=h*lw(i)enddocreturncendcsubroutine pload(id,f,b,nneq,neq) cc.....Form load vector in compact formcimplicit real*8(a-h,o-z)dimension f(nneq),b(neq),id(nneq)common/iofile/ior,iowcb=0.0d0cj=id(n)if(j.gt.0)thenb(j)=f(n)endifenddocreturnendcsubroutine prtdis(id,b,ndf,numnp,neq)cc Print out nodal displacementscimplicit real*8(a-h,o-z)dimension id(ndf,numnp),b(neq),u(ndf,numnp)common/iofile/ior,iowcu=0.0d0do100i=1,numnpdo j=1,ndfn=id(j,i)if(n>0)u(j,i)=b(n)end do100continuecc Out nodal displacementscwrite(iow,'(//,19hnodal displacements,/)')do i=1,numnpwrite(iow,'(5x,i5,2x,3(e12.4,3x))')i,(u(k,i),k=1,ndf) end docreturnendcdouble precision function dot(a,b,n)implicit real*8(a-h,o-z)dimension a(n),b(n)cc.....Dot product functioncdot=0.0d0do10k=1,ndot=dot+a(k)*b(k)10continuereturn end。

有限元算例分析

有限元算例分析

一、平面3节点三角形单元分析的算例如图所示为一矩形薄平板,在右端部受集中力F=10000N 作用,材料常数为:弹性模量1E 二1 107 Pa 、泊松比,板的厚度为t 二0.1m ,试按平面应力问题计算各个节点位3移及支座反力。

閹4-^20右瑞部受集中力作用的平面问题(高深梁)解:(1) 结构的离散化与编号形单元。

载荷F 按静力等效原则向节点 1节点2移置等效。

约束的支反力列阵: R =「0 0 0 0 R X 3 &3 R x4 Ry 4T其中(R X 3, R y3)和(R x4,R y4)分别为节点3和节点4的两个方向的支反力。

(2)各个单元的描述当两个单元取图示中的局部编码(i,j,m)时,其单元刚度矩阵完全相同,即a=X j y m —X m y j , b i=y j —y m , C i=X j —X m a j =X m y i -xy m , b j =y m -y i , c^x^X i a m =X j y m —X m y j , b m =y i —y j , c^x^X j对该结构进行离散,单元编号及节点编号如图4-20(b)所示,即有二个3节点三角 节点位移列阵:q - g v u 2 v 2U 3 V 3 U 4 V 4 r1-^b r b s 十 ---- C r C s2 1 - J亠 -------- b r C s 2^C r b s十丁农I1 - J GG 2brbs"b r C sk iik ⑴,(2)k jjkmma)制赳描述 b)冇限元分折模型节点外载列阵:k ijk jmk mj1 00132I23-12T1I3023434323220042一』—112427433212d413L 333T(3)建立整体刚度方程按单元的位移自由度所对应的位置进行组装可以得到整体刚度矩阵,成k二k⑴k⑵具体写出单元刚度矩阵的各个子块在总刚度矩阵中的对应位置如下该组装过程可以写代入整体刚度方程Kq =P中,有(5)支反力的计算将所求得的节点位移式代入总刚度方程中,可求得支反力如下9Et/ 2 4 、 “(-U i ——V i + — V 2) = —2 F 32 3 3 9Et 2 1 4(U v U 2)»0.07F 32 3 3 3 9Et 2 (-U 2 V 2) =2F32 3 9Et 2 1 (u 2 v 2) = 1.07F7 亍474 3 n — 3-1—3斗1 3 q21-4一 一 □0 33 3 34 r74 "q—0 □-13 3 7亍31341-4 033 33 I2 4 "7'4"-1 7 0亍T7亍r 141 32— —□=-4 33J3 3 i hi BW-Wa-ivKaH4q7 4 0 □ -1——-—33 3 331 2413■^= -^^a--433373 J9Z732(4) 边界条件的处理及刚度方程求解该问题的位移边界条件为 U 3 = 0,V 3 二 0, U 4 二 0,V4 -0 将其代入上式中,划去已知节点位移对应的第5行至第8行(列),有13由上式可求出节点位移如下[U i w u 2 v 2]Et131.88 -8.99-1.50 -8.42 TR X 4 R y432 3 3、MATLAB —平面3节点三角形单元分析的算例(Triangle2D3Node)解:(1)结构的离散化与编号将结构离散为二个3节点三角形单元,单元编号及节点编号如图4-20(b)所示。

有限元-用三角形单元分析

有限元-用三角形单元分析

(e 1,2,3,4) 分块形式如下:
k e
(4-28)
页码: 9
材料成形数值模拟
School of Materials Science and engineering, WHUT 平面三角形单元整体分析
第4章 平面单元有限元法
2) 求各单元的贡献矩阵 K e 以单元②为例,贡献矩阵 K 2 由式(4-41)求出:
F K
F1 k11 F k 2 21 F6 k 61
分块形式
k12 k 22 k 62


k 66 6
解题步骤:先进行单元分析,得出单元矩阵; 考虑单元综合,得出整体矩阵。因此,平面问题有限元法步骤:
离散化→单元分析→整体分析
页码: 1
材料成形数值模拟
School of Materials Science and engineering, WHUT
4.4 平面三角形单元分析
第4章 平面单元有限元法
u1 1 v 1
则三角形单元结点位移向量为:
u1 v 1 1 u 2 e 2 v 2 3 u 3 v3 以 6 个结点位移分量作为基本未知量,对应的物理量是六个结点力分量, U 1 V F1 1 U 2 F e F2 V 2 F3 U 3 V3
Str 1 2 3 4 1 2 1 0 1 1 0 2 0 2 3 Et 1 0 3 1 4 4 1 2 1 3 5 0 0 2 0 1 0 1 1 6 1 2 6 0 1 1 0 0 2 1 2 0 1 2 0 3 0 1 3 E 5

有限元单元法程序设计

有限元单元法程序设计

有限元单元法程序设计有限元单元法是一种用于工程结构分析和设计的计算方法,它将大型结构分解为许多小的离散单元,通过分析单元之间的相互作用来预测结构的力学行为。

有限元单元法程序设计是指针对特定工程问题,编写计算机程序来实现有限元分析的过程。

下面将介绍有限元单元法程序设计的基本流程和关键要点。

一、问题建模和网格划分有限元单元法程序设计的第一步是对工程结构进行合理的建模和网格划分。

建模的目的是将实际结构抽象为适用于有限元分析的数学模型,包括定义结构的几何特征、材料属性、边界条件等。

网格划分是将结构分解为许多小的单元,每个单元具有一定的形状和尺寸,以便于数值计算。

常用的单元形状包括三角形、四边形、四面体、六面体等,根据结构的特点选择合适的单元形状和尺寸。

二、单元刚度矩阵和载荷矩阵的求解在有限元单元法程序设计中,需要编写算法来求解每个单元的刚度矩阵和载荷矩阵。

单元刚度矩阵描述了单元内部的力学性能,包括刚度、弹性模量、泊松比等,它们通常通过数学公式或有限元理论推导得到。

载荷矩阵描述了单元受到的外部荷载,可以是均匀分布载荷、集中载荷或者边界条件引起的约束力。

通过合适的数值积分方法,可以计算得到每个单元的刚度矩阵和载荷矩阵。

三、组装全局刚度矩阵和载荷向量在有限元单元法程序设计中,需要将所有单元的刚度矩阵和载荷向量组装成整个结构的全局刚度矩阵和载荷向量。

这涉及到单元之间的连接关系以及边界条件的处理。

采用适当的组装算法,可以将各个单元的刚度矩阵和载荷向量叠加在一起,形成整个结构的刚度矩阵和载荷向量。

四、求解位移和应力有限元单元法程序设计的最后一步是求解结构的位移和应力。

通过斯蒂芬-泰勒算法或者其他迭代算法,可以得到整个结构的位移分布,然后根据位移场计算各个点的应变和应力。

这一过程涉及到对整个结构刚度矩阵的求解和对位移的后处理。

有限元单元法程序设计是一个复杂而又精密的工作,需要深入理解有限元原理、结构力学知识和数学方法。

matlab有限元三角形单元程序

matlab有限元三角形单元程序

matlab有限元三角形单元程序以下是一个简单的 MATLAB 有限元三角形单元程序的示例:```matlab% 定义模型参数E = 1000; % 弹性模量nu = 0.3; % 泊松比thickness = 1; % 板的厚度% 定义节点坐标nodes = [0, 0; 1, 0; 1, 1; 0, 1; 0.5, 0.5];% 定义单元连接关系connectivity = [1, 2, 5; 2, 3, 5; 3, 4, 5; 4, 1, 5];% 计算总节点数和总单元数numNodes = size(nodes, 1);numElements = size(connectivity, 1);% 初始化全局刚度矩阵和载荷向量K = zeros(numNodes);F = zeros(numNodes, 1);% 循环遍历每个单元for i = 1:numElements% 查找当前单元的节点编号nodesIndex = connectivity(i, :);% 根据节点编号从全局坐标矩阵中取出节点坐标coordinates = nodes(nodesIndex, :);% 计算当前单元的局部刚度矩阵localK = calculateLocalStiffness(E, nu, thickness, coordinates);% 组装局部刚度矩阵到全局刚度矩阵中K(nodesIndex, nodesIndex) = K(nodesIndex, nodesIndex) + localK;% 计算当前单元的局部载荷向量localF = calculateLocalLoad(thickness, coordinates);% 组装局部载荷向量到全局载荷向量中F(nodesIndex) = F(nodesIndex) + localF;end% 边界条件:节点1固定K(1, :) = 0;K(1, 1) = 1;F(1) = 0;% 解线性方程组U = K \ F;% 输出位移结果disp('节点位移:');disp(U);% 计算应力结果stress = calculateStress(E, nu, thickness, nodes, connectivity, U);% 输出应力结果disp('节点应力:');disp(stress);% 计算局部刚度矩阵的函数function localK = calculateLocalStiffness(E, nu, thickness, coordinates)% 计算单元的雅可比矩阵J = (1/2) * [coordinates(2,1)-coordinates(1,1), coordinates(3,1)-coordinates(1,1);coordinates(2,2)-coordinates(1,2), coordinates(3,2)-coordinates(1,2)];% 计算雅可比矩阵的逆矩阵invJ = inv(J);% 计算单元刚度矩阵B = invJ * [-1, 1, 0; -1, 0, 1];D = (E/(1-nu^2)) * [1, nu, 0; nu, 1, 0; 0, 0, (1-nu)/2]; localK = thickness * abs(det(J)) * (B' * D * B);end% 计算局部载荷向量的函数function localF = calculateLocalLoad(thickness, coordinates) localF = zeros(3, 1);midPoint = [sum(coordinates(:,1))/3,sum(coordinates(:,2))/3];localF(3) = thickness * 1 * det([coordinates(1,:); coordinates(2,:); midPoint]);end% 计算各节点应力的函数function stress = calculateStress(E, nu, thickness, nodes, connectivity, U)stress = zeros(size(nodes, 1), 3);for i = 1:size(connectivity, 1)nodesIndex = connectivity(i, :);coordinates = nodes(nodesIndex, :);Ke = calculateLocalStiffness(E, nu, thickness, coordinates);Ue = U(nodesIndex);stress(nodesIndex, :) = stress(nodesIndex, :) + (Ke * Ue)';endstress = stress / thickness;end```这个程序实现了一个简单的平面三角形单元有限元分析,包括定义节点坐标和单元连接关系、计算全局刚度矩阵和载荷向量、施加边界条件、解线性方程组、计算节点位移和应力等。

有限元的实施步骤

有限元的实施步骤

有限元的实施步骤引言有限元方法是一种用于求解工程问题的数值分析方法。

它通过将连续问题离散化为有限个小单元,然后以计算机模拟的方式求解这些小单元上的方程来近似求解原始问题。

本文将介绍有限元方法的实施步骤,并使用Markdown格式进行编写。

步骤一:建立几何模型1.确定几何模型的尺寸、形状和边界条件。

2.使用几何建模工具创建几何模型,例如计算机辅助设计(CAD)软件。

3.将几何模型导出为适合有限元分析的文件格式,例如.STL或.IGES。

步骤二:划分网格1.将几何模型划分为有限个小单元,通常是三角形或四边形。

2.划分网格时,需要考虑到准确度和计算效率的平衡。

3.在划分网格时,要注意避免产生倾斜或退化的单元。

步骤三:确定材料属性1.确定物体的材料属性,例如弹性模量、泊松比、密度等。

2.如果需要,可以使用实验方法或材料数据库来获得材料属性数据。

步骤四:建立边界条件1.确定边界条件,例如加载、约束条件等。

2.边界条件可以是力、位移或温度等。

3.边界条件的选择要考虑到模拟对象的实际情况以及所需的分析目标。

步骤五:建立数学模型1.选择适当的数学模型,例如弹性力学、热传导等。

2.根据数学模型建立有限元方程,例如弹性力学中的应力平衡方程。

步骤六:求解有限元方程1.将有限元方程转化为线性代数方程组。

2.使用数值方法(例如矩阵求解方法)求解线性代数方程组,得到近似解。

3.可以使用现有的数值计算软件(例如MATLAB、Python等)来实现求解过程。

步骤七:后处理结果1.对求解结果进行后处理,例如计算变形、应力、温度等。

2.可以使用可视化工具将结果以图形的形式展示出来,进一步分析和评估模拟结果。

结论有限元方法是一种求解工程问题的重要数值分析方法,它通过将连续问题离散化为有限个小单元来近似求解原始问题。

本文介绍了有限元方法的实施步骤,包括建立几何模型、划分网格、确定材料属性、建立边界条件、建立数学模型、求解有限元方程和后处理结果等。

三角形单元有限元程序设计

三角形单元有限元程序设计

三角形单元有限元程序设计一、引言
⑴文档背景
⑵文档目的
⑶读者对象
⑷名词解释
二、程序结构设计
⑴程序流程图
⑵程序组成模块描述
⑶主要数据结构设计
⑷代码逻辑设计
三、数据预处理
⑴数据输入格式与读取
⑵数据清洗与去噪
⑶数据预处理方法
⑷数据分割与划分
四、网格
⑴网格算法介绍
⑵网格质量评估与改善
⑶网格的实现方法
五、有限元方法
⑴有限元离散的原理
⑵有限元单元的选择
⑶有限元离散的网格节点选取
⑷有限元插值函数的计算六、模型求解
⑴线性方程组的求解方法
⑵模型参数的设置与调整
⑶迭代算法的选择与实现七、模型评估与验证
⑴结果评估指标的选择
⑵模型验证方法
⑶结果可视化与分析
八、性能优化
⑴程序性能分析与评估
⑵程序高效化的方法与技巧
⑶并行计算与优化
九、实例与案例
⑴实例介绍与问题描述
⑵实例数据处理过程
⑶实例模型求解与结果分析十、总结与展望
⑴工作总结
⑵程序改进与优化展望
⑶研究方向与发展趋势
十一、附件
●附件1、程序源代码
●附件2、输入数据样例文件
●附件3、网格结果数据文件附录:法律名词及注释
●法律名词1、注释1
●法律名词2、注释2
●法律名词3、注释3
请注意,附件的具体文件名和数据内容将根据你的实际情况进行调整。

法律名词及注释部分需要根据实际需要进行扩充和修改。

请合理对文档结构和章节内容进行调整,以符合你的具体要求。

有限元2-弹性力学平面问题有限单元法(2.1三角形单元,2.2几个问题的讨论)分析

有限元2-弹性力学平面问题有限单元法(2.1三角形单元,2.2几个问题的讨论)分析

第2章弹性力学平面问题有限单元法2.1 三角形单元(triangular Element)三角形单元是有限元分析中的常见单元形式之一,它的优点是:①对边界形状的适应性较好,②单刚形式及其推导比较简单,故首先介绍之。

一、结点位移和结点力列阵设右图为从某一结构中取出的一典型三角形单元。

在平面应力问题中,单元的每个结点上有沿x、y两个方向的力和位移,单元的结点位移列阵规定为:相应结点力列阵为: (式2-1-1)二、单元位移函数和形状函数前已述及,有限单元法是一种近似方法,在单元分析中,首先要求假定(构造)一组在单元内有定义的位移函数作为近似计算的基础。

即以结点位移为已知量,假定一个能表示单元内部(包括边界)任意点位移变化规律的函数。

构造位移函数的方法是:以结点(i,j,m)为定点。

以位移(u i ,v i ,…u m v m )为定点上的函数值,利用普通的函数插值法构造出一个单元位移函数。

在平面应力问题中,有u,v两个方向的位移,若假定单元位移函数是线性的,则可表示成:(,)123u u x y x yααα==++546(,)v v x y x yααα==++(2-1-2)a式中的6个待定常数α1 ,…, α6 可由已知的6个结点位移分量(3个结点的坐标) {}⎪⎭⎪⎬⎫⎪⎩⎪⎨⎧=⎪⎪⎪⎪⎭⎪⎪⎪⎪⎬⎫⎪⎪⎪⎪⎩⎪⎪⎪⎪⎨⎧=mjimeddddmjjivuvuvui{}iijjmXYX(2-1-1)YXYiejmmFF FF⎧⎫⎪⎪⎪⎪⎧⎫⎪⎪⎪⎪⎪⎪==⎨⎬⎨⎬⎪⎪⎪⎪⎩⎭⎪⎪⎪⎪⎪⎪⎩⎭确定。

将3个结点坐标(x i,y i ),(x j,y j ),(x m,y m )代入上式得如下两组线性方程:123i i i u x y ααα=++ 123j j j u x y ααα=++ (a)123m m m u x y ααα=++和546i i i v x y ααα=++ 546j j j v x y ααα=++ (b)546m m m v x y ααα=++利用线性代数中解方程组的克来姆法则,由(a)可解出待定常数1α 、2α 、3α :11A Aα=22A Aα=33A Aα=式中行列式:1i i i j j j m m m u x y A u x y u x y =2111i i j j m mu y A u y u y =3111i i j j m m x u A x u x u = 2111i i j j m mAx y A x y x y ==A 为△ijm 的面积,只要A 不为0,则可由上式解出:11()2m m i ij j a u a u a u A α=++ 21()2m m i ij j bu b u b u A α=++ (C )31()2m mi i j j c u c u c u A α=++式中:m m i j j a x y x y =- m m j i i a x y x y =- m i j j i a x y x y =-m i j b y y =- m j i b y y =- m i j b y y =- (d )m i j c x x =- m j i c x x =- m j i c x x =-为了书写方便,可将上式记为: m m i j ia x y x y =-m ij by y =- (,,)i j m u u u u ruu u u r m i jc x x =-(,,)i j m u u u u ru u u u r表示按顺序调换下标,即代表采用i,j,m 作轮换的方式便可得到(d)式。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

平面三角形单元有限元程序设计P9 m 9 m一、题目如图1所示,一个厚度均匀的三角形薄板,在顶点作用沿板厚方向均匀分布的竖向载荷。

已知:P=150N/m,E=200GPa,=0、25,t=0、1m,忽略自重。

试计算薄板的位移及应力分布。

要求:1.编写有限元计算机程序,计算节点位移及单元应力。

(划分三角形单元,单元数不得少于30个);2.采用有限元软件分析该问题(有限元软件网格与程序设计网格必须一致),详细给出有限元软件每一步的操作过程,并将结果与程序计算结果进行对比(任选取三个点,对比位移值);3.提交程序编写过程的详细报告及计算机程序;4.所有同学参加答辩,并演示有限元计算程序。

有限元法中三节点三角形分析结构的步骤如下:1)整理原始数据,如材料性质、荷载条件、约束条件等,离散结构并进行单元编码、结点编码、结点位移编码、选取坐标系。

2)单元分析,建立单元刚度矩阵。

3)整体分析,建立总刚矩阵。

4)建立整体结构的等效节点荷载与总荷载矩阵5)边界条件处理。

6)解方程,求出节点位移。

7)求出各单元的单元应力。

8)计算结果整理。

一、程序设计网格划分如图,将薄板如图划分为6行,并建立坐标系,则刚度矩阵的集成建立与总刚度矩阵等维数的空矩阵,已变单元刚度矩阵的集成。

由单元分析已知节点、单元的排布规律,继而通过循环计算求得每个单元对应的节点序号。

通过循环逐个计算:(1)每个单元对应2种单元刚度矩阵中的哪一种; (2)该单元对应总刚度矩阵的那几行哪几列 (3)将该单元的单元刚度矩阵加入总刚度矩阵的对应行列循环又分为3层循环:(1)最外层:逐行计算(2)中间层:该行逐个计算(3)最里层:区分为第 奇/偶 数个计算XYPXYP节点编号单元编号单元刚度的集成:[][][][][][]''''''215656665656266256561661eZeeeZeZeeeekkkKkkkkkk+⋯++=⇓=⇒==⇒==⇒=⨯⨯⨯⨯⨯⨯M边界约束的处理:划0置1法适用:这种方法适用于边界节点位移分量为已知(含为0)的各种约束。

做法:(1)将总刚矩阵〔K〕中相应于已知位移行主对角线元素置1,其她元素改为零;同时将载荷列阵{R}中相应元素用已知位移置换。

◎这样,由该方程求得的此位移值一定等于已知量。

(2)将〔K〕中已知位移相应的列的非主对角成元素也置0,以保持〔K〕的对称性。

◎当然,在已知位移分量不为零的情况下,这样做就改变了方程左端的数值,为保证方程成立,须在方程右端减去已知位移对该方程的贡献——已知位移与相应总刚元素的乘积。

◎若约束为零位移约束时,此步则可省去。

特点:(1)经以上处理同样可以消除刚性位移(约束足够的前提下),去掉未知约束反力。

(2)但这种方法不改变方程阶数,利于存贮。

(3)不过,若就是要求出约束反力,仍要重新计算各个划去的总刚元素。

程序如下:变量说明NNODE 单元节点数NPION 总结点数NELEM 单元数NVFIX 受约束边界点数FIXED 约束信息数组NFORCE 节点力数FORCE 节点力数组COORD 结构节点坐标数组LNODS 单元定义数组YOUNG 弹性模量POISS 泊松比THICK 厚度B 单元应变矩阵(3*6)D 单元弹性矩阵(3*3)S 单元应力矩阵(3*6)A 单元面积ESTIF 单元刚度矩阵ASTIF 总体刚度矩阵ASLOD 总体荷载向量ASDISP 节点位移向量ELEDISP 单元节点位移向量STRESS 单元应力%********************************************************** %初始化clearformat short e %设定输出类型clear %清除内存变量NELEM=36 %单元个数(单元编码总数)NPION=28 %结点个数(结点编码总数) NVFIX=2 %受约束边界点数NFORCE=1 %结点荷载个数YOUNG=2e11 %弹性模量POISS=0、25 %泊松比THICK=0、1 %厚度LNODS=[1 2 3;2 4 5;2 5 3;3 5 6;4 7 8;4 8 5;5 8 9;5 9 6;6 9 10;7 11 12;7 12 8;8 12 13;8 13 9;9 13 14;9 14 10;10 14 15;11 16 17;11 17 12; 12 17 18; 12 18 13;13 18 19; 13 19 14;14 19 20;14 20 15;15 20 21;16 22 23;16 23 17;17 23 24;17 24 18;18 24 25;18 25 19;25 19 26;19 26 20;20 26 27;20 27 21;21 27 28] %单元定义数组(单元结点号)%相应为单元结点号(编码)、按逆时针顺序输入COORD=[0 0;-0、75 1、5;0、75 1、5;-1、5 3;0 3;1、5 3;-2、25 4、5;-0、75 4、5;0、75 4、5;2、25 4、5;-3 6;-1、5 6;0 6;1、5 6;3 6;-3、75 7、5;-2、25 7、5; -0、75 7、5;0、75 7、5;2、25 7、5;3、75 7、5;-4、5 9;-3 9;-1、5 9;0 9;1、5 9;3 9;4、5 9] %结点坐标数组%坐标:x,y 坐标(共NPOIN 组)FORCE=[1 0 -15] %结点力数组(受力结点编号, x 方向,y 方向) FIXED=[22 1 1;28 1 1] %约束信息(约束点,x 约束,y 约束)%有约束为1,无约束为0%**********************************************************%生成单元刚度矩阵并组成总体刚度矩阵ASTIF=zeros(2*NPION,2*NPION); %生成特定大小总体刚度矩阵并置0%**********************************************************for i=1:NELEM%生成弹性矩阵 DD= [1 POISS 0;POISS 1 0;0 0 (1-POISS)/2]*YOUNG/(1-POISS^2)%**********************************************************%计算当前单元的面积A=-det([1 COORD(LNODS(i,1),1) COORD(LNODS(i,1),2);1 COORD(LNODS(i,2),1) COORD(LNODS(i,2),2);1 COORD(LNODS(i,3),1) COORD(LNODS(i,3),2)])/2%**********************************************************%生成应变矩阵 Bfor j=0:2b(j+1)=COORD(LNODS(i,(rem((j+1),3))+1),2)-COORD(LNODS(i,(rem( (j+2),3))+1),2);c(j+1)=-COORD(LNODS(i,(rem((j+1),3))+1),1)+COORD(LNODS(i,(rem((j+2),3))+1),1);endB=[b(1) 0 b(2) 0 b(3) 0;0 c(1) 0 c(2) 0 c(3);c(1) b(1) c(2) b(2) c(3) b(3)]/(2*A);B1( :,:,i)=B;%**********************************************************%求应力矩阵S=D*BS=D*B;ESTIF=B'*S*THICK*A; %求解单元刚度矩阵a=LNODS(i,:); %临时向量,用来记录当前单元的节点编号for j=1:3for k=1:3ASTIF((a(j)*2-1):a(j)*2,(a(k)*2-1):a(k)*2)=ASTIF((a(j)*2-1):a(j)*2,(a(k)* 2-1):a(k)*2)+ESTIF(j*2-1:j*2,k*2-1:k*2);%根据节点编号对应关系将单元刚度分块叠加到总刚%度矩阵中endendend%**********************************************************%将约束信息加入总体刚度矩阵(对角元素改一法)for i=1:NVFIXif FIXED(i,2)==1ASTIF(:,(FIXED(i,1)*2-1))=0; %一列为零ASTIF((FIXED(i,1)*2-1),:)=0; %一行为零ASTIF((FIXED(i,1)*2-1),(FIXED(i,1)*2-1))=1; %对角元素为 1end%**********************************************************%生成单元刚度矩阵并组成总体刚度矩阵%**********************************************************if FIXED(i,3)==1ASTIF( :,FIXED(i,1)*2)=0; %一列为零ASTIF(FIXED(i,1)*2,:)=0; %一行为零ASTIF(FIXED(i,1)*2 ,FIXED(i,1)*2)=1; %对角元素为 1 endend%**********************************************************%生成荷载向量ASLOD(1:2*NPION)=0; %总体荷载向量置零for i=1:NFORCEASLOD((FORCE(i,1)*2-1):FORCE(i,1)*2)=FORCE(i,2:3);end%**********************************************************%求解内力ASDISP=ASTIF\ASLOD' %计算节点位移向量ELEDISP(1:6)=0; %当前单元节点位移向量for i=1:NELEMfor j=1:3ELEDISP(j*2-1:j*2)=ASDISP(LNODS(i,j)*2-1:LNODS(i,j)*2);%取出当前单元的节点位移向量endiSTRESS=D*B1(:, :, i)*ELEDISP' %求内力end(程序计算结果与有限元软件得出的结果稍有偏差,可能就是程序某些地方数据输入时出了问题,还在寻找具体原因)二、有限元软件分析设置材料参数网格划分添加载荷边界约束。

相关文档
最新文档