Page 5 - Demo
P. 5


                                    Planar TrussExamplefor ComrelAdd-onRCPConsult, 2021-2025Page 5endelsifnf ==3# set a main subtitle of plotplt.text(12.0,8.0,'Internal member von Mises stress $\\sigma_{v}$ [MPa]',fontsize:16,ha:'center')# prepare color mappingjet=pltget_cmap('jet')minA=[*[*@NN.abs/areab*1e-6].to_a].minmaxA=[*[*@NN.abs/areab*1e6].to_a].maxcNorm=plt.Normalize.call(minA,maxA)scalarMap=cmx.ScalarMappable.call(norm:cNorm,cmap:jet)plt.colorbar(scalarMap,use_gridspec:true,ax:plt.gca())# plot for internal member von Mises stressdA=maxAminAfore in0..nfe1@Su=@NN[e].abs/areab[e]*1e-6l=leng[e]/2n=@Su/dA*0.2@X=DFloat[*[l,l,l,l]]@Y=DFloat[*[n,n,n,n]]c=Math.cos(theta[e])# cosine inclination angles=Math.sin(theta[e])# sinus inclination anglex=(@XY[ien[e,0]1,0]+@XY[ien[e,1]1,0])/2y=(@XY[ien[e,0]-1,1]+@XY[ien[e,1]-1,1])/2@Xrot=@X*c@Y*s+x@Yrot=@X*s+@Y*c+yco=scalarMap.to_rgba(@Su)plt.fill(@Xrot.to_a,@Yrot.to_a,color:co,l0.5,alpha:0.7)plt.text(x,y,'%0.0f'%@Su,fontsize:7,ha:'center',va:'center')endend## do rest for all plotsplt.title(tit,fontsize:18)# plot values of input dataplt.text(22,5.5,'A1=%g $m^2
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

%@A1,fontsize:8)plt.text(22,5.2,'A2=%g $m^2
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

%@A2,fontsize:8)plt.text(22,4.9,'E1=%g $N/m^2
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

%@E1,fontsize:8)plt.text(22,4.6,'E2=%g $N/m^2
   1   2   3   4   5   6   7   8   9   10

 

 

 

 

 

%@E2,fontsize:8)plt.text(-1.0,5.5,'%s'%$StrurelModule+' '+'%s'%$StrurelVersion,fontsize:12)# plot a main title of plot# plot a main title of plotif$StrurelMode==0plt.text(1.0,5.0,'State at Mean Values',fontsize:10)# input data at state of mean valueselsif$StrurelMode==2plt.text(-1.0,5.0,'%s'%$StrurelIMET+', '+'%s'%$StrurelIOPT,fontsize:10)# input data at beta-pointendif$StrurelMode==2plt.text(-1.0,4.5,'beta=%.5f'%$StrurelBeta+', '+'Pf=%.5f'%$StrurelPf,fontsize:10)# calculated beta and Pfendplt.text(1.9,9.7,'matplotlib '+mpl.__version__,fontsize:7)# invoked version of matplotlibplt.text(-1.9,-1.8,'%s'%$StrurelEngine,fontsize:7)# invoked version of engineplt.axis('scaled')plt.axis([-2,26,-2,10])# plot frameplt.grid(true,alpha:0.3)#plt.pause(0.1)$StrurelPlotCount+=1if$StrurelPlotMode==2or$StrurelPlotMode==3pltsavefig($StrurelPlotName+'%s'%$StrurelPlotCount+$StrurelPlotType)# save a plot as image fileendif$StrurelPlotMode==1or$StrurelPlotMode==3plt.show()# display plotendendendend## Return value of script (def)@a[7]# vertical deflection at bottom center (N04)endRuby3.1.x-x64 has a changed C-runtime called UCRT replacing the old MSVCRT.Therefore it is necessary to addWindows MSYS2 UCRTsupportmingw-w64-ucrt-x86-64-rubyand mingw-w64-ucrt-x86-64-lapackfor MINGW.In the script above it is demonstrated how to create additional visualization from Ruby. For this an interactionbetween Rubyand Pythonwill be used. That means you need to install Pythonand its special plotting library matplotlibadditionallyon your computer.
   1   2   3   4   5   6   7   8   9   10