Description Usage Arguments Details Value Examples

This building block describes a flow between compartments.

1 | ```
flow(definition, from = NA_character_, to = NA_character_)
``` |

`definition` |
Equation describing the flow |

`from` |
Name of the source compartment (NA for an inflow without source) |

`to` |
Name of the sink compartment (NA for an outflow without sink) |

Flows define the connections between compartments and the equations according to which exchanges occur.

The first function argument is the flow equation. It is defined using R formulas that can start with the tilde `~`

operator and do not
need to have a left-hand side (i.e., `~k0`

is a valid flow definition).

Flow equations can contains the special variables `A`

and `C`

which can be used to refer to the amount and concentration in the compartment specified via
the `from=`

argument. For example, the following code creates a flow building block describing the first-order transfer from the depot to the central
compartment

1 | ```
flow(~ka*A, "depot", "central")
``` |

When the model is rendered, `A`

and `C`

will get replaced with the corresponding compartment reference. assemblerr will raise an error if `A`

or `C`

are used
without specifying the `from=`

compartment (such as in an inflow).

The connection between compartments can be specified using the `from=`

and `to=`

arguments of the function. Setting either `from=`

or `to=`

to `NA`

allows
the definition of in and outflows without a source or sink. Setting both arguments to `NA`

results in error.

When flows are rendered they are converted to ordinary differential equations (ODEs). The connection between compartments together with the flow equations allow assemblerr to determine whether an analytic solution can be generated. This automatic optimization of differential equations can be disabled via the rendering options.

A building block of type 'flow'

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
# one-compartment model with first-order elimination
m <- model() +
prm_log_normal("v") +
prm_log_normal("cl") +
compartment("central", volume = ~v) +
flow(declaration(~cl*C), from = "central") +
obs_additive(~C["central"])
# an analytic solution is generated
render(m)
# one-compartment model with Michaelis-Menten elimination
m2 <- model() +
prm_log_normal("v") +
prm_log_normal("vmax") +
prm_no_var("km") +
compartment("central", volume = ~v) +
flow(declaration(~vmax*C/(km+C)), from = "central") +
obs_additive(~C["central"])
# an ODE is generated
render(m2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.