Config File
This documentation page is intended for the Command Line Interface (CLI). If you're new to DuneCopasi, we recommend starting with our Tutorials.
To express different mathematical problems we typically write a configuration file (with .ini
extension by convention) which entails all the information that is needed for the DuneCopasi solver to construct the problem at hand.
The configuration file consists of a parameter tree containing the simulation options. The nodes at the top level can be divided in 4 categories:
Category | Description |
---|---|
grid | The nodes under the grid header describe the basic properties of the grid. For example the dimension, extension, origin, etc. |
parser_context | Under this node we are able to define constant and functions that can be used to define the mathematical model. |
compartments | In this category we define the properties related to division of the problem to multiple compartments. |
model | This is the heart of the mathematical problem where we define the reaction terms, diffusion, etc. |
The ini files we use follow the DUNE convention. In short, the data is composed of a key鈥搗alue pairs on the form key = value
. For example, to define a property
of the category grid
we write
grid.property = value
In essence the ini file is nothing else than a parameter tree of key-value pairs. For convenience one can use sections to avoid rewriting the leading part and provide more structure. This is done by using [section.subsection]
syntax. The keys below will now be within the designated subsection. As an example, the three following ini files, are equivalent
- No grouping
- Grouping
- Nested grouping
# No preceding section (everything after a '#' will be ignored)
section.subsection.first = 1.0
section.subsection.second = 2.0
[section]
subsection.first = 1.0
subsection.second = 2.0
[section.subsection]
first = 1.0
second = 2.0
- Heat Eqs
- Volka-Terra Eqs
- Grey-Scott Eqs
#########################################################################
# HEAT EQUATION:
#
# 鈭傗倻u = 鈭傗倱(T路鈭傗倱u) + 鈭傖掸(T路鈭傖掸u)
#
# where u(x,y,t) is the temperature at a time t on the domain for a
# thermal conductivity T.
#
# See: https://en.wikipedia.org/wiki/Heat_equation
#
#########################################################################
[grid]
# extensions of the grid in x and y directions
extensions = 1 0.1
# where the grid left-bottom corner starts
origin = 0.0 0.0
# number of cells of the initial grid in x and y directions
cells = 10 1
# number of times to refine the grid
refinement_level = 5
# defines a compartment with the name "domain"
[compartments.domain]
expression = 1
# Define a constant with name "T" to use in the equations
[parser_context.T]
type = constant
value = 0.005
# our model is linear because there is no reaction
[model]
is_linear = true
##### Definition of the equation to solve function u(x,y,t) ######
# Declares the compartment where this function is defined
[model.scalar_field.u]
compartment = domain
# Declares that the equation is transient
[model.scalar_field.u.storage]
expression = 1
# Declares the diffusion part on the diffusion-reaction equation
[model.scalar_field.u.cross_diffusion.u]
expression = T
[model.scalar_field.u.initial]
# Declares the value of the function at the initial time: u(x,y,0)
# Try changing this to be a function of x and y: use "position_x" and "position_y"
# to represents its values, for example:
# "expression = position_x^2"
# represents the case where u(x,y,0) := x^2
# ...
# function for u(x,y,0)
expression = 10
# Declares the diffusion part on the diffusion-reaction equation
# Here we use the following ExprTk syntax to constraint the left and right parts of
# the compartment: "condition ? if_true : if_false"
# the "if_true" part contains the values set on the left and right boundaries
[model.scalar_field.u.constrain.boundary]
expression = (position_x <= 0. or position_x >= 1.) ? 0. : no_value
parser_type = ExprTk
[model.time_step_operator]
# initial time of the simulation
time_begin = 0
# final time of the simulation
time_end = 10
#########################################################################
# VOLKA-TERRA EQUATIONS:
#
# 鈭傗倻u = 伪路u - 尾路u路v
# 鈭傗倻v = 未路u路v - 纬路v
#
# See: https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations
#
# Note that there is not derivative on the positions x or y, so the
# functions are the same on every point in x and y for a given time t.
# Hence, we do not refine the grid at all.
#
#########################################################################
[grid]
# extensions of the grid in x and y directions
extensions = 1 1
# number of cells of the initial grid in x and y directions
cells = 1 1
# defines a compartment with the name "domain"
[compartments.domain]
expression = 1
# Define constants with name "alpha", "beta", "delta", and "gamma"
# representing 伪, 尾, 未, and 纬 respectively
[parser_context.alpha]
type = constant
value = 0.666666
[parser_context.beta]
type = constant
value = 1.33333
[parser_context.delta]
type = constant
value = 1
[parser_context.gamma]
type = constant
value = 1
# our model is linear because there is a non-linear reaction part
[model]
is_linear = false
##### Definition of the equation to solve function u(x,y,t) ######
# Declares the compartment where this function is defined
[model.scalar_field.u]
compartment = domain
# Declares that the equation is transient
[model.scalar_field.u.storage]
expression = 1
# Declares the reaction part on the diffusion-reaction equation for equation for u
[model.scalar_field.u.reaction]
expression = alpha*u - beta*u*v
# Declares the jacobian of the reaction of u
[model.scalar_field.u.reaction.jacobian.u]
# 鈭傖丹(伪路u - 尾路u路v) = 伪 - 尾路v
expression = alpha - beta*v
[model.scalar_field.u.reaction.jacobian.v]
# 鈭傖单(伪路u - 尾路u路v) = - 尾路u
expression = -beta*u
[model.scalar_field.u.initial]
# function for u(x,y,0)
expression = 1
##### Definition of the equation to solve function v(x,y,t) ######
# Declares the compartment where this function is defined
[model.scalar_field.v]
compartment = domain
# Declares that the equation is transient
[model.scalar_field.v.storage]
expression = 1
# Declares the reaction part on the diffusion-reaction equation for equation for v
[model.scalar_field.v.reaction]
expression = delta*u*v - gamma*v
# Declares the jacobian of the reaction of v
[model.scalar_field.v.reaction.jacobian.u]
# 鈭傖丹(未路u路v - 纬路v) = 未路v
expression = delta*v
[model.scalar_field.v.reaction.jacobian.v]
# 鈭傖单(未路u路v - 纬路v) = 未路u - 纬
expression = delta*u-gamma
[model.scalar_field.v.initial]
# function for v(x,y,0)
expression = 1
[model.time_step_operator]
# initial time of the simulation
time_begin = 0
# final time of the simulation
time_end = 20
# limit the maximum time-step
time_step_max = 0.25
#########################################################################
# GREY-SCOTT EQUATIONS:
#
# 鈭傗倻u = 2路D路鈭傗倱鈭傗倱u + f路(1-u) - u路v虏
# 鈭傗倻v = D路鈭傗倱鈭傗倱u - (f+k)路v + u路v虏
#
# See: https://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/
#
#########################################################################
[grid]
extensions = 1 1
dimension = 2
refinement_level = 7
[parser_context.bump]
type = function
expression = x, y: 0.5*exp(-100*(x^2 + y^2))
parser_type = ExprTk
[parser_context.F]
type = constant
value = 0.0420
[parser_context.k]
type = constant
value = 0.0610
[parser_context.D]
type = constant
value = 1e-5
[model]
order = 1
parser_type = ExprTk
[model.time_step_operator]
time_begin = 0
time_end = 10000
time_step_initial = 0.1
time_step_max = 50
[model.time_step_operator.linear_solver]
type = RestartedGMRes
preconditioner.type = Jacobi
[model.time_step_operator.nonlinear_solver]
type = Alexander2
convergence_condition.relative_tolerance = 1.00000000000000002e-08
convergence_condition.absolute_tolerance = 0
[model.writer.vtk]
path = vtk
[compartments]
compartment.expression = 1
[model.scalar_field.U]
compartment = compartment
initial.expression = 0.7
storage.expression = 1
reaction.expression = F*(1-U) - U*V^2
reaction.jacobian.U.expression = -F - V^2
reaction.jacobian.V.expression = -2*U*V
cross_diffusion.U.expression = D*2
[model.scalar_field.V]
compartment = compartment
initial.expression = bump(0.25-position_x, 0.25-position_y) + bump(0.25-position_x, 0.75-position_y) + bump(0.75-position_x, 0.25-position_y) + bump(0.75-position_x, 0.75-position_y)
storage.expression = 1
reaction.expression = -(F+k)*V + U*V^2
reaction.jacobian.U.expression = V^2
reaction.jacobian.V.expression = -(F+k) + 2*U*V
cross_diffusion.V.expression = D