Page 5 - Demo
P. 5
Planar Truss Example for Comrel Add-on RCP Consult, 2022-2025 Page 5 b=reshape(a,nnp,2); // deflection vector DF=XY+b*2; // deformed coordinates with scale factor 2. for i (1, nfe, 1); _pline=1~6~XY[IEN[i,1],1]~XY[IEN[i,1],2]~XY[IEN[i,2],1]~XY[IEN[i,2],2]~1~11~1; draw; // cyan color for initial state endfor; for i (1, nfe, 1); _pline=1~6~DF[IEN[i,1],1]~DF[IEN[i,1],2]~DF[IEN[i,2],1]~DF[IEN[i,2],2]~1~12~1; draw; // red color for initial state endfor; for i (1, nfe, 1); x=(XY[IEN[i,1],1]+XY[IEN[i,2],1])/2; y=(XY[IEN[i,1],2]+XY[IEN[i,2],2])/2; _pmsgctl=x~y~.07~0~1~15~1; _pmsgstr=sprintf(\draw; endfor; for i (1, nnp, 1); _pmsgctl=XY[i,1]~XY[i,2]~.07~0~1~15~1; _pmsgstr=sprintf(\draw; endfor; _pmsgctl=DF[4,1]~DF[4,2]-0.2~.07~0~1~15~1; _pmsgstr=sprintf(\draw; // value of vertical deflection in node N04 fd=zeros(ndof,1); for i (1, rows(P), 1); fd[14+2*i] = P[i]; // vertical forces [N] endfor; fd=reshape(fd,nnp,ned)*0.000025; // forces with scale factor 0.000025 n=0; for i (1, nnp, 1); if fd[i,2] > 0.1; n=n+1; _parrow=XY[i,1]+fd[i,1]~XY[i,2]+fd[i,2]~XY[i,1]~XY[i,2]~3~0.1~1~9~1~6~2; draw; _pmsgctl=XY[i,1]+fd[i,1]+0.1~XY[i,2]+fd[i,2]~.07~0~1~15~1; _pmsgstr=sprintf(\0); draw; endif; endfor; elseif nf == 2; //! Internal member forces N // Plot a main title of plot _pmsgctl={8.0 8.0 .12 0 1 15 5}; _pmsgstr=\draw; // Plot internal member forces N ll=ones(4,1); cc={1, 1, 1, 1}; ww={1, 1, 1, 1}; tt={6, 6, 6, 6}; for i (1, nfe, 1); l=leng[i]/2; n=abs(NEL[i])*0.0000005; X=-l~l~l~-l; Y=-n~-n~n~n; co=cos(theta[i]); // cosine inclination angle si=sin(theta[i]); // sine inclination angle Xrot=X*co-Y*si; Yrot=X*si+Y*co; x=(XY[IEN[i,1],1]+XY[IEN[i,2],1])/2; y=(XY[IEN[i,1],2]+XY[IEN[i,2],2])/2; xo=Xrot[1]|Xrot[2]|Xrot[3]|Xrot[4]; xe=Xrot[2]|Xrot[3]|Xrot[4]|Xrot[1]; yo=Yrot[1]|Yrot[2]|Yrot[3]|Yrot[4]; ye=Yrot[2]|Yrot[3]|Yrot[4]|Yrot[1]; if NEL[i] >= 0; cn=12; else; cn=9; endif; _pline=ll~tt~xo + x~yo + y~xe + x~ye + y~ll~cc*cn~ww; draw; _pmsgctl=x-0.5~y~.05~0~1~15~1; _pmsgstr=sprintf(\draw; endfor; elseif nf == 3; //! Internal member Tensile stress // Plot a main title of plot _pmsgctl={6.0 8.0 .12 0 1 15 5}; _pmsgstr=\draw; minA=minc(abs(NEL./reshape(area,nfe,1)*1e-6)); maxA=maxc(abs(NEL./reshape(area,nfe,1)*1e-6)); dA=maxA-minA; // Plot internal member von Mises stress ll=ones(4,1); cc={1, 1, 1, 1}; ww={1, 1, 1, 1}; tt={6, 6, 6, 6}; for i (1, nfe, 1); Su=abs(NEL[i]/area[i]*1e-6); l=leng[i]/2; n=Su/dA*0.2; X=-l~l~l~-l; Y=-n~-n~n~n; co=cos(theta[i]); // cosine inclination angle si=sin(theta[i]); // sine inclination angle Xrot=X*co-Y*si; Yrot=X*si+Y*co; x=(XY[IEN[i,1],1]+XY[IEN[i,2],1])/2; y=(XY[IEN[i,1],2]+XY[IEN[i,2],2])/2; xo=Xrot[1]|Xrot[2]|Xrot[3]|Xrot[4]; xe=Xrot[2]|Xrot[3]|Xrot[4]|Xrot[1]; yo=Yrot[1]|Yrot[2]|Yrot[3]|Yrot[4]; ye=Yrot[2]|Yrot[3]|Yrot[4]|Yrot[1]; _pline=ll~tt~xo + x~yo + y~xe + x~ye + y~ll~cc*14~ww; draw; _pmsgctl=x-0.5~y~.05~0~1~15~1; _pmsgstr=sprintf(\draw; endfor; endif; // Invoked version of Gauss Engine _pmsgctl={-1.9 -1.52 .08 0 1 15 3}; _pmsgstr=StrurelEngine; draw; endwind; endfor; endif;endif; // begin of plot blockretp(uout); // vertical deflection at bottom center (N04)endp; // end of procedure