The program is supposed to solve for U_T (terminal velocity of a particle falling in water)

Everything can be found except Re and U_T

Re is basically 100 < Re <10000. I TRIED to create a while loop for Re. I am more used to Matlab than C programing, but it needs to be done in C.

The while loop should stop when F_D + F_B = W

After it breaks I want it to display the U_T and Re used

The difficult part is that U_T is used in another equation. I am wondering if I need to take it out of the loop.

I was wondering if you guys can tell me if I am using the while loop correctly?

And if you can tell me how to make it print the U_T and Re values when it is done.

Code:

// by Eric
// Math program to solve for terminal velocity of particle falling into water
#include<stdio.h>
#include<math.h>
int main(int argc,char *argv[])
{
int D; //diameter
int rho_p; //density of sand particle
int rho_f; //density of fluid
int mu_f; //dynamic viscosity of fluid
int g; //gravity
int F_D; //Drag Force
int C_D; //Coefficent of Drag
int U_T; //Terminal Velocity solving for
int F_B; //Force of Bounacy
int m //mass
int Re //Reynolds Number
int W //Weight
int PI //pi
D = 300*10^(-6); // diameter of sand particle in units of meters
rho_p = 2000; // density of sand particle in units of kg/m^3
rho_f = 998.2; // density of fluid (kg/m^3) at 68 F
mu_f = 1.002*10^(-3); // Dynamic Viscosity of fluid(kg/m*s) at 68 F
g = 9.81; // gravity (m/s^2)
PI = 3.141592653589793;
//Re=((U_T·D·rho_f) / (mu_f));
//U_T=((Re*mu_f)/(D*rho_f));
//F_D=C_D·((PI·D*D) / (4))*0.5·rho_f·U_T*U_T;
//F_B=rho_f·((PI*pow (D, 3)) / (6))·g;
W=m·g;
m=rho_p·((PI*pow (D, 3)) / (6));
//C_D=((24) / (Re))*pow ((1+0.27·Re), 0.43)+0.47·(1-exp (-0.04*pow (Re, 0.38)));
Re=100;
while (Re <= 10000)
{
U_T=((Re*mu_f)/(D*rho_f));
F_D=C_D·((PI·D*D) / (4))*0.5·rho_f·U_T*U_T;
F_B=rho_f·((PI*pow (D, 3)) / (6))·g;
C_D=((24) / (Re))*pow ((1+0.27·Re), 0.43)+0.47·(1-exp (-0.04*pow (Re, 0.38)));
Re++;
if (F_D+F_B == W)
break;
}
return 0;
}