Displaying differences for changeset
 
display as  

src/java/hydraulics/StandardStepMethod.java

@@ -24,12 +24,9 @@
 * @author Chris Dumler
 * @since 22-June-2015
 */
-
 public class StandardStepMethod {
-    
     //Inputs
-    String subFolder = "RegularGeometryTest";
-    String mainFolder = "U:/Java Projects/StandardStepMethod";
+    String mainFolder = "U:/Java Projects/StandardStepMethod/RegularGeometryTest";
     boolean irregularGeometry = false;
     boolean downstreamCalculation = true;
     boolean useThalwegElevation = true;
@@ -53,73 +50,50 @@
     public void setBottomWidth(double bottomWidth){
         this.bottomWidth = bottomWidth;
     }
-    
     public void setSideSlope(double sideSlope){
         this.sideSlope = sideSlope;
     }
-    
     public void setDepth_DS(double measuredDownstreamDepth){
         this.measuredDownstreamDepth = measuredDownstreamDepth;
     }
-    
     public void setDischarge_DS(double discharge_DS){
         this.discharge_DS = discharge_DS;
     }
-    
     public void setManningRoughness(double manning_n){
         this.manning_n = manning_n;
     }
-    
     public void setBedSlope(double bedSlope){
         this.bedSlope = bedSlope;
     }
-    
     public void setSeepage(double seepage){
         this.seepage = seepage;
     }
-    
     public void setChannelLength(double channelLength){
         this.channelLength = channelLength;
     }
-    
     public void setNumberOfCrossSections(int numberOfCrossSections){
         this.numberOfCrossSections = numberOfCrossSections;
     }
-    
     public void setMainFolder(String mainFolder){
         this.mainFolder = mainFolder;
     }
-    
-    public void setSubFolder(String subFolder){
-        this.subFolder = subFolder;
-    }
-    
     public void setIrregularGeometry(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 getFilePath(){
-        String filePath = mainFolder + File.separator + subFolder;
-        return filePath;
-    }
-    
     public String getElevationGraphTitle(){
         if (downstreamCalculation){
             return "Downstream Elevation Profile.png";
@@ -128,60 +102,34 @@
             return "Upstream Elevation Profile.png";
         }
     }
-    
     public String getElevationGraphOutputName(){
         if (downstreamCalculation){
             String title = "_" + measuredDownstreamDepth + "m_StartDepth_DownstreamElevationProfile.png";
-            return subFolder + title;
+            return title;
         }
         else{
             String title = "_" + measuredDownstreamDepth + "m_StartDepth_UpstreamElevationProfile.png";
-            return subFolder + title;
+            return title;
         }
     }
-    
     public String getSummaryTitle(){
         if (downstreamCalculation){
-            return subFolder + " Downstream Summary Data";
+            return " Downstream Summary Data";
         }
         else{
-            return subFolder + " Upstream Summary Data";
+            return " Upstream Summary Data";
         }
     }
     public String getSummaryOutputName(){
         if (downstreamCalculation){
             String title = "_" + measuredDownstreamDepth + "m_StartDepth_DownstreamData.txt";
-            return subFolder + title;
+            return title;
         }
         else{
             String title = "_" + measuredDownstreamDepth + "m_StartDepth_UpstreamData.txt";
-            return subFolder + title;
+            return title;
         }
     }
-    
-    /**
-     * Created new Standard Step Model object and starts 'run' method.
-     * 
-     * @param args
-     * 
-     * @throws IOException 
-     */
-    
-    public static void main(String[] args) throws IOException {
-        StandardStepMethod model = new StandardStepMethod();
-        model.run();
-    }//end main
-    
-    /**
-     * Starts calcStandardStepMethod().
-     * 
-     * @throws IOException 
-     */
-
-    public void run() throws IOException {
-        calcStandardStepMethod();
-    }//end run
-
     /**
      * Calculates the water depth at each subsequent cross section using the
      * Standard Step Equation.
@@ -210,13 +158,11 @@
      * @throws IOException
      * 
      */
-    
-    public void calcStandardStepMethod() throws IOException {
+    public void run() throws IOException {
         
-        String filePath = getFilePath();
         int numberOfReaches;
         if (irregularGeometry) {
-            numberOfReaches = readLines(filePath + File.separator + "reaches.txt");
+            numberOfReaches = readLines(mainFolder + File.separator + "reaches.txt");
         }
         else{
             numberOfReaches = numberOfCrossSections-1;
@@ -430,7 +376,6 @@
                 numberOfReaches,
                 getElevationGraphTitle(),
                 getElevationGraphOutputName(),
-                filePath,
                 "Water Surface Elevation",
                 "Critical Depth",
                 "Normal Depth",
@@ -438,9 +383,8 @@
                 "Elevation (m)");
         }
         if (createSummaryFile){
-            writeSummaryFile(filePath,
-                                crossSectionResultsArray,
-                                reachResultsArray);
+            writeSummaryFile(crossSectionResultsArray,
+                             reachResultsArray);
         }
         
     }//end calcStandardStepMethod
@@ -457,7 +401,6 @@
      * 
      * @throws IOException
      */
-    
     public double[] calcBoundaryConditions(double depth_DS,
                                             double criticalDepth,
                                             double normalDepth) throws IOException {
@@ -538,7 +481,6 @@
      * @return A 2-dimensional array containing the calculated depth values for 
      * the current cross-section.
      */
-    
     public double[][] writeCrossSectionResultsArray(double waterDepth,
                                         double critDepth,
                                         double normDepth,
@@ -574,7 +516,6 @@
      * 
      * @throws IOException
      */
-
     public int readLines(String file_path) throws IOException {
         
         int numberOfLines = 0;
@@ -605,7 +546,6 @@
      * 
      * @throws IOException
      */
-
     public String[] transferTXTFile(String file_path) throws IOException {
         
         String[] crossSections = new String[0];
@@ -636,12 +576,9 @@
      * 
      * @throws IOException
      */
-
     public int calcLargestCrossSection() throws IOException {
-        
-        String filePath = getFilePath();
-        String[] sections = transferTXTFile(filePath + File.separator + "crossSections.txt");
-        int numberOfLines = readLines(filePath + File.separator + "crossSections.txt");
+        String[] sections = transferTXTFile(mainFolder + File.separator + "crossSections.txt");
+        int numberOfLines = readLines(mainFolder + File.separator + "crossSections.txt");
 
         int i;
         int n;
@@ -666,12 +603,9 @@
      * 
      * @throws IOException
      */
-
     public double[][][] setCrossSectionGeometries() throws IOException {
-        
-        String filePath = getFilePath();
-        int numberOfSections = readLines(filePath + File.separator + "crossSections.txt");
-        String[] sections = transferTXTFile(filePath + File.separator + "crossSections.txt");
+        int numberOfSections = readLines(mainFolder + File.separator + "crossSections.txt");
+        String[] sections = transferTXTFile(mainFolder + File.separator + "crossSections.txt");
         int length = calcLargestCrossSection();
         String[][] xypointlist;
         int i;
@@ -701,12 +635,9 @@
      * 
      * @throws IOException
      */
-
     public double[][] setReachProperties() throws IOException {
-        
-        String filePath = getFilePath();
-        int numberOfSections = readLines(filePath + File.separator + "reaches.txt");
-        String[] reaches = transferTXTFile(filePath + File.separator + "reaches.txt");
+        int numberOfSections = readLines(mainFolder + File.separator + "reaches.txt");
+        String[] reaches = transferTXTFile(mainFolder + File.separator + "reaches.txt");
         double[][] reachProperties = new double[numberOfSections][4];
         int i;
         for (i = 0; i < numberOfSections; i++) {
@@ -735,7 +666,6 @@
      * 
      * @return The water velocity at the current cross-section.
      */
-    
     public double calcVelocity(ChannelGeometry values) { //Need to move to ChannelGeomety Class?
 
         if (irregularGeometry) {
@@ -759,7 +689,6 @@
      * 
      * @return The water friction slope at the current cross-section.
      */
-
     public double calcFrictionSlope(ChannelGeometry values) {
 
         if (irregularGeometry) {
@@ -791,7 +720,6 @@
      * 
      * @throws IOException
      */
-    
     public double calcThalwegElevationSlope(int currentReach)throws IOException {
         GeneralFunctions general = new GeneralFunctions();
         double[][][] geometries = setCrossSectionGeometries();
@@ -816,13 +744,13 @@
      * @param currentCrossSectionGeometry_DS An array containing the xy-points for the
      * downstream cross-section.
      * @param currentReachProperties An array containing the properties of the current reach.
+     * @param bedSlope
      * @param depth The calculated depth of the downstream cross-section.
      * 
      * @return A new ChannelGeometry object with the values set for the downstream cross-section.
      * 
      * @throws IOException 
      */    
-
     public ChannelGeometry setDSValues(double[][] currentCrossSectionGeometry_DS,
                                             double[] currentReachProperties,
                                             double bedSlope,
@@ -856,13 +784,13 @@
      * upstream cross-section.
      * @param currentReachProperties An array containing the properties of the current reach.
      * @param currentReachLength The distance between the up and downstream cross-sections.
+     * @param bedSlope
      * @param depth The calculated depth of the upstream cross-section.
      * 
      * @return A new ChannelGeometry object with the values set for the upstream cross-section.
      * 
      * @throws IOException 
      */ 
-
     public ChannelGeometry setUSValues(double[][] currentCrossSectionGeometry_US,
                                             double[] currentReachProperties,
                                             double currentReachLength,
@@ -908,7 +836,6 @@
      * 
      * @throws IOException 
      */
-
     private double standardStepEquation(double velocity_DS,
                                             double velocity_US,
                                             double frictionSlope_DS,
@@ -936,7 +863,6 @@
      * @param numberOfReaches The total number of reaches calculated.
      * @param graphTitle The title of the graph.
      * @param graphOutputName The file name under which the graph jpeg will be saved.
-     * @param filePath The folder into which the graphs will be saved.
      * @param series1_name The name of the depth or elevation series.
      * @param series2_name The name of the critical depth series.
      * @param series3_name The name of the normal depth series.
@@ -945,12 +871,10 @@
      * 
      * @throws IOException 
      */
-
     public void graphLongitudinalProfile(double[][][] resultsArray,
             int numberOfReaches,
             String graphTitle,
             String graphOutputName,
-            String filePath,
             String series1_name,
             String series2_name,
             String series3_name,
@@ -1021,7 +945,7 @@
         legendTitle.setItemFont(general.masterFont);
 
         try {
-            String path = filePath + File.separator + graphOutputName;
+            String path = mainFolder + File.separator + graphOutputName;
             ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800);
             System.out.println(path);
         } catch (IOException e) {
@@ -1031,22 +955,16 @@
     
     /**
      * Writes out the formatted output file as expected by eRAMS to be used for a JHighchart XY
-     * @param filePath
      * @param crossSectionResultsArray
      * @param reachResultsArray
     
      * @throws IOException 
      */
-    
-    public void writeSummaryFile(String filePath,
-                                double[][][] crossSectionResultsArray,
-                                double reachResultsArray[][]) throws IOException {
+    public void writeSummaryFile(double[][][] crossSectionResultsArray,
+                                 double reachResultsArray[][]) throws IOException {
         //open the file writer and set path
-        
-        
         String summaryOutputName = getSummaryOutputName();
-        
-        String path = filePath + File.separator + summaryOutputName;
+        String path = mainFolder + File.separator + summaryOutputName;
         FileWriter writer =  new FileWriter(path, false);
         PrintWriter print_line = new PrintWriter(writer);
         
@@ -1077,25 +995,15 @@
         writer.close();
         System.out.println("Text File located at:\t" + path);
     }//end writeSummaryFile
-    
     /**
-     * Writes a given line to a text file.
+     * Created new Standard Step Model object and starts 'run' method.
      * 
-     * @param textLine The line to be written.
-     * @param append_to_file If false, erases the current content of the text file before writing new line.
-     * If true, adds the new line to the end of the existing content of the text file.
-     * @param summaryOutputName The file name under which the text file will be saved.
+     * @param args
      * 
      * @throws IOException 
      */
-    
-    public void writeToFile(String textLine, boolean append_to_file, String summaryOutputName) throws IOException {
-        String filePath = getFilePath();
-        FileWriter write = new FileWriter(filePath + File.separator + summaryOutputName,append_to_file);
-        PrintWriter print_line;
-        print_line = new PrintWriter(write);
-        print_line.printf("%s" + "%n", textLine);
-        print_line.close();
-    }//end writeToFile
-
+    public static void main(String[] args) throws IOException {
+        StandardStepMethod model = new StandardStepMethod();
+        model.run();
+    }//end main
 }//end StandardStepMeth
\ No newline at end of file

src/java/m/hydraulics/StandardStepMethod_V1_0.java

@@ -18,6 +18,7 @@
 
     @Override
     protected String process() throws Exception {
+        model.setMainFolder(getWorkspaceDir().toString());
         model.setBottomWidth(getDoubleParam("bottomWidth"));
         model.setSideSlope(getDoubleParam("sideSlope"));
         model.setDepth_DS(getDoubleParam("depth"));
@@ -27,8 +28,6 @@
         model.setSeepage(getDoubleParam("seepage"));
         model.setChannelLength(getDoubleParam("channelLength"));
         model.setNumberOfCrossSections(getIntParam("numberOfReaches"));
-        model.setMainFolder(getStringParam("mainFolder"));
-        model.setSubFolder(getStringParam("subFolder"));
         model.setIrregularGeometry(getBooleanParam("irregularGeometry"));
         model.setDownstreamCalculation(getBooleanParam("downstreamCalculation"));
         model.setUseThalwegElevation(getBooleanParam("useThalwegElevation"));

src/java/m/hydraulics/StandardStepMethod_V1_0Req.json

@@ -56,18 +56,6 @@
       "value": 200
     },
     {
-      "name": "mainFolder",
-      "description": "The folder in which all standard step method project files are stored.",
-      "unit": "n/a",
-      "value": "U:/Java Projects/StandardStepMethod"
-    },
-    {
-      "name": "subFolder",
-      "description": "The specific folder within the mainFolder where the outputs generated by the standard step method are saved. If using irregular geometries, this folder must contain 'crossSections.txt' and 'reaches.txt' correctly formatted.",
-      "unit": "n/a",
-      "value": "Cive401_Problem1_Thalweg"
-    },
-    {
       "name": "irregularGeometry",
       "description": "The type of channel cross-section geometry being used. True if the cross-section is irregular and False if the cross-section is regular (trapezoid, rectangle, or triangle)",
       "unit": "n/a",