Page 5 - Demo
P. 5
Planar Truss Example for Comrel Add-on RCP Consult, 2021-2026 Page 5 BarD[i]:=line([x1,y1],[x2,y2],color=red): # red color for deformed state end do: DefU:=textplot([XY[4,1],XY[4,2]-0.4,`` || (sprintf(\ction in node N04 AP := Array(1..nP): AV := Array(1..nP): # Plot vertical forces - scale factor 0.00002 fc := Vector(1..ndof): for n to nP do fc[14 + 2*n] := -p[n]*0.00002: end do: n:=0: for i to nnp do if abs(fc[i*2]) > 0.001 then : n:=n+1: AP[n]:=arrow({[XY[i,1],XY[i,2]-fc[i*2]]},{[0,fc[i*2]]},shape=arrow): # single vector AV[n]:=textplot([XY[i,1],XY[i,2]-fc[i*2],`` || (sprintf(\}): # force value end if: end do: # Plot set #1 PlotS:=[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)]: elif np = 2 then PlotT:=textplot([12.5,6.,\ # Plot internal member force N BarN:=Array(1..nfe): # polygon for each bar AN:=Array(1..nfe): # text for each bar pp:=Matrix(2,4): # polygon points for e to nfe do l:=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: if N[e] >= 0 then co:=[1.0,0.6,0.5]: else co:=[0.5,0.6,1.0]: end if: BarN[e]:=polygon([seq(convert(pp[..,i],list),i=1..4)],color=Color(co),thickness=0.5): # rectangle along bar AV[e]:=textplot([x,y,`` || (sprintf(\# value of force N end do: # Plot set #2 PlotS:=[seq(BarN[i],i=1..nfe),seq(AV[i],i=1..nfe)]: elif np = 3 then PlotT:=textplot([12.5,6.,typeset(\): # Plot for internal member with von Mises stress BarS:=Array(1..nfe): # polygon for each bar AS:=Array(1..nfe): # text for each bar pp:=Matrix(2,4): # polygon points nco:=21: cm:=Jet(nco): # jet colormap minA:=min(abs(ElementDivide(N, Area)*1e-6)): maxA:=max(abs(ElementDivide(N, Area)*1e-6)): ddA:=maxA-minA: dA:=ddA/(nco-1): for e to nfe do Su:=abs(N[e]/Area[e]*1e-6): 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 bar AS[e]:=textplot([x,y,`` || (sprintf(\# von Mises stress end do: mapC:=Array(1..nco): # rectangle for each color mapL:=Array(1..2): # colormap limits dy:=(6.-1.)/nco: y=1.: for i to nco do co:=convert(cm[i],list): mapC[i]:=rectangle([26.5,y],[27,y+dy],color=Color(co),thickness=0.1): y:=y+dy: end do: mapL[1]:=textplot([27.1,1.,`` || (sprintf(\ mapL[2]:=textplot([27.1,6.,`` || (sprintf(\

