Open Physics 2021; 19: 454–459
Research Article
Mehrdad Shahmohammadi Beni, Hiroshi Watabe, and Kwan Ngok Yu*
CompVision: An open-source five-compartmental
software for biokinetic simulations
https://doi.org/10.1515/phys-2021-0055
received May 23, 2021; accepted June 29, 2021
without any restriction. The present program would be
useful in a variety of research fields and applications.
Abstract: Simulations and numerical analysis of physical
problems are important steps toward understanding
underlying mechanisms of the processes. Important examples would be medical physics and medical imaging.
Compartmental modeling has been found useful for estimating the transport and temporal variations of drugs/
contaminants (commonly used in medical physics and
medical imaging) in different organs, given that different
organs would be modeled as compartments. Recycling
among these modeled compartments (i.e., organs) was
allowed through defining sets of constant transfer rates.
In order to mathematically define these systems, one
needs to use sets of differential equations (depending on
the number of compartments) which would in fact be timeconsuming and prone to mathematical error. Considering
these issues, there is a need for a versatile computer program that is accurate, robust, and user-friendly to perform
the required computations automatically. In the present
work, we developed and benchmarked an open-source
computer program entitled CompVision that was able to
simulate five-compartmental systems. The present software had an easy-to-use graphical user interface (GUI)
for the users. The executable program and the source
codes were made available publicly under GPLv3 license,
which would allow everyone to use, modify, and distribute
Keywords: compartmental modeling, numerical analysis,
differential equations, computer programming, open-source
software
* Corresponding author: Kwan Ngok Yu, Department of Physics, City
University of Hong Kong, Tat Chee Avenue, Kowloon Tong, Hong
Kong, China, e-mail: peter.yu@cityu.edu.hk, tel: +852-34427812,
fax: +852-34420538
Mehrdad Shahmohammadi Beni: Division of Radiation Protection
and Safety Control, Cyclotron and Radioisotope Center, Tohoku
University, 6-3 Aoba, Aramaki, Aoba-ku, Sendai, Miyagi 980-8578,
Japan; Department of Physics, City University of Hong Kong, Tat
Chee Avenue, Kowloon Tong, Hong Kong, China
Hiroshi Watabe: Division of Radiation Protection and Safety Control,
Cyclotron and Radioisotope Center, Tohoku University, 6-3 Aoba,
Aramaki, Aoba-ku, Sendai, Miyagi 980-8578, Japan
1 Introduction
Compartmental modeling was found to be very useful in a
variety of applications. For example, in the research field
of medical imaging, we previously reviewed the employment and importance of compartmental models in positron emission tomography (PET) imaging [1]. Another
field was nuclear medicine, e.g., the human body was
represented using five compartments, namely, (1) blood,
(2) kidneys, (3) urinary bladder, (4) other organs, and (5)
tumor [2]. The variations of certain drugs or, more generally, the contaminant in these five compartments could
be explained using sets of differential equations [1–4].
Setting up these differential equations in each compartment in the system would in fact be a tedious and timeconsuming task. In addition, one might need to perform a
more in-depth analysis of factors that had influence on
the temporal variations in the concentration of drugs or
contaminants in these five compartments. Considering
these, availability of an open-source computer program
that can simply be used by users would be crucial to
the research community. The present work was the
continuation of our previously published work [4], to
develop an open-source computer program with graphical
user interface (GUI) for modeling five-compartment systems. The present model is versatile and provides full
access to users to control all the parameters such as
(1) intake and fraction of intake rate, (2) depuration
zone, (3) volume of compartments, (4) initial concentration in each compartment, (5) uptake/excretion rates, (6)
transfer rates, and (7) time domain. The present program
would be a useful tool for future investigations, considering the rapid growth in the field of nuclear medicine
and imaging.
Open Access. © 2021 Mehrdad Shahmohammadi Beni et al., published by De Gruyter.
Attribution 4.0 International License.
This work is licensed under the Creative Commons
Compartmental biokinetic simulations
2 Materials and methods
2.1 Mathematical derivations and equations
Considering the compartment i in the system, the rate at
which the concentration is changing can be described as
dxi
=
dt
N
N
j=1
j≠i
j=1
j≠i
∑ rjixi − xi ∑ rij,
(1)
where xi is the concentration in compartment i, N is the
number of compartments in the system, and rij is the set
of transfer rates among all the compartments that are
present in the system. From equation (1), it can be seen
that the concentration of a compartment in the system is
related to the concentrations of its neighboring compartments. The intake rate of drugs/contaminants from an
outside source to compartment i is Pi and the uptake/
excretion rate is ξixi, given ξi and xi are constants and
the concentrations, respectively. In addition, considering
the varying compartment volumes, it would be possible
to relate the number of drug/contaminant molecules (Mi)
with the concentration (xi) and the volume (Vi), which is
simply Mi = xiVi, and knowing which we can have
d(Vx
i i)
= Pi +
dt
⎛N ⎞
∑ rjixj − xi⎜ ∑ rij⎟ − ξixi.
⎜ j=1 ⎟
j=1
⎜
⎟
j≠i
⎝ j≠i ⎠
N
(2)
From equation (2), it can be noted that the diagonal
elements are those at which i = j, so these can be
defined as
N
rii = − ∑ rij − ξi.
j=1
j≠i
(3)
As mentioned in the previous work of Birchall and
James [5], the diagonal elements could be replaced by the
negative of the sum of every row element. Using equations (2) and (3), we can have a matrix form as
d(Vx )
= P + Rx.
dt
(4)
In the present model, we considered the volume of
each compartment to be a constant which did not change
with time. Through defining u = x + R−1P, where u and
R−1 were column vector and the inverse matrix of R,
respectively, equation (4) could be written as
V
du
= Ru .
dt
(5)
455
Solving equation (5) and substituting the variable u,
the general solution to the time-dependent concentration
x(t) would be
x (t ) = [exp(V−1Rt ) − 1]R−1P + exp(V−1Rt )x (0) ,
(6)
where V−1 was the inverse matrix of volume, R−1 was the
inverse matrix of transfer rates, and t was the time. For a
more detailed derivation, interested readers are referred
to refs. [3,4] and references therein.
2.2 Program structure and implementation
The present computer program entitled CompVision was
developed entirely using the FORTRAN90 programming
language. The main reason behind this choice was its
phenomenal computational speed and relatively low
usage of system resources. CompVision had a GUI which
allowed the users to input and control the required parameters such as (1) intake and fraction of intake rate, (2)
depuration zone, (3) volume of compartments, (4) initial
concentration in each compartment, (5) uptake/excretion
rates, (6) transfer rates, and (7) time domain. Numerical
simulations with a user-friendly GUI are important in a
wide variety of research fields, e.g., dynamic food chain
modeling of radionuclides [6–9], modeling of various
pollutants in marine fauna [10–17], modeling of pollutant
transport in the human respiratory tract [18,19], development of solar cells [20], etc. The main part of CompVision
loaded the required modules for the GUI and the dialog
control of the program. The dialog control called the
dialog callback mainly in the form of synchronous callback. The dialog callback controlled and read the input
of the program that was inputted by the user. These
inputs were read in form of 256 character lengths and
were then converted into double precision 8-byte real
numbers which had 15 digits of accuracy. After the dialog
callback obtained all the numbers, it would call the
solver subroutine where all the parameters collected
from the users’ input would be passed to the solver function to perform the mathematical computations. There
were multiple subroutines that would be called by the
solver such as matrix exponential calculator, inverse
matrix, etc. The main interface and the structure of
CompVision are shown in Figure 1.
The GUI helped the user to input the required values
for the program to function. The design and the structure
of the GUI were kept minimal mainly for the ease of use
and also to limit unnecessary code bloats. A total of 41
user input values were needed to be supplied to the present program. For the five-compartment system, we had a
456
Mehrdad Shahmohammadi Beni et al.
Figure 1: Main interface and structure of CompVision program elements.
5 × 5 transfer rate matrix (R). As mentioned in the previous section, the diagonal elements of this 5 × 5 matrix
were the negative of the sum of each row elements.
Therefore, we ended up with a total of 20 (5 × 5 − 5 = 20)
transfer rates that required the input from the user. Other
inputs to the program included the volume (total of 5
inputs), initial concentration (total of 5 inputs), and
uptake/excretion rates (total of 5 inputs) of each compartment. In addition to these, the user would need to supply
intake rate to compartment 1, fraction of the intake value
which was actually supplied to the system, and the
time at which intake to the system was halted. The time
domain took the start value, the magnitude of the time
steps, and the maximum cutoff time value. It should be
noted that the time in this version of the program increased
by multiplication of the step value with the preceding time
point. The GUI of CompVision V-1.0 is shown in Figure 2.
Microsoft PowerStation QuickWin run-time libraries and
Microsoft Fortran libraries (using MSFLIB) were used in
building the GUI.
The CompVision V-1.0 program and its source code
could be downloaded from https://figshare.com/articles/
software/CompVision_An_open-source_five-compartmental_
software_for_biokinetic_simulations/14654118. The current version of our program is executable on Microsoft
Windows systems. In addition, we have tested the present program in GNU/Linux environment using Wine and
it worked well. CompVision does not require any installation and it can run in the portable mode. The executable
file has a size on disk of about 516 kB. The CompVision is
distributed under GNU General Public License version 3
(GNU GPLv3).
3 Benchmarking and numerical
tests
3.1 Case study 1: Extreme range of transfer
rates
Similar to our previous work [4], we used the five-compartment model with extreme ranges of transfer rates
introduced by Birchall and James [5]. The extreme transfer
rates and time intervals that were used here were hypothetical to test the numerical performance of the present computer program. It is remarked here that these large and
short time intervals might not correspond to real-life scenarios. These extreme ranges in the transfer rates would in
fact challenge the numerical accuracy and stability of our
program. The system setup and transfer rates for this
numerical example are shown in Figure 3.
The temporal variations of concentrations in the five
different compartments obtained by Birchall and James
[5] and by CompVision are compared in Table 1. Good
agreement between the reported results was shown. It
is remarked here that the model developed by Birchall
and James [5] was relatively more simplified, for example,
the volume of each compartment and the uptake/excretion
Figure 2: Graphical user interface (GUI) of CompVision V-1.0
program.
rates were not considered. Such a difference in the mathematical models led to some discrepancies between the
results shown in Table 1.
Figure 3: Simulated five-compartmental model of Birchall and James
[5] with extreme ranges of transfer rates.
Table 1: Comparisons among contaminant concentrations in five different compartments obtained by Birchall and James [5] and those obtained by our present model
Time
1 (ref. [5])
1
1
1
2.00 × 10
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
1.99 × 101
1.93 × 101
1.52 × 101
1.23 × 101
1.23 × 101
1.24 × 101
1.23 × 101
1.26 × 101
2.83 × 101
2 (CompVision)
1
2.00 × 10
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
2.00 × 101
1.97 × 101
1.75 × 101
8.03
6.11
6.11
6.11
6.11
6.11
6.11
3 (ref. [5])
1
2.73 × 10
5.73 × 101
5.61 × 101
3.04 × 101
7.15 × 10−2
4.59 × 10−3
4.59 × 10−3
4.59 × 10−3
4.59 × 10−3
4.63 × 10−3
4.86 × 10−3
5.03 × 10−3
5.03 × 10−3
5.03 × 10−3
5.01 × 10−3
5.14 × 10−3
1.16 × 10−2
3 (CompVision)
1
2.73 × 10
5.73 × 101
5.61 × 101
3.04 × 101
7.15 × 10−2
4.60 × 10−3
4.60 × 10−3
4.60 × 10−3
4.62 × 10−3
4.75 × 10−3
5.29 × 10−3
5.40 × 10−3
5.40 × 10−3
5.40 × 10−3
5.40 × 10−3
5.40 × 10−3
5.40 × 10−3
4 (ref. [5])
1
2.00 × 10
2.03 × 101
2.38 × 101
4.95 × 101
7.99 × 101
8.00 × 101
8.00 × 101
8.00 × 101
8.01 × 101
8.07 × 101
8.48 × 101
8.77 × 101
8.77 × 101
8.81 × 101
8.73 × 101
8.97 × 101
2.02 × 102
4 (CompVision)
1
2.00 × 10
2.03 × 101
2.38 × 101
4.95 × 101
7.99 × 101
8.00 × 101
8.00 × 101
8.00 × 101
8.03 × 101
8.25 × 101
9.20 × 101
9.39 × 101
9.39 × 101
9.39 × 101
9.39 × 101
9.39 × 101
9.39 × 101
5 (ref. [5])
1
2.11 × 10
2.15 × 101
2.64 × 10−6
5.51 × 10−6
8.90 × 10−6
8.91 × 10−6
8.91 × 10−6
8.91 × 10−6
8.92 × 10−6
8.99 × 10−6
9.45 × 10−6
9.77 × 10−6
9.77 × 10−6
9.82 × 10−6
9.73 × 10−6
9.99 × 10−6
2.25 × 10−5
5 (CompVision)
2.10 × 101
2.15
2.67 × 10−6
5.54 × 10−6
8.93 × 10−6
8.94 × 10−6
8.94 × 10−6
8.94 × 10−6
8.97 × 10−6
9.22 × 10−6
1.03 × 10−5
1.05 × 10−5
1.05 × 10−5
1.05 × 10−5
1.05 × 10−5
1.05 × 10−5
1.05 × 10−5
457
1.16 × 10
2.79 × 10−1
1.34 × 10−6
2.76 × 10−6
4.45 × 10−6
4.45 × 10−6
4.45 × 10−6
4.45 × 10−6
4.46 × 10−6
4.59 × 10−6
5.11 × 10−6
5.22 × 10−6
5.22 × 10−6
5.22 × 10−6
5.22 × 10−6
5.22 × 10−6
5.22 × 10−6
2 (ref. [5])
1.16 × 10
2.79 × 10−1
1.32 × 10−6
2.74 × 10−6
4.43 × 10−6
4.43 × 10−6
4.43 × 10−6
4.43 × 10−6
4.44 × 10−6
4.47 × 10−6
4.70 × 10−6
4.86 × 10−6
4.86 × 10−6
4.88 × 10−6
4.84 × 10−6
4.97 × 10−6
1.12 × 10−5
1 (CompVision)
Compartmental biokinetic simulations
10
10−7
10−6
10−5
10−4
10−3
10−2
10−1
1
101
102
103
104
105
106
107
108
−8
458
Mehrdad Shahmohammadi Beni et al.
Figure 4: Comparisons between temporal activity curves of 90Y-DOTATOC obtained by Jeremic et al. [2] and CompVision for (a) blood and
urinary bladder, (b) kidneys and other organs, and (c) tumor.
3.2 Case study 2: Biokinetics of
90
Y-DOTATOC in human body
For this case study, we used the five-compartmental model
introduced in the previous work of Jeremic et al. [2]. The
human body was modeled using five-compartments, namely,
(1) blood, (2) kidneys, (3) urinary bladder, (4) other organs,
and (5) tumor (see Figure 4). The drug was administered into
compartment 1 (i.e., blood), from which the drug would then
be transferred to other compartments. In this example, the
activities in these five-compartments were determined and
compared with the previously reported results, and the comparisons are shown in Figure 4.
The obtained temporal activity curves from CompVision
were in good agreement with results previously reported by
Jeremic et al. [2]. The intake was supplied through the blood
compartment and therefore the activity for this compartment increased rapidly in the early time intervals. Other
compartments such as kidneys, tumor, urinary bladder,
and other organs were also interconnected with the blood
compartment, so that in later time intervals the activities in
these compartments started to increase. After some time,
the intake to blood was stopped and therefore the activity
in this compartment was reduced. For other compartments,
smoother decreases in the activities with time were noticed,
which were attributed to recycling among these compartments with different transfer rates. In addition, as a result
of excretion, the activities versus time for all compartments
in general followed a descending trend. Interested readers
are referred to ref. [2] for more details. Some noticeable
differences were attributed to employment of different
mathematical models, since Jeremic et al. [2] did not consider the volume of compartments. The volume of different
compartments (i.e., in this case would be organs) could be
vastly different in realistic scenarios, so these parameters
were considered in our model. To facilitate more direct comparisons, we set the volumes of these five-compartments to
unity. In addition, we chose the best initial concentrations
from the reported curves and excretion rates to obtain a
good estimate of these results. The intake rate value into
compartment 1 (i.e., blood) was set to 4.5 GBq as reported by
Jeremic et al. [2] and therefore the obtained results of timeactivity would also be in GBq unit. In addition, the time unit
is in hour, given that the transfer rate units were in h−1 [2].
4 Conclusion
In the present work, we introduced and discussed the
development of an open-source five-compartmental computer program entitled CompVision. The present program
could simulate temporal changes in the concentrations of
drugs/contaminants in the considered compartments. An
open-source program was presented here, which could
be changed/modified by users to perform computations
specific to their studied systems. The present program
would be useful in a variety of applications, ranging
from environmental physics to medical physics and imaging. We hope to further expand this program to be used
for multi-compartmental cases (i.e., cases with more than
five compartments). This user interface can be used in
various research fields including biokinetics and pharmacokinetics simulations, tracer tracking, physiological modeling, environmental-radioactivity modeling, pollutant
modeling, nuclear medicine and imaging (e.g., PET), and
Compartmental biokinetic simulations
internal dosimetry. In particular, the present user interface
would be useful if one would like to track the temporal
changes of a studied substance in different spatial sections. The important features of this user interface include
the ease of use, low usage of system resources, small size
of the program, ability to execute in portable mode (no
installation required), cross platform support (can run on
both Microsoft Windows and Linux machines), and its
optimized computational speed. Last but not the least,
the present program is open-source which enables users
to modify, debug, and execute the program for their
desired specific application. In the future, we aim to
further develop the present user interface by incorporating
different numerical techniques.
Funding information: The present work was supported by
the Special Grant for the Development of Virtual Teaching
and Learning (VTL) no. 6430120 from the University Grants
Committee of Hong Kong SAR, and by Grants-in-Aid for
Scientific Research No. 20H03615 from the Ministry of
Education, Culture, Sports, Science and Technology
(MEXT) of Japan.
Conflict of interest: Kwan Ngok Yu is an Editor of Open
Physics, however he was not involved in peer review
process of this manuscript.
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
[16]
References
[1]
[2]
[3]
[4]
Watabe H, Ikoma Y, Kimura Y, Naganawa M, Shidahara M. PET kinetic
analysis – compartmental model. Ann Nucl Med. 2006;20:583–8.
Jeremic MZ, Matovic MD, Krstic DZ, Pantovic SB, Nikezic DR.
A five-compartment biokinetic model for 90Y-DOTATOC
therapy. Med Phys. 2018;45:5577–85.
Assimakopoulos PA, Ioannides KG, Pakou AA. A general
multiple-compartment model for the transport of trace
elements through animals. Health Phys. 1991;61:245–53.
Shahmohammadi Beni M, Yu KN. Nonlinear fitting of multicompartmental data using Hooke and Jeeves direct search
method. Open Phys. 2021;19:277–80.
[17]
[18]
[19]
[20]
459
Birchall A, James AC. A microcomputer algorithm for solving
first-order compartmental models involving recycling. Health
Phys. 1989;56:857–68.
Yu KN. Monitoring 90Sr contamination in terms of
131
I contamination in imported food. Health Phys.
1993;65:3183–21.
Yu KN, Ng KP, Cheung T, Young ECM. A dynamic food chain
model for Hong Kong based on Radfood model and Birchall
James algorithm. Nucl Sci Tech. 1995;6:37–46.
Ng KP, Yu KN, Young ECM. Transport of radionuclides along
marine foodchain. Nucl Sci Tech. 1995;6:204–11.
Yu KN, Cheung T, Young ECM, Luo DL. The bioconcentration of
131
I in fresh water fish. Health Phys. 1996;71:719–22.
Lam PKS, Yu KN, Ng KP, Chong MWK. Cadmium uptake and
depuration in the soft tissues of Brotla hainanensis
(Gastropoda: Prosobranchia: Thiaridae): a dynamic model.
Chemosphere. 1997;35:2449–61.
Yu PKN, Lam PKS, Ng BKP, Li AMY. Biokinetics of cesium in
Perna viridis. Environ Toxicol Chem. 2000;19:271–5.
Ke C, Yu PKN, Lam PKS, Wang WX. Uptake and depuration
of cesium in the green mussel Perna viridis. Mar Biol.
2000;137:567–75.
Yu KN, Lam PKS, Cheung CCC, Yip CWY. Mathematical modeling of PCB bioaccumulation in Perna viridis. Mar Pollut Bull.
2002;45:332–8.
Yu KN, Choi MC, Shen X, Wu RSS, Wang WX, Lam PKS.
Modeling of depuration of paralytic shellfish toxins in Chlamys
nobilis and Perna viridis. Mar Pollut Bull. 2005;50:474–9.
Kwong RWM, Yu PKN, Lam PKS, Wang WX. Uptake, elimination,
and biotransformation of aqueous and dietary DDT in marine
fish. Environ Toxicol Chem. 2008;27:2053–63.
Kwong RWM, Yu PKN, Lam PKS, Wang WX. Biokinetics and
biotransformation of DDTs in the marine green mussels Perna
viridis. Aquat Toxicol. 2009;93:196–204.
Li AMY, Yu PKN, Hsieh DPH, Wang WX, Wu RSS, Lam PKS.
Uptake and depuration of paralytic shellfish toxins in the
green‐lipped mussel, Perna viridis: a dynamic model.
Environ Toxicol Chem. 2005;24:129–35.
Yu KN, Lau BMF, Nikezic D. Assessment of environmental
radon hazard using human respiratory tract models.
J Hazard Mater. 2006;132:98–110.
Nikezic D, Lau BMF, Yu KN. Comparison of dose conversion
factors for radon progeny from the ICRP 66 regional model and
an airway tube model of tracheo-bronchial tree. Radiat Environ
Biophys. 2006;45:153–7.
Zandi S, Saxena P, Razaghi M, Gorji NE. Simulation of CZTSSe
thin-film solar cells in COMSOL: Three-dimensional optical,
electrical, and thermal models. IEEE J Photovolt. 2020;10:1503–7.