Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Gkeyll documentation
Light Logo Dark Logo
Gkeyll documentation
  • Installing \(\texttt{Gkeyll}\)
  • \(\texttt{Gkeyll}\) Quick Start Guide
  • Postgkyl
    • Installation
    • Examples
      • Inspect a field and extract a lineout
      • Compare profiles across calculations
      • Recover pressure from conserved moments
      • Inspect a gyrokinetic distribution
      • Load derived gyrokinetic quantities
      • Plot in physical R–Z coordinates
      • Measure exponential growth
      • Choose the arithmetic representation
      • Load many files, collect, and animate
      • Plotly: 2-D height surfaces and 3-D isosurfaces
      • PyVista: contours and translucent volumes
      • Access grids and values directly
      • Plot a multiblock dataset
      • Command-line workflows
      • Python and CLI figure comparisons
    • Python API
      • postgkyl.load
      • postgkyl.plot
      • postgkyl.group_blocks
      • postgkyl.info
      • postgkyl.print
      • postgkyl.integrate
      • postgkyl.interpolate
      • postgkyl.local_poly
      • postgkyl.select
      • postgkyl.average
      • postgkyl.eval_at_coord_proj
      • postgkyl.fft
      • postgkyl.magsq
      • postgkyl.mask
      • postgkyl.grid
      • postgkyl.val2coord
      • postgkyl.extract_input
      • postgkyl.fit
      • postgkyl.growth
      • postgkyl.differentiate
      • postgkyl.map
      • postgkyl.represent
      • postgkyl.apply
      • postgkyl.map_to_rz
      • postgkyl.resolve_rz_projection
      • postgkyl.resolve_geometry
      • postgkyl.extract_flux_surface
      • postgkyl.resolve_flux_surface_grid
      • postgkyl.save
      • postgkyl.collect
      • postgkyl.evaluate
      • postgkyl.relchange
      • postgkyl.animate
      • postgkyl.plotly_animate
      • postgkyl.sort
      • postgkyl.available_evaluate_operators
      • postgkyl.plotly
      • postgkyl.pyvista
      • postgkyl.version_report
      • postgkyl.gk.load_distf
      • postgkyl.gk.resolve_frames
      • postgkyl.gk.available_quantities
      • postgkyl.gk.load_quantity
      • postgkyl.gk.fetch_beta_from_bmag_press
      • postgkyl.gk.fetch_diamag_vel
      • postgkyl.gk.fetch_ExB_vel
      • postgkyl.gk.fetch_gradB_vel
      • postgkyl.gk.fetch_M1_from_H
      • postgkyl.gk.fetch_press_from_BiMax
      • postgkyl.gk.fetch_press_from_Max
      • postgkyl.gk.fetch_press_p
      • postgkyl.gk.fetch_Tpar_from_BiMax
      • postgkyl.gk.fetch_Tpar_from_M0_M1_M2par
      • postgkyl.gk.fetch_temp_from_Max
      • postgkyl.gk.fetch_temp_from_Tpar_Tperp
      • postgkyl.gk.fetch_Tperp_from_BiMax
      • postgkyl.gk.fetch_Tperp_from_M0_M2perp
      • postgkyl.gk.energy_balance_error
      • postgkyl.gk.energy_balance
      • postgkyl.gk.particle_balance
      • postgkyl.gk.particle_balance_error
      • postgkyl.gk.nodes
      • postgkyl.gk.multib_tag
      • postgkyl.gk.nodes_to_RZ
      • postgkyl.diagnostics.vm.kinetic.materialize_point_values
      • postgkyl.diagnostics.vm.kinetic.transform_frame
      • postgkyl.diagnostics.vm.trajectory.trajectory
      • postgkyl.diagnostics.mom.enstrophy.enstrophy
      • postgkyl.diagnostics.mom.five_moment.binary
      • postgkyl.diagnostics.mom.five_moment.density
      • postgkyl.diagnostics.mom.five_moment.ke
      • postgkyl.diagnostics.mom.five_moment.mach
      • postgkyl.diagnostics.mom.five_moment.pressure
      • postgkyl.diagnostics.mom.five_moment.sound
      • postgkyl.diagnostics.mom.five_moment.temp
      • postgkyl.diagnostics.mom.five_moment.vel
      • postgkyl.diagnostics.mom.five_moment.velocity
      • postgkyl.diagnostics.mom.five_moment.xvel
      • postgkyl.diagnostics.mom.five_moment.yvel
      • postgkyl.diagnostics.mom.five_moment.zvel
      • postgkyl.diagnostics.mom.ke_dke.ke_dke
      • postgkyl.diagnostics.mom.mhd.bi
      • postgkyl.diagnostics.mom.mhd.bx
      • postgkyl.diagnostics.mom.mhd.by
      • postgkyl.diagnostics.mom.mhd.bz
      • postgkyl.diagnostics.mom.mhd.mach
      • postgkyl.diagnostics.mom.mhd.mag_pressure
      • postgkyl.diagnostics.mom.mhd.pressure
      • postgkyl.diagnostics.mom.mhd.sound
      • postgkyl.diagnostics.mom.mhd.temp
      • postgkyl.diagnostics.mom.multispecies.accumulate_current
      • postgkyl.diagnostics.mom.multispecies.energetics
      • postgkyl.diagnostics.mom.plasma.beta
      • postgkyl.diagnostics.mom.plasma.d
      • postgkyl.diagnostics.mom.plasma.lambdaD
      • postgkyl.diagnostics.mom.plasma.magB
      • postgkyl.diagnostics.mom.plasma.omegaC
      • postgkyl.diagnostics.mom.plasma.omegaP
      • postgkyl.diagnostics.mom.plasma.rho
      • postgkyl.diagnostics.mom.plasma.vA
      • postgkyl.diagnostics.mom.plasma.vt
      • postgkyl.diagnostics.mom.rotations.parrotate
      • postgkyl.diagnostics.mom.rotations.perprotate
      • postgkyl.diagnostics.mom.rotations.bparrotate
      • postgkyl.diagnostics.mom.rotations.bperprotate
      • postgkyl.diagnostics.mom.ten_moment.agyro
      • postgkyl.diagnostics.mom.ten_moment.ke
      • postgkyl.diagnostics.mom.ten_moment.mach
      • postgkyl.diagnostics.mom.ten_moment.mom_agyro
      • postgkyl.diagnostics.mom.ten_moment.p_par
      • postgkyl.diagnostics.mom.ten_moment.p_perp
      • postgkyl.diagnostics.mom.ten_moment.pressure
      • postgkyl.diagnostics.mom.ten_moment.pressure_tensor
      • postgkyl.diagnostics.mom.ten_moment.pxx
      • postgkyl.diagnostics.mom.ten_moment.pxy
      • postgkyl.diagnostics.mom.ten_moment.pxz
      • postgkyl.diagnostics.mom.ten_moment.pyy
      • postgkyl.diagnostics.mom.ten_moment.pyz
      • postgkyl.diagnostics.mom.ten_moment.pzz
      • postgkyl.diagnostics.mom.ten_moment.sound
      • postgkyl.diagnostics.mom.ten_moment.temp
      • postgkyl.diagnostics.pkpm.laguerre_compose
      • postgkyl.diagnostics.pkpm.load_pkpm
      • postgkyl.diagnostics.discovery.available_frames
      • postgkyl.diagnostics.discovery.find_output_stems
      • GData
        • postgkyl.GData.backend
        • postgkyl.GData.bounds
        • postgkyl.GData.clone
        • postgkyl.GData.div
        • postgkyl.GData.file_name
        • postgkyl.GData.get_bounds
        • postgkyl.GData.get_grid
        • postgkyl.GData.get_grid_type
        • postgkyl.GData.get_label
        • postgkyl.GData.get_num_cells
        • postgkyl.GData.get_num_comps
        • postgkyl.GData.get_num_dims
        • postgkyl.GData.get_tag
        • postgkyl.GData.get_values
        • postgkyl.GData.grid
        • postgkyl.GData.info
        • postgkyl.GData.is_interpolated
        • postgkyl.GData.label
        • postgkyl.GData.load
        • postgkyl.GData.mul
        • postgkyl.GData.native
        • postgkyl.GData.num_cells
        • postgkyl.GData.num_comps
        • postgkyl.GData.num_dims
        • postgkyl.GData.output_name
        • postgkyl.GData.push
        • postgkyl.GData.set_grid
        • postgkyl.GData.set_label
        • postgkyl.GData.set_tag
        • postgkyl.GData.set_values
        • postgkyl.GData.tag
        • postgkyl.GData.val2coord
        • postgkyl.GData.values
      • GDataGroup
        • postgkyl.GDataGroup.animate
        • postgkyl.GDataGroup.collect
        • postgkyl.GDataGroup.datasets
        • postgkyl.GDataGroup.evaluate
        • postgkyl.GDataGroup.info
        • postgkyl.GDataGroup.load
        • postgkyl.GDataGroup.plotly_animate
        • postgkyl.GDataGroup.sort
        • postgkyl.GDataGroup.with
    • Command reference
      • pgkyl average
      • pgkyl collect
      • pgkyl differentiate
      • pgkyl eval_at_coord_proj
      • pgkyl evaluate
      • pgkyl extract_flux_surface
      • pgkyl fft
      • pgkyl fit
      • pgkyl grid
      • pgkyl growth
      • pgkyl integrate
      • pgkyl interpolate
      • pgkyl local_poly
      • pgkyl magsq
      • pgkyl map
      • pgkyl map_to_rz
      • pgkyl mask
      • pgkyl relchange
      • pgkyl represent
      • pgkyl select
      • pgkyl sort
      • pgkyl val2coord
      • pgkyl discovery_available_frames
      • pgkyl discovery_find_output_stems
      • pgkyl gk_energy_balance
      • pgkyl gk_load_distf
      • pgkyl gk_load_quantity
      • pgkyl gk_nodes
      • pgkyl gk_particle_balance
      • pgkyl mom_enstrophy_enstrophy
      • pgkyl mom_five_moment_density
      • pgkyl mom_five_moment_ke
      • pgkyl mom_five_moment_mach
      • pgkyl mom_five_moment_pressure
      • pgkyl mom_five_moment_sound
      • pgkyl mom_five_moment_temp
      • pgkyl mom_five_moment_vel
      • pgkyl mom_five_moment_velocity
      • pgkyl mom_five_moment_xvel
      • pgkyl mom_five_moment_yvel
      • pgkyl mom_five_moment_zvel
      • pgkyl mom_ke_dke_ke_dke
      • pgkyl mom_mhd_bi
      • pgkyl mom_mhd_bx
      • pgkyl mom_mhd_by
      • pgkyl mom_mhd_bz
      • pgkyl mom_mhd_density
      • pgkyl mom_mhd_mach
      • pgkyl mom_mhd_mag_pressure
      • pgkyl mom_mhd_pressure
      • pgkyl mom_mhd_sound
      • pgkyl mom_mhd_temp
      • pgkyl mom_mhd_vel
      • pgkyl mom_mhd_xvel
      • pgkyl mom_mhd_yvel
      • pgkyl mom_mhd_zvel
      • pgkyl mom_multispecies_accumulate_current
      • pgkyl mom_multispecies_energetics
      • pgkyl mom_plasma_beta
      • pgkyl mom_plasma_d
      • pgkyl mom_plasma_lambdaD
      • pgkyl mom_plasma_magB
      • pgkyl mom_plasma_omegaC
      • pgkyl mom_plasma_omegaP
      • pgkyl mom_plasma_rho
      • pgkyl mom_plasma_vA
      • pgkyl mom_plasma_vt
      • pgkyl mom_rotations_bparrotate
      • pgkyl mom_rotations_bperprotate
      • pgkyl mom_rotations_parrotate
      • pgkyl mom_rotations_perprotate
      • pgkyl mom_ten_moment_agyro
      • pgkyl mom_ten_moment_density
      • pgkyl mom_ten_moment_ke
      • pgkyl mom_ten_moment_mach
      • pgkyl mom_ten_moment_mom_agyro
      • pgkyl mom_ten_moment_p_par
      • pgkyl mom_ten_moment_p_perp
      • pgkyl mom_ten_moment_pressure
      • pgkyl mom_ten_moment_pressure_tensor
      • pgkyl mom_ten_moment_pxx
      • pgkyl mom_ten_moment_pxy
      • pgkyl mom_ten_moment_pxz
      • pgkyl mom_ten_moment_pyy
      • pgkyl mom_ten_moment_pyz
      • pgkyl mom_ten_moment_pzz
      • pgkyl mom_ten_moment_sound
      • pgkyl mom_ten_moment_temp
      • pgkyl mom_ten_moment_vel
      • pgkyl mom_ten_moment_xvel
      • pgkyl mom_ten_moment_yvel
      • pgkyl mom_ten_moment_zvel
      • pgkyl pkpm_laguerre_compose
      • pgkyl pkpm_load_pkpm
      • pgkyl vm_kinetic_transform_frame
      • pgkyl vm_trajectory_trajectory
      • pgkyl animate
      • pgkyl plot
      • pgkyl plotly
      • pgkyl plotly_animate
      • pgkyl pyvista
      • pgkyl extract_input
      • pgkyl info
      • pgkyl load
      • pgkyl print
      • pgkyl save
    • Working with data
    • Migrating existing workflows
    • Gyrokinetic quantities
    • Developing Postgkyl
    • Troubleshooting and documentation development
    • Documentation source
  • Publications and theses
  • Presentations
  • Developer notes
    • On Developing and Contributing Code to Gkeyll Ecosystem
    • Suggested templates for issues and pull requests to Gkeyll
    • On use of the Maxima CAS
    • Modal basis functions
    • The recovery Maxima code
    • Strong-Stability preserving Runge-Kutta time-steppers
    • Normalized units for the Vlasov-Maxwell system
    • From normalized to physical units in Vlasov and multi-fluid simulations
    • Collision models in Gkeyll
    • The eigensystem of the Maxwell equations with extension to perfectly hyperbolic Maxwell equations
    • The eigensystem of the Euler equations
    • The eigensystem of the ten-moment equations
    • Handling two-fluid five-moment and ten-moment source terms
    • Time step calculation in Gkeyll
    • On Utlilizing The Built-In Debugger For Lua
    • The equations of general relativistic hydrodynamics (GRHD) in Gkeyll
    • The eigensystem of the general relativistic hydrodynamics (GRHD) equations
    • Black hole spacetimes in Gkeyll
    • Relativistic primitive variable reconstruction in Gkeyll
    • Tokamak Topology
    • How to run Valgrind on Gkeyll
    • Guidelines on adding a new regression test
  • Required development processes
    • Gkeyll Design and Code Review Process
    • Gkeyll Design and Code Review Process: Condensed Version
    • Design and Code Review Personnel
  • License
