8000 GitHub - the-rccg/hw2d: Reference implementation for the Hasegawa-Wakatani model of plasma turbulence inside nuclear fusion reactors in two dimensions
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ hw2d Public

Reference implementation for the Hasegawa-Wakatani model of plasma turbulence inside nuclear fusion reactors in two dimensions

License

Notifications You must be signed in to change notification settings

the-rccg/hw2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Hasegawa-Wakatani model of plasma turbulence

hw2d-status hw2d-documentation hw2d-publish PyPI pyversions DOI status

This repository contains a reference implementations for the Hasegawa-Wakatani model in two dimensions using Python. The purpose is to provide a playground for education and scientific purposes: be it testing numerical or machine learning methods, or building related models quicker, while improving the comparability of results.

Stable, verified parameters and values are published along with this repository.

Installation

Install a pure NumPy version via

pip install hw2d

and to include accelerators (currently supporting: Numba), use the following:

pip install hw2d[accelerators]

Usage

Running python -m hw2d will let you run a hw2d simulation. It exposes the CLI Interface of the code located in src/hw2d/run.py with all parameters available there. Simply run python -m hw2d --help to get a full rundown of all available parameters along with their explanations.

If accelerators like Numba are installed, these will be used automatically. To manually decide which function should be run with which accelerator, simply change the imports in srd/hw2d/model.py to select the appropriate function. Default uses Numba for periodic gradients and the Arakawa scheme, and to be extended in the future.

Example Usage

Example of running a fully converged turbulent simulation:

python -m hw2d --step_size=0.025 --end_time=1000 --grid_pts=512 --c1=1.0 --k0=0.15 --N=3 --nu=5.0e-08 --output_path="test.h5" --buffer_length=100 --snaps=1 --downsample_factor=2 --movie=1 --min_fps=10 --speed=5 --debug=0

The code will run a grid of 512x512 in steps of 0.025 from 0 to 1000 for an adiabatic coefficient of 1.0 and hyperdiffusion of order 3 with a coefficient of 5.0e-08. The resulting data will be saved to "test.h5" after every 1 frame and written in batches of 100 using a 2x downsampled representation (256,256). This file will then be turned into a movie with at least 10 frames per second, running at 5t per second. The entire process will use no debugging.

Full documentation is available at: https://the-rccg.github.io/hw2d/

Reference Methods

The implementation presented here is by no means meant to be the optimal, but an easy to understand starting point to build bigger things upon and serve as a reference for other work. This reference implementation uses:

  • Gradients $\left(\partial_x, \partial_y, \nabla \right)$: Central finite difference schemes (2nd order accurate)
  • Poisson Bracket $\left([\cdot, \cdot]\right)$: Arakawa Scheme (2nd order accurate, higher order preserving)
  • Poisson Solver $\left(\nabla^{-2}\cdot\right)$: Fourier based solver
  • Time Integration $\left(\partial_t\right)$: Explicit Runge-Kutta (4th order accurate)

The framework presented here can be easily extended to use alternative implementations.

Contributions encouraged

Pull requests are strongly encouraged.

The simplest way to contribute is running simulations and committing the results to the historical runs archive. This helps in exploring the hyper-parameter space and improving statistical reference values for all.

If you don't know where to start in contributing code, implementing new numerical methods or alternative accelerators make for good first projects!

Code guidelines

All commits are auto-formatted using Black to keep a uniform presentation.

The Hasegawa-Wakatani Model

The HW model describes drift-wave turbulence using two physical fields: the density $n$ and the potential $\phi$ using various gradients on these.

$$ \begin{align} \partial_t n &= c_1 \left( \phi - n \right) - \left[ \phi, n \right] - \kappa_n \partial_y \phi - \nu \nabla^{2N} n \\ \partial_t \Omega &= c_1 \left( \phi - n \right) - \left[ \phi, \Omega \right] - \nu \nabla^{2N} \Omega \\ \Omega &= \nabla^2 \phi \end{align} $$

hw2d_sample.mp4

Dynamics of the different phases

The model produces self-organizing turbulent structures in a three distinct stages: initial self-organization, linear drift waves, and a stable turbulent phase.

For the interesting intermediary phase for the adiabatic coefficient, c1=1, the initial perturbation will start organizing to produce linear drift waves through the $\partial_t \phi$ component. The system transitions into this first linear phase at roughly t=15, saturates at around t=45, and breaks down to transition into the turbulent phase at about t=80. The turbulent phase is visually saturated at around t=125, but physical parameters overshoot and only fall into the long term stable phase at around t=200.

Physical Properties

Numerical values for each frame