Pencil Code



The Pencil Code is a high-order finite-difference code for solving partial differential equations, written in Fortran 95. The code is designed for efficient computation with massive parallelization. Due to its modular structure, it can be used for a large variety of physical setups like hydro- and magnetohydrodynamics relevant for, e.g., astrophysics, geophysics, cosmology, turbulence, and combustion. Many such setups are available as ready-to-run samples. Pencil Code is free software released under the GNU GPL v2.

Methods
The computational scheme is finite-difference and non-conservative; the time integration is implemented by an explicit scheme. Due to the usage of the vector potential, the magnetic field is intrinsically divergence free. High-order (4th, 6th, and 10th order, as well as single-sided or upwind) derivatives are available to resolve strong variations on the grid scale. With a set of automated tests, the functionality of the code is validated on a daily basis. MPI is used for parallelization, but the code can also be run non-parallel on a simple PC. There are modules for different time-integration schemes (e.g. three-step Runge–Kutta), treatment of shocks, embedded particle dynamics, chemistry, massive parallel I/O, etc.

Applications
The Pencil Code has mainly been applied to describe compressible turbulence and resistive magnetohydrodynamics. Applications include studies of planet formation, the solar dynamo, mono-chromatic radiative transfer, the coronal heating problem, debris disks, turbulent combustion of solid fuels, and others.

History
The Pencil Code development was started in 2001 by Axel Brandenburg and Wolfgang Dobler during the 'Helmholtz Summer School' at the Helmholtz Research Centre for Geosciences in Potsdam. It was initially used for MHD turbulence simulations. The development was continued by a team of about ten code owners and around 90 additional developers who extended the code for their scientific research. It is used by additional users from various branches of science. The code repository was hosted at NORDITA until 2008 and was then moved to Google Developers. In April 2015 the code was migrated to GitHub. Since June 2018 the Pencil Code supports the HDF5 data format.