You are on page 1of 6

ASSIGNMENT 1

CE6780
ADVANCED MECHANICS OF STRUCTURES

Submitted by

ARUN KUMAR S L
PhD Scholar
IIT Madras

A1.1 Write a simple code in MATLAB to perform stress transformations and to


determine the principal stresses and their directions for a 3-dimensional state of stress.
%***************************CE6780: Advanced Mechanics of Structures*****
%*******************ASSIGNMENT1*************************************
%*****************Question 1: To determine principal stresses and their
%directions for a given state of stress and also to perform
%transformations*********
%%Code Begins%%
t=input('Enter the stress Tensor :'); %prompting the user to input the stress tensor and
store it in t
[vectors,values]=eig(t);
%finding eigen values and vectors and storing it in values
and vectors resp.
disp('The principal stresses are : ');%displaying principal stresses
principal_stresses=values
tp1=values(1,1)
tp2=values(2,2)
tp3=values(3,3)
disp('direction cosines of tp1 : ')
dctp1=vectors(1:3,1)
%displaying direction cosines of the principal planes
disp('direction cosines of tp2 : ')
dctp2=vectors(1:3,2)
disp('direction cosines of tp3 : ')
dctp3=vectors(1:3,3)
k=input('Do you want to perform stress transformations (Y/N)? :','s');
if k=='y'|| k=='Y'
dc=input('Enter the direction cosines of the new axes(X-Y-Z): ')
disp('Corresponding stress tensor in the transformed coordinte system is given by :')
ttrans=dc*t*dc'
%performing stress transformation
elseif k=='n'||k=='N'
disp('THANK YOU')
else
error('Invalid Choice') %invoking error message due to wrong choice
end
%%Code ends%%

A1.2 Write a simple code in MATLAB to draw the 3D Mohrs circle of stresses, to
perform stress transformations and to determine the principal stresses and their directions
for a 3-dimensional state of stress.
%***************************CE6780: Advanced Mechanics of Structures*****
%*******************ASSIGNMENT1*************************************
%*****************Question 2: To draw the 3D Mohr's circle of stresses,to
%perform stress transformations and to determine the principal stresses
%and their directions for a 3D state of stress
%%Code Begins%%
A=input('Stress Tensor : ');
%prompting the user to input the stress tensor and
store it in A
[v,t]=eig(A);
%finding eigen values and vectors and storing it in v and t
resp.
disp('The principal stresses are : ')
principal_stresses = t
tp1=t(1,1)
tp2=t(2,2)
%displaying principal stresses
tp3=t(3,3)
disp('The direction cosines of t1:')
dc1=v(1:3,1)
disp('The direction cosines of t2:')
%displaying direction cosines of the principal
planes
dc2=v(1:3,2)
disp('The direction cosines of t3:')
dc3=v(1:3,3)
theta=linspace(0,2*pi,100);
xax=linspace(-200,200,100);
yax=linspace(-200,200,100);
tuns=[t(1,1);t(2,2);t(3,3)];
tsort=sort(tuns,'descend')
r1=(tsort(1,1)-tsort(3,1))/2;
r2=(tsort(1,1)-tsort(2,1))/2;
r3=(tsort(2,1)-tsort(3,1))/2;
c1=(tsort(1,1)+tsort(3,1))/2;
%code for drawing 3D Mohr's Circle
c2=(tsort(1,1)+tsort(2,1))/2;
c3=(tsort(2,1)+tsort(3,1))/2;
x1=c1+r1*cos(theta);
y1=0+r1*sin(theta);
x2=c2+r2*cos(theta);
y2=0+r2*sin(theta);
x3=c3+r3*cos(theta);
y3=0+r3*sin(theta);
plot(x1,y1,'r','LineWidth',2)
axis('equal');
xlabel('Normal Stress')
ylabel('Shear Stress')

