برنامه ترسیم دایره تنش موهر در برنامه متلب و تبدیل تنش ها در دایره ی مور
- سه شنبه, ۷ مهر ۱۳۹۴، ۰۹:۳۴ ب.ظ
برنامه برای ترسیم دایره مور در متلب و تبدیل تنش ها و کرنش ها
پروژه درسی کارشناسی ، دکتر دریجانی دانشگاه شهید باهنر کرمان
%Mohr's Circle
%For 2D stress tensor
clear
clc
% Input dialog box for stresses in xy coordinate system
prompt={'\sigma_x','\sigma_y','\tau_{xy}'};
name='Input data for Mohr circle calculations';
numlines=1;
defaultanswer={'80','40','-30'};
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
answer=inputdlg(prompt,name,numlines,defaultanswer,options);
% Stress tensor, Center, and Radius of Circle------------------------------------------------------
S = [str2double(answer(1)) str2double(answer(3)); str2double(answer(3)) str2double(answer(2))];
Center = (S(1,1)+S(2,2))/2;
R = sqrt(((S(1,1)-S(2,2))/2)^2+S(1,2)^2);
% Plot Mohr's circle-------------------------------------------------------------------------------
THETA=linspace(0,2*pi,1000);
RHO=ones(1,1000)*R;
[X,Y] = pol2cart(THETA,RHO);
center=[Center,0];
X=X+center(1);
Y=Y+center(2);
c_handle=plot(X,Y);
axis square;
hold on
hold on
plot([S(1,1), S(2,2)],[-S(1,2), S(1,2)],'k-','LineWidth',2)
plot(Center,0,'ko','MarkerFaceColor','k') % Center
plot(S(1,1),-S(1,2),'ko','MarkerFaceColor','k') %A
plot(S(2,2),S(1,2),'ko','MarkerFaceColor','k') %B
plot(Center,R,'ko','MarkerFaceColor','k') % Tau_max
plot(Center,-R,'ko','MarkerFaceColor','k') % Tau_max (negative)
plot(Center+R, 0, 'ko','MarkerFaceColor','k') % sigma_1
plot(Center-R, 0, 'ko','MarkerFaceColor','k') % sigma_2
% Plot options
axis equal
set(c_handle,'Color','k','LineWidth',2)
ylim([-1.25*R, 1.25*R])
xlim([Center-1.25*R, Center+1.25*R])
plot([Center-1.25*R, Center+1.25*R],[0, 0],'k-') % line through 0 tau
text(S(1,1)+R/12,-S(1,2),sprintf('A (%d, %d)',S(1,1),-S(1,2)),...
'HorizontalAlignment','left')
text(S(2,2)-R/12,S(1,2),sprintf('B (%d, %d)',S(2,2),S(1,2)),...
'HorizontalAlignment','right')
text(Center,1.1*R,'\tau_{max}',...
'HorizontalAlignment','center')
text(Center,-1.1*R,'\tau_{max}',...
'HorizontalAlignment','center')
text(Center+1.1*R,R/12,'\sigma_{1}',...
'HorizontalAlignment','center')
text(Center-1.1*R,R/12,'\sigma_{2}',...
'HorizontalAlignment','center')
% Calculation of principal tensions-----------------------------------------------------------------------
%---------------------------------------------------------------------------------------------------------
sigma_max=(S(1,1)+S(2,2))/2+sqrt(((S(1,1)-S(2,2))/2)^2+S(1,2)^2);
sigma_min=(S(1,1)+S(2,2))/2-sqrt(((S(1,1)-S(2,2))/2)^2+S(1,2)^2);
fprintf('Sigma_max is equal to %f and Sigma_min is equal to %f \n',sigma_max,sigma_min)
%--------------------------------------------------------------------------------------------------------
% Calculation of principal vectors-----------------------------------------------------------------------
teta_1=.5*atan((2*S(1,2))/(S(1,1)-S(2,2)));
teta_2=teta_1+pi/2;
fprintf('\n')
fprintf('teta 1 in radian base is equal to %f and teta 2 in radian base is equal to %f \n',teta_1,teta_2)
%-------------------------------------------------------------------------------------------------------
% Calculate new tenstions after rotation----------------------------------------------------------------
teta=input('insert your favorite degree in radian for new tensors (for example: pi): ');
sigmax_prime=(S(1,1)+S(2,2))/2+((S(1,1)-S(2,2))/2)*cos(2*teta)+S(1,2)*sin(2*teta);
tawxy_prime=S(1,2)*cos(2*teta)-(((S(1,1)-S(2,2))/2)*sin(2*teta));
sigmay_prime=S(1,1)+S(2,2)-sigmax_prime;
fprintf('\n')
disp('New tensions after rotation: ')
sigmax_prime
sigmay_prime
tawxy_prime
%-------------------------------------------------------------------------------------------------------
% Draw rectangular element after rotation with degree of teta-------------------------------------------
xel=[1 2 2 1 1];
yel=[1 1 2 2 1];
plot(xel,yel,'k-','LineWidth',2)
hold on
grid on
g=plot(xel,yel);
xlim([-3 3])
ylim([-3 3])
hold on
zdir = [0 0 1];
rotate(g,zdir,teta*(180/pi));
hleg = legend('Before Rotation','After Rotation around [0 0]');
hold on
annotation('arrow',[0.52 .65],[.52 .65]);
.1838*cos(pi/2)+.52
plot(0,0,'ko','MarkerFaceColor','k')
[latc,longc] = scircle1(0,0,sqrt(2)/2,[45 45+(teta*(180/pi))]);
plot(latc,longc,'k-','LineWidth',2)
annotation('arrow',[0.52 .1838*cos(pi/4+teta)+.52],[.52 .1838*sin(pi/4+teta)+.52]);
- ۹۴/۰۷/۰۷
اقا دست شما درد نکنه عالی