PGE 310 - HW6 -Solution

PGE 310 - HW6 -Solution - The University of Texas at Austin...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 The University of Texas at Austin PGE 310: Formulation and Solution in Geosystems Engineering Homework #6: Root Finding (Secant Method) and Solving Linear System of Equations By Hossein Roodi Questions 1 is solved for both cases: using global variables and not using global variables Question #1 Solution: Not Using Global Variables: 1. Root Finding: Using Secant Method (MATLAB PROGRAMMING) The Colebrook equation is used for friction factor in fully developed pipe flow: ! " # $ ) Re 51 . 2 7 . 3 / log( 2 1 f D f % 0 ) Re 51 . 2 7 . 3 / log( 2 1 $ " " $ f D f y Where f is friction factor, D / is the relative roughness of the pipe material, and Re is Reynolds number based on pipe diameter D . You are supposed to solve this equation for f using secant method . a) Write a MATLAB function called “ Colebrook.m” that when sent Darcy factor ( f ), Relative roughness ( eD ) and Reynolds number ( Re), it returns the value of function. - Note: In MATLAB, log (x) is reserved for natural log of x . For logarithm in base of 10 you are supposed to use log10(x).So in this problem if you write log instead of log10 , your root will be 0.0108 instead of 0.0572 and the number of iteration will change. b) Write a MATLAB function called “ secant.m” that when sent a function ( func ), initial guesses ( 0 x & 1 x ), it returns the root of equation ( root ) and the number of iterations. In your function file, choose a tolerance that you think is appropriate . Recall that secant method formulation is: ) ( ) ( ) )( ( 1 1 1 i i i i i i i x f x f x x x f x x # # # $ # # " So, in each step two estimations are needed, like x i and x i-1 and the next guess for root is obtained by the above mentioned formulation. (x i+1 is obtained based on x i and x i-1 ) In the following function secant.m x0 and x1 are assigned as the two estimation values using in secant method formulation. Aftereach iteration x0 and x1 are updated.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 c) Write a script file called “ frictionfac.m ” to calculate the value of friction factor for the following values " Set 6 10 Re $ , 03 . 0 / $ D % , 006 . 0 0 $ x and 007 . 0 1 $ x Results: Print all your files and the results. Upload function files and script file on the Blackboard. (35 %)
Background image of page 2
3 If global variables are used for eD and Re , then it is not required to declare them as input variables neither in Colebrooks.m nor in secant.m . MATLAB assumes them global and recognizes them within all functions. To make them global, only thing you need to do is writing command“ global eD Re” at the beginning of your script file and your function files. Also, since Colebrook.m will have only one input, you need to erase them from the end of feval functions in secant.m .
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 2. Developing System of Equations for a Real World Problem: (By HAND) An oil company called OILHW6 wants to make decision about pumping from three oil wells in one of its reservoirs in Texas. Unknowns are oil outputs from each well: Q1, Q2 and Q3 Q1 contains 30% Gasoline , 30% Diesel Fuel and 40% Kerosene Q2 contains 60% Gasoline , 20% Diesel Fuel and 20% Kerosene Q3 contains 50% Gasoline , 20% Diesel Fuel and 30% Kerosene In order to separate these chemicals, OILHW6 transfers Q1, Q2 and Q3
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

PGE 310 - HW6 -Solution - The University of Texas at Austin...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online