API Reference

CPU

Grid

Grid generation and spherical geometry utilities for EPR simulations.

This module provides the Grid class to generate SOPHE-like spherical grids under different point-group symmetries and to compute integration weights, Voronoi areas, and spherical triangle indices for Delaunay triangulation.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.grid.Grid(grid='SOPHE', point_group='Ci', knots=15)[source]

Bases: object

Spherical integration grid for EPR simulations.

The grid is generated in spherical coordinates and can be returned either in spherical or Cartesian representation. Symmetry-dependent reductions are supported through point groups, with corresponding weight factors for integration on the sphere.

Parameters:
  • grid (str) – Grid family to generate. Currently only "SOPHE" is supported.

  • point_group (str, default="Ci") – Point-group symmetry used to construct the reduced grid.

  • knots (int) – Resolution parameter controlling the number of grid knots.

get_areas()[source]

Get integration areas for all current grid points.

Returns:

Area weights with shape (N,). For "O3" and "Dooh", precomputed weights are returned directly; otherwise Voronoi-cell areas multiplied by symmetry weight factors are returned.

Return type:

array

get_grid(point_group='Ci', cartesian=False)[source]

Get the grid for a given point group.

Parameters:
  • point_group (str) – Symmetry identifier. "C1" returns the full-sphere grid.

  • cartesian (bool) – If True, coordinates are returned in Cartesian form (x, y, z). Otherwise spherical coordinates (theta, phi, r) are returned.

Returns:

Grid coordinates with shape (N, 3).

Return type:

array

get_triangle_idx()[source]

Get the indices for all possible triangle of the current grid.

Returns:

triangles – Indices for theta and phi to obtain a triangle on the grid. Also contains the area of the Delaunay triangle. (idx1, idx2, idx3, area)

Return type:

array

show(voronoi=False)[source]

Visualize the current grid and optionally its Voronoi tessellation.

Parameters:

voronoi (bool, default=False) – If True and a Voronoi tessellation is available, Voronoi vertices and geodesic edges are plotted in addition to grid points.

eprbase.grid.cartesian_to_spherical(x, y, z)[source]

Transform Cartesian coordinates to spherical coordinates.

\[\begin{split}r &= \sqrt{x^2 + y^2 + z^2} \\ \theta &= \arccos\left(\frac{z}{r}\right) \\ \phi &= \arctan2(y, x)\end{split}\]
Parameters:
  • x (array) – X components.

  • y (array) – Y components.

  • z (array) – Z components.

Returns:

Spherical coordinates with shape (N, 3) as (elevation, azimuth, radius).

Return type:

array

Notes

This convention uses a right-handed coordinate system.

eprbase.grid.spherical_to_cartesian(theta, phi, r=1.0)[source]

Transform spherical coordinates to Cartesian coordinates.

\[\begin{split}x &= r\sin(\theta)\cos(\phi) \\ y &= r\sin(\theta)\sin(\phi) \\ z &= r\cos(\theta)\end{split}\]
Parameters:
  • theta (array) – Elevation angles in radians.

  • phi (array) – Azimuth angles in radians.

  • r (array) – Radius values. Default is 1.0.

Returns:

Cartesian coordinates with shape (N, 3).

Return type:

array

Hamiltonian

Hamiltonian construction for EPR simulations of radical pairs.

This module provides the Hamiltonian class to set up and diagonalize the spin Hamiltonian, including Electron-Zeeman (EZ), Hyperfine (HFI), Dipolar (DIP), and Exchange (EX) interactions.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.hamiltonian.Hamiltonian[source]

Bases: object

Spin Hamiltonian for coupled radical pairs.

Handles the construction and caching of the total spin Hamiltonian matrix, including Zeeman, hyperfine, dipolar, and exchange terms. Provides methods to retrieve the Hamiltonian matrix and its eigenvalues/eigenvectors for given magnetic fields and orientations.

_EZ, _HFI, _DIP, _SI, _matrix

Internal caches for interaction tensors and the full Hamiltonian.

Type:

ndarray or None

_eigenvalues, _eigenvectors

Internal caches for eigenvalues and eigenvectors of the Hamiltonian.

Type:

ndarray or None

_multiplicity

Total spin multiplicity of the system.

Type:

int

get(field, theta, phi)[source]

