Skip to main content

Diffusion-Limited Aggregation (DLA) solver with Numba acceleration

Project description

dla-ideal-solver: Diffusion-Limited Aggregation Solver

DOI

Python License: MIT PyPI version

NumPy Matplotlib Numba netCDF4 tqdm Pillow

High-performance Diffusion-Limited Aggregation (DLA) solver with Numba JIT compilation and parallel rendering.

radial_injection

Physics

Simulates particle aggregation through random walks on a 2D lattice:

  1. Random Walk: Particles perform 4-neighbor random walks
  2. Sticking Rule: Particles stick when adjacent to existing aggregate
  3. Growth: Dendritic structures emerge from stochastic aggregation

Fractal Analysis: Mass-radius relationship $M(R) \propto R^D$ gives fractal dimension $D \approx 1.71$ (2D DLA)

Features

  • Numba JIT: Compiled random walk for 100x speedup
  • Parallel rendering: Multi-core GIF generation
  • NetCDF output: Compact compressed format
  • 4 test cases: Classic, competitive, controlled, dense
  • Fractal analysis: Automatic $D$ calculation

Installation

# From PyPI
pip install dla-ideal-solver

# From source
git clone https://github.com/sandyherho/dla-ideal-solver.git
cd dla-ideal-solver
pip install -e .

Quick Start

Command line:

# Run single case
dla-simulate case1

# Run all cases
dla-simulate --all

# Custom cores
dla-simulate case1 --cores 8

Python API:

from dla_ideal import DLASolver

solver = DLASolver(N=512, n_cores=8)

result = solver.solve(
    n_walkers=10000,
    n_seeds=1,
    max_iter=100000,
    injection_mode='random'
)

print(f"Particles: {result['n_particles']}")
print(f"Aggregates: {result['n_aggregates']}")
print(f"Fractal dimension: {result['fractal_dimension']:.3f}")

Test Cases

Case Description Seeds Walkers Physics
1 Classic DLA 1 10k Baseline dendritic
2 Multiple Seeds 12 15k Competition & fusion
3 Radial Injection 1 10k Controlled growth
4 High Density 1 25k Dense packing

Configuration

Key parameters:

lattice_size = 512          # Grid size (N×N)
n_walkers = 10000           # Number of particles
n_seeds = 1                 # Initial sticky particles
max_iterations = 100000     # Safety limit
injection_mode = random     # 'random' or 'radial'
injection_radius = 180      # For radial mode
snapshot_interval = 100     # Frames per N particles

Output

NetCDF variables:

  • grid(x,y): Final aggregate
  • snapshots(time,x,y): Growth evolution
  • glued_counts(time): Particle timeline
  • radii, masses: Fractal analysis data

Attributes:

  • fractal_dimension: $D$ from $M(R)$ fit
  • n_aggregates: Number of clusters
  • n_particles: Total stuck particles

Reading data:

import netCDF4 as nc

data = nc.Dataset('outputs/case1_classic_dla.nc')
grid = data['grid'][:]
snapshots = data['snapshots'][:]
D = data.fractal_dimension
print(f"Fractal dimension: {D:.3f}")

Mathematical Background

The fractal dimension $D$ is computed from the mass-radius scaling relationship:

$$M(R) = \int_0^R \rho(r) , dV \propto R^D$$

where $M(R)$ is the mass within radius $R$ from the aggregate center. For 2D DLA:

$$\log M(R) = D \log R + \text{const}$$

The slope $D$ is obtained via linear regression on $\log$-$\log$ scale. Theoretical predictions give $D \approx 1.71$ for 2D DLA structures.

Citation

@software{dla_solver_2025,
  author = {Herho, Sandy H. S. and Fajary, Faiz R. and 
            Trilaksono, Nurjanna J. and Anwar, Iwan P. and Khadami, F. and Suwarman, Rusmawan and
            Irawan, Dasapta E.},
  title = {DLA Solver: Diffusion-Limited Aggregation with Numba},
  year = {2026},
  version = {0.0.3},
  license = {MIT}
}

Authors

  • Sandy H. S. Herho (sandy.herho@ronininstitute.org)
  • Faiz R. Fajary
  • Nurjanna J. Trilaksono
  • Iwan P. Anwar
  • Faruq Khadami
  • Rusmawan Suwarman
  • Dasapta E. Irawan

License

MIT License - See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dla_ideal_solver-0.0.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dla_ideal_solver-0.0.3-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file dla_ideal_solver-0.0.3.tar.gz.

File metadata

  • Download URL: dla_ideal_solver-0.0.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for dla_ideal_solver-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d7d5362552df3c1b15c89e459f656602d9bf0dff6b59ef6e8570395e107eb154
MD5 fe02764842c02dc6c51e12e1d80eeefc
BLAKE2b-256 59b2a8d018373a70ee7410d27705823fa7050b83fe9f30cac9f4e7988b7a8b7f

See more details on using hashes here.

File details

Details for the file dla_ideal_solver-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: dla_ideal_solver-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for dla_ideal_solver-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c4a061ac8bb4e46372b283f88c54e47d515e9f1905ad7cba3c7842851f552b1
MD5 6c55a424e87da18389400cc68c7043df
BLAKE2b-256 780f9cc4d2720fad36f9a5e84dc3e92edeb76b6cb6fddf2cfd57af3f83cee496

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page