Week 4.1 - Solving second order ODEs
EXPLENATIONS:
1.what is Differential Equvation ?
- Differential equvation one involve with one or more thanincluding the study of chenges.
- A derivative or slope is the retio chenge in Y with respect to X respectively.
- Differetiating the function y=f(x),lead to the 'Frist order derivitive' dy/dx.
2.Types of differential equvation
- Ordenary diffferential equvation
- partial differential equvation
1.odenary differential equvation
A Differential equvation contaningone or more functions of one indepedent veariable.
2.Partial Differential equvation
A Differential equvation one or more than function of two or more indepedent variable.
3.APLLICATIONS
- Used in the of chenges where it helps in analysis of problem involving flow studies.
- Helps in the computational simulations of real world problem.
Highly aplied in fluid dynamics, stucheral analysis and thermal studies.
- NUMERICAL TECHNIQUES TO SOLVE ODEs
- Solving differential equvation analaticaly would beatedicies process.
- There are a caratin numerical methodes to solve differontial equvation computationally.
The differential equvation should be discritized and will be representat as liner algebric form known as'Numerical Discretistation'.
A. Taylor series
In the mathamatics ,tylor series is the function of an infinite sum of terms that are expressed in term of the function derivitives at single point .
B. RK Methodes
It ovrercomes demerits of the 'tyor series approximation ' by excluding the calculations of 'higher order derivitives',in trun it can be used for a function of having high accuracies.
Discritistation of an ODE
d2 (theta )/dt^2+b/ml*d(theta)/dt+g/lsin(theta)=0
displacement
theta=theta1
velocity
d(theta)/dt........1
d2(theta)/dt^2=-b/ml *theta2-g/l*sin(theta1).......2
Initilising the variable;
- damping coiff b=0.5 Nm/s
- acc due to gravity ,g=10 m/s^2
- lenth of string l=0.75m
- mass of bob m=1 kg
- Initial displacement =0rad
- Initial velocity v5 rad/s
- time, tspan =0to 10 second
CODES;
Their are two kinds of a code
1.function code
2.main code
1.FUNCTION CODE:
function [dtheta dt] = ode_func(t,theta,b,g,l,m)
theta1=theta(1)
theta2=theta(2)
dtheta1dt=theta2
dtheta2dt=-(b/m)*theta2-(g/l)*sin(theta1);
dthetadt=[dtheta1dt dtheta2dt];
end
2.MAIN CODE:
clear all
close all
clc
b=0.05;
g=9.81;
l=1.2;
m=0.3;
ct=1
%Initial comdition
theta_0=0.5;
%time points
t_span= linspace(0,100,500);
%solve ODE
[t,results]=ode45(@(t,theta) ode_func(t,theta,b,l,m),t_span,theta);
plot(t,results(:,1))
hold on
plot(t,results(:,2))
ylabel('plot')
xlabel('time')
ct=ct+1;
M(ct)= getfream(gcf);
%To creat a animation
movie(M)
videopfile =videowriter('ode_main.avi','Uncompressed AVI')
open(videofile)
writevideo(videofile,M)
close(videofile)
OUPUTS:
given a output grphs is bellow
