0% found this document useful (0 votes)
56 views

AM5810: Computational Techniques Lab Assignment 4 - Group A: Jithin Devan P AM15M009 1 Semester Applied Mechanics

This document contains the details of Assignment 4 submitted by Jithin Devan for the Computational Techniques Lab course. It includes the MATLAB code and output for two problems - solving a second order differential equation describing ice buildup using the Runge-Kutta method, and solving a system of two first order differential equations over a given interval.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

AM5810: Computational Techniques Lab Assignment 4 - Group A: Jithin Devan P AM15M009 1 Semester Applied Mechanics

This document contains the details of Assignment 4 submitted by Jithin Devan for the Computational Techniques Lab course. It includes the MATLAB code and output for two problems - solving a second order differential equation describing ice buildup using the Runge-Kutta method, and solving a system of two first order differential equations over a given interval.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Computational Lab 1

Assignment 4
09-10-2015

AM5810: Computational Techniques Lab


Assignment 4 Group A

Submitted by,

Jithin Devan P
AM15M009
1st Semester Applied Mechanics

Computational Lab 2
Assignment 4
1. The differential equation
(

( )

describes ice build up on a frozen lake in terms of thermal resistance x(t) at time t. Develop a
program to solve this DE using R-K routine from time 0 to 1.5 with steps of 0.05.
Matlab code developed is shown below;
clear all;
clc
syms x t v;
disp('Computational Lab Assignment-4');
disp('By Jithin Devan AM15M009');
disp('-----------------------------------------');
disp('Question-1 Develop a program to solve 2nd Order DE using RK
method');
disp('-----------------------------------------')
disp('Let v = dx/dt, Re-write d2x/dt2 in terms of t, x & v')
f=input('Enter d2x/dt2 = ');
tn=input('Initial value of t = ');
xn=input('Corresponding value of x = ');
vn=input('Corresponding value of v = ');
D=input('Enter the interval in matrix form = ');
h=input('Enter step size, h = ');
i=(D(1,2)-D(1,1))/h; i=round(i);
fn=subs(f,v,vn);fn=subs(fn,x,xn);fn=subs(fn,t,tn);
A(1,1)=tn; A(1,2)=xn; A(1,3)=vn; A(1,4)=fn; j=2;
for n=1:i
dx1=h*vn;
dv1=subs(f,v,vn);dv1=subs(dv1,x,xn);dv1=subs(dv1,t,tn);dv1=h*dv1;
dx2=h*(vn+(dv1/2));
p=vn+(dv1/2); q=xn+(dx1/2); r=tn+(h/2);
dv2=subs(f,v,p);dv2=subs(dv2,x,q);dv2=subs(dv2,t,r);dv2=h*dv2;
dx3=h*(vn+(dv2/2));
p=vn+(dv2/2); q=xn+(dx2/2); r=tn+(h/2);
dv3=subs(f,v,p);dv3=subs(dv3,x,q);dv3=subs(dv3,t,r);dv3=h*dv3;
dx4=h*(vn+dv3);
p=vn+dv3; q=xn+dx3; r=tn+h;
dv4=subs(f,v,p);dv4=subs(dv4,x,q);dv4=subs(dv4,t,r);dv4=h*dv4;
dx=(dx1+(2*dx2)+(2*dx3)+dx4)/6;
dv=(dv1+(2*dv2)+(2*dv3)+dv4)/6;
tn=tn+h; xn=xn+dx; vn=vn+dv;
fn=subs(f,v,vn);fn=subs(fn,x,xn);fn=subs(fn,t,tn);
A(j,1)=tn; A(j,2)=xn; A(j,3)=vn; A(j,4)=fn; j=j+1;
end
disp('
t
x(t)
v(t)
d2x/dt2');
disp(A);

Computational Lab 3
Assignment 4
Output obtained is shown below;

Computational Lab 4
Assignment 4
2. Write a program for solving the system of differential equations.
( )

( )

Over the interval [2, 5] with h = 0.25


Matlab code developed is shown below;
clear all;
clc
syms x y t;
disp('Computational Lab Assignment-4');
disp('By Jithin Devan AM15M009');
disp('-----------------------------------------');
disp('Question-2 Write a program for solving the system of differential
equations');
disp('-----------------------------------------')
dy=input('Enter dy/dt = ');
dx=input('Enter dx/dt = ');
tn=input('Initial value of t = ');
yn=input('Corresponding value of y = ');
xn=input('Corresponding value of x = ');
D=input('Enter the interval in matrix form = ');
h=input('Enter step size, h = ');
n=(D(1,2)-D(1,1))/h; n=round(n);
for i=1:n
A(i,1)=tn; A(i,2)=yn; A(i,3)=xn;
dy=subs(dy,t,tn);
dy=subs(dy,x,xn);
dy=subs(dy,y,yn);
dx=subs(dx,t,tn);
dx=subs(dx,x,xn);
dx=subs(dx,y,yn);
yn=yn+dy*h;
xn=xn+dx*h;
tn=tn+h;
end
A(i,1)=tn; A(i,2)=yn; A(i,3)=xn;
disp('
t
y
x');
disp(A);

Computational Lab 5
Assignment 4
Output obtained is shown below;

You might also like