postgkyl.gk.energy_balance

postgkyl.gk.energy_balance(name, species, *, path='./', relative_error=False, multib='-10', field_dot_file=None, apar_dot_file=None, fdot_file=None, source_file=None, bflux_files=None, f_file=None, field_file=None, apar_file=None, dt_file=None, logy=False, absy=False, xlabel='Time (s)', ylabel=None, title=None, indent_left=0.0, add_width=0.0, show=False, saveas=None)

Plot (and compute) the energy balance of a gyrokinetic simulation.

Requires, per species (named <name>-<species_name>): an _fdot_integrated_moms.gkyl file, and (only if the run had sources or non-periodic boundaries) _source_integrated_moms.gkyl and _bflux_<direction><side>_integrated_HamiltonianMoments.gkyl files. A <name>-field_energy_dot.gkyl file is required; <name>-apar_energy_dot .gkyl is read if present (electromagnetic simulations). If relative_error is requested, the corresponding non-_dot (_integrated_moms.gkyl/field_energy.gkyl/apar_energy.gkyl) and <name>-dt.gkyl files are also required.

Parameters:
  • name – Simulation name (also the file prefix).

  • species – Species names to sum over.

  • path – Directory holding the simulation output.

  • relative_error – Plot the relative error instead of every balance term.

  • multib – "-10" (default) for a single block; "-1" to discover every block; otherwise a comma list or 'start:stop[:step]' slice of block indices (see get_block_indices()).

  • field_dot_file – Explicit field-energy derivative path override.

  • apar_dot_file – Explicit parallel-vector-potential energy derivative path.

  • fdot_file – Explicit distribution derivative moments path override.

  • source_file – Explicit source moments path override.

  • bflux_files – Optional per-boundary path overrides, keyed by "<direction><side>" (e.g. "xlower"); unlisted boundaries use the naming convention.

  • f_file – Explicit integrated distribution moments path override.

  • field_file – Explicit field-energy path override.

  • apar_file – Explicit parallel-vector-potential energy path override.

  • dt_file – Explicit time-step history path override. In path overrides, * stands for block index and, for per-species files, species name.

  • logy – Log-scale the y axis.

  • absy – Take the absolute value of every trace before plotting.

  • xlabel – Horizontal-axis label.

  • ylabel – Vertical-axis label; use the derived formula when None.

  • title – Figure title; use the balance description when None.

  • indent_left – Horizontal axes-position adjustment in figure units.

  • add_width – Axes-width adjustment in figure units.

  • show – Call plt.show() before returning.

  • saveas – If given, save the figure to this path.

Returns:

(figure, traces).

Raises:

FileNotFoundError – if a required file family is missing.

CLI: gk_energy_balance