Skip to main content

Simulation toolkit for particle tracking in strong fields.

Project description

sfparticles

Introduction

sfparticles is a simulation toolkit for particle tracking. Unklike particle-in-cell simulations, sfparticles does not solve field equations but instead tracks individual particles in pre-defined fields, without considering the inter-particle interactions. This allows for fast 3D simulations of large numbers of particles when plamsa denisty is low.

Features

  • Numba Acceleration: sfparticles leverages Numba to accelerate simulations by compiling Python code to machine code.
  • Cascade Simulation: Optimized for exponentially growing number of particles.
  • Flexible Field Configuration: sfparticles allows you to define complex electromagnetic fields using python functions.
  • Particle Tracking: Track the trajectories of particles. see example.

Installation

from github:

git clone https://github.com/xsgeng/sfparticles.git
cd sfparticles
pip install --user -e .

from pypi:

pip install sfparticles

Usage

Basic Simulation

To run a basic simulation, you can refer to the example scripts provided in the examples directory. For instance, to simulate a particle cascade, you can use the cascade.py script:

python examples/cascade.py
# set number of threads
NUMBA_NUM_THREADS=64 python examples/cascade.py

For trajectory simulations, you can use the trajectory.py script:

python examples/trajectory.py

Advanced Settings

You can set environment variables to configure the simulation. For example, to use an optical depth radiation model, set the SFPARTICLES_OPTICAL_DEPTH environment variable:

SFPARTICLES_OPTICAL_DEPTH=1 python examples/cascade.py

GPU Acceleration

For even faster simulations, sfparticles supports GPU acceleration. To enable this feature, you need to install CUDA and set SFPARTICLES_USE_GPU=1 environment variable.

Note: GPU is slow for small number of particles.

Installing CUDA

conda install -c conda-forge cupy cudatoolkit=11.2

Enabling GPU Acceleration

SFPARTICLES_USE_GPU=1 python examples/cascade.py

For Slurm job schedulers, you can use the following command:

SFPARTICLES_USE_GPU=1 srun -p gpu -G 1 -u python examples/cascade.py

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

sfparticles-0.4.10.tar.gz (3.2 MB view details)

Uploaded Source

Built Distribution

sfparticles-0.4.10-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

Details for the file sfparticles-0.4.10.tar.gz.

File metadata

  • Download URL: sfparticles-0.4.10.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sfparticles-0.4.10.tar.gz
Algorithm Hash digest
SHA256 4021177f22fba82e02d304cee643c02aa45fd57afc474a8ac64d3563625528a5
MD5 efa665c8502b88d2bc1cd6e8961c4291
BLAKE2b-256 5cd113bfca550525041885141c6542e50495b5e1e9d0376e309b4685c5629739

See more details on using hashes here.

File details

Details for the file sfparticles-0.4.10-py3-none-any.whl.

File metadata

File hashes

Hashes for sfparticles-0.4.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d9064057497c95f03270c1de930c50a2390104b2c7831f1d28ac00022bd6ae88
MD5 aabfcdbdf94668cefba636c612ef3487
BLAKE2b-256 1353441daf0ec16056bb98140f724e0100931ba6954322261f707d9b20a158eb

See more details on using hashes here.

Supported by

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