function color_section_stress (i_p) % Copyright 2006, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Plot failure criterion over cirular or rectangular % of a shaft (or space frame ?) % ------------------------------------------------------ if (nargin == 0 ) i_p = 4 end % if % Set control data: load section_pt_stresses.tmp ; CIR = section_pt_stresses (1, 1) ; ELEM = section_pt_stresses (2, 1); SECT = section_pt_stresses (3, 1); RAD = section_pt_stresses (4, 1); H_Y = section_pt_stresses (4, 2); H_Z = section_pt_stresses (4, 3); N_C = section_pt_stresses (4, 4); if ( CIR == 1.0 ) H_Y = RAD ; H_Z = RAD ; end % if % Build Z-y pts z(1) = 0. ; y(1) = 0. ; z(2) = 0. ; y(2) = H_Y ; z(3) = 0. ; y(3) = -H_Y ; z(4) = H_Z ; y(4) = 0.0 ; z(5) = -H_Z ; y(5) = 0.0 ; z(6) = -H_Z ; y(6) = H_Y ; z(7) = H_Z ; y(7) = H_Y ; z(8) = H_Z ; y(8) = -H_Y ; z(9) = -H_Z ; y(9) = -H_Y ; % area connections loop_1 = [1, 4, 7, 2] ; loop_2 = [1, 2, 6, 5] ; loop_3 = [1, 5, 9, 3] ; loop_4 = [1, 3, 8, 4] ; % Extract failure criterion values v(1:N_C) = section_pt_stresses (5:(4+N_C), i_p) ; if ( CIR == 1.0 ) ; v (6) = 0.5*(v(2) + v(5)) ; y (6) = y(6) * 0.707 ; z (6) = z(6) * 0.707 ; v (7) = 0.5*(v(2) + v(4)) ; y (7) = y(7) * 0.707 ; z (7) = z(7) * 0.707 ; v (8) = 0.5*(v(3) + v(4)) ; y (8) = y(8) * 0.707 ; z (8) = z(8) * 0.707 ; v (9) = 0.5*(v(3) + v(5)) ; y (9) = y(9) * 0.707 ; z (9) = z(9) * 0.707 ; end % if ymax = max (y) ; zmax = max (z) ; vmax = max (v) ; ymin = min (y) ; zmin = min (z) ; vmin = max (v) ; axis ([zmin, zmax, ymin, ymax]) axis ('equal') % true shape style % caxis % caxis ([vmin vmax]) clf hold on fill (z(loop_1), y(loop_1), v(loop_1)) fill (z(loop_2), y(loop_2), v(loop_2)) fill (z(loop_3), y(loop_3), v(loop_3)) fill (z(loop_4), y(loop_4), v(loop_4)) grid % add grid dots xlabel (['Z-coordinate, Section ', int2str(SECT), ... ', Element ', int2str(ELEM), ' ']) ylabel ('Y-coordinate') format short if ( i_p == 1 ) title ('Shaft Cross-sectional Area Principle Stress P1') elseif ( i_p == 2 ) title ('Shaft Cross-sectional Area Principle Stress P2') elseif ( i_p == 3 ) title ('Shaft Cross-sectional Area Principle Shear Stress') elseif ( i_p == 4 ) title ('Shaft Cross-sectional Area Von Mises Stress') else error('Argument 1-P1, 2-P2, 3-Max Shear, 4-Von Mises') end % if colorbar % -depsc -tiff % for an eps version %b print -dpsc color_el_at_a_node hold off %b fprintf ('Created file color_el_at_a_node.ps \n') % end of color_section_stress