-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource_dyn_stat.java
More file actions
110 lines (96 loc) · 3 KB
/
Copy pathSource_dyn_stat.java
File metadata and controls
110 lines (96 loc) · 3 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: Source_stat
//
// Description: input constant disturbance
// ( input disturbance signal used for process
// different options can be chosen by setting
// the variable type, e.g 'osc' or 'imp' )
//
// Output variables (poles):
// out - output
//
// Variables:
// init_stat -
// final_stat -
// initstate_val -
// steps -
// step_nr -
//
// Created: 23.02.2011
// Last modified: 04.03.2011
//----------------------------------------------------
import java.text.*;
class Source_dyn_stat {
/*@ specification Source_dyn_stat {
// double init_stat;
// double final_stat;
double init_val;
double final_val;
double initstate_val;
double out;
// double steps;
// double step_nr;
double Y_steps;
double Y_step_nr;
// State variables
double initstate_c, oldstate_c, state_c;
double nextstate_c, finalstate_c;
alias (double) initstate = (initstate_c);
alias (double) oldstate = (oldstate_c);
alias (double) state = (state_c);
alias (double) nextstate = (nextstate_c);
alias (double) finalstate = (finalstate_c);
// Collecting outputs
alias (double) result = (out, nextstate_c);
// Evaluating initstate components
initstate_c = initstate_val;
//*************************************************
// Methods specifications
init_val, Y_steps, final_val,
Y_step_nr, state_c
-> result {Source_dyn_stat_calc};
// Default conditions:
// init_stat = 0;
// final_stat = 10;
// initstate_val = init_stat;
initstate_val = init_val;
}@*/
//====================================================
// init_stat, steps, final_stat,
// step_nr, state_c
// -> result {Source_stat_calc}
// result = (out, nextstate_c);
//====================================================
public double[] Source_dyn_stat_calc
( double init_stat, double steps,
double final_stat, double step_nr,
double state_c) {
double[] result = new double[2];
double stp, out, nextstate_c;
if (steps == 1) steps++;
stp = (final_stat - init_stat)/(steps - 1);
out = init_stat + stp * (step_nr - 1);
nextstate_c = out;
//System.out.println("Source_dyn_stat: ch = "+changeable+
// " init_val = "+init_stat+
// " state = "+state_c+
// " steps = "+steps+
// " step_nr = "+step_nr+
// " out = "+out);
// Preparing output
result[0] = out;
result[1] = nextstate_c;
//print_ar("Source_dyn_stat: result ",result);
return result;
}
//=======================================================
// void print_ar (String ar_name, double[] ar)
//=======================================================
public 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();
}
}