Calculate and return the total Hamiltonian matrix.

Caches the result if neither the interaction parameters nor the field/orientation have changed since the last call.

Parameters:
  • field (np.array, shape (N,)) – Magnetic field values.

  • theta (np.array, shape (N,)) – Theta angles in radians.

  • phi (np.array, shape (N,)) – Phi angles in radians.

Returns:

The total Hamiltonian matrix for each orientation/field point.

Return type:

array

get_eigen(field, theta, phi)[source]

Return the eigenvalues and eigenvectors of the Hamiltonian.

Parameters:
  • field (np.array, shape (N,)) – Magnetic field values.

  • theta (np.array, shape (N,)) – Theta angles in radians.

  • phi (np.array, shape (N,)) – Phi angles in radians.

Return type:

tuple[array, array]

Returns:

  • eigenvalues (np.array, shape (N, M)) – Eigenvalues of the Hamiltonian.

  • eigenvectors (np.array, shape (N, M, M)) – Corresponding eigenvectors.

get_eigenvalues(field, theta, phi)[source]

Return only the eigenvalues of the Hamiltonian.

Parameters:
  • field (np.array, shape (N,)) – Magnetic field values.

  • theta (np.array, shape (N,)) – Theta angles in radians.

  • phi (np.array, shape (N,)) – Phi angles in radians.

Returns:

Eigenvalues of the Hamiltonian.

Return type:

array

get_eigenvectors(field, theta, phi)[source]

Return only the eigenvectors of the Hamiltonian.

Parameters:
  • field (np.array, shape (N,)) – Magnetic field values.

  • theta (np.array, shape (N,)) – Theta angles in radians.

  • phi (np.array, shape (N,)) – Phi angles in radians.

Returns:

Eigenvectors of the Hamiltonian.

Return type:

array

get_field_gradients(field, theta, phi)[source]

Calculate the gradients of energy levels along the magnetic field axis.

Parameters:
  • field (array) – Magnetic field values.

  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

Returns:

Gradient along the field for each energy level.

Return type:

array

get_proj()[source]

Return the projection operator.

Returns:

The projection operator matrix.

Return type:

array

get_symmetry()[source]

Get the SO(3) point group symmetry of the Hamiltonian.

Returns:

The SO(3) group identifier. Currently defaults to "Ci".

Return type:

str

set_DIP(theta, phi)[source]

Set up the Dipolar interaction Hamiltonian.

Rotates the dipolar tensor according to the given angles and calculates the interaction term.

Parameters:
  • theta (np.array) – Theta angles in radians.

  • phi (np.array) – Phi angles in radians.

Return type:

None

set_EZ(theta, phi)[source]

Set up the Electron-Zeeman (EZ) interaction Hamiltonian.

\[\hat{\mathcal{H}}_{\mathrm{ez}} = -\sum_{i = x,y,z}{g_{iz} \cdot \hat{S}_i}\]
Parameters:
  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

Return type:

None

set_HFI(theta, phi)[source]

Set up the Hyperfine (HFI) Hamiltonian for multiple nuclei.

\[\begin{split}\hat{\mathcal{H}}_{\mathrm{HF}} &= \sum_i{\mathbf{ \overrightarrow{S}A_i\overrightarrow{I_i}}}\\ &= \sum_i\sum_{m}\sum_{n}a_{i,mn}\cdot\overrightarrow{S}_{m} \cdot\overrightarrow{I}_n\end{split}\]

with:

\[m, n \in\{x, y, z\}\]
Parameters:
  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

set_Nuc(A, spin, acc_len=0)[source]

Set the nuclei coupling with the radical pair and precalculate S*I.

Precalculates the product of electron spin (S) and nuclear spin (I) matrices for the hyperfine coupling.

\[SI_{mn} = S_m \cdot I_n\]
Parameters:
  • A (array) – Hyperfine coupling tensors.

  • spin (array) – Nuclei spin numbers. First the ones for the acceptor electron, then all for the donor electron.

  • acc_len (int) – Number of nuclei which couple to the acceptor electron. The default is 0.

Return type:

None

set_dipolar(D, E)[source]

Set up the Dipolar / Zero-Field Splitting (ZFS) tensor.

\[\]

mathbf{D} = begin{bmatrix} -D+E & 0 & 0 \ 0 & -D-E & 0 \ 0 & 0 & 2cdot D end{bmatrix}

