Documentation and tutorial for ARDiS¶
Getting started¶
Installation guide¶
Requirements¶
CMake (3.10+), g++-7 (C++ 11 standard)
CUDA Compatible Graphics card, and CUDA toolkit (10.2+).
Python 3.6+, with the following modules: * wheel * setuptools * pybind11[global]
Optional¶
WolframScript (1.3.0+) * (for building your own reactor shape)
ImageMagick * (to make gif clips)
Building¶
Make directories ‘build’ and ‘output’
Unpack data.rar
Build library:
$ cd build && cmake ../
$ make
Install library with pip:
$ cd pythonLib
$ python setup.py bdist_wheel
$ pip install dist/*.whl
Contact¶
- For any questions or inquiries, e-mail the author at:
License¶
The MIT License (MIT)
Copyright (c) 2020 Hedi Sellami
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Examples¶
One species in a square¶
In this simulation, we use a single species (no reactions) placed in a square-shaped reactor.
We place an initial concentration of the species in a corner of the reactor.

Here is what the siulation should output after a few iterations of diffusion.

Use WolframScript to create new reactor shapes¶
WolframScript is a free tool for developpers. It allows you to use the Wolfram Engine via the command line.
Once installed, you should have access to the wolframscript
command.
Two scripts are provided in the wolframScripts folder:
ImageToData.wls MazeGenerator.wls
Image to data¶
First, you need to have black and white image, where the white represents the area of your reactor, ad in the exemple below:

Run the ImageToData script using the wolframscript command:
wolframscript /path/to/ImageToData.wls /path/to/image.png
For example, you can run this command from the ARDiS directory:
wolframscript wolframScripts/ImageToData.wls data/maze.png
Maze generator¶
This script generates a random maze at a given path:
wolframscript /path/to/MazeGenerator.wls /given/path size
For example:
wolframscript wolframScripts/MazeGenerator.wls data/myMaze 4
Complete documentation¶
d_vector¶
This class creates and manages an array on the device (aka. on the GPU).
Properties¶
int |
length |
The length of the array. It cannot be resized. |
d_spmatrix¶
This class creates and manages a sparse matrix the device (aka. on the GPU).
Properties¶
(int, int) |
shape |
A (rows, columns) tuple representing the shape of the matrix. |
int |
nnz |
Number of non-zero elements in the matrix. |
dtype |
Number of non-zero elements in the matrix. |
Methods¶
d_spmatrix(int rows, int columns, int nnz = 0, matrix_type type = COO)¶
The constructor creates a sparse matrix of shape (rows, columns) with nnz non-zero elements on the device.
matrix_type¶
An enum that represents the data storage type of a sparse matrix.
state¶
A class for managing the concentrations of species. A state will create and hold a d_vector for each species you add.
Properties¶
int |
n_species |
Number of species |
int |
vector_size |
Number of spatial nodes for each species |
Methods¶
state (int vector_size)¶
The constructor creates a state that will hold vector_size sized species.
add_species (string name, bool diffusion = true)¶
Add a species called name to the state. Set diffusion to False if you don’t want the species to be affected by diffusion.
d_vector get_species (string name)¶
Returns a reference to the current vector of the given species.
Returns NULL if the species is not found.
void set_species (string name, d_vector species_vector)¶
Copies the given vector as the new state-vector of the given species.
If the species is not found, it does nothing.
void set_species (string name, numpy.array species_vector)¶
Overloads the above method.
You can specify the vector as numpy array.
void print (int printCount = 5)¶
Prints each species and its vector.
For each vector, only printCount elements will be printed.
simulation¶
A class for managing simulations. A simulation will create and hold a state.
Properties¶
current_state |
The state object held by the simulation |
|
float |
epsilon |
The error of the conjugate gradient method. Defaults at 10e-3 |
float |
drain |
The drain is a constant value that is deducted from the concentration of each species after each reaction-step |
Methods¶
simulation (int vector_size)¶
The constructor creates a simulation and a state that holds vector_size sized species.
add_species (string name, bool diffusion = true)¶
Add a species called name to the current_state. Set diffusion to False if you don’t want the species to be affected by diffusion.
d_vector get_species (string name)¶
Returns a reference to the current vector of the given species.
Returns NULL if the species is not found.
void set_species (string name, d_vector species_vector)¶
Copies the given vector as the new state-vector of the given species.
If the species is not found, it does nothing.
void set_species (string name, numpy.array species_vector)¶
Overloads the above method.
You can specify the vector as numpy array.
void add_reaction (string reaction, float rate)¶
Adds the given reaction to the simulation. It will be taken into account in all future reaction-steps.
Some examples of reactions that can be written:
"A + B -> C"
" B+C-> "
Note that this method will raise an error if any of the mentioned species has not be added beforehand.
void add_reversible_reaction (string reaction, float rate_forward, float rate_back)¶
Similar to the add_reaction method. Adds both the given reaction and its reverse. The rates for each of the two reactions has to be specified.
void load_dampness_matrix (d_spmatrix dampness_matrix)¶
Sets the given matrix as the reactor’s dampness matrix. Mandatory for performing diffusion.
void load_stiffness_matrix (d_spmatrix stiffness_matrix)¶
Sets the given matrix as the reactor’s stiffness matrix. Mandatory for performing diffusion.