grid
hold on
plot(x2,y2,'b','LineWidth',2)
hold on
plot(x3,y3,'g','LineWidth',2)
plot(c1,0,'+','LineWidth',2)
hold on
plot(c2,0,'+','LineWidth',2)
hold on
plot(c3,0,'+','LineWidth',2)
hold on
text(tsort(1,1),0,'\sigma1')
text(tsort(2,1),0,'\sigma2')
text(tsort(3,1),0,'\sigma3')
disp('Maximum shear stress is given by : ') %displaying maximum shear stress
shearmax=(tsort(1,1)-tsort(3,1))/2
k=input('Do you want to perform stress transformations (Y/N)? :','s');
if k=='y'|| k=='Y'
dc=input('Enter the direction cosines of the new axes(X-Y-Z): ')
disp('Corresponding stress tensor in the transformed axis is given by :')
ttrans=dc*A*dc'
%performing stress transformation
elseif k=='n'||k=='N'
disp('THANK YOU')
else
error('Invalid Choice')
%invoking error message due to wrong choice
end
%%Code ends%%

A1.3 Write a simple MATLAB code to draw the 2D Mohrs circle of stresses, to perform
stress transformations, to determine the principal stresses and their directions for a 2D
state of stress.
%***************************CE6780: Advanced Mechanics of Structures*****
%*******************ASSIGNMENT *************************************
%*****************Question 3: To draw the 2D Mohr's circle of stresses, to
%perform stress transformations and to determine the principal stresses
%and their directions for a 2D state of stress
%%Code Begins%%
t=input('Enter the plane stress tensor :');
%prompting the user to input the stress
tensor and store it in t
[vectors,values]=eig(t);
%finding eigen values and vectors and
storing it in values and vectors resp.
disp('The principal stresses are :')
%displaying principal stresses
Principal_Stresses=values
disp('Direction cosines of first principal stress : ')
dctp1=vectors(1:2,1)
disp('Direction cosines of second principal stress : ') %displaying direction cosines of
the principal planes
dctp1=vectors(1:2,2)
theta=linspace(0,2*pi,100);
c=(t(1,1)+t(2,2))/2;
r=0.5*(sqrt((t(1,1)-t(2,2))^2+(4*t(1,2)^2)));
x=c+r*cos(theta);
y=0+r*sin(theta);
plot(x,y,'r','LineWidth',2)
%code for drawing 2D Mohr's Circle
axis('equal')
xlabel('Normal stress')
ylabel('shear stress')
grid
set(gca,'YDir','reverse');
%reversing the y axis
hold on
plot(c,0,'.')
hold on
line([t(2,2),t(1,1)],[-t(1,2),t(1,2)],'LineWidth',2)
hold on
line([c-r,c+r],[0,0],'LineWidth',2)
tp1=c+r;
tp2=tp1-2*r;
hold on
plot(tp1,0,'.')
hold on
plot(tp2,0,'.')
hold on
text(tp1,0,'\sigma1,\thetap')
text(tp2,0,'\sigma2')

thetap1=(180/pi)*atan(t(1,2)/t(1,1));
%finding the orientation of principal plane
text(t(1,1),t(1,2),'\theta=0')
disp('The direction of principal stress in degrees is :')
thetap1
sortedtp=sort(values);
disp('Maximum shear stress is given by : ')
%displaying maximum shear stress
shearmax=(values(1,1)-values(2,2))/2
text(c,shearmax,'\taumax')
hold on
line([c,c],[-shearmax,shearmax],'LineWidth',2)
k=input('Do you want to perform stress transformations (Y/N)? :','s');
if k=='y'|| k=='Y'
dc=input('Enter the direction cosines of the new axes(X-Y): ')
disp('Corresponding stress tensor in the transformed axis is given by :')
ttrans=dc*t*dc'
%performing stress transformation
elseif k=='n'||k=='N'
disp('THANK YOU')
else
error('Invalid Choice')
%invoking error message due to wrong choice
end

%%Code ends%%

You might also like