SedimentTransport.java [src/java/hydraulics] Revision:   Date:
package hydraulics;

import java.io.IOException;
import java.util.ArrayList;

/**
* Last Updated: 27-February-2015
* @author Tyler Wible
* @since 28-July-2014
*/
public class SedimentTransport {
    String transportType = "Yang";//"Bagnold";//"Brownlie";//"Martin - Church";//"Wilcock - Kenworthy";//"Meyer-Peter - Muller";//"Rating Curve";//
    //Water properties
    double rho = 1000;                         //density of water (kg/m**3)
    double waterTemp = 15.5;                   //water temperature (degrees Celsius)
    double waterKinViscosity = 0.00000111484;  //kinematic viscosity (m**2/s)
    //Sediment properties
    double rho_S = rho * 2.65;         //density of the sediment (kg/m**3) (used for sand in Wilcock/Kenworthy)
    double rho_G = rho * 2.65;         //density of the gravel sediment (kg/m**3)
    double diamSed = 0.399989;         //sediment size (mm)
    double diamGravel = 15.24;         //surface grain size for gravel fraction (mm)
    double sandFraction = 0;           //sand fraction (%)
    double d16 = 0.39998904;           //D16 sediment size (mm)
    double d50 = 0.39998904;           //D50 sediment size (mm)
    double d84 = 0.39998904;           //D85 sediment size (mm)
    double R1 = 46;                    //Multiplier for sediment rating curve sed = R1 * (Q ^ R2)
    double R2 = 3.92;                  //Exponent for sediment rating curve sed = R1 * (Q ^ R2)
    String ratingCurveUnits = "kg/s";  //Units of rating curve for output purposes
    //Channel properties
    double depth = 0.6096;          //depth of flow (m)
    double bottomWidth = 6.8;       //bottom-width of sediment transport (m)
    double area = 31.3548;          //cross-sectional area of flow (m**2)
    double hydRadius = 1.31826;     //hydraulic radius (m)
    double discharge = 100;         //discharge in the channel (m**3/s)
    double bedSlope = 0.0005;       //channel bed slope (m/m)
    double energySlope = 0.0005;    //slope of the energy grade line (m/m)
    double frictionSlope = 0.0005;  //slope of the friction grade line (m/m)
    
    
    //Outputs
    String units = "?";
    double sedTransport = -1;
    
    //Gets
    public double getSedTransport() { return sedTransport; }
    public String getUnits() { return units; }
    