Parameters:
  • D (float) – D value of the zero field splitting.

  • E (float) – E value of the zero field splitting.

Return type:

None

set_exchange(J_ex)[source]

Set up the Hamiltonian for the exchange coupling.

\[\]

hat{mathcal{H}}_{mathrm{ex}} = -2Jcdot hat{S}_1cdot hat{S}_2

Parameters:

J_ex (float) – Exchange coupling constant.

Return type:

None

set_g(g)[source]

Set the principal values of the g tensor for each electron.

Parameters:

g (array) – Principal g-values. Must be provided for each electron in the coupled system.

Return type:

None

eprbase.hamiltonian.rotate_tensor(tensor, phi, theta, psi=None)[source]

Rotate a tensor using Euler transformation in y-convention.

Performs an orthogonal similarity transformation of the tensor:

\[T' = O^{-1} \cdot T \cdot O\]

with:

\[O^{-1} = O^T\]

where \(O\) is the Euler matrix of the SO(3) group in y-convention.

Parameters:
  • tensor (array) – Tensor to be rotated. Can be 2D or 3D.

  • phi (array) – Phi angle(s) in radians.

  • theta (array) – Theta angle(s) in radians.

  • psi (array) – Psi angle(s) in radians. If None, defaults to zero.

Returns:

The rotated tensor.

Return type:

array

Interpolation

Interpolation utilities for EPR simulation data.

This module provides the Interpolator class to perform 3D interpolation of EPR simulation results (intensities, field positions, linewidths) on spherical grids with different symmetries (Dooh and general cases).

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.interpolation.Interpolator(theta, phi, data)[source]

Bases: object

Spherical data interpolator for EPR simulations.

Handles interpolation of EPR simulation results on spherical grids with different symmetries (Dooh and general cases). Supports interpolation of intensities, field positions, linewidths, and transition matrices.

Parameters:
  • theta (array) – Original theta angles in radians.

  • phi (array) – Original phi angles in radians.

  • data (tuple) – Tuple containing (field_positions, intensities, linewidths, transitions).

_Dooh

Whether the data has Dooh symmetry.

Type:

bool

_xyz

Cartesian coordinates of original data points.

Type:

np.array

_res_fields

Resonance field positions.

Type:

np.array

_intensities

Signal intensities.

Type:

np.array

_widths

Linewidths.

Type:

np.array

_transitions

Transition matrices.

Type:

np.array

get_intensities(theta, phi)[source]

Interpolate signal intensities for given angles.

Parameters:
  • theta (np.array) – Theta angles in radians.

  • phi (np.array) – Phi angles in radians.

Returns:

Interpolated intensities.

Return type:

array

get_positions(theta, phi)[source]

Interpolate resonance field positions for given angles.

Parameters:
  • theta (np.array) – Theta angles in radians.

  • phi (np.array) – Phi angles in radians.

Returns:

Interpolated field positions.

Return type:

array

get_transitions(grid_points)[source]

Get transition matrices for given grid points.

Parameters:

grid_points (int) – Number of grid points.

Returns:

Transition matrices repeated for each grid point.

Return type:

array

get_widths(theta, phi)[source]

Interpolate linewidths for given angles.

Parameters:
  • theta (np.array) – Theta angles in radians.

  • phi (np.array) – Phi angles in radians.

Returns:

Interpolated linewidths.

Return type:

array

Resonance fields

Resonance field calculation utilities for EPR simulations.

This module provides the ResonanceFields class to calculate resonance fields, intensities, linewidths, and transition indices for EPR spectra simulations. Uses adaptive spline interpolation and transition probability analysis.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.resonance_fields.ResonanceFields(Hamiltonian, Grid, b_field, nu, rho, testing=False)[source]

Bases: object

Resonance field calculator for EPR simulations.

Handles the calculation of resonance fields, intensities, linewidths, and transition indices using adaptive spline interpolation and transition probability analysis.

Parameters:
  • Hamiltonian (object) – Hamiltonian object for energy calculations

  • Grid (object) – Grid object for orientation sampling

  • b_field (array) – Magnetic field range

  • nu (array) – Frequency range

  • rho (array) – Density matrix

  • testing (bool) – Enable testing mode, by default False

get_res_fields()[source]

Calculate resonance fields for all grid points.

Return type:

list[array, array, array, array]

Returns:

  • res_fields_t (list of np.array) – Resonance fields for each grid point

  • intensities_t (list of np.array) – Intensities for each transition

  • widths_t (list of np.array) – Linewidths for each transition

  • transition_t (list of np.array) – Transition indices for each transition

levels_plot(point, bisections=False)[source]

Plot energy levels with population indication.

Parameters:
  • point (int) – Grid point index to plot

  • bisections (bool) – Show bisection points, by default False

Return type:

None

res_field_plot(point)[source]

Plot energy level diagram with resonance fields.

Parameters:

point (int) – Grid point index to plot

Returns:

(res_fields, intensities, transition, energy_levels, field)

Return type:

None

Spectra

EPR spectra construction utilities.

This module provides the Spectra class to construct EPR spectra from transition data using either summation or projection methods. Supports both Gaussian lineshapes and convolution-based spectral construction.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.spectra.Spectra(res_fields, intensities, widths, transitions, weights=None, triangles=None)[source]

Bases: object

EPR spectra constructor.

Handles the construction of EPR spectra from transition data using either summation or projection methods. Supports both Gaussian lineshapes and convolution-based spectral construction.

Parameters:
  • res_fields (list) – Resonance fields for each transition (shape: (M, N))

  • intensities (list) – Peak intensities for each transition (shape: (M, N))

  • widths (list) – Linewidths for each transition (shape: (M, N))

  • transitions (list) – Energy level indices for each transition (shape: (M, N, 2))

  • weights (array) – Orientation weights from grid.get_areas() (shape: (M,))

  • triangles (array) – Delaunay triangle indices from grid.get_triangle_idx() (shape: (P, 4))

by_projection(field)[source]

Construct spectra by projection onto Delaunay triangles.

Parameters:

field (array) – Magnetic field axis for the spectra (shape: (M,))

Returns:

EPR spectra (shape: (M,))

Return type:

array

by_summation(field)[source]

Construct spectra by simple summation of Gaussian peaks.

Parameters:

field (array) – Magnetic field axis for the spectra (shape: (M,))

Returns:

EPR spectra (shape: (M,))

Return type:

array

eprbase.spectra.conv_function(x, gamma)[source]

Convolution function for elementary spectra construction.

Parameters:
  • x (np.array) – Field values

  • gamma (float) – Linewidth parameter

Returns:

Convolution result

Return type:

np.array

eprbase.spectra.elementary_spec(field, y, gamma)[source]

Construct elementary spectrum for triangular region.

Parameters:
  • field (np.array) – Magnetic field axis

  • y (np.array) – Triangle edge positions

  • gamma (float) – Linewidth parameter

Returns:

Elementary spectrum

Return type:

np.array

GPU

Grid

Spherical grid generation utilities for EPR simulations on GPU.

This module provides the Grid class to generate SOPHE-like spherical grids under different point-group symmetries and to compute integration weights, Voronoi areas, and spherical triangle indices using CuPy for GPU acceleration.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.gpu.grid.Grid(grid='SOPHE', point_group='Ci', knots=15)[source]

Bases: object

Spherical integration grid for EPR simulations on GPU.

The grid is generated in spherical coordinates and can be returned either in spherical or Cartesian representation. Symmetry-dependent reductions are supported through point groups, with corresponding weight factors for integration on the sphere.

Parameters:
  • grid (str) – Grid family to generate. Currently only "SOPHE" is supported.

  • point_group (str, default="Ci") – Point-group symmetry used to construct the reduced grid.

  • knots (int) – Resolution parameter controlling the number of grid knots.

get_areas()[source]

Get integration areas for all current grid points.

Returns:

Area weights with shape (N,). For "O3" and "Dooh", precomputed weights are returned directly; otherwise Voronoi-cell areas multiplied by symmetry weight factors are returned.

Return type:

array

get_grid(point_group='Ci', cartesian=False)[source]

Get the grid for a given point group.

Parameters:
  • point_group (str) – Symmetry identifier. "C1" returns the full-sphere grid.

  • cartesian (bool) – If True, coordinates are returned in Cartesian form (x, y, z). Otherwise spherical coordinates (r, theta, phi) are returned.

Returns:

Grid coordinates with shape (N, 3).

Return type:

array

get_triangle_idx()[source]

Get triangle indices for spherical Delaunay triangulation.

Returns:

Triangle table with shape (T, 4): (idx1, idx2, idx3, area), where indices refer to grid points and area is the spherical triangle area.

Return type:

array

show(voronoi=False)[source]

Visualize the current grid and optionally its Voronoi tessellation.

Parameters:

voronoi (bool, default=False) – If True and a Voronoi tessellation is available, Voronoi vertices and geodesic edges are plotted in addition to grid points.

eprbase.gpu.grid.cartesian_to_spherical(x, y, z)[source]

Transform Cartesian coordinates to spherical coordinates.

\[\begin{split}r &= \sqrt{x^2 + y^2 + z^2} \\ \theta &= \arccos\left(\frac{z}{r}\right) \\ \phi &= \arctan2(y, x)\end{split}\]
Parameters:
  • x (array) – X components.

  • y (array) – Y components.

  • z (array) – Z components.

Returns:

Spherical coordinates with shape (N, 3) as (radius, elevation, azimuth).

Return type:

array

Notes

This convention uses a right-handed coordinate system.

eprbase.gpu.grid.spherical_to_cartesian(theta, phi, r=1.0)[source]

Transform spherical coordinates to Cartesian coordinates.

\[\begin{split}x &= r\sin(\theta)\cos(\phi) \\ y &= r\sin(\theta)\sin(\phi) \\ z &= r\cos(\theta)\end{split}\]
Parameters:
  • theta (array) – Elevation angles in radians.

  • phi (array) – Azimuth angles in radians.

  • r (array) – Radius values. Default is 1.0.

Returns:

Cartesian coordinates with shape (N, 3).

Return type:

array

Hamiltonian

Hamiltonian construction utilities for EPR simulations on GPU.

This module provides the Hamiltonian class to set up and diagonalize the spin Hamiltonian on GPU, including Electron-Zeeman (EZ), Hyperfine (HFI), Dipolar (DIP), and Exchange (EX) interactions using CuPy for GPU acceleration.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.gpu.hamiltonian.Hamiltonian[source]

Bases: object

Spin Hamiltonian constructor for GPU-accelerated EPR simulations.

Handles the construction and caching of the total spin Hamiltonian matrix on GPU, including Zeeman, hyperfine, dipolar, and exchange terms. Provides methods to retrieve the Hamiltonian matrix and its eigenvalues/eigenvectors for given magnetic fields and orientations using CuPy arrays.

_EZ, _HFI, _DIP, _SI, _matrix

Internal caches for interaction tensors and the full Hamiltonian.

Type:

cp.array or None

_eigenvalues, _eigenvectors

Internal caches for spectral data.

Type:

cp.array or None

_multiplicity

Total spin multiplicity of the system.

Type:

int

get(field, theta, phi)[source]

Calculate and return the total Hamiltonian matrix on GPU.

Caches the result if neither the interaction parameters nor the field/orientation have changed since the last call.

Parameters:
  • field (cp.array, shape (N,)) – Magnetic field values.

  • theta (cp.array, shape (N,)) – Theta angles in radians.

  • phi (cp.array, shape (N,)) – Phi angles in radians.

Returns:

The total Hamiltonian matrix for each orientation/field point.

Return type:

array

get_eigen(field, theta, phi)[source]

Return the eigenvalues and eigenvectors of the Hamiltonian on GPU.

Parameters:
  • field (cp.array, shape (N,)) – Magnetic field values.

  • theta (cp.array, shape (N,)) – Theta angles in radians.

  • phi (cp.array, shape (N,)) – Phi angles in radians.

Return type:

tuple[array, array]

Returns:

  • eigenvalues (cp.array, shape (N, M)) – Eigenvalues of the Hamiltonian.

  • eigenvectors (cp.array, shape (N, M, M)) – Corresponding eigenvectors.

get_eigenvalues(field, theta, phi)[source]

Return only the eigenvalues of the Hamiltonian on GPU.

Parameters:
  • field (cp.array, shape (N,)) – Magnetic field values.

  • theta (cp.array, shape (N,)) – Theta angles in radians.

  • phi (cp.array, shape (N,)) – Phi angles in radians.

Returns:

Eigenvalues of the Hamiltonian.

Return type:

array

get_eigenvectors(field, theta, phi)[source]

Return only the eigenvectors of the Hamiltonian on GPU.

Parameters:
  • field (cp.array, shape (N,)) – Magnetic field values.

  • theta (cp.array, shape (N,)) – Theta angles in radians.

  • phi (cp.array, shape (N,)) – Phi angles in radians.

Returns:

Eigenvectors of the Hamiltonian.

Return type:

array

get_field_gradients(field, theta, phi)[source]

Calculate gradients of energy levels along the magnetic field axis on GPU.

Parameters:
  • field (array) – Magnetic field values.

  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

Returns:

Gradient along the field for each energy level.

Return type:

array

get_proj()[source]

Return the projection operator on GPU.

Returns:

The projection operator matrix.

Return type:

array

get_symmetry()[source]

Get the SO(3) point group symmetry of the Hamiltonian on GPU.

Returns:

The SO(3) group identifier. Currently defaults to "Ci".

Return type:

str

set_DIP(theta, phi)[source]

Set up the Dipolar interaction Hamiltonian on GPU.

Rotates the dipolar tensor according to the given angles and calculates the interaction term.

Parameters:
  • theta (cp.array) – Theta angles in radians.

  • phi (cp.array) – Phi angles in radians.

Return type:

None

set_EZ(theta, phi)[source]

Set up the Electron-Zeeman (EZ) interaction Hamiltonian on GPU.

\[\hat{\mathcal{H}}_{\mathrm{ez}} = -\sum_{i = x,y,z}{g_{iz} \cdot \hat{S}_i}\]
Parameters:
  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

set_HFI(theta, phi)[source]

Set up the Hyperfine (HFI) Hamiltonian for multiple nuclei on GPU.

\[\]

hat{mathcal{H}}_{mathrm{HF}} &= sum_i{mathbf{ overrightarrow{S}A_ioverrightarrow{I_i}}} \ &= sum_isum_{m}sum_{n}a_{i,mn}cdotoverrightarrow{S}_{m} cdotoverrightarrow{I}_n

with:

\[m, n \in\{x, y, z\}\]
Parameters:
  • theta (array) – Theta angles in radians.

  • phi (array) – Phi angles in radians.

set_Nuc(A, spin, acc_len=0)[source]

Set the nuclei coupling with the radical pair and precalculate S*I on GPU.

Precalculates the product of electron spin (S) and nuclear spin (I) matrices for the hyperfine coupling.

\[SI_{mn} = S_m \cdot I_n\]

with:

\[m, n \in\{x, y, z\}\]
Parameters:
  • A (array) – Hyperfine coupling tensors.

  • spin (array) – Nuclei spin numbers. First the ones for the acceptor electron, then all for the donor electron.

  • acc_len (int) – Number of nuclei which couple to the acceptor electron. The default is 0.

Return type:

None

set_dipolar(D, E)[source]

Set up the Dipolar/Zero-Field Splitting (ZFS) tensor on GPU.

\[\]

mathbf{D} = begin{bmatrix} -D+E & 0 & 0 \ 0 & -D-E & 0 \ 0 & 0 & 2cdot D end{bmatrix}

Parameters:
  • D (float) – D value of the zero field splitting.

  • E (float) – E value of the zero field splitting.

Return type:

None

set_exchange(J_ex)[source]

Set up the Hamiltonian for the exchange coupling on GPU.

\[\hat{\mathcal{H}}_{\mathrm{ex}} = -2J\cdot \hat{S}_1\cdot \hat{S}_2\]
Parameters:

J_ex (float) – Exchange coupling constant.

Return type:

None

set_g(g)[source]

Set the principal values of the g tensor for each electron on GPU.

Parameters:

g (array) – Principal g-values. Must be provided for each electron in the coupled system.

Return type:

None

eprbase.gpu.hamiltonian.rotate_tensor(tensor, phi, theta, psi=None)[source]

Rotate a tensor using Euler transformation in y-convention on GPU.

Performs an orthogonal similarity transformation of the tensor:

\[T' = O^{-1}\cdot T \cdot O\]

with:

\[O^{-1} = O^T\]
Parameters:
  • tensor (array) – Tensor to be rotated. Can be 2D or 3D.

  • phi (array) – Phi angle(s) in radians.

  • theta (array) – Theta angle(s) in radians.

  • psi (array) – Psi angle(s) in radians. If None, defaults to zero.

Returns:

The rotated tensor.

Return type:

array

Interpolation

Interpolation utilities for EPR simulation data on GPU.

This module provides the Interpolator class to perform 3D interpolation of EPR simulation results (intensities, field positions, linewidths) on spherical grids with different symmetries (Dooh and general cases) using CuPy for GPU acceleration.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.gpu.interpolation.Interpolator(theta, phi, data)[source]

Bases: object

Spherical data interpolator for EPR simulations on GPU.

Handles interpolation of EPR simulation results on spherical grids with different symmetries (Dooh and general cases) using CuPy arrays. Supports interpolation of intensities, field positions, linewidths, and transition matrices with GPU acceleration.

Parameters:
  • theta (array) – Original theta angles in radians.

  • phi (array) – Original phi angles in radians.

  • data (tuple) – Tuple containing (field_positions, intensities, linewidths, transitions).

_Dooh

Whether the data has Dooh symmetry.

Type:

bool

_xyz

Cartesian coordinates of original data points.

Type:

cp.array

_res_fields

Resonance field positions.

Type:

cp.array

_intensities

Signal intensities.

Type:

cp.array

_widths

Linewidths.

Type:

cp.array

_transitions

Transition matrices.

Type:

cp.array

get_intensities(theta, phi)[source]

Interpolate signal intensities for given angles on GPU.

Parameters:
  • theta (cp.array) – Theta angles in radians.

  • phi (cp.array) – Phi angles in radians.

Returns:

Interpolated intensities.

Return type:

array

get_positions(theta, phi)[source]

Interpolate resonance field positions for given angles on GPU.

Parameters:
  • theta (cp.array) – Theta angles in radians.

  • phi (cp.array) – Phi angles in radians.

Returns:

Interpolated field positions.

Return type:

array

get_transitions(grid_points)[source]

Get transition matrices for given grid points on GPU.

Parameters:

grid_points (int) – Number of grid points.

Returns:

Transition matrices repeated for each grid point.

Return type:

array

get_widths(theta, phi)[source]

Interpolate linewidths for given angles on GPU.

Parameters:
  • theta (cp.array) – Theta angles in radians.

  • phi (cp.array) – Phi angles in radians.

Returns:

Interpolated linewidths.

Return type:

array

Resonance fields

Resonance field calculation utilities for GPU-accelerated EPR simulations.

This module provides the ResonanceFields class to calculate resonance fields, intensities, linewidths, and transition indices for EPR spectra simulations using CuPy for GPU acceleration and adaptive spline interpolation.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

Spectra

EPR spectra construction utilities for GPU-accelerated simulations.

This module provides the Spectra class to construct EPR spectra from transition data using either summation or projection methods on GPU. Uses CuPy for GPU acceleration and memory-efficient chunked computation.

© M. Sc. Florian Quintes, 2026. @contact: florian.quintes@pc.uni.freiburg.de @author: Florian Quintes

class eprbase.gpu.spectra.Spectra(res_fields, intensities, widths, transitions, weights=None, triangles=None)[source]

Bases: object

EPR spectra constructor for GPU-accelerated simulations.

Handles the construction of EPR spectra from transition data using either summation or projection methods on GPU. Supports memory-efficient chunked computation for large datasets.

Parameters:
  • res_fields (list) – Resonance fields for each transition (shape: (M, N))

  • intensities (list) – Peak intensities for each transition (shape: (M, N))

  • widths (list) – Linewidths for each transition (shape: (M, N))

  • transitions (list) – Energy level indices for each transition (shape: (M, N, 2))

  • weights (array) – Orientation weights from grid.get_areas() (shape: (M,))

  • triangles (array) – Delaunay triangle indices from grid.get_triangle_idx() (shape: (P, 4))

by_projection(field)[source]

Construct spectra by projection onto Delaunay triangles on GPU.

Parameters:

field (array) – Magnetic field axis for the spectra (shape: (M,))

Returns:

EPR spectra (shape: (M,))

Return type:

array

by_summation(field)[source]

Construct spectra by simple summation of Gaussian peaks on GPU.

Parameters:

field (array) – Magnetic field axis for the spectra (shape: (M,))

Returns:

EPR spectra (shape: (M,))

Return type:

array