Skip to main content

A fast 1D Vlasov Poisson solver using JAX

Project description

One Dimension Vlasov-Poisson Equation JAX Solver

VLAX1D Logo

license last-commit repo-top-language Coverage

This repository provides a numerical solver for the one-dimensional Vlasov-Poisson equation using JAX for high-performance computing. The solver leverages GPU acceleration and JAX's automatic differentiation to efficiently simulate plasma wave dynamics, including Landau damping and instability phenomena.

Project Overview

(add some explanation of calculation) This solver numerically integrates the 1D linear Vlasov-Poisson equation to analyze wave propagation, damping rates, and stability in plasma physics. The solver utilizes JAX to achieve high-performance computations, supporting automatic differentiation and GPU/TPU acceleration.

Features

  • High-performance JAX-based solver: Leverages JAX's automatic differentiation and just-in-time (JIT) compilation.
  • Robust analysis tools: Peak detection, linear fitting, and data export to CSV.
  • Customizable parameters: Easy-to-adjust parameters such as wave number (k), collision frequency (nu), and the mode number for all species (m_max).

Installation

pip install Oned-Vlasov-Poisson-jax-solver

Usage

To run simulations and analyze damping rates:

python two_stream_instability.py

Adjust parameters within the script:

# Set the maximum number of all modes (the dimension of the state variable)
# Which should be an even number because the subsequent code will divide it into two groups
m_max = 40

# Define the time range of the simulation
# From t = 0 to t = 200, a total of 2001 time points (i.e. Δt = 0.1)
t_span = jnp.linspace(0, 200, 2001)

# Set of wave numbers (k values) to loop over or analyze.
# These represent different spatial scales of perturbations in the system.
k_values = jnp.linspace(0.01, 0.40, 40)

# Collision frequency (nu), representing the strength of the damping term.
# Higher values introduce stronger diffusion (e.g., Landau damping, viscosity).
nu = 2

# Average velocities for two interacting populations (e.g., beam and background).
# Used to model counter-propagating or asymmetric systems.
v_e = jnp.array([1, -1])

# Charge weights or coefficients associated with the populations.
# For population one and two.
q = jnp.array([1, 1])

Mathematical Background

We start with the 1D Vlasov equation:

∂f/∂t + v ∂f/∂x + (qE/m) ∂f/∂v = 0

After linearizing and Fourier-transforming:

∂(δf)/∂t + i·k·v·(δf) + (q·δE/m) ∂fₘ/∂v = 0

We expand δf(v, t) in Hermite polynomials:

δf(v, t) = Σₙ fₙ(t) Hₙ((v - vₑ)/α)

Then, projecting onto each Hermite mode:

∂fₙ/∂t = -i√[(n+1)/2] fₙ₊₁ - i√[n/2] fₙ₋₁ - i·vₑ·fₙ - C·f₀·δₙ₁

where C ∝ 1/k from Poisson's equation.

for more detail please check plasma_equation in docs


Project Structure

OneD_Vlasov_Poisson_JAX_Solver/
├── .github/
│   └── workflows/
│       └── test.yml              # GitHub Actions for CI
│
├── data/
│   ├── damping_rate.csv          # Reference damping data
│   └── growth_rate.csv           # Reference instability growth data
│
├── dist/                         # Python package builds
│   ├── oned_vlasov_poisson_jax_solver-*.tar.gz
│   └── oned_vlasov_poisson_jax_solver-*.whl
│
├── docs/
│   ├── plasma_equation.pdf       # Mathematical background
│   ├── requirements.txt          # Build dependencies for Sphinx
│   └── VLAX1D_logo.png            # Project logo
│
├── examples/
│   ├── Landau_damping.py         # Example: Landau damping
│   └── two_stream_instability.py # Example: Two-stream instability
│
├── source/
│   ├── conf.py                   # Sphinx configuration
│   ├── index.rst                 # Sphinx main index
│   ├── installation.rst
│   ├── modules.rst
│   └── usage.rst
│
├── src/
│   ├── Oned_Vlasov_Poisson_jax_solver.egg-info/ # Package metadata
│   ├── __init__.py
│   ├── equations.py               # Equation definitions
│   ├── plot.py                    # Plotting functions
│   ├── Refactoring.py             # Hermite reconstruction and utilities
│   └── solver.py                  # Solver using Diffrax
│
├── tests/
│   ├── __init__.py
│   ├── test_equations.py
│   ├── test_plot.py
│   ├── test_Refactoring.py
│   └── test_solver.py
│
├── .coverage
├── coverage.xml
├── LICENSE
├── Makefile
├── make.bat
├── MANIFEST.in
├── pyproject.toml
├── pytest.ini
├── README.md                     # Project overview
├── readthedocs.yml                # ReadTheDocs configuration
├── requirements.txt              # Python runtime requirements
└── setup.py                       # Setup script for pip installation

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

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

vlax1d-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

vlax1d-0.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file vlax1d-0.1.1.tar.gz.

File metadata

  • Download URL: vlax1d-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for vlax1d-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8f18cda8c058c13e96b61de4b47b9039b01ca5a14cfd1a436f9029fa6c435420
MD5 8b6134d53808bdd23a9c7b4ded2a08dd
BLAKE2b-256 e508eee6e027c9989365fd8f35d13b3a1900b0de1532051fea5f1f072f1e16a1

See more details on using hashes here.

File details

Details for the file vlax1d-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vlax1d-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for vlax1d-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a037f54ce208dd8b39333f5e2fd5d63856c67287adefb6712e8fca5c02a5221
MD5 e9c8f396a63090d6b87e199613f12680
BLAKE2b-256 9b8907599cc222fca39016909d2039a5922d4a6f80bc6da92d781ec31d06f93f

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