# Modules

ModuleSource FileDescription
mod_arpack_typemod_arpack_type.f08

Module containing a dedicated type for the ARPACK solvers. All needed variables are defined and allocated here, along with sanity checks when setting certain values.

mod_assertmod_assert.f08

Module defining the assertion routine used by assert.fpp.

mod_atmosphere_curvesmod_atmosphere_curves.f08

Contains data for a realistic solar atmosphere model taken from Avrett, E. H., & Loeser, R. (2008). Models of the solar chromosphere and transition region from SUMER and HRTS observations: formation of the extreme-ultraviolet spectrum of hydrogen, carbon, and oxygen. ApJS, 175(1), 229. link.

mod_boundary_managermod_boundary_manager.f08
smod_essential_boundariessmod_essential_boundaries.f08
smod_natural_boundariessmod_natural_boundaries.f08
smod_natural_bounds_conductionsmod_natural_bounds_conduction.f08
smod_natural_bounds_flowsmod_natural_bounds_flow.f08
smod_natural_bounds_hallsmod_natural_bounds_hall.f08
smod_natural_bounds_regularsmod_natural_bounds_regular.f08
smod_natural_bounds_resistivesmod_natural_bounds_resistive.f08
smod_natural_bounds_viscositysmod_natural_bounds_viscosity.f08
mod_check_valuesmod_check_values.f08

This module contains various methods to check for small, NaN or negative values, equal values or inf values. Interfaces are provided for functionality with real and complex variables.

mod_cooling_curvesmod_cooling_curves.f08

All data of the different cooling curves is contained in this module, along with handling piecewise cooling curves.

mod_eigenfunctionsmod_eigenfunctions.f08

Main module responsible for eigenfunction management. Contains routines and interfaces to initialise and calculate the eigenfunctions and derived quantities.

smod_base_efssmod_base_efs.f08

This submodule initialises and calculates the base eigenfunctions, i.e. the ones corresponding to the basic state vector variables (rho, v1, v2, etc.)

smod_ef_operationssmod_ef_operations.f08

This submodule contains procedures and functions to be used when we are either assembling eigenfunctions based on the eigenvectors, or retransforming them.

smod_derived_efssmod_derived_efs.f08

This submodule calculates various quantities derived from the base eigenfunctions: - entropy S - $\nabla \cdot \mathbf{v}_1$ - all 3 components of $\nabla \times \mathbf{v}_1$ - $\nabla \cdot \mathbf{B}_1$ - all 3 components of $\mathbf{B}_1$ - all 3 components of $\nabla \times \mathbf{B}_1$

smod_derived_pp_efssmod_derived_pp_efs.f08

This submodule calculates quantities derived from the base eigenfunctions that are parallel or perpendicular to the background magnetic field: - parallel and perpendicular components of $\mathbf{B}_1$ - parallel and perpendicular components of $\nabla \times \mathbf{B}_1$ - parallel and perpendicular components of $\mathbf{v}_1$ - parallel and perpendicular components of $\nabla \times \mathbf{v}_1$

mod_equilibriummod_equilibrium.f08

Parent module governing all equilibrium types and submodules. This module contains all equilibrium types and the initial declarations of the module subroutines. Every equilibrium submodule extends this module, implementing one of the module subroutines declared here. All "main" equilibrium configurations are set in the submodules. The ones that depend on "main" arrays, like radiative cooling, are set here through calls to their respective modules.

This submodule defines a simple, adiabatic homogeneous medium in Cartesian geometry. The geometry can be overridden using the parfile.

smod_equil_constant_currentsmod_equil_constant_current.f08

This submodule defines an equilibrium in cylindrical geometry with a constant axial current. The geometry can be overridden using the parfile.

smod_equil_coronal_flux_tubesmod_equil_coronal_flux_tube.f08

This submodule defines a magnetic flux tube embedded in a uniform magnetic environment. In this case the flux tube is under coronal conditions $c_s < c_A < c_{Ae}$ where the subscript e denotes the outer region. More specifically the equilibrium is defined as $c_{Ae} = 5c_s, c_{se} = c_s/2, c_A = 2c_s$. The geometry can be overridden in the parfile, and is cylindrical by default for $r \in [0, 10]$.

smod_equil_couette_flowsmod_equil_couette_flow.f08

This submodule defines a steady plane Couette flow in a Cartesian geometry.

smod_equil_discrete_alfvensmod_equil_discrete_alfven.f08

This submodule defines an equilibrium in cylindrical geometry with an axial current profile ($\nu = 2$), modelling a solar coronal loop in which discrete Alfvén waves are present. The geometry can be overridden in the parfile.

smod_equil_flow_driven_instabilitiessmod_equil_flow_driven_instabilities.f08

