Page 5 - Demo
P. 5
Planar TrussExamplefor ComrelAdd-onRCPConsult, 2019-2025Page 5plt.text(12.0,8.0,'Internal member forces [N]',fontsize=16,ha='center')# Plot internal member force Nfore inrange(nfe):l=leng[e]/2n=np.abs(N[e])*0.0000005X=np.array([l,l,l,l])Y=np.array([-n,-n,n,n])c =np.cos(theta[e])# cosine inclination angles =np.sin(theta[e])# sinus inclination angleXrot =X*c -Y*sYrot =X*s +Y*cx=(XY[IEN[e,0],0]+XY[IEN[e,1],0])/2y=(XY[IEN[e,0],1]+XY[IEN[e,1],1])/2if(N[e]>=0):co=(1.0,0.6,0.5)else:co=(0.5,0.6,1.0)plt.fill(Xrot +x,Yrot +y,color=co,ec='0',lw=0.5)plt.text(x,y,'%0.1f N'%N[e],fontsize=7,ha='center',va='center')elifnf ==2:# Set a main subtitle of plotplt.text(12.0,8.0,r'Internal member von Mises stress $\\sigma_{v}$ [MPa]',fontsize=16,ha='center')# Prepare color mappingjet =plt.get_cmap('jet')minA=min(abs(N/area*1e6))maxA=max(abs(N/area*1e6))cNorm=plt.Normalize(minA,maxA)scalarMap=cmx.ScalarMappable(norm=cNorm,cmap=jet)plt.colorbar(scalarMap,use_gridspec=True,ax=plt.gca())# Plot for internal member von Mises stressdA=maxA-minAfore inrange(nfe):Su=abs(N[e]/area[e]*1e6)l=leng[e]/2n=Su/dA*0.2X=np.array([-l,l,l,-l])Y=np.array([n,n,n,n])c =np.cos(theta[e])# cosine inclination angles =np.sin(theta[e])# sinus inclination angleXrot =X*c -Y*sYrot =X*s +Y*cx=(XY[IEN[e,0],0]+XY[IEN[e,1],0])/2y=(XY[IEN[e,0],1]+XY[IEN[e,1],1])/2co=scalarMap.to_rgba(Su)plt.fill(Xrot +x,Yrot +y,color=co,lw=0.5,alpha=0.7)plt.text(x,y,'%0.0f'%Su,fontsize=7,ha='center',va='center')## Do rest for all plotsplt.title(tit,fontsize=18)plt.text(22,5.5,'A1=%g $m^2