User Tools

Site Tools


Coupling multiple models: continuum.nano

This page is accurate as of Nanoverse v1.0.0-a6. If you are using a later version, some aspects may have changed.

This tutorial builds on the vocabulary introduced in the exponential growth example, and introduces a key feature of Nanoverse: coupling between agent layers and continuum layers.

This feature is brand new, and the idioms used to specify continuum interactions are not yet mature. Please have patience if some of the code required is a little verbose. If you have ideas or suggestions about how to make it easier to work with coupled layers, please email David.


Layers are a key feature of Nanoverse. Layers are independent simulations that share a coordinate system, and which can be coupled through ongoing or discrete relationships. The previous examples used only agent layers. The current example introduces continuum layers as well.

Layers are specified in the layers property of the project file. By default, there is a single agent layer. The user can omit the agent layer, or include it along with one or more continuum layers. The continuum.nano example has two layers: an agent layer and a continuum layer called solute.

Continuum layers require an id, which is used to identify them throughout the simulation. Users can also specify the type of continuum layer solver to use. Nanoverse currently supports only a single agent layer. If you need multiple agent layers, please email David.

All layers, both agent and continuum, have an associated boundary condition. By default, agents (and continuum values) that go beyond the edge of the world simply fall off it.


Nanoverse has an internal linear algebra library which can be used to update the state of a continuum layer. This library is based on matrix-toolkit-java and is somewhat slow.

On [wp>POSIX]]-compliant platforms (Mac and Linux), Nanoverse can also use the PETSc library. PETSc is a numerical library for scientific computing. It is significantly faster than the MTJ solver, and can solve a wider range of systems. The PETSc library is used automatically on compatible platforms.

Relating agents to continuum layers

Agents can continuously alter the state of a continuum layer through a relationship with that layer. Relationships are specified in the agent description, and alter the continuum wherever the agent is located. Agents can also make discrete, one-time changes to the continuum layer through actions, such as the Inject action.

Injection and exponentiation

The state of a continuum is updated through the application of a linear operation. As such, values can be multiplied or added at any site. Within Nanoverse, scaling the local value is called exponentiation (because it is exponentiation). Adding or subtracting a fixed amount from the local value is called injection.

Agent relationships can specify an injection amount (inj), an exponentiation amount (exp), or both. These values will be applied at the location of the agent when the layer is updated.

Units in equilibrium continuum layers

In a continuum layer with and equilibrium solver, the state of the layer is solved to steady state. This assumes that processes taking place on the continuum are infinitely fast relative to the time scale of the simulation.

This means that rates (and therefore units) don't actually matter except relative to each other. In the continuum.nano example, the agent injects 0.01 units of solute per unit time. The diffusion constant is also 0.01 units of solute per time per area. These quantities are relative to each other, but not to the simulation time scale.

Relating the other way

While agents can see the local value of a continuum, there aren't many actions that can take account of this information. (This will change with the advent of user-defined variables and arithmetic expressions, both of which are a high priority for development.) In the meantime, it is usually most straightforward to create an ad hoc action that handles continuum state exactly as desired. Please email David for more information. It's not hard, but it does require writing some Java.

Continuum processes

In addition to direct relationships between agents and continuum layers, the continuum layer can also be evolved through global continuum processes. These processes affect the state of the entire continuum. In continuum.nano, a Diffuse process subjects the entire solute layer to a diffusion process. In conjunction with the Absorbing boundary and the agent's inj relationship, this diffusion process results in a solute value that decays from a point source at the agent.

Hold and release

See "Continuum layers: hold and release."

Hold and Release help to limit the computational complexity of handling continuum processes and relationships. In between these two “meta-processes”, anything that would affect the solute layer is held up. At the Release point, all changes are applied at once, including agent relationships, incurring only one solution cycle. Note that Release can be delayed by more than one integration cycle by setting a period argument.

Visualizing continuum values

As with the previous tutorial, we wish to visualize the simulation. This time, we wish to visualize the state of the continuum. To do this, we have to specify that we want the colors of the visualization to vary with continuum value. We achieve this by setting a color model.

In the previous tutorial, we specified a number of dependent output modes in order to create our visualization. To create a continuum visualization, we must specify one more: the ContinuumStateWriter, which does exactly what its name suggests: write the continuum state to disk so that it can be used in a visualization.

continuum.txt · Last modified: 2015/11/17 12:06 by david