Skip to content
/ pygyro Public

Python library for parallel gyro-kinetic simulations

Notifications You must be signed in to change notification settings

pyccel/pygyro

Repository files navigation

PyGyro
======

PyGyro is a Python-3 library for parallel gyro-kinetic simulations.


Requirements
============

The following python packages are required:

coverage
h5py
matplotlib
mpi4py
numpy
pytest
scipy

This project requires parallel h5py. The commands to install this are as follows:

```
export CC=mpicc
export HDF5_MPI="ON"
export HDF5_DIR=$HDF5_HOME

pip install --no-binary=h5py h5py
```

On a module based system the following modules must first be loaded:

```
module load impi
module load anaconda/3
module load mpi4py
module load hdf5-mpi
```

If the module based system does not have parallel h5py installed, a virtual environment can be used. In this case the following modules must be loaded:
```
module load impi
module load anaconda/3
module load hdf5-mpi
```
Then the virtual environment with mpi4py and h5py can be created using the following commands:
```
export CC=$(which mpicc)
export HDF5_MPI="ON"
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --no-binary=mpi4py mpi4py
python3 -m pip install --no-binary=h5py h5py
python3 -m pip install -r requirements.txt
```
The virtual environment can be accessed using `source venv/bin/activate` and is deactivated with the command `deactivate`.


Run
===

The pure python code can be run using the command:

python fullSimulation.py

There are 2 obligatory positional arguments. The first is the end time of the simulation. The second is the maximum real-world runtime.

In addition there are 3 optional arguments:
-f foldername
-c constantsFile
-s saveStep

Either a constants file or a folder containing a constants file must be provided.

Example constants files can be found in the testSetups/ folder

Acceleration
============

The code can be run using pure python, using acceleration provided by numba or using acceleration provided by pyccel.

Numba
=====

In order to run pygyro using numba, the numba package must be installed.

The command

```
make ACC=numba numba
```

will compile the code using the numba ahead-of-time compiler.

The code can then be run as previously described for the pure python setup.

Pyccel
======

In order to run pygyro using pyccel, the pyccel package must be installed.

The command

```
make ACC=pycc LANGUAGE=[X] pycc
```

will compile the code which has been generated by pyccel. Where [X] is one of: fortran, c

The code can then be run as previously described for the pure python setup.

When using the pyccel generated code the option `COMP=intel` can also be specified if the intel compiler should be used.

These options can all be specified in the makefile. A simple `make` command defaults to `make ACC=pycc LANGUAGE=fortran pycc COMP=gnu`.

Pythran
=======

In order to run pygyro using pythran, the pythran package must be installed.

The command

```
make ACC=pythran pythran
```

will compile the code using pythran.

The code can then be run as previously described for the pure python setup.

Plotting
========

Several plotting tools are provided inside the plotting/ folder.

Some of these import tools from inside pygyro. In order to use these please run the following command from the pygyro home directory before calling them:

```
export PYTHONPATH=$(pwd)
```

About

Python library for parallel gyro-kinetic simulations

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages