The code in this repository implements a branching network with spatial connectivity to study the role of network strcuture on critical dynamics. Details are provived in the paper below. If you are using this code for a scientific publication, please cite the paper.
Zeraati*, R., Buendía*, V., Engel, T. A., & Levina, A. (2024). Topology-dependent coalescence controls scaling exponents in finite networks. Physical Review Research, 6(2), 023131. https://doi.org/10.1103/PhysRevResearch.6.023131
There are implementations both in C++ and in Python, each one in its respective folder, cpp and python. The C++ run faster, but lacks all the coalescence measurements. Code to replicate the figures of the paper is also included, but the data has to be generated by the user.
The files avalanche_generator.py and lattice_activity.py contain the core functions to simulate the system and calculate the relevant observables. These can be invoked from the run_*.py files:
run_av.pygenerates avalanches.run_pd.pyruns an entire phase diagram.run_singlepd.pyis the same as the previous one, but it only computes the value for a single branching ratio. It is useful to paralellize the simulations in a cluster.run_coalescence.pycomputes the amount of active units and uses them to measure the amount of coalescence.run_br_adaptive.pysimulates an adaptive branching process using the measured coalescence. In order to execute this file,run_coalescence.pymust be invoked first.
Note that in the Python code, sigma refers to the branching parameter, which is called m in the paper.
The core functions are inside the lbnm.cpp file. In order to perform the simulations, there are several Python scripts that compile and execute automatically the C++ code, for ease of use. These are
run_avalanches.pygenerates avalanches.run_phase_diagram.pygenerates a complete phase diagram. The launcher divides the work between the given amount of coresrun_phase_diagram_rewire.pygenerates a complete phase diagram for a network with rewired connections
The figures can be generated by generating the data first and then using the code provided in the Jupyter Notebooks. Note that the paths to the data folder must be changed to the ones selected by the user (inside the results folder).