Back to top
View this page

Modal basis functions¶

Each of the kinetic equations Gkeyll’s solvers discretize using the discontinuous Galerkin algorithm—the Vlasov equation, the gyrokinetic equation, and the PKPM system—all benefit from utilizing polynomials for the basis in the underlying solution space. There is enormous freedom for the specific form of the polynomials, and Gkeyll benefits from a specific class of orthonormal modal basis functions for representing the discrete distribution function and other variables of interest.

These basis functions are defined on a d-dimensional hypercube \(I_d = [-1,1]^d\). Let \(\psi_k(\mathbf{x})\), \(k=1,\ldots,N\), with \(\psi_1\) a constant, be the basis. Then the basis satisfy

\[\langle \psi_k \psi_m \rangle = \delta_{km}\]

where the angle brackets indicate integration over the hypercube \(I_d\). In this note we describe some common operations that are needed while working with these basis sets.

Pre-computed basis functions¶

Precomputed modal basis sets on phase-space for 1x1v, 1x2v, 1x3v, 2x2v, 2x3v, 3x2v, and 3x3v phase-space are stored as Lisp files in gkyl/cas-scripts/basis-precalc directory. Both maximal-order and serendipity basis sets are computed for polynomial orders 1, 2, 3 and 4. Computing orthonormal basis set in higher dimensions is time-consuming and so these pre-computed lisp files should be used. For example:

