Slender-body hydrodynamics
This repository contains the Python/C++ and Matlab codes for the publications:
- [1] "An integral-based spectral method for inextensible slender fibers in Stokes flow," by Ondrej Maxian, Alex Mogilner, and Aleksandar Donev, Jan. 2021. See arxiv for text and Phys. Rev. Fluids for published version.
- [2] "Simulations of dynamically cross-linked actin networks: morphology, rheology, and hydrodynamic interactions," by O. Maxian, R. P. Peláez, A. Mogilner, and A. Donev, Dec. 2021. See bioarxiv for text and PLoS Comp. Bio for published version.
- [3] "Interplay between Brownian motion and cross-linking kinetics controls bundling dynamics in actin networks," by O. Maxian, A. Donev, and A. Mogilner. Biophysical Journal, April 2022. See bioarxiv for text and BJ for published version.
- [4] "The hydrodynamics of a twisting, bending, inextensible fiber in Stokes flow," by O. Maxian, B. Sprinkle, C.S. Peskin, and A. Donev. Submitted to Phys. Rev. Fluids, Jan. 2022. See arxiv for text.
Organization is as follows:
- Python: directory with python codes
- Python/cppmodules: directory with C++ modules linked to python using pybind11 (compile with included makefile)
- Python/Examples: python scripts to reproduce the tests and examples in the paper. See the README there for more information.
- Python/Dependencies: contains all dependencies for the python codes. Some are submodules, while some are modified copies of the libraries.
- Matlab: directory with matlab codes. These are the only codes used in [4].
- FINUFFT. I have modified some of the v 1.0 code and included the raw code in Python/Dependencies.
- krypy. I have modified some of this and included the raw code in Python/Dependencies.
- scipy
- LaPack (for C++ functions)
- PyBind11 (to link python and C++)
- numba (to accelerate and parallelize native python)
- UAMMD (for Ewald splitting on the GPU). This is used as a submodule in Python/Dependencies.
For nearly singular SBT integrals, we use a modified version of the quadrature scheme of Ludvig af Klinteberg and Alex Barnett. Their original code is here; we have made some modifications to switch their Legendre discretization to a Chebyshev one in Python/cppmodules/SpecialQuadratures.cpp The code here is independent of the linequad code of af Klinteberg and Barnett.
- Clone this repo using
git clone --recursive https://github.com/stochasticHydroTools/SlenderBody
This will also clone the submodules in the dependency folder. Then run
cd SlenderBody
bash install.sh
in the main directory. This will compile all of the dependencies and C++ modulues. It will also add the appropriate directories (where the python modulues are compiled) to your PYTHONPATH.
If the compilation process fails this script will show an error. In that case fix the compilation issue and run bash install.sh
again.
- Common mistakes:
- When compiling UAMMD in the dependencies, the compiler may complain depending on what version of nvcc you use. If it complains that there is no file called cub, cd into SlenderBody/Python/Dependencies/UAMMD_PSE_Python/uammd/src/third_party and change the folder called "cub_bak" to "cub." This should fix that issue. See also the UAMMD webpage for more compilation instructions.
- Run the python scripts in Python/Examples. For example,
python3 ThreeShearedFibs.py
will run the example in Section 5.1.2 of [1]
There are three portions of our code that are parallelized. We first note that the number of OpenMP threads (environment variable) MUST be set to one to obtain good performance. In particular, you must use
export OMP_NUM_THREADS=1
in linux prior to running our code. The parallelization is then implemented in python in the following three ways:
- The (CPU) nonlocal velocity calculations (Ewald splitting), near fiber corrections, and force and stress calculations for
cross linkers are parallelized within C++ using OpenMP. The number of threads in these calculations can be set by passing an integer
to the constructor of fiberCollection.py. An example of this is on line 49 of Python/Examples/CheckStability.py. We also have a GPU version. - The linear solves on all fibers are parallelized using numba. The number of numba threads can be set
on the command line in linux using (for example, to obtain 4 threads)
export NUMBA_NUM_THREADS=4
-
Run
make clean
inside the Python folder. -
The install.sh script modifies the .bashrc file (which are marked as written by the script). Simply remove these lines.