Skip to content

JacobHass8/extremeDiffusion1D

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

extremeDiffusion1D

Description

High performance simulations of random walks in various environments. The costly functions are written in C++ and then ported to Python using PyBind11.

Installation

Installation is automated in bash with the setup.sh script.

Dependences:

Python Iterfaces

Data Structures

Numerical data is handled using the npquad numpy extension. Floating point data is returned as numpy arrays with dtype=np.quad. Note that quad precision support is limited so downcasting to np.float64 after all calculations are done is recommended. Some helper functions are located in /pysrc/fileIO.py and /pysrc/quadMath.py.

File Strucutre

  • pyDiffusion
    • Contains Python code which wraps the generated C++ library.
  • src
    • Contains the C++ library to simulate many particles diffusing on a 1D lattice in a space-time random field.
  • runFiles
    • Python and Bash scripts that measure statistics about systems of diffusing particles. The code is written to run on a HPC using Slurm.

Examples

import sys

sys.path.append("pysrc")
from pydiffusionPDF as DiffusionPDF
import matplotlib

matplotlib.use("Agg")
from matplotlib import pyplot as plt

# Specify some constants like the number of particles, beta, and number of
# timesteps to evolve the system
nParticles = 1e50
beta = 1
num_of_timesteps = 10_000

# Initialize the system with parameters and other key word arguments
d = DiffusionPDF(
    nParticles,
    beta=beta,
    occupancySize=num_of_timesteps,
    probDistFlag=False,
)

# Evolve the system to the specified number of timesteps
d.evolveToTime(num_of_timesteps)

# Get the rightmost edge and the time
maxEdge = d.maxDistance
time = d.time

# Plot the rightmost edge over time and save
fig, ax = plt.subplots()
ax.set_xlabel("Time")
ax.set_ylabel("Distance to Center")
ax.set_xscale("log")
ax.set_yscale("log")
ax.plot(time, maxEdge)
plt.show()

plot

About

Simulations of the 1d RWRE model for diffusion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 72.0%
  • C++ 20.6%
  • Shell 7.4%