Git Product home page Git Product logo

pic-nix's Introduction

PIC-NIX

A Particle-In-Cell (PIC) simulation code for collisionless space plasmas.
This is based on the kinetic plasma simulation framework nix, which can be found here.

Compiling and Executing the Code

Environment Variable

$ export PICNIX_DIR=/some/where/pic-nix

Setting the environment variable PICNIX_DIR is optional, but it will be useful for running diagnostic python scripts.

Clone

Clone the repository to a local working directory via:

$ git clone [email protected]:amanotk/pic-nix.git

Compile

The code can be compiled with cmake, to which a proper C++ compiler and its compiler flags should be specified.
The simplest way is to use a pre-configured cache file provided in cmake directory.
For instance, you can do as follows in the repository's top directory:

$ cmake -S . -B build -C cmake/linux-gcc.cmake
$ cmake --build build

which means that you are going to use mpicxx as a C++ compiler with g++ backend with OpenMP enabled.

This is equivalent to the following manual build configuration:

$ cmake -S . -B build \
	-DCMAKE_CXX_COMPILER=mpicxx \
	-DCMAKE_CXX_FLAGS="-march=native -fopenmp -O3"
$ cmake --build build

Note that this is the so-called out-of-source build, which produces compiled binaries in the build directory (in this particular case). Therefore, you will find executable files main.out in, e.g., build/example/beam.

See here for details about build configuration. Please also refer to CMake Reference Documentation.

Run

You can now execute main.out using mpiexec (or mpirun).
For example, you can run a simulation with default setup in example/beam/twostream.

$ cd build/example/beam/twostream
$ export OMP_NUM_THREADS=2
$ mpiexec -n 8 ../main.out -e 86400 -t 200 -c config.toml

In this example, you use 8 MPI processes, each launching 2 threads. The simulation parameters will be read from the configuration file config.toml.

Available command-line options will be shown with the --help option:

$ ./main.out --help
usage: ./main.out --config=string [options] ...
options:
  -c, --config     configuration file (string)
  -l, --load       prefix of snapshot to load (string [=])
  -s, --save       prefix of snapshot to save (string [=])
  -t, --tmax       maximum physical time (double [=1.79769e+308])
  -e, --emax       maximum elapsed time [sec] (double [=3600])
  -v, --verbose    verbosity level (int [=0])
  -?, --help       print this message

Plot

After finishing the simulation, you can run the following command in the same directory:

$ python batch.py data/profile.msgpack

You will now see image files twosteam-XXXXXXXX.png for each snapshot and twostream.mp4, which is a movie file encoded by using ffmpeg.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.