Hierarchical semantic composition of biosimulation models using bond graphs

Simulating complex biological and physiological systems and predicting their behaviours under different conditions remains challenging. Breaking systems into smaller and more manageable modules can address this challenge, assisting both model development and simulation. Nevertheless, existing computational models in biology and physiology are often not modular and therefore difficult to assemble into larger models. Even when this is possible, the resulting model may not be useful due to inconsistencies either with the laws of physics or the physiological behaviour of the system. Here, we propose a general methodology for composing models, combining the energy-based bond graph approach with semantics-based annotations. This approach improves model composition and ensures that a composite model is physically plausible. As an example, we demonstrate this approach to automated model composition using a model of human arterial circulation. The major benefit is that modellers can spend more time on understanding the behaviour of complex biological and physiological systems and less time wrangling with model composition.

Introduction https://github.com/SemBioProcess/SemGen/releases). SemGen is a free Java-based application designed for annotating, merging, and extracting biosimulation 77 models encoded in CellML [33], Systems Biology Markup Language (SBML) [34] and 78 JSim's Mathematical Modelling Language (MML) [35,36]. It generates the semantic 79 annotations as Resource Description Framework (RDF) triples 80 (https://www.w3.org/RDF) and adds them to the model code. Unlike other 81 composition approaches that rely on pre-defined module interfaces for coupling, 82 SemGen uses a 'white box' approach in which any element of the modules can be 83 selected as joint components by constructing required mappings between the module 84 elements [37]. In contrast, for example, in 'black box' compositions, the internal 85 components of the blocks are hidden. Only the input/output variables are available for 86 the user for coupling the modules [3]. One of the disadvantages of this approach in the 87 biological context is that usually the majority of the entities in a model are potentially 88 capable of being considered as coupling ports. Therefore, using the 'black box' 89 configuration is not compatible with our modelling purposes. 90 Here, we demonstrate a general method for semantics-based automated model 91 composition using bond graphs, which enables rapid construction of whole body 92 multiscale models. To demonstrate this, we construct and combine simplified, reusable 93 bond graph modules for the Anatomically Detailed Arterial Network (ADAN) open-loop 94 circulatory model based on existing work by Safaei et al. [25,38]. The ADAN model, 95 first mathematically developed as a partial differential equation (PDE) model by 96 Watanabe et al. [39], anatomically and physiologically describes the arterial network in 97 terms of segments and branches in which blood flow is simulated. Safaei

108
This section discusses the composition of CellML models using SemGen's merging tool 109 to reconstruct the ADAN open-loop model of the arterial system. Particularly, we will 110 show that we only need three templates to generate the 86 vessel segments of the 111 ADAN open-loop model. Later, we will demonstrate the potential for reuse in the case 112 of having similar sections in a system (as in the right and left limbs). Ultimately, the 113 quantities for all the biological entities can also be mapped to the model variables using 114 the SemGen merger tool. Our approach is summarised in Fig 1, illustrating the 115 flowchart of the modelling procedure. SemGen annotator and merger tools are discussed 116 further in [37]. The left column illustrates the general approach in the integration of bond graph models in CellML using SemGen, and the right column shows the same procedure specific to the ADAN circulation model. In both approaches, the bond graph models are created based on template models (1), and annotated using the SemGen Annotator (2). Later, depending on whether the system has similar larger compartments or any symmetry, the SemGen merger tool joins the modules in a number of steps (3). The amounts for the symbolic model parameters are allocated from a CellML file containing the annotated parameters and their values (4). In stage (

Semantic model composition using SemGen
SemGen has been used to integrate several mathematical models by treating them as 119 modules [35,40]. However, SemGen does not currently have the capability to edit the 120 equations in the models being merged [41]. Thus, conflicts may arise while coupling the 121 mathematical models, requiring post-merging adjustments in equations. Often, these 122 post-merging modifications are error-prone, prolonged [40,42] and require a to produce an integrated biological model which produces feasible results [35,40,42,43]. 126 To avoid this, we propose using the bond graph approach for creating the modules. 127 Describing biological and physiological systems in terms of bond graphs in CellML 128 allows us to take the advantage of both the energy-based and hierarchical nature of the 129 bond graph approach and the convenient semi-automated merging tool of SemGen.

