Skip to content

tberlok/psecas

Repository files navigation

CircleCI Build Status codecov

Psecas

Psecas (Pseudo-Spectral Eigenvalue Calculator with an Automated Solver) is a collection of methods for solving eigenvalue problems (EVPs) using pseudo-spectral methods. Psecas was developed for solving the kind of eigenvalue problem that often arises when a linear stability calculation is performed in astrophysical fluid dynamics. The code was introduced in a MNRAS paper where details on how it all works can be found (arxiv version can be downloaded here).

Gallery and examples

A collection of example calculations and a gallery can be found here.

Publications

So far Psecas has been used in the following publications

  • Berlok, T. & Pfrommer, C. (2019). On the Kelvin-Helmholtz instability with smooth initial conditions – Linear theory and simulations, MNRAS, 485, 908
  • Berlok, T. & Pfrommer, C. (2019). The impact of magnetic fields on cold streams feeding galaxies, MNRAS, 489, 3368
  • Berlok, T., Quataert, E., Pessah, M. & Pfrommer, C. (2019). Suppressed heat conductivity in the intracluster medium: implications for the magneto-thermal instability, MNRAS, 504, 3435

If you are here for the Kelvin-Helmholtz instability verification tests presented in Table 2 in the first paper, then you can find more information here.

How it works

Pseudo-spectral methods are described in e.g. the books Spectral Methods in Matlab by Lloyd N. Trefethen, A Practical Guide to Pseudospectral Methods by Bengt Fornberg and Chebyshev and Fourier Spectral Methods by John P. Boyd.

In Psecas, the user writes down a linearized set of equations, the eigenvalue problem, which is automatically discretized on either an infinite, finite or periodic domain. The resulting EVP can then be solved to a requested precision.

Grids

An overview of various grid types is shown on page 11 in the book by Boyd.

The code currently has all the grids mentioned on this figure, they are illustrated with 9 grid points below:

We use (a fork) of a Python version of

J. A. C. Weidemann and S. C. Reddy, A MATLAB Differentiation Matrix Suite, ACM Transactions on Mathematical Software, 26, (2000): 465-519.

for creating the Laguerre and Hermite grids. The other grids are created using the descriptions in the books by Boyd and Trefethen.

Installation

I assume you have Python 3.6 installed. If so, all requirements are simply installed by running the following command

$ pip install -r requirements.txt

at the top-level directory.

Testing

Before using the code, the tests should be run to make sure that they are working. From the top-level directory

$ pytest tests/

Overview of the code

Psecas consist of three main classes

  • The Grid class

    which contains the grid points and methods for performing spectral differentation on it.

  • The System class

    which contains the linearized equations in string format, and other parameters of the problem. The parameters are allowed to depend on the coordinate.

  • The Solver class

    which contains functionality for

    • automatically creating a (generalized) eigenvalue problem of dimension d × N where N is the number of grids points and d is the number of equations in the system.
    • solving the eigenvalue problem to a specified tolerance, e.g. 1e-6, of the returned eigenvalue.

Developers

Main developer

Thomas Berlok

Contributors

Gopakumar Mohandas (Implementation of the Legendre grid, VSI and Hall-MRI examples, advice and encouragement)

About

A framework for solving numerical eigenvalue problems using pseudo-spectral methods.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages