Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Determining fluid flow through pipes and tubes has great relevance in many areas

ID: 3773947 • Letter: D

Question

Determining fluid flow through pipes and tubes has great relevance in many areas of The resistance to flow in such conduits is p arameterized by a dimensionless number called the friction factor. For turbulent flow, the Colebrook equation provides a means to calculate the friction factor 2.51 Equation 1 +2.0log 3.7D Rev Le friction factor E the roughness (m), D diameter (m) and Re- the Reynolds number, defined by the following equation, Re m Equation 2 p the fluid's density Dkg/m3] v its velocity [m/s], and dynamic viscosity [N In addition to appearing in Equation 2, the Reynolds number also serves as the criterion for whether flow is turbulent (Re 4000); the Colebrook equation apply under this condition. parameters have values that range as follows The various pipe Roughness E(in millimeters): 0.0001 to 3 (e.g. cement lined cast iron pipe: 1.5 tubing: 0,0015) pipe: 0.046, drawn Fluid density p (in kg/mt): 0.5 (air is 1.2) to 2000 (95% sulfiuric acid is 1839) viscosity (in N m 10 air is 18.6x104 to 300 (peanut butter is 250) Finding the value of friction factor f from Equation (i) using analytical means is far from results by using a root finding method, that is, umerical methods can provide very good trivial. N finding the root of the function g0 defined as 2.0log 3.7D Rev f will give the friction factorfaccording to the Colebrook sawaaeuwofEquation

Explanation / Answer

Answer:

#include<stdio.h>

#include <math.h>

//Define the tolerance value

#define tolErr 0.001

//define the variables as global

double r=0,dia=0,fd=0,vel=0,vis=0;

double re=0;

//Given function

double GF(double fval)

{

     return ((1/sqrt(fval))+(2 * log((r/(3.7*dia))+(2.51/(re*sqrt(fval))))));

}

//main method

int main()

{

     //Declare the needed variables

   int kk = 1;

   float fval0,fval1,fval2;

     int uc;

   double gf1,gf2,gf0;

     FILE * fpp;

    

     //promptuser wish to read values from file

     printf("Do u want to read data from file:");

     scanf("%d", &uc);

     //if user wishes to read from file

     if(uc==1)

     {

          //open the file

          fpp=fopen("values.txt","r");

          //read values

fscanf(fpp,"%lf%lf%lf%lf%lf", &r, &dia, &fd, &vel, &vis);

          //close the file

          fclose(fpp);

     }

     //else, get the new values

     else

     {

    

printf("Enter roughtness, diameter, fluid density, velocity, viscocity:");

          scanf("%lf%lf%lf%lf%lf", &r, &dia, &fd, &vel, &vis);

     }

     //find re

     re=(fd*vel*dia)/vis;

     //initial value

   printf(" Enter the value of fval0: ");

   scanf("%f",&fval0);

     //ending value

   printf(" Enter the value of fval1: ");

   scanf("%f",&fval1);

     //print the values of each iteratiom

  

printf(" Steps fval0        fval1 fval2    gf0    gf1    gf2");

  

   do

   {

          //find middle value

        fval2=(fval0+fval1)/2;

          //get GF value at gf0

        gf0=GF(fval0);

          //get GF value at gf1

        gf1=GF(fval1);

          //get GF value at gf2

        gf2=GF(fval2);

          //print the values

printf(" %d %f %f %f %lf %lf %lf", kk, fval0,fval1,fval2,gf0,gf1,gf2);

          //Check the criterion

        if(gf0*gf2<0)

          {

              //set fval2 to fval1

              fval1=fval2;

          }

          else

          {

              //set fval2 to fval0

              fval0=fval2;

          }

          kk++;

   }while(fabs(gf2)>tolErr); //checking the tolerance

     //print approximate f value

     printf(" Approximate f-value = %f",fval2);

    

     return 0;

}

Sample output:

Do u want to read data from file:2

Enter roughtness, diameter, fluid density, velocity, viscocity:

1 1 1 1 1

Enter the value of fval0: 1

Enter the value of fval1: 1000

Steps     fval0           fval1 fval2       gf0       gf1       gf2

1 1.000000 1000.000000 500.500000 3.045096 -2.070060 -1.877538

2 1.000000 500.500000 250.750000 3.045096 -1.877538 -1.630476

3 1.000000 250.750000 125.875000 3.045096 -1.630476 -1.321349

4 1.000000 125.875000 63.437500 3.045096 -1.321349 -0.945339

5 1.000000 63.437500 32.218750 3.045096 -0.945339 -0.501857

6 1.000000 32.218750 16.609375 3.045096 -0.501857 0.003637

7 16.609375 32.218750 24.414062 0.003637 -0.501857 -0.299007

8 16.609375 24.414062 20.511719 0.003637 -0.299007 -0.165209

9 16.609375 20.511719 18.560547 0.003637 -0.165209 -0.086155

10 16.609375 18.560547 17.584961 0.003637 -0.086155 -0.042762

11 16.609375 17.584961 17.097168 0.003637 -0.042762 -0.019962

12 16.609375 17.097168 16.853271 0.003637 -0.019962 -0.008265

13 16.609375 16.853271 16.731323 0.003637 -0.008265 -0.002340

14 16.609375 16.731323 16.670349 0.003637 -0.002340 0.000642

Approximate f-value= 16.670349

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote