COMP1004 Semester 1, 2020 Home‐based Programming Assignment
Instructions (Read Carefully):
This is an open book programming assignment. You are allowed to use online resources to assist in this assignment;
This is an individual assignment and no collusion with other students of any kind is allowed;
Your program has to work. That means it has to compile correctly, run according to specifications, and give correct results. The submitted assignment must also meet the following criteria:
Good design, including good pseudocode and algorithms; and
Adequate testing, especially the testing of data boundaries and special cases.
You must observe good programming practices, including comment, documentation, and readability of your program;
To facilitate program readability, you must include function calls in your program whenever possible;
All names of constants, types, variables, functions, etc. must be "self‐documenting" and "self‐describing." For example, you should call a variable a name such as "total" if it is used to store a Give a function a name like "PrintList" if its job is to print a list;
Estimating the frictional pressure loss for fluid flow in straight pipes
Background
Civil, mechanical, chemical and petroleum engineers all have to deal with the flow of fluids in pipes. For example, the Goldfields Pipeline from Perth to Kalgoorlie‐Boulder supplies around 14.1 billion litres of water per year over a distance of about 560 km. Piping alone can represent around 10% of the total capital cost of a typical chemical plant, amounting to many millions of dollars. Engineers who design and operate piping systems need to minimise the associated costs. Roughly speaking, a larger diameter pipe costs more to buy (capital cost), but is cheaper to run (operating cost) because it would have a lower frictional pressure loss. Estimating the frictional pressure loss for the flow of a gas or liquid in straight pipe is a common and important engineering task.
𝐷, 𝜖 Δ𝑝f𝑣𝜌, 𝜇𝐿
The frictional pressure loss in single‐phase, incompressible flow in a straight pipe may be found by:
fΔ𝑝 = 𝑓L 1 𝜌𝑣2 D 2
where Δ𝑝f is the frictional pressure loss (Pa), 𝑓 is the Moody friction factor (unitless), 𝐿 is the pipe length (m), 𝐷 is the pipe’s internal diameter (m), 𝜌 is the fluid density (kg/m3) and 𝑣 is the mean fluid velocity inside the pipe (m/s). The friction factor depends on a quantity called the Reynolds number, which characterizes the ratio of inertial to viscous forces in the flow, and the roughness of the pipe, which depends on the pipe’s material and method of fabrication. The Reynolds number for pipe flow is calculated using
𝑅𝑒 = Dvqµ
where 𝑅𝑒 is the Reynolds number (unitless) and 𝜇 is the fluid’s dynamic viscosity (Pa.s). When the Reynolds number is below about 2100 for pipes, the flow is laminar, while above about 4000, the flow is turbulent; in between, the flow regime is transitional: it could be laminar or turbulent, or swap randomly between them. Different equations for the friction factor are needed for the different flow regimes. One possible set of equations is 𝑓𝑜𝑟 𝑅𝑒 ≤ 2100 (𝑙𝑎𝑚𝑖𝑛𝑎𝑟)
Re𝑓 =𝑓 + (𝑓 — 𝑓 ) ( Re–2100 ) 𝑓𝑜𝑟 2100 € 𝑅𝑒 ≤ 4000 (𝑡𝑟𝑎𝑛𝑠𝑖𝑡𝑖𝑜𝑛𝑎𝑙)
where 𝑓L is the laminar friction factor equation evaluated at 𝑅𝑒 = 2100, 𝑓T is the turbulent friction factor evaluated at 𝑅𝑒 = 4000 and 𝜖 is the pipe roughness (m). Some typical roughness values are:
Pipe material Roughness (mm) 
Commercial carbon or stainless steel 0.045 
Ordinary concrete 1.0 
Glass tube 0.0015 
PVC / plastic 0.0060 
Table 1 : Pipe materials and their associated roughness values. Note: These values are in mm and need to be converted to m before calculating 𝑓.
Programming Tasks
Your task is to develop a working C program
Read from an external file (name this file input.txt) which stores the input values for the pipe diameter, pipe length, fluid velocity, fluid density and fluid viscosity. Student can choose the format of the external file so long as it is a text file;
Ask the user to select the pipe material (i.e. carbon/steel, concrete, glass or PVC/plastic) for which the program will assign the associated roughness value (in mm) according to Table 1;
Calculate and print the Reynolds number, the frictional pressure loss and the flow regime (i.e. laminar, transitional or turbulent) onto the computer screen; and
For a series of fluid velocity values, between 1m/s and 2m/s in step of 0.1m/s, calculate the resultant frictional pressure loss and write the pair of values (i.e. fluid velocity versus frictional pressure loss) onto an external excel spreadsheet (name this file output.csv) so that the data can be viewed and plotted on Microsoft Excel Spreadsheet.
To facilitate program readability, you must include function calls in your program whenever possible. To help with checking your program for part 3 above, you should get the following results for the following two test cases:
Inputs 
Water in Goldfields Pipeline 
Pipe diameter (m) 
0.76 
Pipe length (m) 
560000.00 
Fluid velocity (m/s) 
1.00 
Fluid density (kg/m3) 
1000.00 
Fluid viscosity (Pa.s) 
0.001 
Pipe roughness (mm) 
0.045 
Outputs 

Reynolds number 
7.60e+005 
Frictional pressure loss (Pa) 
4.82e+006 
Flow regime 
Turbulent 
Test Case 1 : For water in the Goldfields pipeline
Inputs 
Water in garden hose 
Pipe diameter (m) 
0.012 
Pipe length (m) 
5.00 
Fluid velocity (m/s) 
0.15 
Fluid density (kg/m3) 
1000.00 
Fluid viscosity (Pa.s) 
0.001 
Pipe roughness (mm) 
0.006 
Outputs 

Reynolds number 
1.80e+003 
Frictional pressure loss (Pa) 
1.67e+002 
Flow regime 
Laminar 
Test Case 2 : For water in a typical garden hose
What you have to submit
The pseudo code documenting the design of the program. This should be submitted as a pdf naming it pdf (10%);
A well‐documented, syntax‐free and correctly‐working C program source Name this file
program.c (60%);
The txt and output.csv files (5%); and
A report recording the set of tests (i.e. test cases) that you performed on your program to verify the correctness of the This should be submitted as a pdf naming it report.pdf (25%).
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
Get Free Quote!
384 Experts Online