Discrete rate
1. What is Discrete Rate library
Discrete Rate Library helps to simulate the behavior of a system of interconnected flow elements that can receive, store, or send out a continuous quantity of some material.
Material is a homogeneous substance in the modeled system. Examples of materials include liquids ('Crude oil with density 0.7', 'Drinking water', etc.) and loose solid cargo ('Sand', 'Gravel', etc.).
Flow elements can receive, contain, or send out a mix of materials.
There are several types of flow elements: tanks, bunkers, splits, merges, conveyors, and valves.
2. Example
Here is a basic example of how a simple flow environment can be set up.
This flow environment contains one source bunker with water connected to two destination bunkers via a 'split' element. The split works as follows: one of the destination bunkers gets 20 % of the material, and the rest 80% goes to the second destination bunker.
The simulation duration is 10 arbitrary chosen units of model time (e.g. hours, or minutes, etc.).
The material (water) flows along each flow connection at the speed of 'one material unit per one unit of model time'.
@Test
void proportionalSplitExample() {
(1)
Engine engine = new Engine();
FlowEnvironment<String> flowEnvironment = new FlowEnvironment<>(engine);
(2)
Bunker<String> sourceBunker = new Bunker<>(flowEnvironment, "Source bunker", 1, 25, 1);
Bunker<String> smallDestBunker = new Bunker<>(flowEnvironment, "Small dest bunker", 1, 7, 1);
Bunker<String> largeDestBunker = new Bunker<>(flowEnvironment, "Large dest bunker", 1, 35, 1 );
Split<String> split = new Split<>(flowEnvironment, FlowRateDistributionPolicy.PROPORTIONAL);
(3)
sourceBunker.connectToElement(split);
FlowConnection<String> connection1 = split.connectToElement(smallDestBunker);
split.setOutflowRateFraction(connection1, 0.2);
FlowConnection<String> connection2 = split.connectToElement(largeDestBunker);
split.setOutflowRateFraction(connection2, 0.8);
(4)
sourceBunker.replaceContents("Water", 25);
(5)
flowEnvironment.init();
(6)
engine.scheduleRelative(10, () -> engine.stop());
engine.setFastMode(true);
engine.run(true);
(7)
Assertions.assertEquals(15, sourceBunker.getContentsAmount());
(8)
Assertions.assertEquals(2, smallDestBunker.getContentsAmount());
(9)
Assertions.assertEquals(8, largeDestBunker.getContentsAmount());
}
Let’s see what happens in this code:
1 | Engine and FlowEnvironment are created. |
2 | Several flow elements are created: source bunker, two destination bunkers, and a 'Split' in between. |
3 | Flow elements are connected to each other. A material can flow along a connection. |
4 | Source bunker is filled with water. |
5 | Flow environment gets initialized. |
6 | Simulation is executed. Simulation duration is 10 units of model time. |
7 | 15 of initial 25 material units are left in the source bunker; 10 were transported to the two dest bunkers. |
8 | 2 of 10 material units have been transported to the small dest bunker. |
9 | 8 of 10 material units have been transported to the large dest bunker. |

See more examples and details in the Discrete Rate Library page.