-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserOutputs.java
146 lines (122 loc) · 6.27 KB
/
UserOutputs.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import java.io.File;
import java.io.IOException;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class UserOutputs {
//Code for User output.
private String[] resultsNames;
private double[] resultsValues;
private String filepathoutput;
public UserOutputs(UserOutputs source) {
this.resultsNames = source.resultsNames;
this.resultsValues = source.resultsValues;
}
public UserOutputs(AbsorptionSimulation myAbsorptionSimulation, Optimization myOptimization,
UserInputs myUserInputs) throws RowsExceededException, WriteException {
this.filepathoutput = myUserInputs.getfilepathoutput();
this.resultsNames = getResultsNames();
this.resultsValues = getResultsValues(myAbsorptionSimulation, myOptimization, myUserInputs);
this.printPart1();
}
public void printPart1() throws RowsExceededException, WriteException {
WritableWorkbook myFirstWbook = null;
try {
myFirstWbook = Workbook.createWorkbook(new File(filepathoutput));
WritableSheet excelSheet = myFirstWbook.createSheet("Sheet 1", 0);
// Printing out the variable name of the results
for (int i = 0; i < this.resultsNames.length; i++) {
Label label = new Label(i, 0, this.resultsNames[i]);
excelSheet.addCell(label);
}
// Printing out the variables corresponds to the tables
for (int i = 0; i < this.resultsValues.length; i++) {
Number number = new Number(i, 1, resultsValues[i]);
excelSheet.addCell(number);
}
myFirstWbook.write();
System.out.println("---- The excel can be found in the specified folder! ----");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (myFirstWbook != null) {
try {
myFirstWbook.close();
} catch (IOException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}
}
}
public String[] getResultsNames() {
String[] arrayResultsNames = { "[Non-Optimized] Height Liquid [Trapezoid] (m): ",
"[Non-Optimized] Height Gas [Trapezoid] (m): ",
"[Non-Optimized] Height Error Percentage [Trapezoid] (%): ",
"[Non-Optimized] Height Liquid [Simpson] (m): ", "Height Gas [Simpson] (m): ",
"[Non-Optimized] Height Error Percentage [Simpson] (%): ",
"[Non-Optimized] Height Liquid [Modified-Simpson] (m): ",
"[Non-Optimized] Height Gas [Modified-Simpson] (m): ",
"[Non-Optimized] Height Error Percentage [Modified-Simpson] (%): ",
"[Optimized] Number of Iterations [Trapezoid]: ", "[Optimized] Height on Liquid Side [Trapezoid] (m): ",
"[Optimized] Height on Gas Side [Trapezoid] (m): ", "[Optimized] Highest Height [Trapezoid] (m): ",
"[Optimized] Percentage Error for Liquid and Gas Side [Trapezoid] (%): ",
"[Optimized] Solute-Free Liquid Flowrate [Trapezoid] (kgmole/h): ",
"[Optimized] Inlet Liquid Flowrate [Trapezoid] (kgmole/h): ",
"[Optimized] Number of Iterations [Simpsons]: ", "[Optimized] Height on Liquid Side [Simpson] (m): ",
"[Optimized] Height on Gas Side [Simpson] (m): ", "[Optimized] Highest Height [Simpson] (m):",
"[Optimized] Percentage Error for Liquid and Gas Side [Simpson] (%):",
"[Optimized] Solute-Free Liquid Flowrate [Simpson] (kgmole/h): ",
"[Optimized] Inlet Liquid Flowrate [Simpson] (kgmole/h): ",
"[Optimized] Number of Iterations [Modified-Simpson]: ",
"[Optimized] Height on Liquid Side [Modified-Simpson] (m): ",
"[Optimized] Height on Gas Side [Modified-Simpson] (m): ",
"[Optimized] Highest Height [Modified-Simpson] (m): ",
"[Optimized] Percentage Error for Liquid and Gas Side [Modified-Simpson] (%): ",
"[Optimized] Solute-Free Liquid Flowrate [Modified-Simpson] (kgmole/h): ",
"[Optimized] Inlet Liquid Flowrate [Modified-Simpson] (kgmole/h): " };
return arrayResultsNames;
}
public double[] getResultsValues(AbsorptionSimulation myAbsorptionSimulation, Optimization myOptimization,
UserInputs myUserInputs) {
double[][] arrayResultsOptimizedValues = myOptimization.summaryofOptimizedResults(
myOptimization.OptimizedArrayResultsRangeofLiquidFlowrate(myAbsorptionSimulation, myUserInputs));
double[] arrayResultsValues = new double[30];
arrayResultsValues[0] = myAbsorptionSimulation.calculateHeightTrapezoid()[0];
arrayResultsValues[1] = myAbsorptionSimulation.calculateHeightTrapezoid()[1];
arrayResultsValues[2] = myAbsorptionSimulation.calculateHeightErrorPercentageTrapezoid();
arrayResultsValues[3] = myAbsorptionSimulation.calculateHeightSimpson()[0];
arrayResultsValues[4] = myAbsorptionSimulation.calculateHeightSimpson()[1];
arrayResultsValues[5] = myAbsorptionSimulation.calculateHeightErrorPercentageSimpson();
arrayResultsValues[6] = myAbsorptionSimulation.calculateHeightModifiedSimpson()[0];
arrayResultsValues[7] = myAbsorptionSimulation.calculateHeightModifiedSimpson()[1];
arrayResultsValues[8] = myAbsorptionSimulation.calculateHeightErrorPercentageModifiedSimpson();
arrayResultsValues[9] = arrayResultsOptimizedValues[0][0];
arrayResultsValues[10] = arrayResultsOptimizedValues[0][1];
arrayResultsValues[11] = arrayResultsOptimizedValues[0][2];
arrayResultsValues[12] = arrayResultsOptimizedValues[0][3];
arrayResultsValues[13] = arrayResultsOptimizedValues[0][4];
arrayResultsValues[14] = arrayResultsOptimizedValues[0][5];
arrayResultsValues[15] = arrayResultsOptimizedValues[0][6];
arrayResultsValues[16] = arrayResultsOptimizedValues[1][0];
arrayResultsValues[17] = arrayResultsOptimizedValues[1][1];
arrayResultsValues[18] = arrayResultsOptimizedValues[1][2];
arrayResultsValues[19] = arrayResultsOptimizedValues[1][3];
arrayResultsValues[20] = arrayResultsOptimizedValues[1][4];
arrayResultsValues[21] = arrayResultsOptimizedValues[1][5];
arrayResultsValues[22] = arrayResultsOptimizedValues[1][6];
arrayResultsValues[23] = arrayResultsOptimizedValues[2][0];
arrayResultsValues[24] = arrayResultsOptimizedValues[2][1];
arrayResultsValues[25] = arrayResultsOptimizedValues[2][2];
arrayResultsValues[26] = arrayResultsOptimizedValues[2][3];
arrayResultsValues[27] = arrayResultsOptimizedValues[2][4];
arrayResultsValues[28] = arrayResultsOptimizedValues[2][5];
arrayResultsValues[29] = arrayResultsOptimizedValues[2][6];
return arrayResultsValues;
}
}