This submodule defines flow driven instabilities in a Cartesian geometry. This equilibrium can not be called explicitly from the parfile, but rather acts as a "parent setup" for the Rayleigh-Taylor and Kelvin-Helmholtz submodules which use this specific kind of equilibrium but with different parameters. This submodule is called within its implicit children.

smod_equil_gold_hoylesmod_equil_gold_hoyle.f08

This submodule defines a Gold-Hoyle equilibrium in cylindrical geometry. This equilibrium configuration models a filament with a uniform twist such that all fieldlines perform an equal amount of turns around the cylinder axis. The geometry can be overridden in the parfile.

smod_equil_gravito_acousticsmod_equil_gravito_acoustic.f08

This submodule defines an equilibrium in Cartesian geometry with a stratified equilibrium profile, giving rise to gravito-acoustic waves. No magnetic fields are included, such that this treats the hydrodynamic regime. The geometry can be overridden using the parfile.

smod_equil_gravito_mhdsmod_equil_gravito_mhd.f08

This submodule defines an equilibrium in Cartesian geometry with a stratified equilibrium profile, giving rise to gravito-MHD waves. The geometry can be overridden using the parfile.

smod_equil_harris_sheetsmod_equil_harris_sheet.f08

This submodule defines a resistive equilibrium with tearing modes created by a Harris sheet.

smod_equil_interchange_modessmod_equil_interchange_modes.f08

This submodule defines an exponentially stratified medium in Cartesian geometry with a constant gravity term and magnetic shear. The geometry can be overridden in the parfile.

smod_equil_internal_kink_instabilitysmod_equil_internal_kink_instability.f08

This submodule defines internal kink modes in force-free magnetic fields. The geometry is cylindrical with parabolic density and velocity profiles, The geometry can be overridden in the parfile.

smod_equil_isothermal_atmospheresmod_equil_isothermal_atmosphere.f08

This submodule defines an equilibrium in Cartesian geometry with a stratified equilibrium profile, representing a solar magnetic atmosphere. The equilibrium is isothermal with a constant magnetic field. The scale height is given by The geometry is fixed to Cartesian, boundaries can be overridden using the parfile.

smod_equil_kelvin_helmholtz_cdsmod_equil_kelvin_helmholtz_cd.f08

This submodule defines an unperturbed magnetised jet model in cylindrical geometry, giving rise to Kelvin-Helmholtz and current-driven instabilities. The geometry is fixed for this problem; the cylinder wall is dependent on the equilibrium parameters and is given by 2rj.

smod_equil_KHIsmod_equil_KHI.f08

This submodule defines Kelvin-Helmholtz instabilities in Cartesian geometry. This equilibrium is a specific case of the flow driven instabilities. No magnetic fields are considered in this case (pure HD).

smod_equil_magnetothermal_instabilitiessmod_equil_magnetothermal_instabilities.f08

This submodule defines an equilibrium containing magnetothermal instabilities in a cylindrical geometry. The geometry can be overridden in the parfile.

smod_equil_MRIsmod_equil_MRI_accretion.f08

This submodule defines magneto-rotational instabilities in an accretion disk. Due to the special nature of this equilibrium x_start is hardcoded to one and can not be overridden in the parfile, the same goes for the geometry which is hardcoded to 'cylindrical'. The outer edge can be chosen freely. This equilibrium is chosen in such a way that the angular rotation is of order unity, implying Keplerian rotation. The thin-disk approximation is valid with small magnetic fields, but still large enough to yield magneto-rotational instabilities. Gravity is assumed to go like $g \thicksim 1/r^2$.

smod_equil_photospheric_flux_tubesmod_equil_photospheric_flux_tube.f08

This submodule defines a magnetic flux tube embedded in a uniform magnetic environment. In this case the flux tube is under photospheric conditions $c_{Ae} < c_s < c_{se} < c_A$ where the subscript e denotes the outer region. More specifically the equilibrium is defined as $c_{Ae} = c_s/2, c_{se} = 3c_s/2, c_A = 2c_s$. The geometry can be overridden in the parfile, and is cylindrical by default for $r \in [0, 10]$.

smod_equil_resistive_homosmod_equil_resistive_homo.f08

This submodule defines a simple, homogeneous medium in Cartesian geometry with a constant resistivity value. The geometry can be overridden using the parfile.

smod_equil_resistive_tearingsmod_equil_resistive_tearing.f08

This submodule defines an equilibrium in Cartesian geometry with a constant resistivity value. Parameters are taken in such a way as to allow for resistive tearing modes. The geometry can be overridden using the parfile.

smod_equil_resistive_tearing_flowsmod_equil_resistive_tearing_flow.f08

This submodule defines an equilibrium in Cartesian geometry with a flow profile and a constant resistivity value. Parameters are taken in such a way as to allow for resistive tearing modes. The geometry can be overridden using the parfile.

smod_equil_resonant_absorptionsmod_equil_resonant_absorption.f08

