Skip to main content

Simulation toolkit for particle tracking in strong fields.

Project description

Introduction

demo-nocap.png

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.5.0.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

sfparticles-0.5.0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sfparticles-0.5.0.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sfparticles-0.5.0.tar.gz
Algorithm Hash digest
SHA256 517a7b6ba4791ee577880a7333cae527b405858a53b18adf38320fdaf517f554
MD5 dd7c30db6e03888ef93eb4931543a582
BLAKE2b-256 4a7cf29276ef20b456e1d8ac3d792aa045bea0380e0756c8deb1c18b95963ff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sfparticles-0.5.0.tar.gz:

Publisher: python-publish.yml on xsgeng/sfparticles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: sfparticles-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sfparticles-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00c32ce769154ca6c04f0d7ea14c56f744fb130c3ca1259a631b95775e87a019
MD5 420e7244e4ecac7d46215ce0e17d3942
BLAKE2b-256 73e48f42d213d7f2bbb90e4322c13c10a2fb4e2560c56ff092375a61843de464

See more details on using hashes here.

Provenance

The following attestation bundles were made for sfparticles-0.5.0-py3-none-any.whl:

Publisher: python-publish.yml on xsgeng/sfparticles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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