gbspy.theta module

This file compute the terms on the RHS of the theta equation

gbspy.theta.theta_lhs(gsim, verbose=True, t1=None, t2=None)

Compute the LHS terms of theta equation

Parameters
  • gsim (gbspy.Sim) – Simulation object.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_LHS

Return type

numpy.ndarray

gbspy.theta.theta_rhs(gsim, verbose=True, t1=None, t2=None)

Compute RHS terms of theta equation

A documentation for the returned variables can be found in the GBS documentation.

Parameters
  • gsim (gbspy.Sim) – Simulation object.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_rhs_nl, theta_rhs_cu, theta_rhs_pa, theta_rhs_em, theta_rhs_pd, theta_rhs_so, theta_rhs_di

Return type

numpy.ndarray

gbspy.theta.theta_rhs_cu(gsim, fld='theta', verbose=False, t1=None, t2=None)

Compute curvature term of theta of n

Parameters
  • gsim (gbspy.pp.Sim) – Simulation object

  • fld (str, optional) – Controls the term is computed for the right-hand side of the theta (or n) equation. Possible values are 'theta' and 'n'.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_rhs_cu – Curvature term of theta or n

Return type

np.ndarray

gbspy.theta.theta_rhs_multiproc(gsim, ncpu, verbose, t1, t2)

Stores the RHS terms of the theta equation

Computes the time and toroidal average of the terms in the rhs of theta equation and save them in a Numpy binary archive called theta_rhs.npz.

Parameters
  • gsim (gbspy.pp.Sim) – Simulation object

  • ncpu (int) – Number of CPUs that should compute these terms concurrently. Each worker thread will be assigned to a single time slice and the results will be joined before saving.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float) – First time slice to load.

  • t2 (float) – Last time slice to load.

See also

numpy.lib.format

Binary file formats to save Numpy arrays to disk.

Notes

A Numpy binary archive is written to the current working directory (theta_rhs.npz) and contains the following arrays:

  1. theta_rhs_nl: Poisson brackets

  2. theta_rhs_cu: Curvature terms

  3. theta_rhs_pa: Parallel tersm

  4. theta_rhs_pd: Parallel diffusion

  5. theta_rhs_em: Electromagnetic flutter

  6. theta_rhs_di: Perpendicular diffusion

  7. theta_rhs_so: Source term

gbspy.theta.theta_rhs_nl(gsim, fld='theta', verbose=False, t1=None, t2=None)

Compute Poisson bracket of theta or n

Parameters
  • gsim (gbspy.pp.Sim) – Simulation object

  • fld (str, optional) – Controls the term is computed for the right-hand side of the theta (or n) equation. Possible values are 'theta' and 'n'.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_rhs_nl – Poisson bracket of theta or n

Return type

np.ndarray

gbspy.theta.theta_rhs_pa(gsim, fld='theta', verbose=False, t1=None, t2=None)

Compute parallel term of theta or n equation

Parameters
  • gsim (gbspy.pp.Sim) – Simulation object

  • fld (str, optional) – Controls the term is computed for the right-hand side of the theta (or n) equation. Possible values are 'theta' and 'n'.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_rhs_pa – Parallel term of theta or n equation

Return type

np.ndarray

gbspy.theta.theta_rhs_so(gsim, fld='theta', verbose=True, t1=None, t2=None)

Compute source term in theta or n equation

Parameters
  • gsim (gbspy.pp.Sim) – Simulation object

  • fld (str, optional) – Controls the term is computed for the right-hand side of the theta (or n) equation. Possible values are 'theta' and 'n'.

  • verbose (bool, optional) – If True, plots the result before returning.

  • t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.

  • t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.

Returns

theta_rhs_so – Source term of theta or n

Return type

np.ndarray