This submodule defines an inhomogeneous medium in Cartesian geometry with a constant resistivity value. Two (constant) density profiles are defined which are connected by a sine profile, representing the interface inbetween. This density profile allows for resonant absorption, the geometry can be overridden in the parfile.

smod_equil_rotating_plasma_cylindersmod_equil_rotating_plasma_cylinder.f08

This submodule defines a cylindrical equilibrium, resembling a rotating plasma cylinder. The geometry can be overridden using the parfile.

smod_equil_RTIsmod_equil_RTI.f08

This submodule defines Rayleigh-Taylor instabilities in Cartesian geometry. This equilibrium is a specific case of the flow driven instabilities.

smod_equil_RTI_KHIsmod_equil_RTI_KHI.f08

This submodule defines Rayleigh-Taylor and Kelvin-Helmholtz instabilities in Cartesian geometry. This equilibrium is a specific case of the flow driven instabilities.

smod_equil_RTI_theta_pinchsmod_equil_RTI_theta_pinch.f08

This submodule defines Rayleigh-Taylor instabilities in rotating theta pinches. The straight cylinder approximation is used with a constant angular frequency. Density and pressure profiles decrease over the domain, with a uni-directional increasing magnetic field profile. Mode numbers $k = 0$ correspond to HD Rayleigh-Taylor instabilities, while $k \neq 0$ represent MHD RTIs. The geometry is hardcoded to 'cylindrical', the domain is forced to $0 <= r <= 1$ through division by x_end.

smod_equil_suydam_clustersmod_equil_suydam_cluster.f08

This submodule defines a cylindrical equilibrium in which a Suydam surface is present, such that this gives rises to Suydam cluster modes. The geometry can be overriden using the parfile.

smod_equil_taylor_couettesmod_equil_taylor_couette.f08

This submodule defines a steady Taylor-Couette flow in a cylindrical geometry where a fluid is confined between two (rotating) coaxial cylinders (without a magnetic field).

smod_equil_tc_pinchsmod_equil_tc_pinch.f08

This submodule defines a steady Taylor-Couette flow in a cylindrical geometry where a plasma is confined between two (rotating) coaxial cylinders with an azimuthal magnetic field and constant resistivity.

smod_user_definedsmod_user_defined.f08

Submodule for user-defined equilibria. Look at the examples in the equilibria subdirectory or consult the website for more information.

mod_equilibrium_paramsmod_equilibrium_params.f08

Module containing all equilibrium parameters. All parameters used in the equilibrium submodules are defined here for convenience, including the wave numbers $k_2$ and $k_3$. All of these values are NaN initially, such that variables that are not properly set propagate their value and are easy to spot in follow-up checks.

mod_exceptionsmod_exceptions.f08

Module to explicitly handle exceptions. Depending on the application at hand we override what happens when an exception is raised, which is useful for testing purposes (no error stop if we expect something to fail). Loosely based on an example given in https://github.com/Goddard-Fortran-Ecosystem/pFUnit_demos/blob/main/Basic/src/throw.F90

mod_global_variablesmod_global_variables.f08

All global variables are defined in this module, and can be accessed throughout the entire code. Most variables are first initialised to a default value, and are properly set either in the parfile or in an equilibrium submodule.

mod_gridmod_grid.f08

Module containing all grid-related things. Contains subroutines to create the base grid, Gaussian grid and scale factors. Also handles mesh accumulation. An integral of $f(x)$ in $[a, b]$ can be approximated with where $w_i$ and $x_i$ are the weights and nodes of the Gaussian quadrature. The Gaussian grid is hence set up in every interval $[a, b]$ across the four nodes $j$ as

mod_hallmod_hall.f08

!> Module containing Hall-related routines, calculates and sets the Hall and inertia term factors based on the specified profiles.

mod_inputmod_input.f08

Module to handle parfile reading. Contains subroutines to retrieve the parfile based on the commandline arguments and to read the parfile, setting the global variables.

mod_inspectionsmod_inspections.f08

Module to inspect if certain conditions are fulfilled by doing additional sanity checks on the equilibrium configuration. For cylindrical geometries we check if $k_2$ is an integer and if the on-axis values obey regularity conditions. Equilibrium balance for both the Cartesian and cylindrical cases is checked.

mod_integrationmod_integration.f08

Module responsible for integration of differential equations, useful when setting equilibria or integrating the equilibrium equation. Contains subroutines to numerically solve the following systems of differential equations: These are solved using a fifth-order Runge-Kutta method.

mod_interpolationmod_interpolation.f08

Module responsible for table interpolations and array lookups. Contains subroutines for table interpolations, numerical derivatives of arrays and lookup functions. Subroutines are loosely based on routines implemented in the MPI-AMRVAC code.

mod_loggingmod_logging.f08