130
Existing merging tools like SemGen do not consider physical constraints, while the bond 131 graph framework imposes these constraints to the system. Consequently, by defining the 132 CellML modules using bond graphs, the network structure allows conservation 133 equations to be systematically updated when merging models. This allows us to avoid 134 manually mapping the relationships between the sub-models in CellML. Furthermore, work. Here, we demonstrate that the same can be achieved in an automated manner 144 using the SemGen merger tool and intrinsic hierarchical properties of bond graphs. We 145 also demonstrate that adding an auxiliary variable to each bond graph module in models becomes simpler, systematic, hence time-efficient, and less error-prone.

148
Each vessel segment can be modelled in bond graphs using R, C, and I components, 149 representing the viscous resistance, vessel wall compliance, and mass inertial effect in 150 fluid mechanics, respectively [25]. Here,

151
• The potential variable is u, the energy density or pressure (J/m 3 ). The flow 152 variable is v, the fluid volumetric flow (m 3 /s);

153
• Segment compliances are defined using C components, given by the constitutive 'flow' which enable the bidirectional flow of information [44,45]. A more extensive 164 presentation of bond graph theory, and several examples can also be found in [46,47].

165
The parameters of each segment were calculated in terms of vessel properties using 166 the equations: The biological and geometric interpretations of the arterial parameters used in Eqs 168 (1), (2) and (3) are given in Table 1.
The wall thickness constants (a, b, c, d) are mathematical fitting parameters and are considered to be the same for all the vessels.
The dependency of the vessel wall thickness and its radius is logarithmic, as 170 discussed in [48] and later in [49] and [25]. an R and I in series, connected by bonds (Fig 2). To emphasise the concept of sharing 175 common potential and common flow in '0' and '1' junctions, we denote them as '0 : u' 176 and '1 : v', respectively, in which u stands for potential and v stands for flow. To ensure the conservation of mass and energy, potential and flow must obey 184 conservation laws, i.e., the sum of all the energy flows at each junction is zero [47] (i.e., 185 energy is neither created nor destroyed at a junction): where i indicates the number of bonds impinging on a junction. Depending on the type 187 of junction, one co-variable is considered fixed in the conservation equations. In a '0 : u' 188 junction the potential is fixed; and in a '1 : v' junction the flow is fixed. Eqs (5) and (6) 189 are the conservation relations for '0 : u' and '1 : v' junctions, respectively.
The terminal junctions in each module are selected for coupling with other modules. 191 When two modules are coupled, and a bond is added to a junction, there is  would be: By adding a bond between the junctions, the constitutive equations of the 207 components at 1 : v A * junction in A remain as in Eq (7). However, based on the 208 conservation laws in Fig 5, In order to compose models from these modules, we need to impose these changes  Bond graph modular connection of the vessel models. v in the initial junction of the following module will be mapped to v x at the terminal junction of its preceding module. In the same way, u at the terminal junction of each module will be mapped to u x at the initial junction of its following module. v x and u x are auxiliary variables.
We also need to deal with the case when a vessel is split into two or more branches. 217 We have already stated that for any number of branching or even non-branching vessels, 218 we use a common type of bond graph configuration. In this case, the idea is to impose a 219 priori a maximum number of branching occurring in a vessel of the network (say four). 220 Then we create our template module having four v x variables (see Fig 7). This creates 221 the generic modules we require for composing the full circulation model. The series of vessel segments in each lumped module is shown in Figure 9. The segments network is adopted from [25].
To visualise how the SemGen merger tool is utilised, the merging of two modules is 242 depicted in Fig 10. We started the model composition by creating the input to the system, which was 244 generating the output flow of the heart left ventricle. The flow wave was obtained from 245 digitising the analogous signal in the whole heart model, previously created in the 246 ADAN closed-loop system [25]. The fitting task was performed in MATLAB, using a 247 two-term Gaussian function as in Eq (8) with the settings shown in S1 Table. 248  To compare the simulation results between the two approaches, normalised root 251 mean square error (NRMSE) was also computed for each set of results as in Eq (9)    the long-term goals presented for SemGen, the capability of equation modification in the case of merging two models will be added [41]. This will enable the reuse of the existing modules without needing to add such extra variables.

307
This approach can also be utilised in other domains of application, for example the SemGen merger tool for coupling the modules allowed us to skip the manual 328 code-wise mappings between the modules in CellML. We anticipate that our approach 329 will enable future work on constructing multiscale models of organs that bridge 330 biochemical processes at the cellular level to tissue-level processes such as circulation.
helpful comments and suggestions.

334
All the authors have revised and provided the final approval of the submitted 335 manuscript.