Skip to main content

NeutPy - A neutrals code for tokamak fusion reactors

Project description

NeutPy - A code for the calculation of neutral particle transport in plasmas based on the transmission and escape probability method

NeutPy is the Python 2.x port of GTNEUT, which was written by John Mandrekas.

GTNEUT is a two-dimensional code for the calculation of the transport of neutral particles in fusion plasmas. It is based on the Transmission and Escape Probabilities (TEP) method and can be considered a computationally efficient alternative to traditional Monte Carlo methods. The code has been benchmarked extensively against Monte Carlo and has been used to model the distribution of neutrals in fusion experiments.

The original physics background can be found at

Mandrekas, John. (2004). GTNEUT: A code for the calculation of neutral particle transport in plasmas based on the Transmission and Escape Probability method. Computer Physics Communications. 161. 36-64. 10.1016/j.cpc.2004.04.009.

The original FORTRAN 95 GTNEUT code can be found at The Fusion Research Center GitHub at https://github.com/gt-frc/GTNEUT

Installation

Triangle Installation

The Triangle 2D mesh generator is required for NeutPy mesh generation. This guide can be used to install Triangle locally. If you imagine using triangle otherwise, consider following the steps below but with consideration for global installation (e.g., cloning to /opt/ instead of your home directory). Ensure that you have a C compiler installed. Download the Triangle zip file from https://www.cs.cmu.edu/~quake/triangle.html or

$ cd ~

$ git clone https://github.com/libigl/triangle.git

$ cd triangle

Make your bin directory

$ mkdir bin

Read the README file for instructions on how to compile. It's pretty basic. We recommend simply compiling triangle alone with (using GCC) since we do not use showme.

$ gcc -O -o bin/triangle triangle.c -lm

If you want to fully compile triangle and showme, edit the makefile, noting any special options from the README.

Keep SRC = ./ and set BIN = ./bin/

Make triangle

$ make

After triangle is compiled, set executable

$ cd bin

$ sudo chmod +x triangle

Set link (this allows triangle to be called on command line as triangle) to /usr/local/bin or some other directory on your PATH.

$ sudo ln -s /full/path/to/triangle /usr/local/bin/triangle

Install NeutPy

Using pip

$ pip install neutpy

From GitHub

If you'd like to work on the actual neutpy code, you can clone from GitHub:

$ cd /your/future/neutpy/home/

  • Master branch

Clone master branch from github

$ git clone https://github.com/gt-frc/neutpy.git

  • Other branches

You can clone another branch from github as follows:

$ git clone -b <branch> https://github.com/gt-frc/neutpy.git

Enter NeutPy

$ cd neutpy

Setup your virtual environment (install virtualenv using apt, yum, etc.)

$ virtualenv --python=/usr/bin/python2.7 venv

Activate it

$ source venv/bin/activate

Install packages

$ pip install -r requirements.txt

Usage

NeutPy requires 6 input files and 2 configuration files.

Configuration files:

toneutpy.conf is the main input file for a shot. This file will change with each shot.

neutpy.conf is the main NeutPy configuration file and includes parameters that probably wouldn't change between shots and other variables. This file needs to be in the current working directory and cannot be renamed. Grab an example copy from the FRC GitHub (https://github.com/gt-frc/neutpy/)

Data files:

The names of the data files included follow the GT3 gt3_shotid_timeid_profile.dat convention but can be defined differently in your toneutpy.conf file.

Ion/Electron density and temperature data are X/Y (normalized rho/value) two-column data. Temperatures are in keV. Densities should be given in #/m^3. Psi data are non-normalized 3-column R/Z/value data, with R/Z in meters.

Example File Structure

gt3_shotid_timeid_ne.dat (Electron density profile)

gt3_shotid_timeid_ni.dat (Ion density profile)

gt3_shotid_timeid_Te.dat (Electron temperature profile)

gt3_shotid_timeid_Ti.dat (Ion temperature profile)

gt3_shotid_timeid_psirz.dat (Non-normalized psi grid)

gt3_diid_wall.dat (Machine wall coordinates (R/Z))

Example Usage

Import the neutrals class.

>>> from neutpy import neutrals

There are three main entry points into NeutPy: from_file, from_mesh, and from_gt3.

from_file()

>>> neuts = neutrals()
INITIALIZING NEUTPY
>>> neuts.from_file('/relative/path/to/your/toneutpy.conf')

where the filename is relative to the CWD.

from_gt3()

>>> neuts = neutrals()
INITIALIZING NEUTPY
>>> neuts.from_gt3(<GT3 object>)

The from_mesh method is in development.

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

neutpy-0.0.3.tar.gz (105.8 kB view details)

Uploaded Source

Built Distribution

neutpy-0.0.3-py2-none-any.whl (110.6 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: neutpy-0.0.3.tar.gz
  • Upload date:
  • Size: 105.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/2.7.18rc1

File hashes

Hashes for neutpy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 df451329860f3d1d94cbff956bc06a158d6766a7b45b812960c73317ea9cf2ea
MD5 c94ca66f680ad4a1b5b4bcc2ab8a2a49
BLAKE2b-256 a57893e0daa6ad61b766c0cc14285f90e5232ee503b47c3d45bc35a4cbd0755d

See more details on using hashes here.

File details

Details for the file neutpy-0.0.3-py2-none-any.whl.

File metadata

  • Download URL: neutpy-0.0.3-py2-none-any.whl
  • Upload date:
  • Size: 110.6 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/2.7.18rc1

File hashes

Hashes for neutpy-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 8cf2b47de6f11340691fbec3b4b39d3e4b45b50c0630bea7c78eed70c0b17344
MD5 dd2b70b291ed5a5cdcea35829cc44735
BLAKE2b-256 9bd8836c2ebeee2452a7a8cb9851a4b45ac06477519c115b34d4a0fadd359bce

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