Page 5 - Demo
P. 5
Planar Truss Example for Comrel Add-on RCP Consult, 2019-2024 Page 5 plt.text(12.0, 8.0, 'Internal member forces [N]',fontsize=16,ha='center') # Plot internal member force N for e in range(nfe): l=leng[e]/2 n=np.abs(N[e])*0.0000005 X=np.array([-l, l, l, -l]) Y=np.array([-n, -n, n, n]) c = np.cos(theta[e]) # cosine inclination angle s = np.sin(theta[e]) # sinus inclination angle Xrot = X*c - Y*s Yrot = X*s + Y*c x=(XY[IEN[e,0],0]+XY[IEN[e,1],0])/2 y=(XY[IEN[e,0],1]+XY[IEN[e,1],1])/2 if(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') elif nf == 2: # Set a main subtitle of plot plt.text(12.0, 8.0, 'Internal member von Mises stress $\\sigma_{v}$ [MPa]',fontsize=16,ha='center') # Prepare color mapping jet = plt.get_cmap('jet') minA=min(abs(N/area*1e-6)) maxA=max(abs(N/area*1e-6)) 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 stress dA=maxA-minA for e in range(nfe): Su=abs(N[e]/area[e]*1e-6) l=leng[e]/2 n=Su/dA*0.2 X=np.array([-l, l, l, -l]) Y=np.array([-n, -n, n, n]) c = np.cos(theta[e]) # cosine inclination angle s = np.sin(theta[e]) # sinus inclination angle Xrot = X*c - Y*s Yrot = X*s + Y*c x=(XY[IEN[e,0],0]+XY[IEN[e,1],0])/2 y=(XY[IEN[e,0],1]+XY[IEN[e,1],1])/2 co=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 plots plt.title(tit,fontsize=18) plt.text(22, 5.5, 'A1=%g $m^2