Description
Programming Assignment 4: Ordinary Differential Equations
1) Write a computer program for solving IVPs.
dy x0 and
Input: (i) Ordinary differential equation to be solved f x y , ; (ii) initial values dx
y0 ; (iii) final value xf (iv) interval size h ; (v) maximum tolerance tol .
Options: The user should have the option of selecting one or more of the following –
(a) Euler Forward
(b) Euler Backward
(c) Trapezoidal
(d) 4th -order Adams-Bashforth
(e) 4th -order Adams-Moulton
(f) 4th -order Backward Difference Formulation (BDF)
(g) 4th Order Runge-Kutta
Obtaining analytical solution is optional.
Output: The output from the program should be:
(a) A text file containing the values of xi and corresponding yi ; (b) A figure showing y vs x .
Test Problem: Provided at the end as well other problems in Tutorial 12.
2) Write a computer program to solve the following BVP:
Conservation of energy can be used to develop a heat balance equation at any cross section of the body. When the body is not insulated along its length and the system is at steady state, its temperature satisfies the following ODE:
d T dT
where, a(x), b(x), and f(x) are functions of the cross-sectional area, heat transfer coefficients, and the heat sinks inside the body. In the present case, they are given by
ax xx13, bx xx132 , and f x 2x 1 3bx.
a) Discretize the above equation using 2nd order central difference approximation and formulate the set of linear simultaneous equations. Incorporate the boundary conditions such that the accuracy of the scheme is preserved. Use x = 0.5.
b) Solve the system of equations using Thomas Algorithm and draw the temperature profile indicating the values at the nodes.
In the program, keep the following user options:
• Grid size (h)
• Implementation options for the small end boundary: 2nd order Backward Difference or 2nd order Central Difference with Ghost Node
Test Problem: Problems in Tutorial 13.
Make a single zip folder with all your program file(s) name it roll_number.zip (e.g., If your roll no. is 123456, the folder name should be ‘P3_123456.zip’). The folder should include –
(i) All the computer program file(s), input file(s) and output file(s)
(ii) A PDF file of the plots and the solution of the test cases given in this assignment.
Send the zip file by e-mail to: eso208.sec*@gmail.com, where * is section number 1-10. Example: for section O5, it is eso208.sec5@gmail.com; for section O10, it is
eso208.sec10@gmail.com
Additional Test Data: Part 1:
Sample input file dy 100(x2)2 0.5y
5e
dx x0 0.0 y0 0.5
xf 4.0
h 0.2
hmax 2.0 0.25 tol 105
Sample output files
x y_analytical y_eulerF y_trapezoidal y_RK4 0.00000 0.50000 0.50000 0.50000 0.50000 0.20000 0.45242 0.45000 0.45250 0.45242 0.40000 0.40937 0.40500 0.40951 0.40937 0.60000 0.37041 0.36450 0.37061 0.37041 0.80000 0.33516 0.32805 0.33540 0.33516 1.00000 0.30327 0.29525 0.30354 0.30327 1.20000 0.27441 0.26572 0.27470 0.27441 1.40000 0.24829 0.23915 0.24861 0.24829 1.60000 0.22466 0.21523 0.22499 0.22466 1.80000 0.20534 0.19371 0.20374 0.20642 2.00000 0.61483 0.19265 0.55135 0.58950 2.20000 0.96673 1.17339 0.81685 0.92054 2.40000 0.87663 1.07437 0.73845 0.83578 2.60000 0.79321 0.96693 0.66830 0.75625 2.80000 0.71773 0.87024 0.60481 0.68428 3.00000 0.64942 0.78321 0.54736 0.61916 3.20000 0.58762 0.70489 0.49536 0.56024 3.40000 0.53170 0.63440 0.44830 0.50693 3.60000 0.48111 0.57096 0.40571 0.45869 3.80000 0.43532 0.51387 0.36717 0.41504
4.00000 0.39390 0.46248 0.33229 0.37554




Reviews
There are no reviews yet.