    //Sets
    public void setTransportType(String transportType) {this.transportType = transportType; }
    public void setWaterDensity(double rho) {this.rho = rho; }
    public void setWaterTemperature(double waterTemp) {this.waterTemp = waterTemp; }
    public void setWaterKinematicViscosity(double waterKinViscosity) {this.waterKinViscosity = waterKinViscosity; }
    public void setSedDensity(double rho_S) {this.rho_S = rho_S; }
    public void setGravelDensity(double rho_G) {this.rho_G = rho_G; }
    public void setSedDiameter(double diamSed) {this.diamSed = diamSed; }
    public void setGravelDiameter(double diamGravel) {this.diamGravel = diamGravel; }//Used by Wilcock&Kenworthy only
    public void setSandFraction(double sandFraction) {this.sandFraction = sandFraction; }//Used by Wilcock&Kenworthy only
    public void setSedD16(double d16) {this.d16 = d16; }//used by Brownlie only
    public void setSedD50(double d50) {this.d50 = d50; }//used by Brownlie only
    public void setSedD84(double d84) {this.d84 = d84; }//used by Brownlie only
    public void setR1(double R1) {this.R1 = R1; }//used by rating curve only
    public void setR2(double R2) {this.R2 = R2; }//used by rating curve only
    public void setRatingCurveUnits(String ratingCurveUnits) {this.ratingCurveUnits = ratingCurveUnits; }//used by rating curve only
    public void setChannelDepth(double depth) {this.depth = depth; }
    public void setChannelBottomWidth(double bottomWidth) {this.bottomWidth = bottomWidth; }
    public void setChannelArea(double area) {this.area = area; }
    public void setChannelHydraulicRadius(double hydRadius) {this.hydRadius = hydRadius; }
    public void setChannelDischarge(double discharge) {this.discharge = discharge; }//used by Martin&Church only
    public void setChannelBedSlope(double bedSlope) {this.bedSlope = bedSlope; }
    public void setChannelEnergySlope(double energySlope) {this.energySlope = energySlope; }
    public void setChannelFrictionSlope(double frictionSlope) {this.frictionSlope = frictionSlope; }
    /**
     * Calculates sediment transport (kg/s) using Bagnold's Bed Load Equation
     * For use with unimodal sediment, a separate function is needed for bi-modal sediment
     * @param d_mqb  modal grain size of a given bed-load transport observation (m)
     * @param rhoS  density of sediment (kg/m**3)
     * @param D  depth of flow in the channel (m)
     * @param width  width of flow in the channel (m)
     * @param V  the velocity of the flow in the channel (m/s)
     * @param S  the slope of the channel bed (m/m)
     * @param rho  density of water (kg/m**3)
     * @return  sediment transport (kg/s)
     * @throws java.io.IOException
     */
    public void bagnold1980(double d_mqb,
                            double rhoS,
                            double D,
                            double width,
                            double V,
                            double S,
                            double rho) throws IOException{

        //Bagnold reference values
        double g = 9.81;//gravitational constant (m/s**2)
        double qb_star = 0.1;//reference transport rate (kg/s/m)
        double w_w0_star = 0.5;//reference excess stream power (kg/s/m)
        double D_star = 0.1;//reference stream depth (m)
        double d_star = 0.0011;//reference particle size (m)

        //Calculate unit stream power (kg/s/m)
        double w = rho * D * S * V;

        //Calculate critical unit stream power for unimodal sediment
        double d_mss = 1;
        double w0 = 5.75 * Math.pow( ((rhoS/rho) - 1) * rho * 0.04, 1.5) * Math.sqrt(g/rho) * Math.pow(d_mss,  1.5) * Math.log10(12 * D / d_mqb);

        //Calculate critical unit stream power for bimodal sediment
        //double w0 = (w0 for first mode * w0 for second mode)^0.5 (geometric mean of the critical stream power for the two modes

        //Calculate sediment discharge per unit width of river
        double qb = (rhoS / (rhoS -rho)) * qb_star * Math.pow((w - w0) / w_w0_star, 1.5) * Math.pow(D/D_star, -2.0/3.0) * Math.pow(d_mqb / d_star, -0.5);

        //Convert sediment transport to kg/s
        qb = qb * width;
        throw new IOException("There is no 'd_mss' term defined for the bagnold 1980 equation");
//        return qb;
    }
    /**
     * Calculates sediment transport (ppm) using Brownlie's Total Load Equation
     * @param ds  diameter of the sediment size for sediment transport (feet)
     * @param d84  diameter of the 84th percentile sediment (feet)
     * @param d50  diameter of the 50th percentile sediment (feet)
     * @param d16  diameter of the 16th percentile sediment (feet)
     * @param G  specific gravity of the sediment (gammaWater / gammaSediment) (unitless)
     * @param A  the cross-sectional area of flow in the channel (ft**2)
     * @param R  the hydraulic radius of the channel (ft)
     * @param Q  the discharge of the flow in the channel (ft**3/s)
     * @param Sf  the slope of the friction grade line (ft/ft)
     * @param nu  kinematic viscosity of the water (ft**2 / s)
     * @return sediment transport (ppm)
     */
    public double brownlie1981(double ds,
                               double d84,
                               double d50,
                               double d16,
                               double G,
                               double A,
                               double R,
                               double Q,
                               double Sf,
                               double nu){
        double g = 32.2;//gravitational constant (feet/s**2)
        
        //Calculate cross-section averaged velocity, (ft/s)
        double V = Q / A;
        
        //Calculate Y parameter
        double Y = Math.pow( Math.sqrt((G-1) * g * d50 * d50 * d50) / nu, -0.6);

        //Calculate critical shear stress by Bronlie's continuous function for the Shields curve
        double t_starC = 0.22 *  Y + 0.06 * Math.pow(10.0, -7.7 * Y);

        //Calculate ratio of sediment sizes (sigma_g)
        double sigma_g = Math.sqrt(d84 / d16);

        //Calculate Vc fraction
        double Vc = 4.596 * Math.pow(t_starC, 0.529) * Math.pow(Sf, -0.1405) * 
                    Math.pow(sigma_g, 0.1606) * Math.sqrt((G - 1) * g * ds);

        //Calculate sediment concentration
        double C_ppm = 9022.0 * Math.pow((V/Math.sqrt((G-1) * g * ds)) - (Vc/Math.sqrt((G-1) * g * ds)), 1.978) * 
                       Math.pow(Sf, 0.6601) * Math.pow(R/d50, -0.3301);

//        //Convert ppm to mg/L
//        //Gray, J.R., G.D. Glysson, L.M. Turcios, G.E. Schwarz. 2000. Comparability of Suspended-Sediment Concentration and Total Suspended Solids Data. U.S. Department of the Interior, U.S. Geolotical Survey Water-Resources Investigations Report 00-4191.
//        //Cmg/L= Cppm/(1-Cppm(6.22 x 10-7)
//        double C_mgL = C_ppm;
//        if(C_ppm > 7960.389){//C_mgL > 8000mg/L
//            C_mgL = C_ppm / (1 - C_ppm * 0.000000622);
//        }
//        
//        //Convert sediment transport to kg/s (mass/time)
//        Units unit = new Units();
//        double C_kgL = unit.convertUnits(C_mgL, "milligrams", "kilograms", 1, false);  //convert milligrams/L to kilograms/L
//        double C_kgM3 = C_kgL * (1000. / 1.);  //convert kilograms/L to kilograms/m**3
//        double C_kgFT3 = unit.convertUnits(C_kgM3, "feet", "meters", 3, false);  //convert kilograms/m**3 to kilograms/ft**3
//        double C_kgS = C_kgFT3 * Q;  //convert kilograms/ft**3 to kilograms/s
//        
//        return C_kgS;
        return C_ppm;
    }
    /**
     * Calculates sediment transport (kg/s) using Martin and Church's revisitation of Bagnold's Bed Load Equation
     * Assumes a critical dimensionless shear stress (t_starC) of 0.04
     * @param ds  median particle size, d50, does not handle bimodal sediments (m)
     * @param rhoS  density of sediment (kg/m**3)
     * @param h  depth of flow in the channel (m)
     * @param width  bottom width of flow in the channel (m)
     * @param Q  the discharge in the channel (m**3/s)
     * @param S  the slope of the channel bed (m/m)
     * @param rho  density of water (kg/m**3)
     * @return  sediment transport (kg/s)
     */
    public double martinChurch2000(double ds,
                                   double rhoS,
                                   double h,
                                   double width,
                                   double Q,
                                   double S,
                                   double rho){
        //Martin and Church reference values
        double g = 9.81;//gravitational constant (m/s**2)
        double t_starC = 0.04;
        double G = rhoS / rho;

        //Calculate unit stream power (kg/ms)
        //double w = rho * D * S * V;
        double w = rho * S * Q / width;

        //Calculate critical specific stream power (kg/ms)
        //double W0 = 305.0 * Math.log10(12 * h / ds) * Math.pow(ds,  1.5);//for SI units with g, rho, t_starC, and G assumed standard
        double w0 = Math.pow(t_starC * (G-1) * ds, 1.5) * rho * Math.sqrt(g) * 5.75 * Math.log10(12.0 * h / ds);

        //Calculate unit with mass-bed-load transport
        //double qbm = 0.0139 * (Math. pow(ds, 0.25))  * Math.pow(w - w0,  1.5);//for SI units with g and rho assumed standard
        double q_bm = (1 / (Math.sqrt(rhoS - rho) * Math.pow(g, 0.25)) ) * (Math.pow(ds,  0.25) / h) * Math.pow(w - w0, 1.5);

        //Convert sediment transport to mass/time
        q_bm = q_bm * width;

        return q_bm;
    }
    /**
     * Calculates sediment transport (?) using Meyer-Peter and Muller's Bed Load Equation
     * @param d  the mean particle diameter for the i-th size class (m)
     * @param d90_s  the surface particle size for which 90% of the sediment sample is finer (m)
     * @param d50_ss  the subsurface particle size for which 90% of the sediment sample is finer (m)
     * @param rhoS  density of sediment (kg/m**3)
     * @param D  depth of flow in the channel (m)
     * @param R  the hydraulic radius of the channel (m)
     * @param S  the slope of the channel bed (m/m)
     * @param rho  density of water (kg/m**3)
     * @return sediment transport (?)
     */
    public double meyerPeterMuller1948(double d,
                                       //double d90_s,
                                       //double d50_ss,
                                       double rhoS,
                                       //double D,
                                       double R,
                                       double S,
                                       double rho){
        //Original Sediment Transport, simplified
        double tStar_c = 0.047;
        double tStar = R * S / (((rhoS/rho)-1) * d);
        double q_bStar = 8 * Math.pow(tStar - tStar_c, 1.5);

        //Reexamination (by Wong, 2003; Wong and Parker, 2006)
        //double tStar_c = 0.047;
        //double tStar = R * S / ((G-1) * d);
        //double q_bStar = 4.93 * Math.pow(tStar - tStar_c, 1.6);

        //Original Sediment Transport, un-simplified
        //double g = 9.81;//gravitational constant (m/s**2)
        ////Calculate n_prime
        //double n_prime = Math.pow(d90_s, 1.0/6.0) / 26.0;
        //
        ////Calculate size-specific critical Shields' stress, tStar_c
        //double tStar_c = 0.0834 * Math.pow(d/d50_ss, -0.872);
        //
        ////Calculate size-specific bed-load transport rate
        //double q_b = 8 * f (rhoS / (rhoS - rho)) * Math.sqrt(g / rho) * Math.pow(Math.pow(n_prime/n_t, 1.5) * rho * S * D - tStar_c * (rhoS - rho) * d, 1.5);

        return q_bStar;
    }
    /**
     * Calculates sediment transport per unit width (m**2/s) using Wilcock and Kenworthy's Two-Phase Bed Load Equation
     * @param Dg  surface grain size for gravel fraction (m)
     * @param Ds  surface grain size for sand fraction (m)
     * @param Fs  sand fraction (0-1) (to ignore the sand fraction, set Fs to zero)
     * @param rho_G  density of gravel sediment
     * @param rho_S  density of sand sediment
     * @param width  bottom width of flow in the channel (m)
     * @param R  the hydraulic radius of the channel (m)
     * @param S  the slope of the channel bed (m/m)
     * @param rho density of water
     * @return sediment transport (kg/s)
     */
    public double wilcockKenworthy2002(double Dg,
                                       double Ds,
                                       double Fs,
                                       double rho_G,
                                       double rho_S,
                                       double width,
                                       double R,
                                       double S,
                                       double rho){
        double g = 9.81;//gravitational constant (m/s**2)
        double G_g = rho_G / rho;
        double G_s = rho_S / rho;

        //Wilcock and Kenworthy reference values
        double tStar_rg0 = 0.035;                  //upper limit of gravel incipient motion (based on sand fraction)
        double tStar_rg1 = 0.011;                  //lower limit of graph incipient motion (based on sand fraction)
        double tStar_rs0 = tStar_rg0 * (Dg / Ds);  //upper limit of sand incipient motion (based on sand fraction)
        double tStar_rs1 = 0.065;                  //lower limit of sand incipient motion (based on sand fraction)
        double A = 115;                            //field data calibrated transport function coefficient
        double phi_ref = 1.27;                     //field data calibrated transport function coefficient
        double xi = 0.923;                         //field data calibrated transport function coefficient
        double Fg = 1 - Fs;                        //Gravel fraction

        //Calculate the dimensionless incipient motion criterion for the sand and gravel portions
        double tStar_rg = tStar_rg1 + (tStar_rg0 - tStar_rg1) * Math.exp(-14 * Fs);
        double tStar_rs = tStar_rs1 + (tStar_rs0 - tStar_rs1) * Math.exp(-14 * Fs);

        //Calculate actual shear stress
        double tStar_g = R * S / ((G_g-1) * Dg);
        double tStar_s = R * S / ((G_s-1) * Ds);

        //Calculate phi values
        double phi_g = tStar_g / tStar_rg;
        double phi_s = tStar_s / tStar_rs;

        //Calculate the gravel transport by volume
        double q_bg = 0;
        if(phi_g < phi_ref){
            q_bg = Math.sqrt((G_g-1) * g * Dg * Dg * Dg) * 0.002 * (Fg / Math.pow(tStar_rg,  7.5)) * Math.pow(tStar_g, 9);
        }else{ 
            q_bg = Math.sqrt((G_g-1) * g * Dg * Dg * Dg) * A * Fg * Math.pow(1 - xi * Math.pow(tStar_rg/tStar_g, 0.25), 4.5) * Math.pow(tStar_g, 1.5);
        }

        //Calculate the sand transport by volume/time/width
        double q_bs = 0;
        if(phi_s < phi_ref){
            q_bs = Math.sqrt((G_s-1) * g * Ds * Ds * Ds) * 0.002 * (Fs / Math.pow(tStar_rs,  7.5)) * Math.pow(tStar_s, 9);
        }else{ 
            q_bs = Math.sqrt((G_s-1) * g * Ds * Ds * Ds) * A * Fs * Math.pow(1 - xi * Math.pow(tStar_rs/tStar_s, 0.25), 4.5) * Math.pow(tStar_s, 1.5);
        }
        
        //Convert sediment transport to volume/time (and not per unit width)
        q_bg = q_bg * width;   //now units of m**3/s
        q_bs =  q_bs * width;  //now units of m**3/s
        
        //Convert sediment transport to mass/time
        q_bg = q_bg * rho_G;  //now units of kg/s
        q_bs = q_bs * rho_S;  //now units of kg/s
        
        //Sum the result
        double q_bm = q_bg + q_bs;

        return q_bm;
    }
    /**
     * Calculates fall velocity using Rubey's formula (1933) for fall velocity of gravel, sand, and silt
     * @param g  gravitational constant (feet/s**2)
     * @param d  sediment size (feet)
     * @param T  water temperature (Fahrenheit)
     * @param nu  kinematic viscosity of the water (ft**2 / s)
     * @param gamma_S  unit weight of the sediment (lbs/ft**3)
     * @param gamma  unit weight of water (lbs/ft**3)
     * @return  fall velocity of the particle (ft/s)
     */
    public double rubey1933_fallVelocity(double g, double d, double T, double nu, double gamma_S, double gamma){
        //Calculate the F parameter
        double fraction = (36. * nu * nu) / (g * d * d * d * ((gamma_S / gamma) - 1.));
        double F = Math.sqrt((2.0/3.0) + fraction) - Math.sqrt(fraction);
        double d_mm = 304.8 * d;
        double T_c = (5.0/9.0) * (T - 32.0);
        if(d_mm > 1 && 10 < T_c && T_c < 25){
            //Special condition, If d(ft) < 1mm and T > 10 degrees Celsius and T < 25 degrees Celsius
            F = 0.79;
        }

        //Calculate the fall velocity "w"
        double w = F * Math.sqrt(d * g * ((gamma_S - gamma)/gamma));
        //if(d > 2mm && T = 16 Degrees C) w = 6.01 * Math.sqrt(d);//"d" = ft, "w" = ft/s (approximation)
        //if(d > 2mm && T = 16 Degrees C) w = 3.32 * Math.sqrt(d);//"d" = m, "w" = m/s (approximation)

        return w;
    }
    /**
     * Calculates sediment transport (ppm) using Yang's Total Load Equation for sand.
     * The fall velocity used is from Rubey's formula (1933) for fall velocity of gravel, sand, and silt
     * @param d  sediment diameter (feet)
     * @param gamma_S  specific weight of the sediment (lbs/ft**3)
     * @param A  the cross-sectional area of flow in the channel (ft**2)
     * @param R  the hydraulic radius of the channel (ft)
     * @param Q  the discharge of the flow in the channel (ft**3/s)
     * @param Se  the slope of the energy grade line (ft/ft)
     * @param S  the slope of the channel bed (ft/ft)
     * @param T  water temperature (Fahrenheit)
     * @param gamma  specific weight of water (lbs/ft**3)
     * @param nu  kinematic viscosity of the water (ft**2 / s)
     * @return  sediment transport (ppm)
     * @throws IOException  if the provided parameters are outide of Yang's incipient motion ranges
     */
    public double yang1996(double d, 
                           double gamma_S,
                           double A,
                           double R,
                           double Q,
                           double Se,
                           double S,
                           double T,
                           double gamma,
                           double nu) throws IOException{
        double g = 32.2;//gravitational constant (feet/s**2)
        
        //Calculate cross-section averaged velocity, (ft/s)
        double V = Q / A;
        
        //Calculate fall velocity, (ft/s)
        double w = rubey1933_fallVelocity(g, d, T, nu, gamma_S, gamma);

        //Calculate shear velocity, u_star (ft/s)
        double u_star = Math.sqrt(g * R * Se);

        //Calculate dimensional critical velocity (Vc / w) at incipient motion based on Reynold's number
        double Vcw = 0;
        double Re_star = (u_star * d) / nu; 
        if(1.2 < Re_star && Re_star < 70){
            Vcw = (2.5 / (Math.log10(u_star * d / nu) - 0.06)) + 0.66;
        }else if(Re_star >= 70){
            Vcw = 2.05;
        }else{
            ArrayList<String> errorMessage = new ArrayList<String>();
            errorMessage.add("The specified sediment is outside the acceptable range of Yang's Total Load Equation for " + 
                            "Sand with a Reynold's number = (u_star * diameter of sediment) / kinematic viscosity  = " + Re_star + " < 1.2");
            writeError(errorMessage);
        }
        
        //Calculate concentration of sediment (ppm)
        double logC_ppm = 5.435 - 0.286 * Math.log10((w * d) / nu) - 0.457 * Math.log10(u_star / w) + 
                        (1.799 - 0.409 * Math.log10((w * d) / nu) - 0.314 * Math.log10(u_star / w)) * Math.log10((V * S / w) - Vcw * S);
        double C_ppm = Math.pow(10, logC_ppm);
        
//        //Convert ppm to mg/L
//        //Gray, J.R., G.D. Glysson, L.M. Turcios, G.E. Schwarz. 2000. Comparability of Suspended-Sediment Concentration and Total Suspended Solids Data. U.S. Department of the Interior, U.S. Geolotical Survey Water-Resources Investigations Report 00-4191.
//        //Cmg/L= Cppm/(1-Cppm(6.22 x 10-7)
//        double C_mgL = C_ppm;
//        if(C_ppm > 7960.389){//C_mgL > 8000mg/L
//            C_mgL = C_ppm / (1 - C_ppm * 0.000000622);
//        }
//        
//        //Convert sediment transport to kg/s (mass/time)
//        Units unit = new Units();
//        double C_kgL = unit.convertUnits(C_mgL, "milligrams", "kilograms", 1, false);  //convert milligrams/L to kilograms/L
//        double C_kgM3 = C_kgL * (1000. / 1.);  //convert kilograms/L to kilograms/m**3
//        double C_kgFT3 = unit.convertUnits(C_kgM3, "feet", "meters", 3, false);  //convert kilograms/m**3 to kilograms/ft**3
//        double C_kgS = C_kgFT3 * Q;  //convert kilograms/ft**3 to kilograms/s
//        
//        return C_kgS;
        return C_ppm;
    }
    /**
     * Writes out the error message, if any, and then exits the program
     * @param error  string array to be written as each line of an error message
     * @throws IOException
     */
    public void writeError(ArrayList<String> error) throws IOException{
        //Output data to text file
        String errorContents = error.get(0);
        for(int i=1; i<error.size(); i++){
            errorContents = errorContents + "\n" + error.get(i);
        }
        throw new IOException("Error encountered. Please see the following message for details: \n" + errorContents);
    }
    public void run() throws IOException{
        //Determine Sediment Transport Type:
        GeneralFunctions genFuncs =  new GeneralFunctions();
        Units unit = new Units();
        if(transportType.equalsIgnoreCase("Yang")){
            //Convert units to english for Yang 1996
            double diamSed_eng = unit.convertUnits(diamSed, "millimeters", "feet", 1, false);  //convert mm to ft
            double area_eng = unit.convertUnits(area, "meters", "feet", 1, false);             //convert m to ft
            double hydRadius_eng = unit.convertUnits(hydRadius, "meters", "feet", 1, false);   //convert m to ft
            double discharge_eng = unit.convertUnits(discharge, "meters", "feet", 3, false);   //convert m**3/s to ft**3/s
            double waterTemp_eng = waterTemp * (9./5.) + 32;                                   //convert degrees Celsius to degress Fahrenheit
            double rho_eng = unit.convertUnits(rho, "kg", "slugs", 1, false);                  //convert kg/m**3 to slugs/m**3
            rho_eng = unit.convertUnits(rho_eng, "feet", "meters", 3, false);                  //convert slugs/m**3 to slugs/ft**3
            double gamma = rho_eng * 32.2;                                                     //specific weight of water (lbs/ft**3)
            double rho_S_eng = unit.convertUnits(rho_S, "kg", "slugs", 1, false);              //convert kg/m**3 to slugs/m**3
            rho_S_eng = unit.convertUnits(rho_S_eng, "feet", "meters", 3, false);              //convert slugs/m**3 to slugs/ft**3
            double gamma_S = rho_S_eng * 32.2;                                                 //specific weight of the sediment (lbs/ft**3)
            double waterKinViscosity_eng = unit.convertUnits(waterKinViscosity, "meters", "feet", 2, false);  //convert m**2/s to ft**2/s
            
            //Yang Total Load Example (CIVE 413 Homework 3 Prob. 1, Part D, 2013)
            double C_ppm = yang1996(diamSed_eng,             //0.0013123; //sediment size (ft)
                                    gamma_S,                 //165.36;    //specific weight of the sediment (lbs/ft**3)
                                    area_eng,                //337.5;     //flow area (ft**2)
                                    hydRadius_eng,           //4.325;     //hydraulic radius (ft)
                                    discharge_eng,           //1200;      //flow velocity (ft/s)
                                    energySlope,             //0.0005;    //slope of the energy grade line (ft/ft)
                                    bedSlope,                //0.0005;    //channel bed slope (ft/ft)
                                    waterTemp_eng,           //60;        //water temperature (degrees Fahrenheit)
                                    gamma,                   //62.4;      //specific weight of water (lbs/ft**3)
                                    waterKinViscosity_eng);  //0.000012;  //kinematic viscosity of water (ft**2/s)
            //Store Results
            this.sedTransport = genFuncs.round(C_ppm,3);
            this.units = "ppm";
            System.out.println("Yang Sediment Transport: " + C_ppm + " (ppm)");
            
        }else if(transportType.equalsIgnoreCase("Bagnold")){
            //Bagnold Example
            throw new IOException("Need example/verification for Bagnold 1980 equation");
            
        }else if(transportType.equalsIgnoreCase("Brownlie")){
            //Convert units to english for Yang 1996
            double diamSed_eng = unit.convertUnits(diamSed, "millimeters", "feet", 1, false);  //convert mm to ft
            double d84_eng = unit.convertUnits(d84, "millimeters", "feet", 1, false);          //convert mm to ft
            double d50_eng = unit.convertUnits(d50, "millimeters", "feet", 1, false);          //convert mm to ft
            double d16_eng = unit.convertUnits(d16, "millimeters", "feet", 1, false);          //convert mm to ft
            double area_eng = unit.convertUnits(area, "meters", "feet", 1, false);             //convert m**2 to ft**2
            double hydRadius_eng = unit.convertUnits(hydRadius, "meters", "feet", 1, false);   //convert m to ft
            double discharge_eng = unit.convertUnits(discharge, "meters", "feet", 3, false);   //convert m**3/s to ft**3/s
            double waterKinViscosity_eng = unit.convertUnits(waterKinViscosity, "meters", "feet", 2, false);  //convert m**2/s to ft**2/s
            
            //Brownlie Total Load Example (CIVE 413 Homework 3, Prob.1, Part D, 2013)
            double C_ppm = brownlie1981(diamSed_eng,             //0.0013123;  //sediment size (ft)
                                        d84_eng,                 //0.0013123;  //D84 sediment size (ft)
                                        d50_eng,                 //0.0013123;  //D50 sediment size (ft)
                                        d16_eng,                 //0.0013123;  //D16 sediment size (ft)
                                        rho_S/rho,               //2.65;       //Specific Gravity of sediment (unitless)
                                        area_eng,                //337.5;     //flow area (ft**2)
                                        hydRadius_eng,           //4.325;      //hydraulic radius (ft)
                                        discharge_eng,           //1200;      //flow velocity (ft/s)
                                        frictionSlope,           //0.0005;     //slope of the friction grade line (ft/ft)
                                        waterKinViscosity_eng);  //0.000012;   //kinematic viscosity of water (ft**2/s)
            //Store Results
            this.sedTransport = genFuncs.round(C_ppm,3);
            this.units = "ppm";
            System.out.println("Brownlie Sediment Transport: " + C_ppm + " (ppm)");
            
        }else if(transportType.equalsIgnoreCase("Martin - Church")){
            //Convert units for Martin and Church 2000
            double diamSed_met = unit.convertUnits(diamSed, "millimeters", "meters", 1, false);  //convert mm to m
            //Calculate sediment transport
            double q_bm = martinChurch2000(diamSed_met,  //0.02;    //sediment size (m)
                                           rho_S,        //2650;    //density of sediment (kg/m**3)
                                           depth,        //2;       //depth of flow (m)
                                           bottomWidth,  //35;      //bottom width of flow (m)
                                           discharge,    //100;     //discharge in the channel (m**3/s)
                                           bedSlope,     //0.0015;  //slope of channel (m/m)
                                           rho);         //1000;    //density of water (kg/m**3)
            //Martin and Church/Bagnold Example (CIVE 413 Homework 3, Prob2, 2013)
            
            //Store Results
            this.sedTransport = genFuncs.round(q_bm,3);
            this.units = "kg/s";
            System.out.println("Martin and Church Sediment Transport: " + q_bm + " (kg/s)");
            
        }else if(transportType.equalsIgnoreCase("Wilcock - Kenworthy")){
            //Convert units for Wilcock and Kenworthy 2002
            double diamGravel_met = unit.convertUnits(diamGravel, "millimeters", "meters", 1, false);  //convert mm to m
            double diamSed_met = unit.convertUnits(diamSed, "millimeters", "meters", 1, false);        //convert mm to m
            
            //Calculate sediment transport
            double q_bm = wilcockKenworthy2002(diamGravel_met,  //0.05;         //surface grain size for gravel fraction (m)
                                               diamSed_met,     //0.001;        //surface grain size for sand fraction (m)
                                               sandFraction,    //0;            //sand fraction
                                               rho_G,           //2650;         //density of the gravel sediment (kg/m**3)
                                               rho_S,           //2650;         //density of the sand sediment (kg/m**3)
                                               bottomWidth,     //6.8;          //bottom width of channel (m)
                                               hydRadius,       //0.386189237;  //hydraulic radius (m)
                                               bedSlope,        //0.00743;      //slope of channel bed (m/m)
                                               rho);            //1000;         //density of water (kg/m**3)
            //Wilcock and Kenworthy Example (CIVE 413 Homework 3, Prob 3, 2013)
            
            //Store Results
            this.sedTransport = genFuncs.round(q_bm,3);
            this.units = "kg/s";
            System.out.println("Wilcock and Kenworthy Sediment Transport: " + q_bm + " (kg/s)");
            
        }else if(transportType.equalsIgnoreCase("Meyer-Peter - Muller")){
            //Meyer-Peter and Muller Example
            throw new IOException("Need example/verification for Meyer-Peter and Muller equation");
        }else if(transportType.equalsIgnoreCase("Rating Curve")){
            //Use a rating curve sed = R1 * Q ^ R2
            double qSed = R1 * Math.pow(discharge, R2);
            
            //Store Results
            this.sedTransport = genFuncs.round(qSed,3);
            this.units = ratingCurveUnits;
            System.out.println("Sediment Rating Curve Transport: " + qSed + " (" + ratingCurveUnits + ")");
        }
    }
    public static void main(String[] args) throws IOException{
        SedimentTransport sedimentModel = new SedimentTransport();
        //Run Model
        sedimentModel.run();
    }
}