liu-lijun188 / SymPIC

The Symplectic Particle-in-Cell Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SymPIC

The symplectic structure preserving particle-in-cell (PIC) code is designed for long-term simulations of the Vlasov-Maxwell system. It exactly preserves the symplectic two-form associated with the discrete Hamiltonian Vlasov-Maxwell equation and in most cases numeric errors of invariants such as the total energy and momentum will be bounded within a small value during the whole simulation.

This is a MPI and OpenMP implemention of the parallel explicit 2nd-order charge conservative non-canonical symplectic PIC scheme introduced in Ref. [1] and the 1st-order relativistic charge conservative symplectic PIC scheme in Ref. [2]. Some codes are compiled for x86-64 machines. Most c files are generated by a scheme-like lisp dialect PSCMC designed for multi-platform parallel programmings. Source code will be opened in the near future.

In this program, uthash.h (http://troydhanson.github.com/uthash/) is used.

To build the program, run the following command:

./compile.sh

We have only tested the clang5.0/6.0, gcc-7.3.1 and icc-11 compiler.

Configuration files are executable scheme (a dialect of lisp) codes. To run the example,

cd example

STDLIB=../stdlib.scm mpirun -n 4 ../sympic x_ebw.ss

After it exits, three files (tmpEB tmpEN and tmpJ) will be generated. These files are in the GAPS-IO format. We can use the matplotlib (ipython) to show the spectrum of the extraordinary and electron Bernstein wave.

execfile("../cgapsio/pygapsio.py")

Ey_field=reshape(GAPS_IO_Load("tmpEB"),[512,2,512,3])[:,0,:,1]

contour(abs(fftn(Ey_field))[:60,:256])

The tmpEB file stores the electromagnetic fields, its shape is 2Nt * Nz * Ny * Nx * 3, where for 0, 2, 4, ... time step the electric field is stored, and for 1, 3, 5, ... time step the magnetic field is stored. The tmpEN file stores some particle informations, currently its shape is Nt * Nz * Ny * Nx * (7NUM_SPEC), where 7 components are

\sum_{p \in grid} [m_i vx_p^2/2,m_i vy_p^2/2,m_i vz_p^2/2, vx_p, vy_p, vz_p, 1].

There is also a GUI based on Tkinter(python2) for generating and modifying the configuration files, it is located at gui/gui.py

cd gui

export STDLIB=../stdlib.scm

python2 gui.py

[1] Physics of Plasmas 22, 112504 (2015); https://aip.scitation.org/doi/abs/10.1063/1.4935904

[2] Plasma Science and Technology 20, 110501 (2018); https://iopscience.iop.org/article/10.1088/2058-6272/aac3d1

About

The Symplectic Particle-in-Cell Code

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C 98.1%Language:Objective-C 1.0%Language:Makefile 0.3%Language:Scheme 0.2%Language:C++ 0.2%Language:Python 0.1%Language:Shell 0.0%