-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHydUtil.java
More file actions
111 lines (101 loc) · 4.23 KB
/
Copy pathHydUtil.java
File metadata and controls
111 lines (101 loc) · 4.23 KB
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
// Class name: Lss
//
// Description: Methods for load sensing system simulation system
//
//
// Created: 02.03.2008
// Last modified: 25.01.2008
//----------------------------------------------------------------
import java.text.*;
public class HydUtil {
//===========================================================================
// state_name, state -> done_print_state { print_state };
//===========================================================================
static void print_state (String state_name, double[][] st) {
DecimalFormat dF = new DecimalFormat("0.###E0");
System.out.print(state_name + ":");
for (int i = 0; i < st.length; i++ ){
if (st[i].length > 1 ) System.out.print(" (");
for (int j = 0; j < st[i].length; j++ ){
System.out.print ( " " + dF.format(st[i][j]) + " ");
}
if (st[i].length > 1 ) System.out.print(") ");
}
System.out.println();
}
//===========================================================================
// state_name, state -> done_print_state { print_state_2 };
//===========================================================================
static void print_state_2 (String state_name, double[][] st) {
DecimalFormat dF_num = new DecimalFormat("#.####");
DecimalFormat dF_sci = new DecimalFormat("0.###E0");
System.out.println("");
System.out.println(state_name + ":");
for (int i = 0; i < st.length; i++ ){
if (i < 9) System.out.print(" ");
System.out.print((i+1)+":");
for (int j = 0; j < st[i].length; j++ ){
if ((st[i].length > 1)&&(j==0)) System.out.print(" (");
if ((st[i].length > 1)&&(j>0)) System.out.print(" ");
if ( (Math.abs(st[i][j]) > 0.01) && (Math.abs(st[i][j]) < 10000))
{System.out.print ( " " + dF_num.format(st[i][j]) + " "); }
else
{System.out.print ( " " + dF_sci.format(st[i][j]) + " "); }
if ((st[i].length > 1)&&(j==st[i].length-1))
System.out.print(" )");
System.out.println();
}
}
}
//===========================================================================
// state_name, state -> done_print_state { print_state_3 };
//===========================================================================
static void print_state_3 (String state_name, double[][][] st) {
DecimalFormat dF = new DecimalFormat("0.###E0");
System.out.println("");
System.out.println(state_name + ":");
for (int i = 0; i < st.length; i++ ){
if (i < 9) System.out.print(" ");
System.out.print((i+1)+":");
for (int j = 0; j < st[i].length; j++ ){
if ((st[i].length > 1)&&(j==0)) System.out.print(" (");
if ((st[i].length > 1)&&(j>0)) System.out.print(" ");
if (j < 9) System.out.print(" ");
System.out.print((j+1)+":");
for (int k = 0; k < st[i][j].length; k++ ){
if ((st[i][j].length > 1)&&(k==0)) System.out.print(" (");
if ((st[i][j].length > 1)&&(k>0)) System.out.print(" ");
System.out.print ( " " + dF.format(st[i][j][k]) + " ");
if ((st[i][j].length > 1)&&(k==st[i][j].length-1))
System.out.print(" )");
if ((st[i].length > 1)&&(j==st[i].length-1))
System.out.print(" )");
System.out.println();
}
}
}
}
//===========================================================================
// errorap, errorr, finalstate ->
// printing_ready { printErrorValues };
//===========================================================================
static double printErrorValues ( double[][] errorap,
double[][] errorr,
double[][] finalstate ) {
print_state_2 ("====== Absolute error values", errorap);
print_state_2 ("====== Relative error values", errorr);
return (double) 1;
}
//================================================================
// void print_ar (String ar_name, double[] ar)
//================================================================
// public void print_ar (String ar_name, double[] ar) {
static void print_ar (String ar_name, double[] ar) {
DecimalFormat dF = new DecimalFormat("0.###E0");
System.out.print(ar_name + ":");
for (int i = 0; i < ar.length; i++ ) {
System.out.print(" " + dF.format(ar[i]));
}
System.out.println();
}
}