<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing with OASIS Tables v3.0 20080202//EN" "journalpub-oasis3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table" xml:lang="en" dtd-version="3.0">
  <front>
    <journal-meta><journal-id journal-id-type="publisher">GMD</journal-id><journal-title-group>
    <journal-title>Geoscientific Model Development</journal-title>
    <abbrev-journal-title abbrev-type="publisher">GMD</abbrev-journal-title><abbrev-journal-title abbrev-type="nlm-ta">Geosci. Model Dev.</abbrev-journal-title>
  </journal-title-group><issn pub-type="epub">1991-9603</issn><publisher>
    <publisher-name>Copernicus Publications</publisher-name>
    <publisher-loc>Göttingen, Germany</publisher-loc>
  </publisher></journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.5194/gmd-14-1885-2021</article-id><title-group><article-title>Rapid development of fast and flexible environmental models: the Mobius
framework v1.0</article-title><alt-title>The Mobius
framework v1.0</alt-title>
      </title-group><?xmltex \runningtitle{The Mobius
framework v1.0}?><?xmltex \runningauthor{M.~D.~Norling et al.}?>
      <contrib-group>
        <contrib contrib-type="author" corresp="yes" rid="aff1">
          <name><surname>Norling</surname><given-names>Magnus Dahler</given-names></name>
          <email>magnus.norling@niva.no</email>
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff2">
          <name><surname>Jackson-Blake</surname><given-names>Leah Amber</given-names></name>
          
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff1">
          <name><surname>Calidonio</surname><given-names>José-Luis Guerrero</given-names></name>
          
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff2">
          <name><surname>Sample</surname><given-names>James Edward</given-names></name>
          
        <ext-link>https://orcid.org/0000-0002-0861-3982</ext-link></contrib>
        <aff id="aff1"><label>1</label><institution>Norwegian Institute for Water Research, 0349 Oslo, Norway</institution>
        </aff>
        <aff id="aff2"><label>2</label><institution>Norwegian Institute for Water Research, 4879 Grimstad, Norway</institution>
        </aff>
      </contrib-group>
      <author-notes><corresp id="corr1">Magnus Dahler Norling (magnus.norling@niva.no)</corresp></author-notes><pub-date><day>9</day><month>April</month><year>2021</year></pub-date>
      
      <volume>14</volume>
      <issue>4</issue>
      <fpage>1885</fpage><lpage>1897</lpage>
      <history>
        <date date-type="received"><day>27</day><month>January</month><year>2020</year></date>
           <date date-type="rev-request"><day>28</day><month>April</month><year>2020</year></date>
           <date date-type="rev-recd"><day>9</day><month>December</month><year>2020</year></date>
           <date date-type="accepted"><day>21</day><month>February</month><year>2021</year></date>
      </history>
      <permissions>
        <copyright-statement>Copyright: © 2021 Magnus Dahler Norling et al.</copyright-statement>
        <copyright-year>2021</copyright-year>
      <license license-type="open-access"><license-p>This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this licence, visit <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">https://creativecommons.org/licenses/by/4.0/</ext-link></license-p></license></permissions><self-uri xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021.html">This article is available from https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021.html</self-uri><self-uri xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021.pdf">The full text article is available as a PDF file from https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021.pdf</self-uri>
      <abstract><title>Abstract</title>
    <p id="d1e114">The Mobius model building system is a new open-source
framework for building fast and flexible environmental models. Mobius makes
it possible for researchers with limited programming experience to build
performant models with potentially complicated structures. Mobius models can
be easily interacted with through the MobiView graphical user interface and
through the Python programming language. Mobius was initially developed to
support catchment-scale hydrology and water-quality modelling but can be
used to represent any system of hierarchically structured ordinary
differential equations, such as population dynamics or toxicological models.
Here, we demonstrate how Mobius can be used to quickly prototype several
different model structures for a dissolved organic carbon catchment model
and use built-in auto-calibration and statistical uncertainty analysis tools
to help decide on the best model structures. Overall, we hope the modular
model building platform offered by Mobius will provide a step forward for
environmental modelling, providing an alternative to the “one size fits
all” modelling paradigm. By making it easier to explore a broader range of
model structures and parameterisations, users are encouraged to build more
appropriate models, and in turn this improves process understanding and
allows for more robust modelling in support of decision making.</p>
  </abstract>
    </article-meta>
  </front>
<body>
      

<sec id="Ch1.S1" sec-type="intro">
  <label>1</label><title>Introduction</title>
      <p id="d1e126">Environmental models are increasingly used both to formalise the current
state of scientific knowledge and to support policy and practical decision
making. There is therefore a strong need for robust models. Present-day
system knowledge, new data sources (for instance from remote sensing), and
the practical experience of many modellers suggest that model structure and
complexity should be tailored to the system of interest based on (i) the
research or policy question of interest, (ii) the response characteristics
of the system, and (iii) the availability of observational data. When
developing a model application, a compromise therefore needs to be reached
between the realism with which natural processes are represented as a set of
equations, whether those processes are important for the specific
objectives of the modelling exercise, whether it is computationally feasible
to represent those processes, and whether data are available to evaluate the
hypotheses put forward by the model
(Clark et al., 2015). Within catchment
hydrology and water-quality modelling, for example, the dominant processes
that dictate the system response to external drivers vary according to the
scale of interest, with different processes revealing themselves to be the
main driver as scale increases from plot to hillslope to catchment
(e.g. Sivapalan et al., 2003). Appropriate
process representation may also vary from catchment to catchment
(Kavetski and Fenicia,
2011; Wagener et al., 2007). Despite this, many popular water-quality models
provide limited flexibility for customising model structure. For example,
spatially semi-distributed models typically allow users to define their own
hydrological response units (HRUs), but the process representation within
each HRU is essentially fixed. It is common for users to make implicit
changes to the model structure, for example by setting parameter values to
zero or <inline-formula><mml:math id="M1" display="inline"><mml:mo>±</mml:mo></mml:math></inline-formula> infinity, but this approach is both inflexible and opaque.
Inflexible model structures are problematic when attempting to generalise
complex models developed in areas with detailed monitoring data to less
well-studied regions with<?pagebreak page1886?> sparse data. Overfitting is a serious problem for
many environmental models and several authors have expressed concerns
regarding testability or falsifiability of model simulations
(see, e.g. Kirchner, 2006). The predominance
of inflexible model structures has led to a vast number of models, often
developed for a specific location or to answer a specific question and then
(perhaps inappropriately) transferred elsewhere
(e.g. hydrology models are considered in Beven,
2012). To tackle this issue, calls have been made for open-source community
models (e.g. Mooij et al., 2010; Weiler and Beven, 2015) and/or so-called “models of everywhere”, where the idea is to move from generic models that are customised to particular locations, for example through appropriate
parameterisation, to models that are specific to particular places (Blair et al., 2019).</p>
      <p id="d1e136">Modular (or flexible) modelling systems try to address these issues by
providing a unified computational environment within which models can be
developed and therefore offer an attractive and increasingly popular
alternative to the “one size fits all” paradigm. A well-designed framework
makes it possible to quickly explore alternative model structures and to
explicitly customise existing models for specific applications. Model
evaluation and comparison then become significantly easier, as all model
variants can use the same input and output data formats and share components
of the same code base where appropriate. The user can therefore be certain
that differences in output are due to intended structural changes and not
to implementation differences (e.g. in data pre-processing, secondary model
components, or numerical solving schemes), meaning more significant
scientific insight can be gained when comparing alternative process
representations
(Mooij et
al., 2010). Modular frameworks also make it possible for users to extend or
combine previously developed models, for example by quickly developing
multiple variants of a water-quality model, all underpinned by the same
hydrology module.</p>
      <p id="d1e139">Although modelling frameworks have many advantages compared to traditional
(fixed structure) approaches, they are difficult to implement in practice as
building a flexible, generalisable framework requires considerably more
programming expertise than building a static model. Many modellers have
skills in interpreted languages such as Python or R, which are reasonably
well-suited to rapid prototyping of alternative model structures. However,
exploring uncertainty in model predictions, or formally comparing model
structures, typically requires methods such as Bayesian MCMC, which involves
running each model thousands or even millions of times. This can be a big
limitation for models coded in interpreted languages, which are
comparatively slow. One solution is to build models using compiled languages
like C++ or Fortran, but many modellers lack the time or inclination to
develop the necessary programming skills.</p>
      <p id="d1e142">This paper presents a new modelling framework, Mobius, which allows flexible
and fast model building by researchers with a relatively basic level of
programming. Mobius models meet modern demands for computational speed and
allow for the complexity of process representation to be varied depending on
progressing system knowledge, research question, or scale. Several
hydrological model building frameworks exist to date, such as FUSE
(Clark et al., 2008), SUPERFLEX
(Fenicia et al., 2011), FARM
(Euser et al., 2013), and SUMMA
(Clark et al., 2015). These all allow
predefined components to be connected in user-specified ways to create a
model, with a focus on catchment hydrology. The framework presented here
takes these existing approaches further, allowing the user to define any
component or process. It is therefore, to our knowledge, one of the first
frameworks to be fully generalisable; although initially developed to
support catchment-scale hydrology and water-quality modelling, it can be
used to represent any system of hierarchically structured ordinary
differential equations (ODEs), such as population dynamics or toxicological
models. Moreover, the Mobius framework does more of the heavy lifting of
organising the program structure than what we find in other frameworks. The
user can create models with a complex structure without having to organise
that structure explicitly using programming architecture. A range of popular
hydrology and water-quality models have already been implemented in Mobius,
for instance the INCA family of models
(Futter
et al., 2007, 2014; Jackson-Blake et al., 2016; Wade et al., 2002; Whitehead
et al., 1998) and the Simply models
(Jackson-Blake et al., 2017); these are available to use either as stand-alone models or as starting points
for further development and customisation.</p>
      <p id="d1e146">In the remainder of the paper, we first describe the core of the Mobius
framework (Sect. 2). We then describe tools for
interacting with Mobius models, including the MobiView application (Sect. 3.1.1), a user-friendly graphical user interface
(GUI) compatible with all Mobius models, and the Mobius Python wrapper
(Sect. 3.1.2), which provides Python bindings to
core Mobius functionality and incorporates many powerful optimisation and
uncertainty estimation tools from the Python ecosystem. We then demonstrate
the utility of Mobius by developing a new illustrative dissolved organic
carbon catchment model, including rapid development of a variety of
potential model structures, and using the tools available through the Python
wrapper to choose an appropriate structure for model application in a
Norwegian catchment (Sect. 3.2). We also include a
model run speed benchmarking test to demonstrate that performance is only
marginally compromised by the increase in flexibility (Sect. 3.3). We finish by discussing the current scope and
limitations of the framework, as well as future plans (Sect. 4).</p>
</sec>
<sec id="Ch1.S2">
  <label>2</label><title>Overview of Mobius</title>
      <p id="d1e157">Mobius is a general framework for building models consisting of ordinary
differential equations (ODEs) and equations evaluated only once per time
step (discrete time step<?pagebreak page1887?> equations). Only limited programming knowledge is
needed to build or modify Mobius models. When building a Mobius model, the
user specifies what state variables are in the model and what equations
govern these. Equations can depend on the values of input time series, such
as meteorological forcings, and be tuned using parameters. The core Mobius
framework is built using highly optimised C++ code, but users can create
new models or adapt existing ones by adding new model equations, parameters,
inputs, and dependencies between these, without having a detailed
understanding of C++.</p>
      <p id="d1e160">When programming models without a framework one must typically do a
significant amount of work when adding in new processes or parameters. This
may involve putting the mathematical equations in the right place in the
model evaluation code or even restructuring the model evaluation code,
recording the value of the equations at each time step for later exporting,
packing various values into structures for use inside ODE integrators
(something that can be daunting to inexperienced programmers), updating
parameter file formats and parsers, and updating the code that exports the
result time series to the desired final format. Any user interface or
plotting code that is designed to visualise the new process will
typically also need updating. The Mobius framework automatically takes care
of these things, allowing the researcher to focus only on the mathematical
formulation of the processes. Even with this flexibility, run speeds are
comparable to custom-coded C++ models and considerably faster than
models written in languages such as Python or R (see Sect. 3.3).</p>
      <p id="d1e163">The framework exposes two application programming interfaces (APIs): the
