{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PGE 310 - HW6 -Solution

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

Info icon This 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 SOLUTION 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.
Image of page 1

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

View Full Document Right 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 %)
Image of page 2
3 Question #1 Solution Using Global Variables: 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 .
Image of page 3

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

View Full Document Right 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
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern