Displaying differences for changeset
 
display as  

src/java/hydraulics/StandardStepMethod.java

@@ -27,24 +27,27 @@
 
 public class StandardStepMethod {
     
-    boolean irregularGeometry =false;
-    boolean downstreamCrossSections = true;
+    //Inputs
+    String subFolder = "Cive401_Problem1";
+    //String mainFolder = "C:/Users/Chris/Documents/Java Projects/StandardStepMethod" + File.separator + subFolder; //Home PC
+    String mainFolder = "U:/Java Projects/StandardStepMethod" + File.separator + subFolder;//Work computer
+    
+    boolean irregularGeometry =true;
+    boolean downstreamCalculation = false;
     boolean useThalwegElevation = false;
+    boolean createGraph = true;
+    boolean createSummaryFile = true;
+    double measuredDownstreamDepth = .5;
+    double discharge_DS = 14.5;
     
-    String subFolder = "SeepageTest3";
-    String mainFolder = "C:/Users/Chris/Documents/Java Projects/StandardStepMethod" + File.separator + subFolder ;
-    double measuredDownstreamDepth = 7;
-    
-    //Downstream x-section characteristics
+    //Uniform Geometry Cross-Section Characteristics
     double bottomWidth = 10;
     double sideSlope = 2;
-    double discharge_DS = 200;
 
-    //Reach Characteristics
+    //Uniform Geometry Reach Characteristics
     double manning_n = .035;
     double bedSlope = 0.0004;
     double seepage = 0.005;
-    
     double channelLength = 20000; //Distance between sample x-sections
     int numberOfReaches = 100; //Length between calculated x-section
     
@@ -93,31 +96,49 @@
         this.subFolder = subFolder;
     }
     
-    public void setSamplingDirection(boolean downstreamCrossSections){
-        this.downstreamCrossSections = downstreamCrossSections;
+    public void irregularGeometry(boolean irregularGeometry){
+        this.irregularGeometry = irregularGeometry;
+    }
+    
+    public void setDownstreamCalculation(boolean downstreamCalculation){
+        this.downstreamCalculation = downstreamCalculation;
+    }
+    
+    public void setUseThalwegElevation(boolean useThalwegElevation){
+        this.useThalwegElevation = useThalwegElevation;
+    }
+    
+    public void setCreateGraph(boolean createGraph){
+        this.createSummaryFile = createGraph;
+    }
+    
+    public void setCreateSummaryFile(boolean createSummaryFile){
+        this.createGraph = createSummaryFile;
     }
     
     //gets
     public String getElevationGraphTitle(){
-        if (downstreamCrossSections){
-            return "Downstream Longitudinal Elevation Profile.png";
+        if (downstreamCalculation){
+            return "Downstream Elevation Profile.png";
         }
         else{
-            return "Upstream Longitudinal Elevation Profile.png";
+            return "Upstream Elevation Profile.png";
         }
     }
     
     public String getElevationGraphOutputName(){
-        if (downstreamCrossSections){
-            return subFolder + " Downstream Longitudinal Elevation Profile.png";
+        if (downstreamCalculation){
+            String title = "_" + measuredDownstreamDepth + "m_StartDepth_DownstreamElevationProfile.png";
+            return subFolder + title;
         }
         else{
-            return subFolder + " Upstream Longitudinal Elevation Profile.png";
+            String title = "_" + measuredDownstreamDepth + "m_StartDepth_UpstreamElevationProfile.png";
+            return subFolder + title;
         }
     }
     
     public String getSummaryTitle(){
-        if (downstreamCrossSections){
+        if (downstreamCalculation){
             return subFolder + " Downstream Summary Data";
         }
         else{
@@ -125,11 +146,13 @@
         }
     }
     public String getSummaryOutputName(){
-        if (downstreamCrossSections){
-            return subFolder + " Downstream Summary Data.txt";
+        if (downstreamCalculation){
+            String title = "_" + measuredDownstreamDepth + "m_StartDepth_DownstreamData.txt";
+            return subFolder + title;
         }
         else{
-            return subFolder + " Upstream Summary Data.txt";
+            String title = "_" + measuredDownstreamDepth + "m_StartDepth_UpstreamData.txt";
+            return subFolder + title;
         }
     }
     
@@ -235,7 +258,7 @@
             }
             
             
-            if (downstreamCrossSections == false){
+            if (downstreamCalculation == false){
                 length = -length;
             }
             
@@ -341,7 +364,7 @@
             } 
             else {
                 guessDepth_US = (lower + upper) / 2;
-                System.out.println("****Could not solve standard step equation****");
+                System.out.println("Could not solve standard step equation " + downstreamDistance + " m downstream." );
             }
             
             
@@ -388,7 +411,7 @@
             depth_DS = guessDepth_US;
             
         } //end for statement
-
+        if (createGraph){
         graphLongitudinalProfile(crossSectionResultsArray,
                 numberOfReaches,
                 getElevationGraphTitle(),
@@ -399,9 +422,12 @@
                 "Normal Depth",
                 "Channel Bed Elevation",
                 "Elevation (m)");
-        writeSummaryFile(crossSectionResultsArray,
-                            reachResultsArray);
-        
+        }
+        if (createSummaryFile){
+            writeSummaryFile(mainFolder,
+                                crossSectionResultsArray,
+                                reachResultsArray);
+        }
         
     }//end calcStandardStepMethod
     
@@ -1011,49 +1037,53 @@
     }//end graphLongitudinalProfile
     
     /**
-     * Creates a text file in the selected folder that summarizes the calculated
-     * values from the standard step method.
-     * 
-     * @param depthArray A 3-dimensional array containing all the calculated values
-     * for every cross-section.
-     * @param reachArray A 2-dimensional array containing all the calculated values
-     * for every reach.
-     * 
+     * Writes out the formatted output file as expected by eRAMS to be used for a JHighchart XY
+     * @param mainFolder
+     * @param crossSectionResultsArray
+     * @param reachResultsArray
+    
      * @throws IOException 
      */
     
-    public void writeSummaryFile(double[][][] depthArray,
-                                    double[][] reachArray)throws IOException{
+    public void writeSummaryFile(String mainFolder,
+                                double[][][] crossSectionResultsArray,
+                                double reachResultsArray[][]) throws IOException {
+        //open the file writer and set path
         
-        boolean append_to_file = false;
+        
+        String summaryOutputName = getSummaryOutputName();
+        
+        String path = mainFolder + File.separator + summaryOutputName;
+        FileWriter writer =  new FileWriter(path, false);
+        PrintWriter print_line = new PrintWriter(writer);
+        
+        //Print the needed values
+        
         String summaryTitle = getSummaryTitle();
-        String summaryOutputName = getSummaryOutputName();
-        int numberOfCrossSections = depthArray.length;
-        
-        try{
-            writeToFile(summaryTitle,append_to_file,summaryOutputName);
-            for(int i = 0; i<numberOfCrossSections; i++){
-                append_to_file = true;
-                writeToFile("",append_to_file,summaryOutputName);
-                writeToFile("Cross Section " + i + ": " + depthArray[i][0][0] + " m downstream",append_to_file,summaryOutputName);
-                writeToFile("   Depth: " + depthArray[i][1][0]+" m",append_to_file,summaryOutputName);
-                writeToFile("   Discharge: " + depthArray[i][0][1]+" m^3/s",append_to_file,summaryOutputName);
-                writeToFile("   Critical Depth: " + depthArray[i][1][1]+" m",append_to_file,summaryOutputName);
-                writeToFile("   Normal Depth: " + depthArray[i][1][2]+" m",append_to_file,summaryOutputName);
-                writeToFile("   Bed Elevation: " + depthArray[i][1][3]+" m (above origin)",append_to_file,summaryOutputName);
-                writeToFile("   Water Surface Elevation: " + (depthArray[i][1][0] + depthArray[i][1][3])+ " m (above origin)",append_to_file,summaryOutputName);
-                writeToFile("",append_to_file,summaryOutputName);
-                writeToFile("Reach " + (i+1)+":", append_to_file, summaryOutputName);
-                writeToFile("   Length: " + reachArray[i][0]+" m", append_to_file, summaryOutputName);
-                writeToFile("   Slope: " + reachArray[i][1]+" m/m", append_to_file, summaryOutputName);
-                writeToFile("",append_to_file,summaryOutputName);
-            }
-            System.out.println(mainFolder + File.separator + summaryOutputName);
+        print_line.printf("%s" + "\r\n", summaryTitle);
+        print_line.printf("%s" + "\r\n", "");
+                
+        for(int i=0; i<crossSectionResultsArray.length; i++){
+            print_line.printf("%-35s" + "\r\n", "");
+            print_line.printf("%s" + "%.3f" + "%s" + "\r\n", "Cross Section " + i + ": ",crossSectionResultsArray[i][0][0]," m downstream");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Depth: ", crossSectionResultsArray[i][1][0]," m");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Discharge: ", crossSectionResultsArray[i][0][1]," m^3/s");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Critical Depth: ", crossSectionResultsArray[i][1][1]," m");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Normal Depth: ", crossSectionResultsArray[i][1][2]," m");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Bed Elevation (Above Origin): ", crossSectionResultsArray[i][1][3]," m");
+            print_line.printf("%-35s" + "%15.6f" + "%s" + "\r\n","   Water Surface Elevation: ", crossSectionResultsArray[i][1][2]
+                    +crossSectionResultsArray[i][1][0]," m");
+            print_line.printf("%-35s" + "\r\n", "");
+            print_line.printf("%-35s" + "\r\n","Reach" + (i+1));
+            print_line.printf("%-35s" + "%15.6f" +"%s" + "\r\n","   Length: ", reachResultsArray[i][0]," m");
+            print_line.printf("%-35s" + "%15.6f" +"%s" + "\r\n","   Slope: ", reachResultsArray[i][1]," m/m");
         }
-        catch(IOException e){
-            System.out.println("A problem occured while trying to create the Summary Table.");
-        }
-    }
+      
+        // Close the file writer 
+        print_line.close();
+        writer.close();
+        System.out.println("Text File located at:\t" + path);
+    }//end writeSummaryFile
     
     /**
      * Writes a given line to a text file.