Power and Square Root MethodsThe power and square root methods are used to raise the value of one argument to the power of a second. The sqrt(double a) method described later in this chapter is equivalent to the method pow(double a, 0.5).
pow() returns the first argument raised to the power of the second argument, a b . There are some special cases if one or both of the arguments is infinity or NaN . In these cases, the return value will be either infinity or NaN . You can also pass integer arguments to this method, as the integers will be automatically cast into double values. sqrt() returns the square root of the input argument. If the argument is less than zero, NaN is returned. You can pass integer values to the sqrt() method as they will be automatically cast into double values. Example: Using the pow() and sqrt() MethodsThe coefficient of viscosity relates a velocity gradient to the shear stress the velocity gradient will generate. It is an important quantity when performing viscous flow calculations. For a pure gas species, the coefficient of viscosity is given by Eq. (16.5). Equation 16.5
In Eq. (16.5), M is the molar mass of the gas species in gm / mole and T is the temperature in K. The quantity is the reduced collision integral for the gas species. There are many ways to obtain values for the collision integral. For diatomic nitrogen, you can use the curve fit relation in Eq. (16.6). 1 Equation 16.6
The PowDemo class uses the pow() and abs() methods to compute the coefficient of viscosity for diatomic nitrogen at a temperature of 1000 K using Eq. (16.5) and Eq. (16.6). It also makes use of the log() method that will be described later in this chapter. public class PowDemo { public static void main(String args[]) { // Define some variables and some constants double M = 28.0134; double T = 1000.0; double Omega22, eta, grp; // Use the pow() and sqrt() methods to compute // the coefficient of viscosity for diatomic // nitrogen at 1000 K. grp = -0.0203*Math.log(T) + 0.0683; Omega22 = 19.0158*Math.pow(T,grp); eta = 2.6693e-5*Math.sqrt(M*T)/Omega22; System.out.println("Viscosity is " + eta + " gm/cm-sec"); } } Output ” Viscosity is 3.86142846e-4 gm/cm-sec |