model builder API and the model interaction API. The model builder API
allows for specification of models and modules. Finished models can be
interacted with through the model interaction API. The following is an
overarching description. More detail is given in “Documentation<inline-formula><mml:math id="M2" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>model_builder_documentation.pdf” in the
Mobius repository. The core implementation is described in the
“Documentation<inline-formula><mml:math id="M3" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>framework_implementation_documentation.<?xmltex \hack{\newline}?>pdf” and in the source code
itself (see Sect. 5).</p>
<sec id="Ch1.S2.SS1">
  <label>2.1</label><title>The model builder API</title>
      <p id="d1e189">The model builder API allows a model creator to register model entities by
name (a string) and associate metadata with them. Each registration
procedure returns a handle that is used to refer to that entity. Model
entities include parameters, input time series, and equations (state
variables).</p>
      <p id="d1e192">The code that is used to evaluate each equation is provided in-line in the
model building code. Each equation can use the (present or past) value of
other entities that have been registered by referring to them by their
handles. Each equation must return a single value per evaluation. In the
simplest case, each equation is evaluated once per time step, resulting in a
time series. An equation that is registered as an ODE is instead integrated
over the time step, typically using smaller sub-steps (the size of the
sub-time steps can depend on convergence criteria).</p>
      <p id="d1e195">In more complicated setups, parameters and inputs can index over one or more
index sets. Index sets can be viewed as “response units” in a loose way,
meaning for instance a river reach or sub-catchment in a catchment model, a
size class or species in a biological population model, or a grain size and
density class for microplastic particles. For example, in a catchment model
some processes may have different parameterisations depending on land-use
class or sub-catchment. The land-use index set could then contain the
indexes “Forest” and “Agricultural” to allow for separate evaluation of
the common processes for these two land-use types.</p>
      <p id="d1e198">The equations are automatically distributed over auto-generated arrangements
of batches. Batches are groups of equations that are evaluated for each
(tuple of) index(es) in some collection of index sets:
<list list-type="bullet"><list-item>
      <p id="d1e203">If an equation uses the (current time step) output of another, it will be
evaluated after it.</p></list-item><list-item>
      <p id="d1e207">An equation will be indexed by all the index sets that index the entities whose values the equation uses.</p></list-item><list-item>
      <p id="d1e211">Equations are grouped into batches that index over the same index sets if
they can be ordered consecutively according to the above criteria. In
special cases, batch grouping is also determined by what ODE solver is used.</p></list-item></list>
For instance, if an equation depends on a parameter that has a separate
value per “Landscape unit”, then that equation will also have a separate
value per “Landscape unit”. Furthermore, special types of equations and
value access syntax allows an equation to aggregate the value of another
equation over an index set or access values of entities from a different
tuple of indexes to the one being currently considered. In this way, one can
for instance let flow from different parts of the landscape go into a single
river.</p>
      <p id="d1e216">As an example, say that one wants to describe the input of water to the soil
<inline-formula><mml:math id="M4" display="inline"><mml:mrow><mml:msub><mml:mi>q</mml:mi><mml:mi mathvariant="normal">in</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, which in this example is different per land-use class. Let <inline-formula><mml:math id="M5" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> be
the time step (daily in this case, but the framework allows for configurable
time step sizes) and let <inline-formula><mml:math id="M6" display="inline"><mml:mi>u</mml:mi></mml:math></inline-formula> be a land-use class. Let <inline-formula><mml:math id="M7" display="inline"><mml:mrow><mml:msub><mml:mi>p</mml:mi><mml:mi mathvariant="normal">rain</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> be the
amount of rain per day and <inline-formula><mml:math id="M8" display="inline"><mml:mrow><mml:msub><mml:mi>t</mml:mi><mml:mi mathvariant="normal">air</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> be the air temperature (these could be
input time series; in this short example we omit how we compute snow
fall). Let <inline-formula><mml:math id="M9" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="normal">DDF</mml:mi><mml:mi mathvariant="normal">melt</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> be a degree-day factor for snow melt (a parameter)
and let <inline-formula><mml:math id="M10" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mi mathvariant="normal">snow</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> be the computed snow depth. Then a simple equation
describing the water input to soil could be
            <disp-formula id="Ch1.E1" content-type="numbered"><label>1</label><mml:math id="M11" display="block"><mml:mrow><mml:msubsup><mml:mi>q</mml:mi><mml:mrow><mml:mi mathvariant="normal">in</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi></mml:mrow><mml:mi>u</mml:mi></mml:msubsup><mml:mo>=</mml:mo><mml:msub><mml:mi>p</mml:mi><mml:mrow><mml:mi mathvariant="normal">rain</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:mi mathvariant="normal">min</mml:mi><mml:mo>(</mml:mo><mml:msubsup><mml:mi>d</mml:mi><mml:mrow><mml:mi mathvariant="normal">snow</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>u</mml:mi></mml:msubsup><mml:mo>,</mml:mo><mml:msubsup><mml:mi mathvariant="normal">DDF</mml:mi><mml:mi mathvariant="normal">melt</mml:mi><mml:mi>u</mml:mi></mml:msubsup><mml:msub><mml:mi>t</mml:mi><mml:mrow><mml:mi mathvariant="normal">air</mml:mi><mml:mo>,</mml:mo><mml:mi>i</mml:mi></mml:mrow></mml:msub><mml:mo>)</mml:mo><mml:mo>.</mml:mo></mml:mrow></mml:math></disp-formula>
          This system can be added to a Mobius model as follows (code for computing
snow depth and registration of units is omitted).</p>
      <p id="d1e365"><?xmltex \hack{\begin{figure*}[t]}?><?xmltex \igopts{width=355.659449pt}?><inline-graphic xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021-g01.png"/><?xmltex \hack{\end{figure*}}?></p>
      <?pagebreak page1888?><p id="d1e373">Since the “Degree-day snow melt factor” belongs to the “Snow parameters”
parameter group, which is set to index over the “Landscape units” index
set, the equation “Water input to soil” will (when the model is later run)
be evaluated per land-use class since it uses the value of this parameter.
If one also makes it so that “Rain fall” is indexed over the
“Sub-catchment” index set, the equation is evaluated per pair of
(landscape unit, sub-catchment) indexes. Setting the index set dependencies
of inputs can even be done during the model interaction stage, such as through
an input file. Note that “Degree-day snow melt factor” is given a unit and
default min and max values. These are not used in the model run, but they
are metadata that can, e.g. be displayed in a UI to guide the model user.</p>
      <p id="d1e376">What indexes each index set contains can be specified during the later model
interaction step, where they can, e.g. be loaded from a parameter file or set
by a GUI. Land-use and river-connectivity structure in a catchment model,
for example, can thus be specified without changing or recompiling the
model.</p>
      <p id="d1e379">ODE equations are organised into batches by the framework depending on the
selected integrator algorithm. At present, one Runge–Kutta 4 ODE integrator
based on the DASCRU algorithm (Wambecq, 1978) is bundled with
Mobius and there are wrappers for the Boost Odeint solvers
(Ahnert and Mulansky, 2011). Other solvers can be made accessible in
Mobius without having to modify the core framework code.</p>
      <p id="d1e382">When a model is run, all state variables (equations) are recorded each time
step, resulting in a time series corresponding to each of them. When
equations are evaluated for multiple indexes, a time series is produced for
every index combination. In this way you may for instance get a separate
“Soil water volume” time series for each sub-catchment and land-use class
in a hydrology model. This exhaustive recording facilitates introspection
into model processes, for instance in the MobiView user interface (Sect. 3.1.1), which can be used during all stages of model development. This way, a
model can be built iteratively, adding one process at a time and assessing
how it performs.</p>
      <p id="d1e386">The modular system in Mobius allows various modules to be combined. A module
is simply a procedure that registers entities with a model and provides the
associated equation code. A module can access entities that were registered
in other modules. This is done by obtaining the handle to the other entity
by loading it from its string name. One benefit of the fact that the
framework organises the main evaluation loops of the model is that ODE
equations from a module can be solved in the same ODE integrator batch as
the ODE equations from another module without any effort by the model
creator. In this way one module can extend the ODE systems of another,
creating a larger coupled set of equations or even override individual
equations from the other module without creating a separate version of the
source code of that other module.</p>
</sec>
<sec id="Ch1.S2.SS2">
  <label>2.2</label><title>The model interaction API</title>
      <p id="d1e398">Any model created using the model builder API can be compiled to a
dynamically linked library (.dll on Windows, .so on Linux) or can be
included into another C++ project. The model interaction API (which is
exported through the library) can be used to create programs that use the
model for specific purposes. We have created a wrapper for the API in the
Python programming language (Sect. 3.1.2). It is
possible to call these functions from any language with a C foreign function
interface. Some of the things one can do with this API are:
<list list-type="bullet"><list-item>
      <p id="d1e403">Create a “dataset” object that can be structured for a concrete setup of
the model with given parameter values and input time series.</p></list-item><list-item>
      <p id="d1e407">Set specific index set structures in the dataset. In catchment models this
allows for setting up the river-structure and land-use classes.</p></list-item><list-item>
      <p id="d1e411">Run the model one or more times with a given dataset. One can also make
thread-safe (and fast) copies of the dataset to run the model multiple times
in parallel.</p></list-item><list-item>
      <p id="d1e415">Read the resulting time series of any model equation (for a given index
tuple corresponding to this equation's index set dependencies).</p></list-item><list-item>
      <p id="d1e419">Read the full structure of the model and accompanying metadata that was
registered in the model building process. One can, e.g. extract a list of the
names of all the parameters or equations, their units, descriptions, index
set dependencies, etc.</p></list-item></list>
Model entities are interacted with by referring to the string name that they
were registered with. Mobius supports a custom text format for parameter and
input files that is tailor made to be convenient to edit by hand. A json
format for parameter and input files is also supported, which could for
instance be used for serialisation and web communication. The API also makes
it easy to add support for new file or data formats.</p>
      <p id="d1e423">The MobiView user interface (Sect. 3.1.1) is an
example of a program built using this API. Other options are making command
line applications, R modules, (for instance using
Rcpp; see Eddelbuettel and François, 2011), wrappers to other
languages, or complex setups such as running the same model for
multiple climate scenarios, sensitivity analysis, ensemble runs of multiple
models, or autocalibration (more on this in Sect. 3.1.2). The API can also be used to couple Mobius
models to models that were not created in Mobius.</p>
</sec>
</sec>
<?pagebreak page1889?><sec id="Ch1.S3">
  <label>3</label><title>Demonstration of Mobius</title>
<sec id="Ch1.S3.SS1">
  <label>3.1</label><title>Tools for convenient interaction with Mobius models</title>
      <p id="d1e442">Compiled Mobius models can be interacted with in two user-friendly ways,
using a GUI or Python.</p>
<sec id="Ch1.S3.SS1.SSS1">
  <label>3.1.1</label><title>MobiView GUI</title>
      <p id="d1e452">The MobiView GUI can interact with any model that is compiled using the
standard Mobius .dll interface. It is ideal for model users and developers
to quickly explore Mobius model parameters, equations, and inputs, and to carry
out manual calibration. The GUI displays a structured organisation of
parameters, associated descriptions, and recommended ranges. It is easy to
find parameters using a name search. The workflow for manual calibration is
convenient: the user can update a parameter value, then click a button (or
keyboard hot key) to re-run the model and immediately see the results in the
plot view (Fig. 1).</p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F1" specific-use="star"><?xmltex \currentcnt{1}?><?xmltex \def\figurename{Figure}?><label>Figure 1</label><caption><p id="d1e457">The MobiView user interface running INCA-N, a catchment nitrogen
model. The image shows the module and parameter group structure of this
model (top left), some editable parameters (top centre), and a plot that
shows a comparison between modelled and observed flow of water in the river.
Any time series shown in the Equation and Input lists on the right can be
selected for plotting here.</p></caption>
            <?xmltex \igopts{width=483.69685pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021-f01.png"/>

          </fig>

      <p id="d1e466">There are various plot modes and ways to customise the plotting to be able
to analyse the model result time series. For instance, the user can switch
between daily values and monthly and yearly aggregations. There are also
residual plots, residual distribution histograms, and quantile–quantile plots
for analysing the performance of a result time series compared to an
observed time series. MobiView computes several different goodness-of-fit
statistics (including, for example bias, mean absolute
error, mean squared error, and Nash–Sutcliffe efficiency; Nash and
Sutcliffe, 1970). Any observation time series can be loaded for use in
calibration. Other features include visualisation of branched river
structures (for hydrology models), ability to export results to csv formats,
customisation of plot visual layout, and export of plots to image or pdf
formats.</p>
      <p id="d1e470">MobiView is developed using the Ultimate++ framework and the ScatterCtrl
package (<uri>http://ultimatepp.org</uri>, last access: 2 February 2021).</p>
</sec>
<sec id="Ch1.S3.SS1.SSS2">
  <label>3.1.2</label><title>Python wrapper and integration with model auto-calibration and uncertainty
analysis packages</title>
      <p id="d1e484">Users can interact with compiled Mobius models using a Python wrapper.
Python is a high-level programming language well suited to rapid development
and prototyping, as well as being more accessible to domain scientists than
compiled languages such as FORTRAN or C++. Python also offers a wide
range of additional packages, including tools for model optimisation,
calibration, and uncertainty analysis. ODE-based models implemented in
“pure” Python often suffer from poor performance. By implementing the
model using Mobius and communicating with it via the Python wrapper, users
can therefore benefit from both the performance of C++ and the
flexibility and modules available in Python. Although the wrapper adds a
small computational overhead, it generally offers excellent performance
because for most ODE-based models with realistic levels of complexity, the
main performance bottleneck will be running the model itself and not
communicating through the Python interface.</p>
      <p id="d1e487">The wrapper makes it easy for users to modify input time series and
parameter values, run the model, and extract time series of results. This
makes it convenient to script many types of sensitivity and uncertainty
analysis setups that are reusable across different models. Functions are
provided for plotting and visualising outputs, and for calculating a range
of commonly used goodness-of-fit statistics. It is also straightforward to
connect Mobius models to other tools in the Python ecosystem and to
parallelise multiple model runs across many processes or cores. For example,
auto-calibration can be implemented by defining a Python function to update
parameter values, run the model, and return an appropriate summary of the
results (such as the sum of squared errors). This “loss function” can then
be minimised using any of the tools available via Python.</p>
      <p id="d1e490">The current Python wrapper provides access to generic functions to aid model
auto-calibration and uncertainty estimation. Key dependencies are the Python
packages lmfit (Newville et al., 2014) and emcee
(Foreman-Mackey et al., 2013). Lmfit offers a
consistent interface to a range of optimisers (Levenberg–Marquardt,
Nelder–Mead, etc.) as well as providing a “Parameters” class that allows
users to define plausible parameter ranges (e.g. “priors” in the context
of a Bayesian analysis) and choose which model parameters should be
varied and which fixed. Auto-calibration using lmfit is typically fast and
most optimisers return estimates of confidence intervals for the fitted
parameters. It therefore provides an excellent starting point for further
investigation. For more complex models with potentially multi-modal
likelihoods or posterior distributions, or for users wishing to<?pagebreak page1890?> explore
parameter-related uncertainty in more detail (e.g. by explicitly specifying
a likelihood function), emcee provides a state-of-the-art Markov chain Monte
Carlo (MCMC) algorithm based on the affine-invariant ensemble sampler
(Goodman and Weare, 2010). Emcee's ensemble sampler supports
various methods for parallelisation and is well-suited to exploring the
complicated and inhomogeneous posterior distributions characteristic of many
ODE-based environmental models. Although more computationally intensive than
optimisation, sampling using MCMC provides much richer information
describing the (Bayesian) posterior probability of the model's parameters,
given the calibration dataset and the underlying assumptions. The Python
wrapper includes functions for visualising MCMC chains and creating “corner
plots” of the posterior distribution, which provide valuable diagnostic
information that can be used to inform iterative refinement of the model
structure within the core Mobius framework. We give examples of how this can
be used in Sect. 3.2.4.</p>
      <p id="d1e493">A convenient approach to interacting with Mobius models via the Python
wrapper is to use Jupyter Notebooks (Kluyver et al., 2016),
which provide an effective platform for well-documented, shareable, and
reproducible modelling workflows. The Mobius GitHub repository (see Sect. 5) provides example code illustrating how to
interact with models via the Python wrapper, including auto-calibration of
the nutrient model SimplyP (see the “PythonWrapper<inline-formula><mml:math id="M12" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>SimplyP<inline-formula><mml:math id="M13" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>simplyp_calibration.ipynb” file in the
repository).</p>
</sec>
</sec>
<sec id="Ch1.S3.SS2">
  <label>3.2</label><title>Rapid model development – a case study</title>
      <p id="d1e519">We now demonstrate how Mobius can be used to easily build a variety of model
structures and then how the tools made available through the Python wrapper
can be used to decide on an appropriate model structure for a particular
study area, given the observed data available. To illustrate this, we will
develop some simple example alternative model structures to simulate daily
river dissolved organic carbon (DOC) concentrations in a small upland
catchment in Norway. Stream DOC concentrations have been rising in recent
decades in many regions around the world due to a combination of recovery
from acidification and climate change (Monteith et al., 2007; de Wit et al.,
2016) and model predictions of potential future changes are of interest in
terms of drinking water quality, carbon cycling, and climate feedbacks.</p>
<?pagebreak page1891?><sec id="Ch1.S3.SS2.SSS1">
  <label>3.2.1</label><title>Case study site and data for model selection</title>
      <p id="d1e529">The study site is a small stream and associated catchment in southeast
Norway, one of the main inlets to the lake Langtjern (510–750 m a.s.l.;
60.371<inline-formula><mml:math id="M14" display="inline"><mml:msup><mml:mi/><mml:mo>∘</mml:mo></mml:msup></mml:math></inline-formula> N, 9.727<inline-formula><mml:math id="M15" display="inline"><mml:msup><mml:mi/><mml:mo>∘</mml:mo></mml:msup></mml:math></inline-formula> E). The catchment has an area of 0.8 km<inline-formula><mml:math id="M16" display="inline"><mml:msup><mml:mi/><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:math></inline-formula> and land cover
is 80 % pine forest on thin mineral soils and 20 % bog on deeper peat.
Mean annual temperature, precipitation, and discharge (1986–2015) are
2.5 <inline-formula><mml:math id="M17" display="inline"><mml:msup><mml:mi/><mml:mo>∘</mml:mo></mml:msup></mml:math></inline-formula>C, 901, and 650 mm, respectively.</p>
      <p id="d1e568">Water discharge and DOC observations were used for model selection.
Discharge is difficult to simulate in this catchment, due to a combination
of short water residence times and a flashy hydrology, and uncertainty in
the observed discharge (which until 2014 was
based on a water balance for the lake; see de Wit et al., 2018) is high.
Since 1986, stream water grab samples have been collected weekly to monthly
and analysed for total organic carbon (TOC)
(see de Wit et al.,
2014, for details of sampling methods and chemical analysis). In this
catchment, TOC is essentially equivalent to DOC. Starting in August 2014,
there is also daily soil temperature data (at 15 and 20 cm depths).</p>
</sec>
<sec id="Ch1.S3.SS2.SSS2">
  <label>3.2.2</label><title>General model setup</title>
      <p id="d1e579">The modelling aim is to reproduce long-term daily in-stream DOC
concentrations rather than a detailed carbon balance. All DOC model versions
are built on a common hydrology module, SimplyQ, which was developed for
SimplyP (Jackson-Blake et al., 2017),
excluding the deeper soil flow path. In brief, water and associated DOC may
be transported from the land to the stream via “quick” flow (infiltration
and saturation excess overland flow and deeper bypass flow) and/or shallow
soil water flow, which is somewhat slower. DOC fluxes to the stream are
therefore simply via soil water flow, given by <inline-formula><mml:math id="M18" display="inline"><mml:mrow><mml:msub><mml:mi>Q</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>,
and via quick flow, as <inline-formula><mml:math id="M19" display="inline"><mml:mrow><mml:msub><mml:mi>Q</mml:mi><mml:mi mathvariant="normal">quick</mml:mi></mml:msub><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, where <inline-formula><mml:math id="M20" display="inline"><mml:mrow><mml:msub><mml:mi>Q</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is
soil water flow, <inline-formula><mml:math id="M21" display="inline"><mml:mrow><mml:msub><mml:mi>Q</mml:mi><mml:mi mathvariant="normal">quick</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the quick flow, and <inline-formula><mml:math id="M22" display="inline"><mml:mrow><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is
the soil water DOC concentration. Soil water and quick flow vary through
time as a function of precipitation, evapotranspiration, soil moisture
levels and runoff to the stream. The factors that control the variation
through time of <inline-formula><mml:math id="M23" display="inline"><mml:mrow><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> are investigated through the model
selection process described below. As there are no upstream inputs in our
study area, the mixing of these different water sources gives the in-stream
DOC concentration.</p>
      <p id="d1e675">Models were run for the period from 1986–2016 using input meteorological data
(air temperature and precipitation) from a local weather station operated by
<uri>http://met.no</uri>, last access: 20 January 2020, the Norwegian Meteorological Institute.</p>

<?xmltex \floatpos{t}?><table-wrap id="Ch1.T1" specific-use="star"><?xmltex \currentcnt{1}?><label>Table 1</label><caption><p id="d1e684">DOC-related parameters used in the various simple carbon model
structures explored.</p></caption><oasis:table frame="topbot"><oasis:tgroup cols="3">
     <oasis:colspec colnum="1" colname="col1" align="left"/>
     <oasis:colspec colnum="2" colname="col2" align="left"/>
     <oasis:colspec colnum="3" colname="col3" align="right"/>
     <oasis:thead>
       <oasis:row rowsep="1">
         <oasis:entry colname="col1">Parameter</oasis:entry>
         <oasis:entry colname="col2">Symbol</oasis:entry>
         <oasis:entry colname="col3">Model structure</oasis:entry>
       </oasis:row>
     </oasis:thead>
     <oasis:tbody>
       <oasis:row>
         <oasis:entry colname="col1">Baseline soil water DOC concentration</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M24" display="inline"><mml:mrow><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">1–6</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Soil temperature DOC concentration linear response coefficient</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M25" display="inline"><mml:mrow><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">1–6</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Soil temperature DOC concentration second-order response coefficient</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M26" display="inline"><mml:mrow><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">2–6</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Soil carbon solubility response to <inline-formula><mml:math id="M27" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup></mml:mrow></mml:math></inline-formula> deposition</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M28" display="inline"><mml:mrow><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn></mml:msub></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">3–6</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Snow melt DOC concentration</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M29" display="inline"><mml:mrow><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">melt</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">4</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Equilibration speed factor</oasis:entry>
         <oasis:entry colname="col2"><inline-formula><mml:math id="M30" display="inline"><mml:mrow><mml:msub><mml:mi>c</mml:mi><mml:mi mathvariant="normal">eq</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula></oasis:entry>
         <oasis:entry colname="col3">6</oasis:entry>
       </oasis:row>
     </oasis:tbody>
   </oasis:tgroup></oasis:table></table-wrap>

</sec>
<sec id="Ch1.S3.SS2.SSS3">
  <label>3.2.3</label><title>Carbon model structures</title>
      <p id="d1e888">The model development process starts with a statistical exploration of the
observed data and knowledge of the literature, and these together are used
to generate a list of potential processes to include and different possible
formulations for a given process. These are then translated into a range of
model structures. In this example, a strong correlation was found between
observed stream DOC concentration and modelled soil temperature, but there
are questions as to the appropriate representation of this process, and
longer-term processes and hydrological effects such as snowmelt dilution may
also be important. To this end, six model structures were developed (the
DOC-related model parameters are defined in Table 1):
<list list-type="order"><list-item>
      <p id="d1e893">Simple linear relationship between soil water DOC concentration and soil
temperature. The linear relationship describes an empirical relationship
between equilibrium soil water DOC concentration and soil temperature,
<inline-formula><mml:math id="M31" display="inline"><mml:mrow><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>:<disp-formula id="Ch1.E2" content-type="numbered"><label>2</label><mml:math id="M32" display="block"><mml:mrow><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msub><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub><mml:mo>.</mml:mo></mml:mrow></mml:math></disp-formula>Soil temperature is computed based on air temperature using a simplified
version of the Rankinen soil temperature model
(Rankinen et al., 2004). We assume
that the DOC concentration reaches equilibrium instantly.</p></list-item><list-item>
      <p id="d1e958">More complex relationship between soil water DOC concentration and soil
temperature than structure 1, a second-degree polynomial:<disp-formula id="Ch1.E3" content-type="numbered"><label>3</label><mml:math id="M33" display="block"><mml:mrow><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:mo>(</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msub><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub><mml:mo>.</mml:mo></mml:mrow></mml:math></disp-formula></p></list-item><list-item>
      <p id="d1e1027">The observed DOC time series shows a long-term trend that is not explained
by soil temperature, but which other studies have suggested is due to
recovery from soil water acidification
(Futter and de
Wit, 2008; Monteith et al., 2007). To test the importance of this process,
we use yearly means of measured stream <inline-formula><mml:math id="M34" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup></mml:mrow></mml:math></inline-formula>
concentration as a proxy for soil water acidification and add a linear
dependence of DOC concentration on <inline-formula><mml:math id="M35" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup></mml:mrow></mml:math></inline-formula> concentration:<disp-formula id="Ch1.E4" content-type="numbered"><label>4</label><mml:math id="M36" display="block"><mml:mtable columnspacing="1em" class="split" rowspacing="0.2ex" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:mo>(</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msub><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mo>-</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn></mml:msub></mml:mrow></mml:msub><mml:mo>[</mml:mo><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup><mml:mo>]</mml:mo><mml:mo>.</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>Note that in an operational model, this would need replacing with
<inline-formula><mml:math id="M37" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup></mml:mrow></mml:math></inline-formula> concentration in deposition (which should be well
correlated with stream water <inline-formula><mml:math id="M38" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup></mml:mrow></mml:math></inline-formula> concentration) to
allow for future predictions.</p></list-item><list-item>
      <p id="d1e1194">There are visible short-term decreases in the stream DOC concentration
during snow melt, likely due to source exhaustion and dilution. In this
structure, we attempt to simulate this by introducing a separate parameter
for the snow melt DOC concentration:<disp-formula id="Ch1.E5" content-type="numbered"><label>5</label><mml:math id="M39" display="block"><mml:mtable rowspacing="0.2ex" class="split" columnspacing="1em" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mo>(</mml:mo><mml:mtext>quick DOC flux</mml:mtext><mml:mo>)</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:msub><mml:mi>Q</mml:mi><mml:mrow><mml:mi mathvariant="normal">quick</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">melt</mml:mi></mml:mrow></mml:msub><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">melt</mml:mi></mml:msub></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mo>+</mml:mo><mml:msub><mml:mi>Q</mml:mi><mml:mrow><mml:mi mathvariant="normal">quick</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">rain</mml:mi></mml:mrow></mml:msub><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>.</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula></p></list-item><list-item>
      <p id="d1e1259">Starting from structure 3, replace the soil temperature model by the
Lindström model (Lindström et al., 2002)
to see if the effect of the choice of soil temperature model is important.</p></list-item><list-item>
      <p id="d1e1263">Instead of assuming instant equilibration of soil water DOC concentration,
add equilibration as a delayed process. We add a state variable
<inline-formula><mml:math id="M40" display="inline"><mml:mrow><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">eq</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>, which obeys the same equation as <inline-formula><mml:math id="M41" display="inline"><mml:mrow><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> in the formulation from structure 3. We then let
DOC mass in the soil move toward the point where equilibrium is satisfied:<disp-formula specific-use="gather" content-type="numbered"><mml:math id="M42" display="block"><mml:mtable displaystyle="true"><mml:mlabeledtr id="Ch1.E6"><mml:mtd><mml:mtext>6</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mtable rowspacing="0.2ex" class="split" columnspacing="1em" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:msub><mml:mfenced close="]" open="["><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">eq</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:mo>(</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>T</mml:mi><mml:mo>,</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msub><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:msub><mml:mi>T</mml:mi><mml:mi mathvariant="normal">soil</mml:mi></mml:msub></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mo>-</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn></mml:msub></mml:mrow></mml:msub><mml:mo>[</mml:mo><mml:msubsup><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>-</mml:mo></mml:mrow></mml:msubsup><mml:mo>]</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="Ch1.E7"><mml:mtd><mml:mtext>7</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:msub><mml:mi mathvariant="normal">dDOC</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow><mml:mrow><mml:mi mathvariant="normal">d</mml:mi><mml:mi>t</mml:mi></mml:mrow></mml:mfrac></mml:mstyle><mml:mo>=</mml:mo><mml:msub><mml:mi>c</mml:mi><mml:mi mathvariant="normal">eq</mml:mi></mml:msub><mml:mfenced close=")" open="("><mml:mrow><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">eq</mml:mi></mml:mrow></mml:msub><mml:mo>-</mml:mo><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:mfenced><mml:mo>-</mml:mo><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:msub><mml:mi>Q</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="Ch1.E8"><mml:mtd><mml:mtext>8</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mo>[</mml:mo><mml:mi mathvariant="normal">DOC</mml:mi><mml:msub><mml:mo>]</mml:mo><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi mathvariant="normal">DOC</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>/</mml:mo><mml:msub><mml:mi>V</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mlabeledtr></mml:mtable></mml:math></disp-formula>where <inline-formula><mml:math id="M43" display="inline"><mml:mrow><mml:msub><mml:mi>V</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the modelled soil water volume and <inline-formula><mml:math id="M44" display="inline"><mml:mrow><mml:msub><mml:mi>c</mml:mi><mml:mi mathvariant="normal">eq</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the
equilibration speed factor.</p></list-item></list>
Going from one structure to the next typically involves just a few lines of
code (see code and data for this experiment in the Mobius repository;
application files for compiling models, input data files, and parameter files
are in the “Applications<inline-formula><mml:math id="M45" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>SimplyC_paper”
subfolder, while module files containing the definitions of each structure
(inputs, parameters, and equations) are in the “Modules<inline-formula><mml:math id="M46" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>Alternate_versions_of_simplyC” subfolder).</p>
</sec>
<?pagebreak page1892?><sec id="Ch1.S3.SS2.SSS4">
  <label>3.2.4</label><title>Model comparison and selection of the most appropriate structure</title>
      <p id="d1e1546">The model structures were calibrated using data from the period 1986–2003.
The calibrations were then evaluated on data from the period 2004–2016. All
auto-calibrations were performed using the implementation of the Nelder–Mead
algorithm in the Python lmfit package, described in Sect. 3.1.2. We auto-calibrated the hydrology module
separately first and fixed the hydrology parameters for all subsequent
calibrations of the DOC-related parameters. It is possible to calibrate for
hydrology and DOC at the same time, but in this particular experiment we
decided to simplify the parameter space to only those parameters relating to
DOC, to allow more targeted model selection. The two soil temperature
modules used were also calibrated just once each against the more limited
soil temperature data available.</p>
      <p id="d1e1549">For each model structure in order:
<list list-type="order"><list-item>
      <p id="d1e1554">We manually calibrated the DOC-related parameters. If applicable, manual
calibration used the parameter values from the auto-calibration of the
previous structure as a starting point. The manual calibration targeted the
Nash–Sutcliffe coefficient as the goodness-of-fit statistic.</p></list-item><list-item>
      <p id="d1e1558">Auto-calibration was run using the manual calibration as a starting point.
The auto-calibration algorithm uses a least squares fitness measure. In
terms of finding optimal parameters, this is equivalent to optimising for
the Nash–Sutcliffe coefficient.</p></list-item></list>
Auto-calibration of models written in the Mobius framework is fast due to
the fast run speeds of the models. The longest time needed to auto-calibrate
any of these structures was 189 s (time depended on the number of
parameters calibrated; see more on benchmarking in Sect. 3.3). This aids with quick evaluation of new model
structures.</p>

<?xmltex \floatpos{t}?><table-wrap id="Ch1.T2"><?xmltex \currentcnt{2}?><label>Table 2</label><caption><p id="d1e1565">Goodness of fit (Nash–Sutcliffe coefficient) obtained for stream
DOC concentration using the six model structures and number of parameters
relating to DOC processes and soil <inline-formula><mml:math id="M47" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> (parameters based on well-constrained
physically measured quantities are excluded). Nash–Sutcliffe values of 1
indicate a perfect fit; values of 0 suggest the model is no better a
predictor than the mean of the observations.</p></caption><oasis:table frame="topbot"><oasis:tgroup cols="5">
     <oasis:colspec colnum="1" colname="col1" align="left"/>
     <oasis:colspec colnum="2" colname="col2" align="right"/>
     <oasis:colspec colnum="3" colname="col3" align="right" colsep="1"/>
     <oasis:colspec colnum="4" colname="col4" align="right"/>
     <oasis:colspec colnum="5" colname="col5" align="right"/>
     <oasis:thead>
       <oasis:row>
         <oasis:entry colname="col1">Model structure</oasis:entry>
         <oasis:entry namest="col2" nameend="col3" align="center" colsep="1">Goodness of fit </oasis:entry>
         <oasis:entry namest="col4" nameend="col5" align="center">Number of </oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1"/>
         <oasis:entry rowsep="1" namest="col2" nameend="col3" align="center" colsep="1"/>
         <oasis:entry rowsep="1" namest="col4" nameend="col5" align="center">parameters </oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1"/>
         <oasis:entry colname="col2">Calibration</oasis:entry>
         <oasis:entry colname="col3">Validation</oasis:entry>
         <oasis:entry colname="col4">DOC</oasis:entry>
         <oasis:entry colname="col5">Soil</oasis:entry>
       </oasis:row>
       <oasis:row rowsep="1">
         <oasis:entry colname="col1"/>
         <oasis:entry colname="col2">(1986–2003)</oasis:entry>
         <oasis:entry colname="col3">(2004–2016)</oasis:entry>
         <oasis:entry colname="col4"/>
         <oasis:entry colname="col5"><inline-formula><mml:math id="M48" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula></oasis:entry>
       </oasis:row>
     </oasis:thead>
     <oasis:tbody>
       <oasis:row>
         <oasis:entry colname="col1">1</oasis:entry>
         <oasis:entry colname="col2">0.51</oasis:entry>
         <oasis:entry colname="col3">0.50</oasis:entry>
         <oasis:entry colname="col4">2</oasis:entry>
         <oasis:entry colname="col5">2</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">2</oasis:entry>
         <oasis:entry colname="col2">0.65</oasis:entry>
         <oasis:entry colname="col3">0.61</oasis:entry>
         <oasis:entry colname="col4">3</oasis:entry>
         <oasis:entry colname="col5">2</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">3</oasis:entry>
         <oasis:entry colname="col2">0.67</oasis:entry>
         <oasis:entry colname="col3">0.62</oasis:entry>
         <oasis:entry colname="col4">4</oasis:entry>
         <oasis:entry colname="col5">2</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">4</oasis:entry>
         <oasis:entry colname="col2">0.67</oasis:entry>
         <oasis:entry colname="col3">0.62</oasis:entry>
         <oasis:entry colname="col4">5</oasis:entry>
         <oasis:entry colname="col5">2</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">5</oasis:entry>
         <oasis:entry colname="col2">0.65</oasis:entry>
         <oasis:entry colname="col3">0.63</oasis:entry>
         <oasis:entry colname="col4">4</oasis:entry>
         <oasis:entry colname="col5">3</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">6</oasis:entry>
         <oasis:entry colname="col2">0.64</oasis:entry>
         <oasis:entry colname="col3">0.62</oasis:entry>
         <oasis:entry colname="col4">5</oasis:entry>
         <oasis:entry colname="col5">3</oasis:entry>
       </oasis:row>
     </oasis:tbody>
   </oasis:tgroup></oasis:table></table-wrap>

      <p id="d1e1767">Goodness-of-fit statistics from the automatic calibrations of each of the
six model structures are given in Table 2,<?pagebreak page1893?> together
with the number of calibrated DOC-related parameters. A plot of the observed
vs. modelled stream DOC concentration using the auto-calibrated parameter
sets for structures 1, 3, and 5 is shown in Fig. 2.</p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F2" specific-use="star"><?xmltex \currentcnt{2}?><?xmltex \def\figurename{Figure}?><label>Figure 2</label><caption><p id="d1e1772">Time series of observed and modelled stream dissolved organic
carbon (DOC) concentration (model structures 1, 3, and 5; auto-calibrated
parameters).</p></caption>
            <?xmltex \igopts{width=483.69685pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021-f02.png"/>

          </fig>

      <p id="d1e1781">Visually, the results are good overall, but all structures fail to capture
high DOC concentrations during some summers. The improvement of fit from
structure 1 to 2 is obvious (Table 2), as structure 2 allows for a more flexible relationship between soil temperature and soil
water DOC concentration, and this relationship is a strong determining factor
for stream DOC concentration in this catchment. The improvement from
structure 2 to 3 is not as large, but structure 3 does capture long-term
trends a little better – in structure 2 there is a long-term trend in the
residuals that disappears in structure 3 (data not shown).</p>
      <p id="d1e1784">Adding snow melt dilution in structure 4 does not give a significant
improvement of fit. This is possibly because the snow model used is simple
and not constrained by observed snow levels, so that the timing of the snow
melt may be off. Moreover, snow melt happens during a short time span and
so will not register as strongly when just calibrating for DOC
concentrations. If one also calibrated for total DOC fluxes, it would be
more prominent due to the high water flow during snow melt, which would be
something to explore further for an operational model. Changing the soil
temperature model in structure 5 obtains a better fit for soil temperature,
but the stream DOC fit was relatively unchanged, probably because
differences in modelled soil temperature could be compensated for by
variations in the parameters that determine soil DOC response to soil
temperature. Structure 6 captures melt dilution better, but it creates too
much noise in the signal the rest of the year. Calibrating for
goodness of fit tends to adjust the <inline-formula><mml:math id="M49" display="inline"><mml:mrow><mml:msub><mml:mi>c</mml:mi><mml:mi mathvariant="normal">eq</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> parameter to be very high so
that equilibration is almost instant (i.e. the model is close to equivalent
to earlier formulations).</p>
      <p id="d1e1798">Out of the six structures, model 5 performed marginally best during
validation but had two additional parameters compared to structure 3.
Overall, structure 3 seems to be the most appropriate given the observed
data, offering the best compromise between model performance (particularly
during validation) and complexity. More work would be needed to arrive at an
operational model and a more formal model selection process using, e.g. a
Bayesian approach would also be possible
(e.g. Marshall et al., 2005). However,
hopefully this exercise serves to illustrate the relative ease with which
model development can be carried out and alternative structures quickly
explored.</p>
      <p id="d1e1802">To explore how well-constrained parameters in structure 3 are by the
observed data, and also to explore any parameter covariance, we then used
the emcee algorithm (see Sect. 3.1.2) to generate
a sample of the posterior distribution of structure 3 and associated
marginal posteriors of the parameters. The model run interval was the same
as the earlier calibration interval. The sampler was run with 100 chains for
1000 steps, each with a burn-in of 100 steps, and showed good convergence. A
heteroscedastic Gaussian error structure was used, where the standard
deviation of the likelihood at each point in time is assumed to be equal to
a Bayesian error parameter (<inline-formula><mml:math id="M50" display="inline"><mml:mrow><mml:msub><mml:mtext>err</mml:mtext><mml:mi mathvariant="normal">DOC</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>) multiplied by the
simulated value at that point. A corner plot of the results
(Fig. 3) shows that the parameters are well
constrained by the observed data – which is desirable in a model – and gives
an idea of the probable range of each parameter, represented as the 95 %
“credible interval” on each marginal histogram. Clear covariance between
<inline-formula><mml:math id="M51" display="inline"><mml:mrow><mml:msub><mml:mfenced open="[" close="]"><mml:mi mathvariant="normal">DOC</mml:mi></mml:mfenced><mml:mrow><mml:mi mathvariant="normal">s</mml:mi><mml:mo>,</mml:mo><mml:mi mathvariant="normal">base</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M52" display="inline"><mml:mrow><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:msub><mml:mi mathvariant="normal">SO</mml:mi><mml:mn mathvariant="normal">4</mml:mn></mml:msub></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> is also apparent.</p>

      <?xmltex \floatpos{t}?><fig id="Ch1.F3" specific-use="star"><?xmltex \currentcnt{3}?><?xmltex \def\figurename{Figure}?><label>Figure 3</label><caption><p id="d1e1850">Corner plot of the marginal posterior distributions of DOC-related
parameters in model structure 3. Sampled using the emcee algorithm.</p></caption>
            <?xmltex \igopts{width=412.564961pt}?><graphic xlink:href="https://gmd.copernicus.org/articles/14/1885/2021/gmd-14-1885-2021-f03.png"/>

          </fig>

</sec>
</sec>
<sec id="Ch1.S3.SS3">
  <label>3.3</label><title>Benchmarking of model run speeds</title>
      <p id="d1e1868">For benchmarking, we created a hard-coded test model in C++ (i.e. the
model code was written without using a framework) and a mathematically
equivalent model in Mobius. The model was a simple hydrological model
(SimplyQ; Jackson-Blake et al., 2017)
and we verified that the two implementations produced the same results up to
numerical error. The hard-coded model had a straightforward implementation
and was not excessively optimised using advanced techniques such as single
instruction multiple data (SIMD) or optimisation of cache locality, but we
assume that this is not commonly done by most researchers. A hard-coded
version of the model was also produced in Python. Results of the
benchmarking show that Mobius models have a slight performance loss compared
to hard-coded C++ models but run several orders of magnitude faster than
hard-coded Python models (Table 3). The code used in
these experiments can be found in the “Evaluation” subfolder of the Mobius
repository.</p>

<?xmltex \floatpos{t}?><table-wrap id="Ch1.T3"><?xmltex \currentcnt{3}?><label>Table 3</label><caption><p id="d1e1874">Ratio of times taken for 1000 runs of the hard-coded model versions
vs. 1000 runs of the Mobius version. Testing was done on several common
desktop machines and laptops, both under Linux and Windows.</p></caption><oasis:table frame="topbot"><oasis:tgroup cols="2">
     <oasis:colspec colnum="1" colname="col1" align="left"/>
     <oasis:colspec colnum="2" colname="col2" align="left"/>
     <oasis:thead>
       <oasis:row rowsep="1">
         <oasis:entry colname="col1">Hard-coded model language</oasis:entry>
         <oasis:entry colname="col2">Run speed ratio</oasis:entry>
       </oasis:row>
     </oasis:thead>
     <oasis:tbody>
       <oasis:row>
         <oasis:entry colname="col1">C++</oasis:entry>
         <oasis:entry colname="col2">0.5–0.7</oasis:entry>
       </oasis:row>
       <oasis:row>
         <oasis:entry colname="col1">Python</oasis:entry>
         <oasis:entry colname="col2">approximately 200</oasis:entry>
       </oasis:row>
     </oasis:tbody>
   </oasis:tgroup></oasis:table></table-wrap>

      <p id="d1e1919">Note that we only report the ratio of how fast the other implementations run
compared to the Mobius implementation, since that is what shows the
comparative advantage or disadvantage of using Mobius when it comes to model
run speed. This ratio is relatively stable across the machines we tried (for
instance an Intel Core i5-6600K CPU 3.50 GHz and an Intel Core i5-8350U CPU
1.70 GHz).</p>
</sec>
</sec>
<sec id="Ch1.S4" sec-type="conclusions">
  <label>4</label><title>Discussion and outlook</title>
      <p id="d1e1931">Mobius aims to be a framework for rapid development of hydrological and
biogeochemical models and other models based on ODE and discrete time step
equations. Model<?pagebreak page1894?> development should be fast and flexible, and models should
run quickly. The aim is for Mobius to be a virtual environmental laboratory
for researchers to test their hypotheses about natural processes using
quantifiable data.</p>
      <p id="d1e1934">Each component of the Mobius framework targets a different user group:
<list list-type="bullet"><list-item>
      <p id="d1e1939">Practitioners with little or no programming experience can use MobiView to
manually calibrate and apply existing models that have been built by other
users.</p></list-item><list-item>
      <p id="d1e1943">Researchers with basic programming skills can use the Python wrapper to
perform sophisticated model auto-calibration and uncertainty assessments,
make predictions under uncertainty, and consider whether model process
representations are adequate.</p></list-item><list-item>
      <p id="d1e1947">Researchers and developers with more advanced programming skills can use all
components of the framework to iteratively calibrate, evaluate, and refine
process representations and/or make ensemble simulations from a range of
model structures.</p></list-item></list>
We find that Mobius satisfies its aims for a large range of models. More
complicated models than the one described in Sect. 3.2 can be found in the Mobius repository (see
Sect. 5). The automatic model structure
generation and the optimisation and visualisation tools allow the user to
quickly formulate models and test them without having to do technical
programming.</p>
      <p id="d1e1951">With models that have more complicated process descriptions (many equations)
or rely on many different compartments or index sets, it can take some more
training to use Mobius correctly. This is because it takes training to
create dependencies between index sets, parameters, and equations that will
create the intended structure. It may also take some experimenting with the
model design to understand what index sets a model should use. To help with
this, we have included many helpful debugging facilities such as detailed
error messages, printouts of the generated structure, and other statistics.
There is also a detailed user manual and many existing examples.</p>
      <p id="d1e1954">Since the code that computes the state variables should be factored out as
separate code pieces that can be evaluated in order, we find that Mobius is
not that suitable for models where simultaneous computation of several state
variables is needed (unless they can be described as a system of ODEs, which
is well supported). This can happen when using certain linear algebra
operations or when doing computations where several iterations are needed
per time step in order to, e.g. compute an equilibrium of many chemical
compounds. It is possible to build such models in Mobius (the value of other
state variables can be set from a single code piece), but the framework is
not as helpful with this type of model.</p>
      <p id="d1e1958">There is a performance drawback of evaluating equation code through lambdas
that are stored in an array, which is how Mobius stores the equation code,
as that requires calling this code through function pointers. This is
difficult for the compiler to optimise and can cause cache misses. A way to
improve this would be to instead have a code generator that generates the
model run structure as program code based on the model specification code,
which is then compiled separately. The drawback of doing it that way is that
it forces the framework creators to maintain their own parser for the model
specification code, and it would make the model structure non-malleable
after compilation.</p>
      <p id="d1e1961">There are a few other technical limitations in the current implementation:
<list list-type="bullet"><list-item>
      <p id="d1e1966">Strong two-way links (such as two-way fluxes) between different instances of
the same equation batch are not<?pagebreak page1895?> well supported, though workarounds are
possible in simple cases. For instance, it would currently be difficult to
build grid-based models with an ODE-based two-way diffusion of quantities
between neighbouring cells (assuming the number of cells is not fixed by the
model). This is related to the next limitation.</p></list-item><list-item>
      <p id="d1e1970">ODE equations in the same batch can be solved as one coupled ODE system for
each index in the index set of the batch. But it is currently not possible
to solve a coupled system consisting of multiple indexes at the same time.
Instead, they must be solved as separate systems. This limitation only
applies when using the automatic distribution of equations over indexes. If
one instead manually codes every instance of the equations, this limitation
is circumvented, but the flexibility of using the automatic indexing system
is removed.</p></list-item><list-item>
      <p id="d1e1974">Coupling between different Mobius modules works well, and the model
interaction API can be used to couple Mobius models to models not built in
Mobius. However, currently it is not possible to have per-time step
interaction between Mobius models and external models. Either the entire
Mobius model must be run first to then use its outputs as inputs to the
other model, or the other way around.</p></list-item></list>
We hope to remove some of these limitations in the future. Indeed, Mobius is
under active development, and priorities for the near future include
expanding the range of available pre-built models (porting existing models
from elsewhere into Mobius and developing new ones), developing interfaces
for the R and Julia programming languages, and development of a statistical
model comparison framework to aid in model selection.</p>
      <p id="d1e1978">We are keen to build an open-source community of users interested in modular
open-source model development, and to that end we also plan on creating a
user forum, carrying out training workshops, and continuing the development of
on-line documentation, tutorials, and tools for easy interaction with models.</p>
      <p id="d1e1981">Overall, the Mobius framework combines cutting-edge computational speed with
sophisticated model inspection and evaluation tools. This permits
comprehensive model assessment – crucially including consideration of
structural uncertainty – without compromising performance. The framework is
freely available under a GNU Lesser General Public License (v3.0) and we
hope that by making it easier to explore a broader range of model structures
and parameterisations, users will be encouraged to build better and more
appropriate models. We believe this will in turn improve both
process understanding and practical decision making.</p>
</sec>

      
      </body>
    <back><notes notes-type="codedataavailability"><title>Code and data availability</title>

      <p id="d1e1989">The most up-to-date version of Mobius can be found at <uri>https://github.com/NIVANorge/Mobius</uri> (last access: 8 April 2021). An archived version (27 January 2020)
corresponding to the work described in this paper is available on Zenodo
<ext-link xlink:href="https://doi.org/10.5281/zenodo.3628211" ext-link-type="DOI">10.5281/zenodo.3628211</ext-link> (Norling et al., 2020). Mobius is distributed with the GNU Lesser General
Public License (v3.0). Mobius models can be compiled to work on most
platforms, and MobiView works on Windows and Linux. Pre-compiled binaries of
MobiView and selected Mobius models are available for 64-bit Windows
(download instructions are given on the Mobius GitHub front page).</p>

      <p id="d1e1998">User manuals and documentation for Mobius and MobiView are available in the
“Documentation” subfolder of the Mobius repository. See also the README
file in the repository.</p>
  </notes><notes notes-type="authorcontribution"><title>Author contributions</title>

      <p id="d1e2004">MDN developed the Mobius framework and MobiView, co-developed the Python
integration of Mobius, implemented the DOC model examples, and performed some
of the experiments with them. LAJB developed the Simply models, co-developed the DOC model example, and performed some of the experiments
with them. JES co-developed the Python integration of Mobius with the lmfit
and emcee packages. JLGC was involved in the design process of Mobius. MDN
prepared the manuscript with contributions from all co-authors.</p>
  </notes><notes notes-type="competinginterests"><title>Competing interests</title>

      <p id="d1e2010">The authors declare that they have no conflict of interest.</p>
  </notes><ack><title>Acknowledgements</title><p id="d1e2016">Mobius takes many of its design ideas from and supersedes the INCA Core
Framework developed by Dan Butterfield. The development of Mobius was
partially funded by Nordforsk “Nordic eScience Globalisation Initiative
(NeGI)” via the project “An open access, generic ePlatform for
environmental model-building at the river-basin scale” (Machu-Picchu). We
acknowledge the crucial role of Raoul M. Couture and Martyn N. Futter in
getting that project started. Mobius development was also partially funded
by the Norwegian Institute for Water Research (NIVA) and we acknowledge the
very important support that Heleen de Wit and Thorjørn Larssen provided
during development.</p></ack><notes notes-type="reviewstatement"><title>Review statement</title>

      <p id="d1e2021">This paper was edited by Adrian Sandu and reviewed by two anonymous referees.</p>
  </notes><ref-list>
    <title>References</title>

      <ref id="bib1.bib1"><label>1</label><?label 1?><mixed-citation>Ahnert, K. and Mulansky, M.: Odeint – Solving Ordinary Differential Equations in C++, AIP Conference Proceedings, 1389, 1586,  <ext-link xlink:href="https://doi.org/10.1063/1.3637934" ext-link-type="DOI">10.1063/1.3637934</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bib2"><label>2</label><?label 1?><mixed-citation>
Beven, K.: Rainfall-Runoff Modelling, The Primer, Second Edition, Wiley-Blackwell, New Jersey, 2012.</mixed-citation></ref>
      <ref id="bib1.bib3"><label>3</label><?label 1?><mixed-citation>Blair, G. S., Beven, K., Lamb, R., Bassett, R., Cauwenberghs, K., Hankin,
B., Dean, G., Hunter, N., Edwards, L., Nundloll, V., Samreen, F., Simm, W.,
and Towe, R.: Models of everywhere revisited: A technological perspective,
Environ. Model. Softw., 122, 104521, <ext-link xlink:href="https://doi.org/10.1016/j.envsoft.2019.104521" ext-link-type="DOI">10.1016/j.envsoft.2019.104521</ext-link>, 2019.</mixed-citation></ref>
      <ref id="bib1.bib4"><label>4</label><?label 1?><mixed-citation>Clark, M. P., Slater, A. G., Rupp, D. E., Woods, R. A., Vrugt, J. A., Gupta,
H. V., Wagener, T., and Hay, L. E.: Framework for Understanding Structural
Errors (FUSE): A modular framework to diagnose differences between
hydrological models, Water Resour. Res., 44, W00B02, <ext-link xlink:href="https://doi.org/10.1029/2007wr006735" ext-link-type="DOI">10.1029/2007wr006735</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bib5"><label>5</label><?label 1?><mixed-citation>Clark, M. P., Nijssen, B., Lundquist, J. D., Kavetski, D., Rupp, D. E.,
Woods, R. A., Freer, J. E., Gutmann, E. D., Wood, A. W., Brekke, L. D.,
Arnold, J. R., Gochis, D. J., and Rasmussen, R. M.: A unified approach for
process-based hydrologic modeling: 1. Modeling concept, Water Resour. Res., 51, 2498–2514,
<ext-link xlink:href="https://doi.org/10.1002/2015WR017198" ext-link-type="DOI">10.1002/2015WR017198</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bib6"><label>6</label><?label 1?><mixed-citation>de Wit, H. A., Granhus, A., Lindholm, M., Kainz, M. J., Lin, Y.,Veiteberg Braaten, H. F., and Blaszczak, J.: Forest harvest effects on mercury in streams and biota in Norwegian boreal catchments, Forest Ecol. Manag., 324, 52–63, <ext-link xlink:href="https://doi.org/10.1016/j.foreco.2014.03.044" ext-link-type="DOI">10.1016/j.foreco.2014.03.044</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bib7"><label>7</label><?label 1?><mixed-citation>de Wit, H. A., Ledesma, J. L. J., and Futter, M. N.: Aquatic DOC export from subarctic Atlantic blanket bog in Norway is controlled by seasalt deposition, temperature and precipitation, Biogeochemistry, 127, 305–321, <ext-link xlink:href="https://doi.org/10.1007/s10533-016-0182-z" ext-link-type="DOI">10.1007/s10533-016-0182-z</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bib8"><label>8</label><?label 1?><mixed-citation>de Wit, H. A., Couture, R.-M., Jackson-Blake, L., Futter, M. N., Valinia, S., Austnes, K., Guerrero, J.-L., and Lin, Y.: Pipes or chimneys? For carbon cycling in small boreal lakes, precipitation matters most, Limnol. Oceanogr. Lett., 3, 275–284, <ext-link xlink:href="https://doi.org/10.1002/lol2.10077" ext-link-type="DOI">10.1002/lol2.10077</ext-link>, 2018.</mixed-citation></ref>
      <ref id="bib1.bib9"><label>9</label><?label 1?><mixed-citation>Eddelbuettel, D. and François, R.: Rcpp: Seamless R and C++ Integration, J. Statist. Softw., 40, 1–18, <ext-link xlink:href="https://doi.org/10.18637/jss.v040.i08" ext-link-type="DOI">10.18637/jss.v040.i08</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bib10"><label>10</label><?label 1?><mixed-citation>Euser, T., Winsemius, H. C., Hrachowitz, M., Fenicia, F., Uhlenbrook, S., and Savenije, H. H. G.: A framework to assess th<?pagebreak page1897?>e realism of model structures using hydrological signatures, Hydrol. Earth Syst. Sci., 17, 1893–1912, <ext-link xlink:href="https://doi.org/10.5194/hess-17-1893-2013" ext-link-type="DOI">10.5194/hess-17-1893-2013</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bib11"><label>11</label><?label 1?><mixed-citation>Fenicia, F., Kavetski, D., and Savenije, H. H. G.: Elements of a flexible
approach for conceptual hydrological modeling: 1. Motivation and theoretical
development, Water Resour. Res., 47, W11510, <ext-link xlink:href="https://doi.org/10.1029/2010WR010174" ext-link-type="DOI">10.1029/2010WR010174</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bib12"><label>12</label><?label 1?><mixed-citation>Foreman-Mackey, D., Hogg, D. W., Lang, D., and Goodman, J.: emcee: The MCMC Hammer, Publications of the Astronomical Society of the Pacific, 125, 925, <ext-link xlink:href="https://doi.org/10.1086/670067" ext-link-type="DOI">10.1086/670067</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bib13"><label>13</label><?label 1?><mixed-citation>Futter, M. N. and de Wit, H. A.: Testing seasonal and long-term controls of streamwater DOC using empirical and process-based models,  Sci. Total Environ., 407, 698–707, <ext-link xlink:href="https://doi.org/10.1016/j.scitotenv.2008.10.002" ext-link-type="DOI">10.1016/j.scitotenv.2008.10.002</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bib14"><label>14</label><?label 1?><mixed-citation>Futter, M. N., Butterfield, D., Cosby, B. J., Dillon, P. J., Wade, A. J., and
Whitehead, P. G.: Modeling the mechanisms that control in-stream dissolved
organic carbon dynamics in upland and forested catchments, Water Resour.
Res., 43, W02424, <ext-link xlink:href="https://doi.org/10.1029/2006WR004960" ext-link-type="DOI">10.1029/2006WR004960</ext-link>, 2007.</mixed-citation></ref>
      <ref id="bib1.bib15"><label>15</label><?label 1?><mixed-citation>Futter, M. N., Erlandsson, M. A., Butterfield, D., Whitehead, P. G., Oni, S. K., and Wade, A. J.: PERSiST: a flexible rainfall-runoff modelling toolkit for use with the INCA family of models, Hydrol. Earth Syst. Sci., 18, 855–873, <ext-link xlink:href="https://doi.org/10.5194/hess-18-855-2014" ext-link-type="DOI">10.5194/hess-18-855-2014</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bib16"><label>16</label><?label 1?><mixed-citation>Goodman, J. and Weare, J.: Ensemble samplers with affine invariance, Communications in Applied Mathematics and Computer Science, 5, 65–80, <ext-link xlink:href="https://doi.org/10.2140/camcos.2010.5.65" ext-link-type="DOI">10.2140/camcos.2010.5.65</ext-link>, 2010.</mixed-citation></ref>
      <ref id="bib1.bib17"><label>17</label><?label 1?><mixed-citation>Jackson-Blake, L. A., Wade, A. J., Futter, M. N., Butterfield, D., Couture,
R. M., Cox, B., Crossman, J., Ekholm, P., Halliday, S. J., Jin, L.,
Lawrence, D. S. L., Lepistö, A., Lin, Y., Rankinen, K., and Whitehead, P.
G.: The INtegrated CAtchment model of phosphorus dynamics (INCA-P):
Description and demonstration of new model structure and equations, Environ.
Model. Softw., 83, 356–386, <ext-link xlink:href="https://doi.org/10.1016/j.envsoft.2016.05.022" ext-link-type="DOI">10.1016/j.envsoft.2016.05.022</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bib18"><label>18</label><?label 1?><mixed-citation>Jackson-Blake, L. A., Sample, J. E., Wade, A. J., Helliwell, R. C., and
Skeffington, R. A.: Are our dynamic water quality models too complex? A
comparison of a new parsimonious phosphorus model, SimplyP, and INCA-P,
Water Resour. Res., 53, 5390–5399, <ext-link xlink:href="https://doi.org/10.1002/2016WR020132" ext-link-type="DOI">10.1002/2016WR020132</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bib19"><label>19</label><?label 1?><mixed-citation>Kavetski, D. and Fenicia, F.: Elements of a flexible approach for conceptual
hydrological modeling: 2. Application and experimental insights, Water
Resour. Res., 47, W11511, <ext-link xlink:href="https://doi.org/10.1029/2011WR010748" ext-link-type="DOI">10.1029/2011WR010748</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bib20"><label>20</label><?label 1?><mixed-citation>Kirchner, J. W.: Getting the right answers for the right reasons: Linking
measurements, analyses, and models to advance the science of hydrology,
Water Resour. Res., 42, W03S04, <ext-link xlink:href="https://doi.org/10.1029/2005WR004362" ext-link-type="DOI">10.1029/2005WR004362</ext-link>, 2006.</mixed-citation></ref>
      <ref id="bib1.bib21"><label>21</label><?label 1?><mixed-citation>Kluyver, T., Ragan-Kelley, B., Pérez, F., Granger, B., Bussonnier, M., Frederic, J., Kelley, K., Hamrick, J., Grout, J., Corlay, S., Ivanov, P., Avila, D., Abdalla, S., Willing, C., and Jupyter development team: Jupyter Notebooks – a publishing format for reproducible computational workflows, in: Positioning and Power in Academic Publishing: Players, Agents and Agendas, edited by: Loizides, F. and Scmidt, B., IOS Press, Amsterdam, 87–90, <ext-link xlink:href="https://doi.org/10.3233/978-1-61499-649-1-87" ext-link-type="DOI">10.3233/978-1-61499-649-1-87</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bib22"><label>22</label><?label 1?><mixed-citation>Lindström, G., Bishop, K., and Löfvenius, M. O.: Soil frost and runoff at Svartberget, northern Sweden – measurements and model analysis, Hydrol. Process., 16, 3379–3392, <ext-link xlink:href="https://doi.org/10.1002/hyp.1106" ext-link-type="DOI">10.1002/hyp.1106</ext-link>, 2002.</mixed-citation></ref>
      <ref id="bib1.bib23"><label>23</label><?label 1?><mixed-citation>Marshall, L., Nott, D., and Sharma, A.: Hydrological model selection: A Bayesian alternative, Water Resour. Res., 41,  W10422, <ext-link xlink:href="https://doi.org/10.1029/2004WR003719" ext-link-type="DOI">10.1029/2004WR003719</ext-link>, 2005.</mixed-citation></ref>
      <ref id="bib1.bib24"><label>24</label><?label 1?><mixed-citation>Monteith, D. T., Stoddard, J. L., Evans, C. D., de Wit, H. A., Forsius, M., Høgåsen, T., Wilander, A., Skjelkvåle, B. L., Jeffries, D. S., Vuorenmaa, J., Keller, B., Kopácek, J., and Vesely, J.: Dissolved organic carbon trends resulting from changes in atmospheric deposition chemistry, Nature, 450, 537–540, <ext-link xlink:href="https://doi.org/10.1038/nature06316" ext-link-type="DOI">10.1038/nature06316</ext-link>, 2007.</mixed-citation></ref>
      <ref id="bib1.bib25"><label>25</label><?label 1?><mixed-citation>Mooij, W. M., Trolle, D., Jeppesen, E., Arhonditsis, G., Belolipetsky, P.
V., Chitamwebwa, D. B. R., Degermendzhy, A. G., DeAngelis, D. L., De
Senerpont Domis, L. N., Downing, A. S., Elliott, J. A., Fragoso, C. R.,
Gaedke, U., Genova, S. N., Gulati, R. D., Håkanson, L., Hamilton, D. P.,
Hipsey, M. R., 't Hoen, J., Hülsmann, S., Los, F. H., Makler-Pick, V.,
Petzoldt, T., Prokopkin, I. G., Rinke, K., Schep, S. A., Tominaga, K., van
Dam, A. A., van Nes, E. H., Wells, S. A., and Janse, J. H.: Challenges and
opportunities for integrating lake ecosystem modelling approaches, Aquat.
Ecol., 44, 633–667, <ext-link xlink:href="https://doi.org/10.1007/s10452-010-9339-3" ext-link-type="DOI">10.1007/s10452-010-9339-3</ext-link>, 2010.</mixed-citation></ref>
      <ref id="bib1.bib26"><label>26</label><?label 1?><mixed-citation>Nash, J. E. and Sutcliffe, J. V.: River flow forecasting through conceptual models part I – A discussion of principles, J. Hydrol., 10, 282–290, <ext-link xlink:href="https://doi.org/10.1016/0022-1694(70)90255-6" ext-link-type="DOI">10.1016/0022-1694(70)90255-6</ext-link>, 1970.</mixed-citation></ref>
      <ref id="bib1.bib27"><label>27</label><?label 1?><mixed-citation>Newville, M., Stensitzki, T., Allen, D. B., and Ingargiola, A.: LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python (Version 0.8.0), Zenodo, <ext-link xlink:href="https://doi.org/10.5281/zenodo.11813" ext-link-type="DOI">10.5281/zenodo.11813</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bib28"><label>28</label><?label 1?><mixed-citation>Norling, M., Jackson-Blake, L., and Sample, J.: NIVANorge/Mobius: Mobius paper release (Version v1.0), Zenodo, <ext-link xlink:href="https://doi.org/10.5281/zenodo.3628211" ext-link-type="DOI">10.5281/zenodo.3628211</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bib29"><label>29</label><?label 1?><mixed-citation>Sivapalan, M., Blöschl, G., Zhang, L., and Vertessy, R.: Downward
approach to hydrological prediction, Hydrol. Process., 17, 2101–2111, <ext-link xlink:href="https://doi.org/10.1002/hyp.1425" ext-link-type="DOI">10.1002/hyp.1425</ext-link>,
2003.</mixed-citation></ref>
      <ref id="bib1.bib30"><label>30</label><?label 1?><mixed-citation>Wade, A. J., Durand, P., Beaujouan, V., Wessel, W. W., Raat, K. J., Whitehead, P. G., Butterfield, D., Rankinen, K., and Lepisto, A.: A nitrogen model for European catchments: INCA, new model structure and equations, Hydrol. Earth Syst. Sci., 6, 559–582, <ext-link xlink:href="https://doi.org/10.5194/hess-6-559-2002" ext-link-type="DOI">10.5194/hess-6-559-2002</ext-link>, 2002.</mixed-citation></ref>
      <ref id="bib1.bib31"><label>31</label><?label 1?><mixed-citation>Wagener, T., Sivapalan, M., Troch, P., and Woods, R.: Catchment
Classification and Hydrologic Similarity, Geogr. Compass, 1, 901–931,
<ext-link xlink:href="https://doi.org/10.1111/j.1749-8198.2007.00039.x" ext-link-type="DOI">10.1111/j.1749-8198.2007.00039.x</ext-link>, 2007.</mixed-citation></ref>
      <ref id="bib1.bib32"><label>32</label><?label 1?><mixed-citation>Wambecq, A.: Rational Runge–Kutta methods for solving systems of ordinary differential equations, Computing, 20, 333–342, <ext-link xlink:href="https://doi.org/10.1007/BF02252381" ext-link-type="DOI">10.1007/BF02252381</ext-link>, 1978.</mixed-citation></ref>
      <ref id="bib1.bib33"><label>33</label><?label 1?><mixed-citation>Weiler, M. and Beven, K.: Do we need a Community Hydrological Model?, Water
Resour. Res., 51, 7777–7784, <ext-link xlink:href="https://doi.org/10.1002/2014WR016731" ext-link-type="DOI">10.1002/2014WR016731</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bib34"><label>34</label><?label 1?><mixed-citation>Whitehead, P. G., Wilson, E. J., and Butterfield, D.: A semi-distributed
Integrated Nitrogen model for multiple source assessment in Catchments
(INCA): Part I – Model structure and process equations, Sci. Total Environ., 210–211, 547–558,
<ext-link xlink:href="https://doi.org/10.1016/S0048-9697(98)00037-0" ext-link-type="DOI">10.1016/S0048-9697(98)00037-0</ext-link>, 1998.</mixed-citation></ref>

  </ref-list></back>
    <!--<article-title-html>Rapid development of fast and flexible environmental models: the Mobius framework v1.0</article-title-html>
<abstract-html><p>The Mobius model building system is a new open-source
framework for building fast and flexible environmental models. Mobius makes
it possible for researchers with limited programming experience to build
performant models with potentially complicated structures. Mobius models can
be easily interacted with through the MobiView graphical user interface and
through the Python programming language. Mobius was initially developed to
support catchment-scale hydrology and water-quality modelling but can be
used to represent any system of hierarchically structured ordinary
differential equations, such as population dynamics or toxicological models.
Here, we demonstrate how Mobius can be used to quickly prototype several
different model structures for a dissolved organic carbon catchment model
and use built-in auto-calibration and statistical uncertainty analysis tools
to help decide on the best model structures. Overall, we hope the modular
model building platform offered by Mobius will provide a step forward for
environmental modelling, providing an alternative to the <q>one size fits
all</q> modelling paradigm. By making it easier to explore a broader range of
model structures and parameterisations, users are encouraged to build more
appropriate models, and in turn this improves process understanding and
allows for more robust modelling in support of decision making.</p></abstract-html>
<ref-html id="bib1.bib1"><label>1</label><mixed-citation>
Ahnert, K. and Mulansky, M.: Odeint – Solving Ordinary Differential Equations in C++, AIP Conference Proceedings, 1389, 1586,  <a href="https://doi.org/10.1063/1.3637934" target="_blank">https://doi.org/10.1063/1.3637934</a>, 2011.
</mixed-citation></ref-html>
<ref-html id="bib1.bib2"><label>2</label><mixed-citation>
Beven, K.: Rainfall-Runoff Modelling, The Primer, Second Edition, Wiley-Blackwell, New Jersey, 2012.
</mixed-citation></ref-html>
<ref-html id="bib1.bib3"><label>3</label><mixed-citation>
Blair, G. S., Beven, K., Lamb, R., Bassett, R., Cauwenberghs, K., Hankin,
B., Dean, G., Hunter, N., Edwards, L., Nundloll, V., Samreen, F., Simm, W.,
and Towe, R.: Models of everywhere revisited: A technological perspective,
Environ. Model. Softw., 122, 104521, <a href="https://doi.org/10.1016/j.envsoft.2019.104521" target="_blank">https://doi.org/10.1016/j.envsoft.2019.104521</a>, 2019.
</mixed-citation></ref-html>
<ref-html id="bib1.bib4"><label>4</label><mixed-citation>
Clark, M. P., Slater, A. G., Rupp, D. E., Woods, R. A., Vrugt, J. A., Gupta,
H. V., Wagener, T., and Hay, L. E.: Framework for Understanding Structural
Errors (FUSE): A modular framework to diagnose differences between
hydrological models, Water Resour. Res., 44, W00B02, <a href="https://doi.org/10.1029/2007wr006735" target="_blank">https://doi.org/10.1029/2007wr006735</a>, 2008.
</mixed-citation></ref-html>
<ref-html id="bib1.bib5"><label>5</label><mixed-citation>
Clark, M. P., Nijssen, B., Lundquist, J. D., Kavetski, D., Rupp, D. E.,
Woods, R. A., Freer, J. E., Gutmann, E. D., Wood, A. W., Brekke, L. D.,
Arnold, J. R., Gochis, D. J., and Rasmussen, R. M.: A unified approach for
process-based hydrologic modeling: 1. Modeling concept, Water Resour. Res., 51, 2498–2514,
<a href="https://doi.org/10.1002/2015WR017198" target="_blank">https://doi.org/10.1002/2015WR017198</a>, 2015.
</mixed-citation></ref-html>
<ref-html id="bib1.bib6"><label>6</label><mixed-citation>
de Wit, H. A., Granhus, A., Lindholm, M., Kainz, M. J., Lin, Y.,Veiteberg Braaten, H. F., and Blaszczak, J.: Forest harvest effects on mercury in streams and biota in Norwegian boreal catchments, Forest Ecol. Manag., 324, 52–63, <a href="https://doi.org/10.1016/j.foreco.2014.03.044" target="_blank">https://doi.org/10.1016/j.foreco.2014.03.044</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib7"><label>7</label><mixed-citation>
de Wit, H. A., Ledesma, J. L. J., and Futter, M. N.: Aquatic DOC export from subarctic Atlantic blanket bog in Norway is controlled by seasalt deposition, temperature and precipitation, Biogeochemistry, 127, 305–321, <a href="https://doi.org/10.1007/s10533-016-0182-z" target="_blank">https://doi.org/10.1007/s10533-016-0182-z</a>, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib8"><label>8</label><mixed-citation>
de Wit, H. A., Couture, R.-M., Jackson-Blake, L., Futter, M. N., Valinia, S., Austnes, K., Guerrero, J.-L., and Lin, Y.: Pipes or chimneys? For carbon cycling in small boreal lakes, precipitation matters most, Limnol. Oceanogr. Lett., 3, 275–284, <a href="https://doi.org/10.1002/lol2.10077" target="_blank">https://doi.org/10.1002/lol2.10077</a>, 2018.
</mixed-citation></ref-html>
<ref-html id="bib1.bib9"><label>9</label><mixed-citation>
Eddelbuettel, D. and François, R.: Rcpp: Seamless R and C++ Integration, J. Statist. Softw., 40, 1–18, <a href="https://doi.org/10.18637/jss.v040.i08" target="_blank">https://doi.org/10.18637/jss.v040.i08</a>, 2011.
</mixed-citation></ref-html>
<ref-html id="bib1.bib10"><label>10</label><mixed-citation>
Euser, T., Winsemius, H. C., Hrachowitz, M., Fenicia, F., Uhlenbrook, S., and Savenije, H. H. G.: A framework to assess the realism of model structures using hydrological signatures, Hydrol. Earth Syst. Sci., 17, 1893–1912, <a href="https://doi.org/10.5194/hess-17-1893-2013" target="_blank">https://doi.org/10.5194/hess-17-1893-2013</a>, 2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib11"><label>11</label><mixed-citation>
Fenicia, F., Kavetski, D., and Savenije, H. H. G.: Elements of a flexible
approach for conceptual hydrological modeling: 1. Motivation and theoretical
development, Water Resour. Res., 47, W11510, <a href="https://doi.org/10.1029/2010WR010174" target="_blank">https://doi.org/10.1029/2010WR010174</a>, 2011.
</mixed-citation></ref-html>
<ref-html id="bib1.bib12"><label>12</label><mixed-citation>
Foreman-Mackey, D., Hogg, D. W., Lang, D., and Goodman, J.: emcee: The MCMC Hammer, Publications of the Astronomical Society of the Pacific, 125, 925, <a href="https://doi.org/10.1086/670067" target="_blank">https://doi.org/10.1086/670067</a>, 2013.
</mixed-citation></ref-html>
<ref-html id="bib1.bib13"><label>13</label><mixed-citation>
Futter, M. N. and de Wit, H. A.: Testing seasonal and long-term controls of streamwater DOC using empirical and process-based models,  Sci. Total Environ., 407, 698–707, <a href="https://doi.org/10.1016/j.scitotenv.2008.10.002" target="_blank">https://doi.org/10.1016/j.scitotenv.2008.10.002</a>, 2008.
</mixed-citation></ref-html>
<ref-html id="bib1.bib14"><label>14</label><mixed-citation>
Futter, M. N., Butterfield, D., Cosby, B. J., Dillon, P. J., Wade, A. J., and
Whitehead, P. G.: Modeling the mechanisms that control in-stream dissolved
organic carbon dynamics in upland and forested catchments, Water Resour.
Res., 43, W02424, <a href="https://doi.org/10.1029/2006WR004960" target="_blank">https://doi.org/10.1029/2006WR004960</a>, 2007.
</mixed-citation></ref-html>
<ref-html id="bib1.bib15"><label>15</label><mixed-citation>
Futter, M. N., Erlandsson, M. A., Butterfield, D., Whitehead, P. G., Oni, S. K., and Wade, A. J.: PERSiST: a flexible rainfall-runoff modelling toolkit for use with the INCA family of models, Hydrol. Earth Syst. Sci., 18, 855–873, <a href="https://doi.org/10.5194/hess-18-855-2014" target="_blank">https://doi.org/10.5194/hess-18-855-2014</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib16"><label>16</label><mixed-citation>
Goodman, J. and Weare, J.: Ensemble samplers with affine invariance, Communications in Applied Mathematics and Computer Science, 5, 65–80, <a href="https://doi.org/10.2140/camcos.2010.5.65" target="_blank">https://doi.org/10.2140/camcos.2010.5.65</a>, 2010.
</mixed-citation></ref-html>
<ref-html id="bib1.bib17"><label>17</label><mixed-citation>
Jackson-Blake, L. A., Wade, A. J., Futter, M. N., Butterfield, D., Couture,
R. M., Cox, B., Crossman, J., Ekholm, P., Halliday, S. J., Jin, L.,
Lawrence, D. S. L., Lepistö, A., Lin, Y., Rankinen, K., and Whitehead, P.
G.: The INtegrated CAtchment model of phosphorus dynamics (INCA-P):
Description and demonstration of new model structure and equations, Environ.
Model. Softw., 83, 356–386, <a href="https://doi.org/10.1016/j.envsoft.2016.05.022" target="_blank">https://doi.org/10.1016/j.envsoft.2016.05.022</a>, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib18"><label>18</label><mixed-citation>
Jackson-Blake, L. A., Sample, J. E., Wade, A. J., Helliwell, R. C., and
Skeffington, R. A.: Are our dynamic water quality models too complex? A
comparison of a new parsimonious phosphorus model, SimplyP, and INCA-P,
Water Resour. Res., 53, 5390–5399, <a href="https://doi.org/10.1002/2016WR020132" target="_blank">https://doi.org/10.1002/2016WR020132</a>, 2017.
</mixed-citation></ref-html>
<ref-html id="bib1.bib19"><label>19</label><mixed-citation>
Kavetski, D. and Fenicia, F.: Elements of a flexible approach for conceptual
hydrological modeling: 2. Application and experimental insights, Water
Resour. Res., 47, W11511, <a href="https://doi.org/10.1029/2011WR010748" target="_blank">https://doi.org/10.1029/2011WR010748</a>, 2011.
</mixed-citation></ref-html>
<ref-html id="bib1.bib20"><label>20</label><mixed-citation>
Kirchner, J. W.: Getting the right answers for the right reasons: Linking
measurements, analyses, and models to advance the science of hydrology,
Water Resour. Res., 42, W03S04, <a href="https://doi.org/10.1029/2005WR004362" target="_blank">https://doi.org/10.1029/2005WR004362</a>, 2006.
</mixed-citation></ref-html>
<ref-html id="bib1.bib21"><label>21</label><mixed-citation>
Kluyver, T., Ragan-Kelley, B., Pérez, F., Granger, B., Bussonnier, M., Frederic, J., Kelley, K., Hamrick, J., Grout, J., Corlay, S., Ivanov, P., Avila, D., Abdalla, S., Willing, C., and Jupyter development team: Jupyter Notebooks – a publishing format for reproducible computational workflows, in: Positioning and Power in Academic Publishing: Players, Agents and Agendas, edited by: Loizides, F. and Scmidt, B., IOS Press, Amsterdam, 87–90, <a href="https://doi.org/10.3233/978-1-61499-649-1-87" target="_blank">https://doi.org/10.3233/978-1-61499-649-1-87</a>, 2016.
</mixed-citation></ref-html>
<ref-html id="bib1.bib22"><label>22</label><mixed-citation>
Lindström, G., Bishop, K., and Löfvenius, M. O.: Soil frost and runoff at Svartberget, northern Sweden – measurements and model analysis, Hydrol. Process., 16, 3379–3392, <a href="https://doi.org/10.1002/hyp.1106" target="_blank">https://doi.org/10.1002/hyp.1106</a>, 2002.
</mixed-citation></ref-html>
<ref-html id="bib1.bib23"><label>23</label><mixed-citation>
Marshall, L., Nott, D., and Sharma, A.: Hydrological model selection: A Bayesian alternative, Water Resour. Res., 41,  W10422, <a href="https://doi.org/10.1029/2004WR003719" target="_blank">https://doi.org/10.1029/2004WR003719</a>, 2005.
</mixed-citation></ref-html>
<ref-html id="bib1.bib24"><label>24</label><mixed-citation>
Monteith, D. T., Stoddard, J. L., Evans, C. D., de Wit, H. A., Forsius, M., Høgåsen, T., Wilander, A., Skjelkvåle, B. L., Jeffries, D. S., Vuorenmaa, J., Keller, B., Kopácek, J., and Vesely, J.: Dissolved organic carbon trends resulting from changes in atmospheric deposition chemistry, Nature, 450, 537–540, <a href="https://doi.org/10.1038/nature06316" target="_blank">https://doi.org/10.1038/nature06316</a>, 2007.
</mixed-citation></ref-html>
<ref-html id="bib1.bib25"><label>25</label><mixed-citation>
Mooij, W. M., Trolle, D., Jeppesen, E., Arhonditsis, G., Belolipetsky, P.
V., Chitamwebwa, D. B. R., Degermendzhy, A. G., DeAngelis, D. L., De
Senerpont Domis, L. N., Downing, A. S., Elliott, J. A., Fragoso, C. R.,
Gaedke, U., Genova, S. N., Gulati, R. D., Håkanson, L., Hamilton, D. P.,
Hipsey, M. R., 't Hoen, J., Hülsmann, S., Los, F. H., Makler-Pick, V.,
Petzoldt, T., Prokopkin, I. G., Rinke, K., Schep, S. A., Tominaga, K., van
Dam, A. A., van Nes, E. H., Wells, S. A., and Janse, J. H.: Challenges and
opportunities for integrating lake ecosystem modelling approaches, Aquat.
Ecol., 44, 633–667, <a href="https://doi.org/10.1007/s10452-010-9339-3" target="_blank">https://doi.org/10.1007/s10452-010-9339-3</a>, 2010.
</mixed-citation></ref-html>
<ref-html id="bib1.bib26"><label>26</label><mixed-citation>
Nash, J. E. and Sutcliffe, J. V.: River flow forecasting through conceptual models part I – A discussion of principles, J. Hydrol., 10, 282–290, <a href="https://doi.org/10.1016/0022-1694(70)90255-6" target="_blank">https://doi.org/10.1016/0022-1694(70)90255-6</a>, 1970.
</mixed-citation></ref-html>
<ref-html id="bib1.bib27"><label>27</label><mixed-citation>
Newville, M., Stensitzki, T., Allen, D. B., and Ingargiola, A.: LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python (Version 0.8.0), Zenodo, <a href="https://doi.org/10.5281/zenodo.11813" target="_blank">https://doi.org/10.5281/zenodo.11813</a>, 2014.
</mixed-citation></ref-html>
<ref-html id="bib1.bib28"><label>28</label><mixed-citation>
Norling, M., Jackson-Blake, L., and Sample, J.: NIVANorge/Mobius: Mobius paper release (Version v1.0), Zenodo, <a href="https://doi.org/10.5281/zenodo.3628211" target="_blank">https://doi.org/10.5281/zenodo.3628211</a>, 2020.
</mixed-citation></ref-html>
<ref-html id="bib1.bib29"><label>29</label><mixed-citation>
Sivapalan, M., Blöschl, G., Zhang, L., and Vertessy, R.: Downward
approach to hydrological prediction, Hydrol. Process., 17, 2101–2111, <a href="https://doi.org/10.1002/hyp.1425" target="_blank">https://doi.org/10.1002/hyp.1425</a>,
2003.
</mixed-citation></ref-html>
<ref-html id="bib1.bib30"><label>30</label><mixed-citation>
Wade, A. J., Durand, P., Beaujouan, V., Wessel, W. W., Raat, K. J., Whitehead, P. G., Butterfield, D., Rankinen, K., and Lepisto, A.: A nitrogen model for European catchments: INCA, new model structure and equations, Hydrol. Earth Syst. Sci., 6, 559–582, <a href="https://doi.org/10.5194/hess-6-559-2002" target="_blank">https://doi.org/10.5194/hess-6-559-2002</a>, 2002.
</mixed-citation></ref-html>
<ref-html id="bib1.bib31"><label>31</label><mixed-citation>
Wagener, T., Sivapalan, M., Troch, P., and Woods, R.: Catchment
Classification and Hydrologic Similarity, Geogr. Compass, 1, 901–931,
<a href="https://doi.org/10.1111/j.1749-8198.2007.00039.x" target="_blank">https://doi.org/10.1111/j.1749-8198.2007.00039.x</a>, 2007.
</mixed-citation></ref-html>
<ref-html id="bib1.bib32"><label>32</label><mixed-citation>
Wambecq, A.: Rational Runge–Kutta methods for solving systems of ordinary differential equations, Computing, 20, 333–342, <a href="https://doi.org/10.1007/BF02252381" target="_blank">https://doi.org/10.1007/BF02252381</a>, 1978.
</mixed-citation></ref-html>
<ref-html id="bib1.bib33"><label>33</label><mixed-citation>
Weiler, M. and Beven, K.: Do we need a Community Hydrological Model?, Water
Resour. Res., 51, 7777–7784, <a href="https://doi.org/10.1002/2014WR016731" target="_blank">https://doi.org/10.1002/2014WR016731</a>, 2015.
</mixed-citation></ref-html>
<ref-html id="bib1.bib34"><label>34</label><mixed-citation>
Whitehead, P. G., Wilson, E. J., and Butterfield, D.: A semi-distributed
Integrated Nitrogen model for multiple source assessment in Catchments
(INCA): Part I – Model structure and process equations, Sci. Total Environ., 210–211, 547–558,
<a href="https://doi.org/10.1016/S0048-9697(98)00037-0" target="_blank">https://doi.org/10.1016/S0048-9697(98)00037-0</a>, 1998.
</mixed-citation></ref-html>--></article>
