4.2.1. Boil Water
If we take the Boil Water model used in the previous section, taking the equations as they are and setting aside any discussion about the physics and assumptions made, we can examine this as an example of how the metadata can be used to calculate and display results, and how the model can be used to simulate the system under varying conditions.
The formula used to calculate the temperature of the water after a given heating time is based on a simple specific heat formula shown here as it is represented in the FMV using somewhat descriptive key names:
TEMPERATURE = TEMP_Start_C + (POWER_W * TIME_s / QUANTITY_g / Capacity_J_gC)
Where:
TEMP_Start_C is the starting temperature of the water in degrees Celsius (°C)
POWER_W is the power rating of the electric kettle in Watts (W), which is the same as Joules per second (J⋅s-1)
TIME_s is the time that the water is allowed to heat, in seconds (s)
QUANTITY_g is the quantity of the water that is being heated, in grams (g)
Capacity_J_gC is the specific heat capacity of water, at 4.184 Joules per gram, per degree Celsius (J⋅g-1⋅°C-1)
The calculation is entered into the Metadata for the Function <To boil water>. The data used in the calculation is ‘supplied’ by other background Functions, initially as constants that represent properties of the water, kettle, and time, as shown in the following table:
Figure 5.
Initial Key-Value pairs for the “Boil Water” model.
Figure 5.
Initial Key-Value pairs for the “Boil Water” model.
When the FMI interpretation is advanced, on Cycle 0, the background Functions supply this data through their couplings to the aspects of the <To boil water> Function. The Entry Function <To make a cup of tea> also activates and supplies the need for boiled water through the Output [boil water] that couples with the Input of the <To boil water> Function. On the next FMI Cycle, 1, the conditions for the activation of <To boil water> have been fulfilled, such that the aspects are all present and an Input has been received. The TEMPERATURE equation is calculated (91.7°C) and the Output [hot water] is created.
At this point we can display the results of the TEMPERATURE equation by activating the display results panel that allows for the selection of a Metadata key, with the corresponding value displayed as a configurable colour scale. Advancing the FMI interpretation to Cycle 2, the next downstream Function activates <To pour on to tea leaves>.
Figure 6.
FMV Display Results Setup.
Figure 6.
FMV Display Results Setup.
To complete the example model, this function has an equation that takes the temperature value supplied by the [hot water] Input together with a [stewing time] constant (3 minutes) to calculate the quality of the tea produced, where the result is either “Weak”, “Good”, or “Strong”. These results can also be displayed against a second colour scale.
The FMI interpretation concludes on the next Cycle, 3, with the Exit Function <To drink tea>.
The results of the completed interpretation are displayed in the FMV as shown in
Figure 7, with a water temperature of 91.7°C and a tea quality of “Good”, displayed on their Functions as a red bar and green bar respectively.
Figure 7.
Initial FMI results for the “Boil Water” model.
Figure 7.
Initial FMI results for the “Boil Water” model.
The results can also be output as a data table, as shown in
Figure 8.
Figure 8.
Initial FMI results for the “Boil Water” model.
Figure 8.
Initial FMI results for the “Boil Water” model.
Now that the model is able to simulate a set of specific conditions, an instantiation, we can now vary the initial data to create different scenarios for alternative instantiations of the model.
For the second instantiation, let’s double the amount of water supplied in the kettle, where QUANTITY_g now equals 2000 grams (about 2 litres). If the heating time is still constrained to five minutes (TIME_s equals 300 seconds) then executing the model yields a water temperature of 55.85°C and a quality of tea that is “Weak”, shown in
Figure 9 by the orange and pale-yellow results bars, respectively.
Figure 9.
Results for the “Boil Water” second instantiation.
Figure 9.
Results for the “Boil Water” second instantiation.
For a third instantiation, let’s return the water quantity to 1000 grams, but increase the stewing time on the Function <To control the time it is allowed to stew>, from 3 minutes to 7 minutes. Now the results return a water temperature the same as the first instantiation of 91.7°C, but the quality of the tea is now “Strong”, as shown by the brown results bar in
Figure 10.
Figure 10.
Results for the “Boil Water” third instantiation.
Figure 10.
Results for the “Boil Water” third instantiation.
This modelling could be used in a situation where the total time to boil the water, allow the tea to stew, and then enjoy drinking the tea, is constrained: but other parameters such as the quantity of water and the electrical power of the kettle could be optimised to produce quality tea.
One of the background Functions, <To set the target temperature>, has not been used so far in this example. This is provided as an alternative Control aspect where the time is unconstrained, and the kettle would be allowed to continue heating until a set temperature has been achieved. In this case the formula is rearranged to calculate the time required, where:
TIME = (TEMP_target_C - TEMP_Start_C) / POWER_W * QUANTITY_g * Capacity_J_gC / 60
Given the starting values of the initial instantiation, the time required to reach 100°C would be 5.58 minutes. This could then be passed on to downstream Functions for other calculations, such as, the time remaining to enjoy drinking the tea before the break time is over. An application of this type of time calculation is outlined in the Formula 1 Pit Stop model in section 4.3.
It should be noted that the starting temperature of the water in the kettle is another factor that could introduce variability into the results, but so far has been set as a constant at 20°C. As already demonstrated for other parameters, we could manually change this value for subsequent instantiations to model the effects of a range of different values.
Another option for modelling this type of variation in start parameters is to set the model to cycle repeatedly but with different Metadata values. The model takes 3 FMI Cycles to progress from the Entry Function to the Exit Function, so if we set the Entry Function to activate every 3rd Cycle, then the model will restart every time it completes a full interpretation. We also set the FMI Control to ignore the default stop conditions and run continuously.
Next, we have five different options for varying the starting temperature of the water automatically for each instantiation:
- 1.
For the Metadata key TEMP_Start_C on the Function <To fill with a quantity of water>, the value can be changed to 0, to set the starting point for the first instantiation, and then an equation added, where TEMP_Start_C = TEMP_Start_C + 1. This will start with 0°C and increase the temperature by one degree every instantiation.
- 2.
The equation can be set to a pseudo-random number within a given range. For example, to start an instantiation with a random integer between 10 and 30 (inclusive), the equation would be TEMP_Start_C = rndi(10,31). Double precision floating point numbers can also be generated using rnd().
- 3.
The equation can be set to return a pseudo-random number that, on repetition, approximates a normal distribution. For example, a normal distribution with a mean of 20 and a standard deviation of 10 would be TEMP_Start_C = rnorm(20,10)
- 4.
A table of values can be imported into the model, and an equation used to return a value from the table, such as lookup(row number,column number). In our example, the row number can be set from the available system variable that contains the current Cycle number, Cycle, and the first column of the data table, such that: TEMP_Start_C = lookup(Cycle/3,0)
- 5.
Similar to the previous case, a value can be referenced from a data table, but using a cross reference between a row name contained in the first column, and returning data from another column referenced by a column header name, such as TEMP_Start_C = xref(Cycle,”Temp”). In this case the data table does not need to be sorted or sequential.
After allowing the interpretations to run for the desired number of Cycles and repetitions, the results table can be Interrogated (and exported) to analyse the results, for example, to find the minimum starting temperature that would produce quality tea within the given time constraint (this happens at about 19°C, and at Cycle 56 using option 1).
This example has been kept intentionally limited with only two foreground Functions, to the point where the analysis conclusion above could be calculated directly without modelling. However, the intention is to demonstrate the basics of modelling that can be extended to more complex models. Even given the premise in this example, the boundaries of the model could be expanded so that the background Functions themselves become foreground Functions and the parameters discussed are influenced by other upstream Functions. In this way we could begin to model variability that is influenced by numerous interrelated couplings with the possibility of discovering unexpected emergent results.
4.2.2. Plan A or Plan B
It is not uncommon in FRAM models for a Function to have more than one Output, that may collectively couple with a single downstream Function, or the different Outputs may couple with different downstream Functions. The realisation of these potential couplings into actual couplings during an instantiation could differ based on the conditions of the specific instantiation, in effect causing conditional branching of the model during the instantiation.
In the basic FMI, a Function that receives an Input then considers the presence of its aspects according to its defined FMI profile before activating and producing its Outputs. If it activates then all Outputs are created and become actual couplings with downstream Functions. If it does not activate then no Outputs are created. This basic default setup does not consider the Metadata available from upstream couplings before making the ‘decision’ to activate, and if it does activate, it cannot choose to only create one Output over another.
If the interpretation analysis of a model requires this more complex functionality of conditional activation and branching, then it is extended through the use of a special Metadata key named Activate. To illustrate, consider the following “Plan A or Plan B” model that under default conditions will progress the FMI interpretation to the stop conditions with the activation of two Exit Functions, <To carry out Plan A> and <To carry out Plan B>.
Figure 11.
The default “Plan A or Plan B” model.
Figure 11.
The default “Plan A or Plan B” model.
First consider the Function <To meet the critical conditions>. To model an instantiation where the Output of this Function is never realised, and does not create an actual coupling with the downstream Function, then we can add the special Metadata key Activate with a value of 0. If the value is 0 or false, then the Function will not activate.
Figure 12.
The Activate Key with a value of 0.
Figure 12.
The Activate Key with a value of 0.
When the FMI interpretation is run, it stops at Cycle 2 with no Functions activated. The Function <To meet the critical conditions> is on “hold” because of the Activate key as shown by the yellow highlight in
Figure 13. The downstream Function <To execute the critical function> does not activate because the conditions of the default FMI profile for this Function are not satisfied, in that the Precondition aspect is not present.
Figure 13.
The “Plan A or Plan B” model with a Precondition not activated.
Figure 13.
The “Plan A or Plan B” model with a Precondition not activated.
For the next illustration we will set this Activate key to a value of 1, which means that all Outputs will be created. This has the same result as the initial model with the activation of the two Exit Functions.
Next, take the other background Function <To provide the required materials> and create a Metadata Key named Materials with a value of 100.
Now consider the Function <To execute the critical function>. We can model an instantiation where this Function looks at the materials available, and makes a decision on which Output to create. For example, if the Materials are greater than or equal to 70 then [Execute Plan A], otherwise [Execute Plan B]. This is achieved by adding an Activate key to the Function with a conditional formula. If the value of an Activate key (either fixed or calculated) is any other text that is not 0, 1, or false, then it looks for an Output name that is contained within the text, and activates that Output specifically. For this example we enter the formula:
Activate = R4_Materials >= 70 ? "Execute Plan A" : "Execute Plan B"
The first part of the formula up to the question mark is evaluating a statement that can be true or false: “Is the value of the Materials key available on the Resource aspect (R) from the upstream Function (id=4) greater than or equal to 70?”. If this statement is true then the next value (or formula result) up to the colon (:) is returned, in this case the text “Execute Plan A”. Otherwise the remaining value or formula after the colon is returned “Execute Plan B”.
Figure 13.
The Activate Key with a conditional formula.
Figure 13.
The Activate Key with a conditional formula.
When the interpretation is run, only one Exit Function is activated on Cycle 3, <To carry out Plan A>, and the interpretation stops on Cycle 4 with no more Functions activated.
If the Materials key on background Function <To provide the required materials> is changed to a value that is less than 70, and the interpretation re-run, then only the Exit Function <To carry out Plan B> will be activated.
4.2.3. Resilience Potentials
In creating a model, the FRAM method focuses primarily on describing the Functions, with the mutual couplings between Functions emerging from the increasing understanding of the Functions themselves. As a model becomes increasingly complex, it more often resembles a neural network rather than a linear process flow, and some Functions may be both upstream and downstream of others. Since Hollnagel published his Resilience Potentials in 2018 (to respond, to monitor, to learn, and to anticipate), many users of FRAM models have used these as a basis to describe the feedback and feedforward loops in their models. In some cases, like the Patient Management application described later on, they have been added to a model as new Functions to intentionally create new feedback and feedforward loops and introduce resilience into an existing process.
A generic model of the resilience potentials is provided as an example of how the FMI profile handles looping, and how the metadata can be used for iterative calculations.
Figure 15.
A generic FRAM model of the resilience potentials.
Figure 15.
A generic FRAM model of the resilience potentials.
The model has an Entry Function <To cause an event>, that will activate on Cycle 0 of an FMI interpretation. There are two downstream Functions, <To Monitor> and <To Respond>, that would receive Inputs and potentially activate on Cycle 1. However, both Functions have other aspects that are coupled with other downstream functions, that in this case are also upstream of these two Functions. Because the default FMI profile requires that ‘All’ aspects are present before a Function produces an Output, the interpretation hangs at Cycle 1 and no further progress is visualised. This is a valid response, as one of the purposes of the FMI, as described previously, is to identify this type of mutual dependence, and to confirm if it is valid for the given model.
To continue the interpretation, it is necessary to consider the initial activation conditions for the Functions that are waiting for downstream aspects. Take the Function <To Respond> for example, which has a Control aspect of [Better Predicted Response] and a Resource aspect of [Resources needed]. If it is initiated by the event on its Input, can it produce an Output if adequate controls and resources have not yet been established, or is there an initial unprepared reaction that will be later refined by downstream learning? An initial set of controls and resources can be added to the model as additional background Functions, and the FMI profile of the Function set to activate on ‘Any’ Control aspect and ‘Any’ Resource aspect, allowing it to activate if one or the other coupling on each of the aspects is present. For this example, we will take this as assumed and more simply set the FMI profile on both the Control and Resource aspect to ‘none’, so that the Function can activate on the first instance with no other aspect couplings present so that it does not wait for all of its aspects. Similarly, we will also set the Time aspect on the Function <To Monitor> to ‘none’, representing an initial monitoring schedule that will be later refined by downstream learning.
When the FMI is run under these conditions, the interpretation progresses to Cycle 3 with the activation of the Exit Function <To Act>. If we were to advance the interpretation one more Cycle (4), the fourth resilience potential <To Anticipate> would activate for the first time and provide the Control aspect [Better Predicted Response] to the Function <To Respond>. Now, if the Entry Function activated again with a new [External Events] coupling, the model is prepared with more resources and controls for a better response. At this point the FMI interpretation has shown that all Functions can activate and that all potentially couplings are capable of being realised.
Next, we can model the second and subsequent recurring events by setting the FMI profile of the Entry Function to repeat every 4 Cycles, effectively pulsing the model at the same frequency that it takes to activate all Functions. Metadata can be used to represent and display the expected quality of the response based on the number of times the model has iterated through the resilience potentials.
In a very simple case, we can show this by adding a Metadata key of OutputDisplay to each Function. For the Entry Function <To cause an event>, we set the starting value at 1. For all of the remaining Functions, we set them to the same formula, Aavg_OutputDisplay. This is a built-in formula that calculates the average of all of the OutputDisplay values on all of the Aspects. If the aspect is not present, then the value will default to 0. For the <To Monitor> function on Cycle 1, the value coming from the upstream Entry Function is 1, while the Time aspect is not present and evaluates to zero, so the average that is then passed to the Output is 0.5. In this way, the calculated values start at 0.5 and approach 1 on subsequent cycles, as values from looping aspects are added to the calculations.
Finally, we setup the display results for the OutputDisplay key on an orange to blue scale from 0.5 to 1.
Figure 16.
FMV Display Results Setup.
Figure 16.
FMV Display Results Setup.
The first time all Functions produce an output on Cycle 4, their results are all less than or equal to 0.5 and show orange. As the OutputDisplay values approach 1 on subsequent iterations of the model, the display results move from orange, through pale-yellow to blue, with all Functions eventually displaying blue, such as the <To Respond> Function calculating an OutputDisplay value of about 0.9 on Cycle 16.
Figure 17.
“Resilience Potentials” results on Cycle 4, 8, 12 and 16.
Figure 17.
“Resilience Potentials” results on Cycle 4, 8, 12 and 16.
In practice this type of model could represent learning how to monitor for precursors, so that unwanted outcomes can be anticipated, and responses can be preventative or interventionary, as opposed to reactionary.
The principles of repeatedly cycling a model with loops can also be used for other types of iterative calculations, such as modelling steady-state conditions, optimising parameters, or even machine learning algorithms.