nns.c
1.0.1
Nanowire Network simulator
|
nns.c
is a C library that provides types and functions for the high performance simulation of Nanowire Networks. Specifically, it focuses on the randomly-created devices developed at the Polytechnic of Turin by Gianluca Milano, Enrique Miranda and Carlo Ricciardi. The code allows performing analysis of the structural and functional connectivity of the memristive network. The library is inspired by the code used in the paper Connectome of memristive nanowire networks through graph theory, which can be found here.
The main components of the simulator are:
datasheet
: Represents the static information of the Nanowire Network, such as the number of nanowires, their length, etc.network_topology
: Contains the physical distribution of the nanowires and their junctions.network_state
: Contains the dynamic (or instantaneous) state of the Nanowire Network, represented as the equivalent electrical circuit.connected_component
: Represents a connected group of nanowires inside the Nanowire Network, and contains the information to address them in the ‘network state’.An example of their relationship is shown in the following diagram:
The stimulation of the NN uses the interface
and mea
components, that specify how sources, grounds, and loads connect to the NN. Specifically, an interface allows to select all the possible nanowires as sources / grounds / loads. A MEA limits instead the choice to nanowires positioned near to physical electrodes, allowing a more realistic configuration.
Overall, the steps to compile and install the simulator are the following:
cmake . && make
sudo make install
Nevertheless, the installation slightly vary across different Operative Systems. A brief (and not exhaustive) step-guide if given below for each tested OS.
Tested on an Arch installation.
Due to the variety of Linux installations, a precise guide cannot be provided. Assuming that you have installed all the required dependencies in the correct locations, the installation is expected to consist of the following steps:
Tested on a macOS Big Sur installation.
The installation under macOS requires some attentions. Firstly, the Clang compiler used does not yet support the empty initialization of arrays (C23), and cause some problems with OpenMP. To solve these issues, the use of a recent version of GCC and C++ compilers is recommended. However, gcc
in a macOS is a link to the clang
compiler. To overcome this problem, it is necessary to specify the gcc version, targeting a specific installation of the compiler. An example is available below, where I assume GCC-13 e C++-13 to be installed. Another issue relates some brew installations that are not directly accessible by CMake (e.g., OpenBLAS). To allow the compilation to succeed, it is needed to specify the location of those installed libraries. An example is available below.
Installing the dependencies:
Installing the simulator:
Not tested (yet).
The simulator is not currently tested under Windows. The use of the Windows Subsystem for Linux (WSL) is expected to work.
Once the simulator is installed, you can write your code. For a brief introduction, please check the test and example codes. They represent typical usage of the library.
Running the tests:
Running the examples:
Linking the library in your code:
Linking the library in your code (CMake):
Running a Valgrind memory-leak test:
cmake .
you get something such as Could NOT find BLAS (missing: BLAS_LIBRARIES)
, ensure that BLAS is installed in you system and add something such as -DBLAS_LIBRARIES=/usr/lib64/libblas.so
to the call.cmake .
you get something such as Could NOT find LAPACK (missing: LAPACK_LIBRARIES)
, ensure that LAPACK is installed in you system and add something such as -DLAPACK_LIBRARIES=/usr/lib32/liblapack.so
to the call.ulimit -s 65535
.