Page 5 - Demo
P. 5
Planar Truss Examplefor ComrelAdd-onRCPConsult, 2021-2025Page 5enddoDefU:=textplot([XY[4,1],XY[4,2]0.4,``||(sprintf(\||``]):# value of vertical deflection in node N04AP :=Array(1..nP):AV :=Array(1..nP):# Plot vertical forces scale factor 0.00002fc :=Vector(1..ndof):forn tonP dofc[14+2*n]:=-p[n]*0.00002:enddon:=0fori tonnp doifabs(fc[i*2])>0.001then:n:=n+1:AP[n]:=arrow({[XY[i,1],XY[i,2]-fc[i*2]]},{[0,fc[i*2]]},shape=arrow):# single vectorAV[n]:=textplot([XY[i,1],XY[i,2]fc[i*2],``||(sprintf(\||``],align={above,right}):# force valueendif:enddo# Plot set #1PlotS:=[seq(BarL[i],i=1..nfe),seq(BarR[i],i=1..nfe),seq(NodN[i],i=1..nnp),seq(BarD[i],i=1..nfe),DefU,seq(AP[i],i=1..nP),seq(AV[i],i=1..nP)]:elifnp =2thenPlotT:=textplot([12.5,6.,\# Plot internal member force NBarN:=Array(1..nfe):# polygon for each barAN:=Array(1..nfe):# text for each barpp:=Matrix(2,4):# polygon pointsfore tonfe dol:=leng[e]/2:n:=abs(N[e])*0.0000005:X:=Array([-l,l,l,-l]):Y:=Array([n,n,n,n]):c:=cos(theta[e]):s:=sin(theta[e]):Xrot:=X*c -Y*s:Yrot:=X*s +Y*c:x:=(XY[IEN[e,1],1]+XY[IEN[e,2],1])/2:y:=(XY[IEN[e,1],2]+XY[IEN[e,2],2])/2:pp[1,1..4]:=Xrot+x:pp[2,1..4]:=Yrot+y:ifN[e]>=0thenco:=[1.0,0.6,0.5]:elseco:=[0.5,0.6,1.0]:endif:BarN[e]:=polygon([seq(convert(pp[..,i],list),i=1..4)],color=Color(co),thickness=0.5):# rectangle along barAV[e]:=textplot([x,y,``||(sprintf(\||``]):# value of force Nenddo# Plot set #2PlotS:=[seq(BarN[i],i=1..nfe),seq(AV[i],i=1..nfe)]:elifnp =3thenPlotT:=textplot([12.5,6.,typeset(\__v,\# Plot for internal member with von Mises stressBarS:=Array(1..nfe):# polygon for each barAS:=Array(1..nfe):# text for each barpp:=Matrix(2,4):# polygon points nco:=21:cm:=Jet(nco):# jet colormapminA:=min(abs(ElementDivide(N,Area)*1e6)):maxA:=max(abs(ElementDivide(N,Area)*1e-6)):ddA:=maxAminA:dA:=ddA/(nco-1):fore tonfe doSu:=abs(N[e]/Area[e]*1e6):l:=leng[e]/2:n:=Su/ddA*0.2:X:=Array([-l,l,l,-l]):Y:=Array([n,n,n,n]):c:=cos(theta[e]):s:=sin(theta[e]):Xrot:=X*c -Y*s:Yrot:=X*s +Y*c:x:=(XY[IEN[e,1],1]+XY[IEN[e,2],1])/2:y:=(XY[IEN[e,1],2]+XY[IEN[e,2],2])/2:pp[1,1..4]:=Xrot+x:pp[2,1..4]:=Yrot+y:nc:=trunc(((Su-minA)/dA-0.01))+1:co:=convert(cm[nc],list):BarS[e]:=polygon([seq(convert(pp[..,i],list),i=1..4)],color=Color(co),thickness=0.5):# rectangle along barAS[e]:=textplot([x,y,``||(sprintf(\||``]):# von Mises stressenddomapC:=Array(1..nco):# rectangle for each colormapL:=Array(1..2):# colormap limitsdy:=(6.-1.)/nco:y=1.fori tonco doco:=convert(cm[i],list):mapC[i]:=rectangle([26.5,y],[27,y+dy],color=Color(co),thickness=0.1):y:=y+dy:enddomapL[1]:=textplot([27.1,1.,``||(sprintf(\||``],align={above,right}):mapL[2]:=textplot([27.1,6.,``||(sprintf(\||``],align={above,right}):# plot set #3