load("basis-precalc/basisSer2x3v")

will load the serendipity basis sets in 2x3v phase-space.

NOTE: please read Maxima notes to get this command to work.

The files define the following Maxima variables:

varsC, varsP, basisC, basisP

The varsC are the configuration-space independent variables (\(x,y\) in 2X) and varsP are the phase-space independent variables (\(x,y,vx,vy,vz\) in 2X3V). The i-th entry in the list basisC and basisP contain the basis sets of polynomial order \(i\). Hence, to access the phase-space basis for \(p=2\) do something like:

basisP2 : basisP[2].

Computing cell averages¶

Consider some function that is expanded in the basis:

\[f(\mathbf{x}) = \sum_k f_k \psi_k\big(\boldsymbol{\eta}(\mathbf{x})\big)\]

where \(\boldsymbol{\eta}(\mathbf{x})\) maps the physical space to logical space. Then, the cell-average is defined as

\[\overline{f} = \frac{1}{2^d} \langle f \rangle = \frac{1}{2^d} f_1\psi_1 \langle 1 \rangle = f_1\psi_1.\]

where \(\psi_1\) is constant. By orthonormality we have \(\langle \psi_1^2 \rangle = 1\) which indicates that

\[\psi_1 = \frac{1}{\sqrt{2^d}}.\]

This means that the cell-average is given by

\[\overline{f} = \frac{f_1}{\sqrt{2^d}}\]

Convolution of two functions¶

Now consider two functions, \(f\) and \(g\) that are both expanded in the basis. The inner product of the two functions is:

\[\overline{f g} = \frac{1}{2^d} \langle f g \rangle\]

Note the the bar on the LHS, i.e. this expression gives the average of the inner product on a single cell. Now, as the basis functions are orthonormal, this leads to the particularly simple expression

\[\overline{f g} = \frac{1}{2^d} \sum_k f_k g_k\]

This makes it very easy to compute things like electromagnetic energy, and other quadratic quantities.

Next
The recovery Maxima code
Previous
On use of the Maxima CAS
Copyright © 2016-2025, Gkeyll Team
Made with Sphinx and @pradyunsg's Furo
On this page
  • Modal basis functions
    • Pre-computed basis functions
    • Computing cell averages
    • Convolution of two functions