Main handler for console print statements. The level of information printed to the console depends on the corresponding global variable called logging_level defined in the parfile.

mod_make_subblockmod_make_subblock.f08

Module to build a single quadblock by creating the four comprising subblocks. This is done for every grid interval, for specific integral elements and spline functions.

mod_matrix_creationmod_matrix_creation.f08

Assembly of the finite element matrices $\mathcal{A}$ and $\mathcal{B}$ in the matrix eigenvalue problem $\mathcal{A}\textbf{X} = \omega\mathcal{B}\textbf{X}$. Matrix creation proceeds by first assembling a quadblock at every grid interval using the integrals and finite element basis functions, after which this quadblock is shifted along the main diagonal.

mod_matrix_managermod_matrix_manager.f08
smod_conduction_matrixsmod_conduction_matrix.f08
smod_cooling_matrixsmod_cooling_matrix.f08
smod_flow_matrixsmod_flow_matrix.f08
smod_hall_matrixsmod_hall_matrix.f08
smod_regular_matrixsmod_regular_matrix.f08
smod_resistive_matrixsmod_resistive_matrix.f08
smod_viscosity_matrixsmod_viscosity_matrix.f08
mod_matrix_operationsmod_matrix_operations.f08

Module containing various matrix operations (inverting, multiplying, etc). Does calls to relevant BLAS or LAPACK routines.

mod_matrix_shortcutsmod_matrix_shortcuts.f08
mod_outputmod_output.f08

This module contains all routines for file opening and file writing.

mod_paintingmod_painting.f08

This module handles formatting of terminal-printed strings. Contains subroutines to colourise strings.

mod_physical_constantsmod_physical_constants.f08

All physical constants used in the code are defined in this module. We include values both in SI units and in cgs units for convenience. All values are taken from the NRL Plasma Formulary.

Module containing radiative cooling-related routines. This module is responsible for initialising the radiative cooling variables and a correct handling of the cooling curves. If an interpolated cooling curve is selected this module calls the interpolation module to create one.

mod_resistivitymod_resistivity.f08

Module containing resistivity-related routines, calculates and sets the resistivity values based on the equilibrium configuration.

mod_solar_atmospheremod_solar_atmosphere.f08

Module to set a realistic solar atmosphere, using tabulated density and temperature profiles (see mod_atmosphere_curves), in Cartesian geometries only.

mod_solversmod_solvers.f08

Parent module for everything solver-related. Interfaces to the different submodules are defined here, and the solve_evp routine calls the correct solver based on parfile settings.

smod_arnoldismod_arnoldi.f08

Submodule containing the implementation of the various ARPACK solvers. Preprocessor directives are used here, if ARPACK was not found during compilation most of this submodule will not be compiled to avoid unknown calls to methods. We first cycle through the possible modes, set up the relevant matrix operators and call the corresponding methods. Then the reverse communication interface znaupd is called, which will keep iterating until either everything is converged or the maximum number of iterations maxiter is reached. Then eigenvalues are extracted using zneupd, eigenvectors are calculated and the residual of each eigenvalue is computed which should be small for converged values.

smod_qr_invertsmod_qr_invert.f08

Submodule containing the implementation of the QR-invert algorithm. The original problem is written as a standard eigenvalue problem through where $\mathcal{B}$ is always properly conditioned. Various calls to mod_matrix_operations are done to invert the B-matrix and to do matrix multiplications. Eventually a call to LAPACK's zgeev routine is done to obtain all eigenvalues and eigenvectors.

smod_qz_directsmod_qz_direct.f08

Submodule containing the implementation of the QZ-direct algorithm. We keep the general form of the eigenvalue problem and solve this directly by calling LAPACK's zggev routine.

mod_spline_functionsmod_spline_functions.f08

Module that calculates the finite element basis functions. The different basis functions and their derivatives used throughout the code are calculated here. All routines defined in this module simply return the basis functions for a specific point r in the interval (rj_lo, rj_hi).

mod_thermal_conductionmod_thermal_conduction.f08

This module is responsible for calculating and setting the thermal conduction values based on the equilibrium configuration.

mod_timingmod_timing.f08

Module to provide timing facilities.

mod_typesmod_types.f08

Module containing the different types used in the code. All types are defined here, this includes all types where the equilibrium arrays are set as attributes, as well as a type to handle eigenfunctions.

mod_unitsmod_units.f08

This module handles checking and setting all unit normalisations. When setting the normalisations, one should always specify a unit length and a unit magneticfield. The normalisations use a reference value of 2 for plasma beta as is common practice, such that we can write $\beta/2 = \mu * p / B^2 = 1$. The pressure unit is then calculated as Then, if a unit density is specified this fixes the unit temperature and vice-versa, through use of the ideal gas law The other normalisations are then fixed, and are set through Where the latter two denote the luminosity and thermal conduction normalisations.