-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm_description.txt
More file actions
45 lines (32 loc) · 1.08 KB
/
algorithm_description.txt
File metadata and controls
45 lines (32 loc) · 1.08 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
THE MODEL
parameters:
I - inertia, 0.9
A - acceleration, 5
edge parameters
V_ij - velocity (desired flow per tick) between node i and j
V_ij = -V_ji
F_ij - actual flow in current tick
node parameters
basic
C_i - capacity
T_i - current volume
P_i - pressure (like in current system)
auxiliary (computed for the needs of the algorithm)
Vin_i, Vout_i - summaric in/out velocities of a node
Sin_i, Sout_i - satisfaction for incoming and outcoming flow (what fraction of Vin/Vout can be satisfied)
in each tick:
# update the velocities
for each connection i, j:
V_ij := V_ij * I + sgn(P_j-P_i) * A
# compute auxiliary values
for each i:
Vin_i = sum_j max(0, V_ji)
Vout_i = sum_j max(0, V_ij)
Sin_i = min(Vin_i, C_i-T_i) / Vin_i
Sout_i = min(Vout_i, T_i) / Vout_i
# apply flow
for each connection i, j such that Fij > 0:
V_ij := min(Sout_i, Sin_j) * V_ij
T_i -= V_ij
T_j += V_ij
# handle other stuff, ie. pumps or fluid-handling machines