Use of ODE solver to solve for deflection of beam
In this project we will be using the ODE solver to solve for deflection and slope of a simple case of a cantilever beam subjected to a Bending moment M.The Basic differential equation governing the deflection of beam is
`(d^2y)/dx^2 = M/(EI)`
Where ,
dx - is the element along the length of beam ,
dy - is the elemental deflection.
M -bending moment.
E - Elastic constant.
I- area moment of Inertia.(cross-section of the Beam)
In our case a moment Mo is applied at the free end on a cantilever beam of length L.
Let us consider the following for our calculation.
Mo=50Nm.
L=1m.
E = 10*10^10.
I= 2.5*10^-6mm^4.
Now lets us rewrite the second order differential equation into two first order equations as shown.
`y=y_1`
`dy_1/dx =y_2`
`(d^2y)/dx^2 = (d^2y_1)/dx^2 = dy_2/dx`
thus ,
`dy_2/dx =M/(EI)`
A matlab function is to be generated to calculate the y' and y''.
function[dy_x]= odefun_deflection(x,deflection);
E=10*10^11;% Elastic constant
I=2.5*10^-6;% Area Moment of Inertia
M=50; %Bending_Moment
dy_x= zeros(2,1)% intialize the differential matrix
dy_x(1)=deflection(2); % equation 1
dy_x(2)= -M/(E*I); % equation 2
end
Now a main program has to be generated which provides the input to the function odefun_deflcetion, obtains solution from it and processes.
clear all
close all
clc
E=10*10^11;% Elastic constant
I=2.5*10^-6;% Area Moment of Inertia
M=50; %Bending_Moment
x=linspace(0,1,20); %sample space for length of beam
y0=[0;0]; % intial condition @x=0,y=0 and slope is 0
% Numerical solution
[x,deflection] = ode45('odefun_deflection',x,y0)
y_1= -M*x.^2/(2*E*I);%analytical solution for deflcetion
s_1 = -M*x/(E*I);%analytical solution for slope
figure(1)
plot([0 1],[0 0],'color','b','linewidth',3)
hold on;
plot(x,deflection(:,1),'color','r');
hold on;
plot(x,y_1,'*');
xlabel('length of beam');
ylabel('deflection along ');
legend('static beam','numerical_solution','analytical_solution');
figure(2)
plot(x,deflection(:,2),'color','r');
hold on;
plot(x,s_1,'*');
xlabel('length of beam');
ylabel('Slope');
legend('numerical_solution','analytical_solution');
let us alos compare the results obtained from the analytical solution for both deflection and slope against the numerical solution.
Below are the following plots.