@@ -28,17 +28,15 @@ |
public class StandardStepMethod { |
|
//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; |
+ String subFolder = "RegularGeometryTest"; |
+ String mainFolder = "U:/Java Projects/StandardStepMethod"; |
+ boolean irregularGeometry = false; |
+ boolean downstreamCalculation = true; |
+ boolean useThalwegElevation = true; |
boolean createGraph = true; |
boolean createSummaryFile = true; |
- double measuredDownstreamDepth = .5; |
- double discharge_DS = 14.5; |
+ double measuredDownstreamDepth = 6.369; |
+ double discharge_DS = 200; |
|
//Uniform Geometry Cross-Section Characteristics |
double bottomWidth = 10; |
@@ -47,9 +45,9 @@ |
//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 |
+ double seepage = 0.0; |
+ double channelLength = 40000; //Distance between sample x-sections |
+ int numberOfCrossSections = 200; //Length between calculated x-section |
|
//Sets |
public void setBottomWidth(double bottomWidth){ |
@@ -64,7 +62,7 @@ |
this.measuredDownstreamDepth = measuredDownstreamDepth; |
} |
|
- public void setdischarge_DS(double discharge_DS){ |
+ public void setDischarge_DS(double discharge_DS){ |
this.discharge_DS = discharge_DS; |
} |
|
@@ -84,8 +82,8 @@ |
this.channelLength = channelLength; |
} |
|
- public void setReachLength(int numberOfReaches){ |
- this.numberOfReaches = numberOfReaches; |
+ public void setNumberOfCrossSections(int numberOfCrossSections){ |
+ this.numberOfCrossSections = numberOfCrossSections; |
} |
|
public void setMainFolder(String mainFolder){ |
@@ -96,7 +94,7 @@ |
this.subFolder = subFolder; |
} |
|
- public void irregularGeometry(boolean irregularGeometry){ |
+ public void setIrregularGeometry(boolean irregularGeometry){ |
this.irregularGeometry = irregularGeometry; |
} |
|
@@ -117,6 +115,11 @@ |
} |
|
//gets |
+ public String getFilePath(){ |
+ String filePath = mainFolder + File.separator + subFolder; |
+ return filePath; |
+ } |
+ |
public String getElevationGraphTitle(){ |
if (downstreamCalculation){ |
return "Downstream Elevation Profile.png"; |
@@ -209,9 +212,14 @@ |
*/ |
|
public void calcStandardStepMethod() throws IOException { |
- |
+ |
+ String filePath = getFilePath(); |
+ int numberOfReaches; |
if (irregularGeometry) { |
- numberOfReaches = readLines(mainFolder + File.separator + "reaches.txt"); |
+ numberOfReaches = readLines(filePath + File.separator + "reaches.txt"); |
+ } |
+ else{ |
+ numberOfReaches = numberOfCrossSections-1; |
} |
|
double[][][] crossSectionResultsArray = new double[numberOfReaches + 1][2][4]; |
@@ -264,6 +272,7 @@ |
|
ChannelGeometry DSValues = setDSValues(currentCrossSectionGeometry_DS, |
currentReachProperties, |
+ reachSlope, |
depth_DS); |
double velocity_DS = calcVelocity(DSValues); |
double frictionSlope_DS = calcFrictionSlope(DSValues); |
@@ -273,6 +282,7 @@ |
ChannelGeometry USValues = setUSValues(currentCrossSectionGeometry_US, |
currentReachProperties, |
length, |
+ reachSlope, |
depth_DS); |
double critDepth_US = USValues.calcCriticalDepth(); |
double normDepth_US = USValues.calcNormalDepth(); |
@@ -284,6 +294,7 @@ |
USValues = setUSValues(currentCrossSectionGeometry_US, |
currentReachProperties, |
length, |
+ reachSlope, |
lower); |
double velocity_US = calcVelocity(USValues); |
double frictionSlope_US = calcFrictionSlope(USValues); |
@@ -299,6 +310,7 @@ |
USValues = setUSValues(currentCrossSectionGeometry_US, |
currentReachProperties, |
length, |
+ reachSlope, |
upper); |
velocity_US = calcVelocity(USValues); |
frictionSlope_US = calcFrictionSlope(USValues); |
@@ -321,6 +333,7 @@ |
USValues = setUSValues(currentCrossSectionGeometry_US, |
currentReachProperties, |
length, |
+ reachSlope, |
guessDepth_US); |
velocity_US = calcVelocity(USValues); |
frictionSlope_US = calcFrictionSlope(USValues); |
@@ -345,6 +358,7 @@ |
USValues = setUSValues(currentCrossSectionGeometry_US, |
currentReachProperties, |
length, |
+ reachSlope, |
guessDepth_US); |
velocity_US = calcVelocity(USValues); |
frictionSlope_US = calcFrictionSlope(USValues); |
@@ -416,7 +430,7 @@ |
numberOfReaches, |
getElevationGraphTitle(), |
getElevationGraphOutputName(), |
- mainFolder, |
+ filePath, |
"Water Surface Elevation", |
"Critical Depth", |
"Normal Depth", |
@@ -424,7 +438,7 @@ |
"Elevation (m)"); |
} |
if (createSummaryFile){ |
- writeSummaryFile(mainFolder, |
+ writeSummaryFile(filePath, |
crossSectionResultsArray, |
reachResultsArray); |
} |
@@ -509,40 +523,7 @@ |
boundaries[1] = b; |
return boundaries; |
}//end calcBoundaryConditions |
- |
- /** |
- * Creates a 2-dimensional array containing the calculated elevation values for the current |
- * cross-section. This array is then imported into a 3-dimensional array containing the |
- * depth values for every cross-section in a given channel. |
- * |
- * @param waterDepth The calculated depth at the current cross-section. |
- * @param critDepth The calculated critical depth at the given cross-section. |
- * @param normDepth The calculated normal depth at the given cross-section. |
- * @param distance_DS The distance of the given cross-section from the origin. |
- * @param bedElevation The elevation of the channel bed above or below the origin. |
- * |
- * @return A 2-dimensional array containing the calculated elevation values for |
- * the current cross-section. |
- */ |
|
- public double[][] writeElevationArray(double waterDepth, |
- double critDepth, |
- double normDepth, |
- double distance_DS, |
- double bedElevation, |
- double discharge) { |
- |
- double[][] results = new double[2][4]; |
- results[0][0] = distance_DS; |
- results[0][1] = discharge; |
- results[1][0] = waterDepth + bedElevation; |
- results[1][1] = critDepth + bedElevation; |
- results[1][2] = normDepth + bedElevation; |
- results[1][3] = bedElevation; |
- |
- return results; |
- }//end writeElevationArray |
- |
/** |
* Creates a 2-dimensional array containing the calculated depth values for the current |
* cross-section. This array is then imported into a 3-dimensional array containing the |
@@ -658,8 +639,9 @@ |
|
public int calcLargestCrossSection() throws IOException { |
|
- String[] sections = transferTXTFile(mainFolder + File.separator + "crossSections.txt"); |
- int numberOfLines = readLines(mainFolder + File.separator + "crossSections.txt"); |
+ String filePath = getFilePath(); |
+ String[] sections = transferTXTFile(filePath + File.separator + "crossSections.txt"); |
+ int numberOfLines = readLines(filePath + File.separator + "crossSections.txt"); |
|
int i; |
int n; |
@@ -687,8 +669,9 @@ |
|
public double[][][] setCrossSectionGeometries() throws IOException { |
|
- int numberOfSections = readLines(mainFolder + File.separator + "crossSections.txt"); |
- String[] sections = transferTXTFile(mainFolder + File.separator + "crossSections.txt"); |
+ String filePath = getFilePath(); |
+ int numberOfSections = readLines(filePath + File.separator + "crossSections.txt"); |
+ String[] sections = transferTXTFile(filePath + File.separator + "crossSections.txt"); |
int length = calcLargestCrossSection(); |
String[][] xypointlist; |
int i; |
@@ -721,18 +704,26 @@ |
|
public double[][] setReachProperties() throws IOException { |
|
- int numberOfSections = readLines(mainFolder + File.separator + "reaches.txt"); |
- String[] reaches = transferTXTFile(mainFolder + File.separator + "reaches.txt"); |
- double[][] properties = new double[numberOfSections][4]; |
+ String filePath = getFilePath(); |
+ int numberOfSections = readLines(filePath + File.separator + "reaches.txt"); |
+ String[] reaches = transferTXTFile(filePath + File.separator + "reaches.txt"); |
+ double[][] reachProperties = new double[numberOfSections][4]; |
int i; |
for (i = 0; i < numberOfSections; i++) { |
String reach = reaches[i]; |
String[] new_reach = reach.split("\\|"); |
- for (int j = 0; j < 4; j++) { |
- properties[i][j] = Double.parseDouble(new_reach[j]); |
+ if(useThalwegElevation){ |
+ for (int j = 0; j < 3; j++) { |
+ reachProperties[i][j] = Double.parseDouble(new_reach[j]); |
+ } |
} |
- } |
- return properties; |
+ else{ |
+ for (int j = 0; j < 4; j++) { |
+ reachProperties[i][j] = Double.parseDouble(new_reach[j]); |
+ } |
+ } |
+ } |
+ return reachProperties; |
}//end setReachProperties |
|
/** |
@@ -814,7 +805,7 @@ |
|
double currentReachLength = properties[currentReach][0]; |
|
- double slope = (thalwegElevation1 - thalwegElevation2)/currentReachLength; |
+ double slope = (thalwegElevation2 - thalwegElevation1)/currentReachLength; |
return slope; |
}//end calcThalwegElevation |
|
@@ -834,6 +825,7 @@ |
|
public ChannelGeometry setDSValues(double[][] currentCrossSectionGeometry_DS, |
double[] currentReachProperties, |
+ double bedSlope, |
double depth) throws IOException { |
|
ChannelGeometry DSValues = new ChannelGeometry(); |
@@ -844,7 +836,7 @@ |
DSValues.setDepth(depth); |
DSValues.setDischarge(discharge_DS); |
DSValues.setManningRoughness(currentReachProperties[1]); |
- DSValues.setBedSlope(currentReachProperties[3]); |
+ DSValues.setBedSlope(bedSlope); |
} else { |
DSValues.setBottomWidth(bottomWidth); |
DSValues.setSideSlope(sideSlope); |
@@ -874,6 +866,7 @@ |
public ChannelGeometry setUSValues(double[][] currentCrossSectionGeometry_US, |
double[] currentReachProperties, |
double currentReachLength, |
+ double bedSlope, |
double depth) throws IOException { |
|
ChannelGeometry USValues = new ChannelGeometry(); |
@@ -885,7 +878,7 @@ |
double currentReachSeepage = currentReachProperties[2]; |
USValues.setDischarge(discharge_DS+(currentReachSeepage*currentReachLength)); |
USValues.setManningRoughness(currentReachProperties[1]); |
- USValues.setBedSlope(currentReachProperties[3]); |
+ USValues.setBedSlope(bedSlope); |
} else { |
USValues.setBottomWidth(bottomWidth); |
USValues.setSideSlope(sideSlope); |
@@ -943,7 +936,7 @@ |
* @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 mainFolder The folder into which the graphs 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. |
@@ -957,7 +950,7 @@ |
int numberOfReaches, |
String graphTitle, |
String graphOutputName, |
- String mainFolder, |
+ String filePath, |
String series1_name, |
String series2_name, |
String series3_name, |
@@ -1028,7 +1021,7 @@ |
legendTitle.setItemFont(general.masterFont); |
|
try { |
- String path = mainFolder + File.separator + graphOutputName; |
+ String path = filePath + File.separator + graphOutputName; |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println(path); |
} catch (IOException e) { |
@@ -1038,14 +1031,14 @@ |
|
/** |
* Writes out the formatted output file as expected by eRAMS to be used for a JHighchart XY |
- * @param mainFolder |
+ * @param filePath |
* @param crossSectionResultsArray |
* @param reachResultsArray |
|
* @throws IOException |
*/ |
|
- public void writeSummaryFile(String mainFolder, |
+ public void writeSummaryFile(String filePath, |
double[][][] crossSectionResultsArray, |
double reachResultsArray[][]) throws IOException { |
//open the file writer and set path |
@@ -1053,7 +1046,7 @@ |
|
String summaryOutputName = getSummaryOutputName(); |
|
- String path = mainFolder + File.separator + summaryOutputName; |
+ String path = filePath + File.separator + summaryOutputName; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -1074,7 +1067,7 @@ |
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" + "\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"); |
} |
@@ -1097,7 +1090,8 @@ |
*/ |
|
public void writeToFile(String textLine, boolean append_to_file, String summaryOutputName) throws IOException { |
- FileWriter write = new FileWriter(mainFolder + File.separator + summaryOutputName,append_to_file); |
+ 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); |