Mohr circle 2D

%Mohr circle 2D
%Author:Minster
%Mechanical Analysis

close all
clear all

sigma_x= input(‘Sigma X?’);
sigma_y= input(‘Sigma y?’);
tau_xy= input(‘Tau xy?’);

tau_max=sqrt(tau_xy^2+((sigma_x-sigma_y)/2).^2); %max shear stress
sigma_1=(sigma_x+sigma_y)/2+tau_max; %principal stresses
sigma_2=(sigma_x+sigma_y)/2-tau_max;
phi=0:0.01*pi:2*pi;
x1=(sigma_1+sigma_2)/2+tau_max*cos(phi); %Mohr’s circle
y1=tau_max*sin(phi);
x2=sigma_1/2+sigma_1/2*cos(phi); %Mohr’s circle -2nd
y2=sigma_1/2*sin(phi);
x3=sigma_2/2+sigma_2/2*cos(phi); %Mohr’s circle -3rd
y3=sigma_2/2*sin(phi);
m=max(max(abs(sigma_1/2),abs(sigma_2/2)),tau_max); %max shear stress of three circles

p(1,1)=sigma_x;
p(1,2)=tau_xy;
p(2,1)=sigma_y;
p(2,2)=-tau_xy; % defining points on the Mohr’s circle

xaxis=[-1000 0;1000 0];yaxis=[0 -1000 ;0 1000]; %to draw x- and y- axes

if m==tau_max
mx= (sigma_1+sigma_2)/2;
else
mx= sign(sigma_1)*m;
end

plot(p(:,1), p(:,2),’-.mo’, ‘MarkerFaceColor’, ‘g’) %data points
hold on;

plot(x1,y1,’LineWidth’,1) %Mohr’s circle
hold on;
plot([sigma_1, sigma_2],[0,0],’xr’,’LineWidth’,2)% principal stresses
hold on;
axis ([sigma_2-1.5*m sigma_1+1.5*m -2*m 2*m])
axis (‘equal’)
hold on;
plot((sigma_1+sigma_2)/2,tau_max,’dr’) % max shear stress
hold on;

hold on;
plot(xaxis(:,1),xaxis(:,2), ‘-.c’,yaxis(:,1),yaxis(:,2),’-.c’,’LineWidth’,1)

xlabel(‘Normal Stress’)
ylabel(‘Shear Stress’)
hold off;
legend(‘Data Points’,’Biaxial Mohr Circle’,’Principal Stresses’,’Max. Shear Stres’,-1);

xlabel(‘Normal Stress’)
ylabel(‘Shear Stress’)
hold off;
legend(‘Data Points’,’Biaxial Mohr Circle’,’Principal Stresses’,’Max. Shear Stres’,-1);