a 1 program structure a subroutine evalcolebrookfromfriction should evaluate the re 5148686
A.1 Program structure a) Subroutine evalColebrookFromFriction should evaluate the re-arranged Colebrook equation (1) for a given value of the friction factor (received as one of the subroutine arguments). This subroutine should be placed in MODULE moodyMod and CALLed by your nonlinear solver code. The constants g = 9.80665 m/s2 and = 3.14159 should be stored in MODULE moodyMod. Make sure to use the precision specified above for these constants. (b) Generalize your solver to support bisection and regula falsi iterations. Use a character dummy argument named algo (with values restricted to “BS” and “RF”) to select the scheme. (c) Replace the absolute error convergence test on the bracket width with a “mixed” convergence test that combines an absolute tolerance ATOL and a relative tolerance RTOL, as follows: | − | Note: This is a very robust and efficient general-purpose convergence test: small values of x are effectively controlled by ATOL, whereas large values of x are controlled by RTOL. (d) The main program should read all pipe and fluid parameters, as well as numerical algorithm choice, tolerances and iterations limits, from an input file (see below). The main program should then call the nonlinear solver to solve the Colebrook eqn with respect to the friction factor , and then use the Darcy-Weisbach equation to calculate the corresponding headloss hf. (e) The code should work for any valid values of pipe and fluid parameters, and any valid numerical settings (algorithm choice, tolerances, etc). (f) The code should return error messages for cases where invalid parameter values are supplied, and for cases where the requested tolerances could not be met in the allotted number of iterations. A.2 Program inputs (see MyUni for the file layout to be used – do not change it!) All inputs should be read from a file “moody[inputs].txt”, with layout exactly as given on MyUni. No inputs should be expected from the screen or keyboard. A.3 Program outputs (see MyUni for the file layouts and ensure correct content on each line) (a) “results” file “moody[results].txt”. See two examples on MyUni – one for a successful algorithm completion (ALGORITHM_OK) and one with the required error message (ALGORITHM_FAILED) in case of failure for whatever reason. Note that, irrespective of success or failure, the results file generated by the code should be named “moody[results].txt”. (b) “diagnostics” file “moody[diagnostics].txt” containing th