Project Assignment 2 - 2023

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

MAKERERE UNIVERSITY

COLLEGE OF ENGINEERING, DESIGN, ART AND TECHNOLOGY


DEPARTMENT OF MECHANICAL ENGINEERING
MEC2203: COMPUTER PROGRAMMING Project Assignment 2

Project Instructions:
1. This project contains two problems and is to be done in groups of 10-15 students
and carries 50 points.
2. You are required to submit a well written report including all the steps used in
handling the problems, source code and executable files of the project.
3. This project is due on Monday 5th of June 2023 at midday.
4. Submit the files as C++ source code and the executables through MUELE.
5. The documents should be zipped and the file named as
project2_group_names.zip.
6. One member should submit on behalf of each group.

Problem 1: Steady State Temperature in a Thin Metal Plate (20 points)


Imagine a thin metal plate being surrounded by a number of heat sources along each
edge, with the edges held at different temperatures. After a short time, the
temperature at each location on the plate will settle into a steady state. This can be
modelled by dividing the plate into a discrete grid of cells and simulating the change
in temperature of each cell over time as below:

100 100 100 100 100

90 T(1,1) T(1,2) T(1,3) 95

90 T(2,1) T(2,2) T(2,3) 95

90 T(3,1) T(3,2) T(3,3) 95

80 80 80 80 95

At each time step, the temperature in each interior cell (i,j) will be the average of four
of its surrounding neighbours: T(i,j) = (T(i-1,j) + T(i+1,j) + T(i,j-1) + T(i,j+1))/4   

a) Part 1

Develop a program to determine the steady state temperature distribution in the


plate by representing the plate as a two-dimensional array with NROWS rows and
NCOLS columns. NROWS and NCOLS should be declared as global constants
(suggestion: use 20 for both values).

Your program should do the following:


 
 Declare 2 separate two-dimensional arrays named temp and old. Array old will
be used to maintain the current values of the grid temperatures and array
temp will be used to compute the new values obtained at each successive
time step using the equation above.
 Prompt the user and enter temperature values for the top, bottom, left, right
sides. Also prompt and enter an initial temperature T(i,j) for the interior cells. (For
this lab, you may initialize all the interior cells to a single, user-input
temperature.)
 Initialize temp using these values and display the initial contents of the temp
array on the console.
 Obtain a convergence criterion from the user (say, 0.001)
 Use a convergence loop to continue updating the temp array until the
temperature in every cell converges using the following method:
1. Set a boolean variable named steady to true
2. Copy temp to old
3. Loop over all the interior cells (but not the edge cells!)
temp[i][j] = 0.25*(old[i][j-1] + . . .)
if |temp[i][j] – old[i][j]| > convergence_criterion,
then set steady to false

Repeat this 3-step process again and again until all the cells simultaneously satisfy the
convergence criterion.

b) Part 2
Modify your program so that the final temperature data can be written to a file
named temp.dat instead of (or in addition to) the terminal screen.

Problem 2: (30 Points)


In this problem, you are required to demonstrate all that you have learned during this
course. It should be a fully-fledged C++ program, written entirely from scratch by you,
satisfying the requirements below. You are free to work on anything specific – you can
also come up with any idea that you want to work on. A possible idea could be:

An in-memory database (not required to save data to files) in which the user can
enter/modify/view records. For instance, you might make:
 A database of Mechanical Engineering Students (Year 1 to 4) at CEDAT, the
classes they take, etc., allowing adding, removing students, etc.

Further Requirements
 Your project should be large enough to take about 10-20 hours of coding.
 You may not use external libraries (e.g. for graphical interfaces) but stick to
a text interface.
 It is very important that you write easily readable, well designed code.
 Include a README file, with some documentation and instructions on how
to use your program. Also, this README file should include the problems you
had with your project, what challenges, and what you have done
differently if you could do it again.

You might also like