Hamiltonian Functions

Base Class

class Hamiltonian(dimensions, vectors=None, data=None)

Class containing properties of the Hamiltonian.

Essentially wrapper for ndarray with additional attributes of dimensions and spins.

Usual methods (e.g. __setitem__ or __getitem__) access the data attribute.

Note

Algebraic operations with Hamiltonian will return ndarray instance.

Parameters:

dimensions (array-like) – array of the dimensions for each spin in the Hilbert space of the Hamiltonian.

dimensions

array of the dimensions for each spin in the Hilbert space of the Hamiltonian.

Type:

ndarray

spins

array of the spins, spanning the Hilbert space of the Hamiltonian.

Type:

ndarray

vectors

list with spin vectors of form [[Ix, Iy, Iz], [Ix, Iy, Iz], ...].

Type:

list

data

matrix representation of the Hamiltonian.

Type:

ndarray

Total Hamiltonian

bath_hamiltonian(bath, mfield)

Compute hamiltonian containing only the bath spins.

Parameters:
  • bath (BathArray) – array of all bath spins in the cluster.

  • mfield (ndarray with shape (3,) or func) – Magnetic field of type mfield = np.array([Bx, By, Bz]) or callable with signature mfield(pos), where pos is ndarray with shape (3,) with the position of the spin.

Returns:

Hamiltonian of the given cluster without qubit.

Return type:

Hamiltonian

total_hamiltonian(bath, center, mfield)

Compute total Hamiltonian of the given cluster.

Parameters:
  • bath (BathArray) – Array of bath spins.

  • center (CenterArray) – Array of central spins.

  • mfield (ndarray with shape (3,) or func) – Magnetic field of type mfield = np.array([Bx, By, Bz]) or callable with signature mfield(pos), where pos is ndarray with shape (3, ) with the position of the spin.

Returns:

hamiltonian of the given cluster, including central spin.

Return type:

Hamiltonian

central_hamiltonian(center, magnetic_field, hyperfine=None, bath_state=None)

Compute Hamiltonian, containing only central spin.

Parameters:
  • center (CenterArray or Center) – Center spin.

  • magnetic_field (ndarray with shape (3,) or func) – Magnetic field of type magnetic_field = np.array([Bx, By, Bz]) or callable with signature magnetic_field(pos), where pos is ndarray with shape (3,) with the position of the spin.

  • hyperfine (ndarray with shape (..., n, 3, 3)) – Array of hyperfine tensors of bath spins.

  • bath_state (ndarray with shape (n, )) – Array of \(S_z\) projections of bath spins.

Returns:

Central spin Hamiltonian.

Return type:

Hamiltonian

custom_hamiltonian(spins, dims=None, offset=0)

Custom addition to the Hamiltonian from the spins in the given array.

Parameters:
  • spins (BathArray or CenterArray) – Array of the spins.

  • dims (ndarray with shape (n, )) – Dimensions of all spins in the cluster.

  • offset (int) – Index of the dimensions of the first spin from array in dims. Default 0.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (N, N)

custom_single(h, index, dims)

Custom addition to the Hamiltonian from the dictionary with the parameters.

Parameters:
  • h (dict) – Dictionary with coupling parameters.

  • index (int) – Index of the spin in dims.

  • dims (ndarray with shape (n, )) – Dimensions of all spins in the cluster.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (N, N)

Separate Terms

Documentation for the functions used to generate spin Hamiltonian for each cluster.

expanded_single(ivec, gyro, mfield, self_tensor, detuning=0.0)

Function to compute the single bath spin term.

Parameters:
  • ivec (ndarray with shape (3, n, n)) – Spin vector of the bath spin in the full Hilbert space of the cluster.

  • gyro (float or ndarray with shape (3, 3)) –

  • mfield (ndarray wtih shape (3,) – Magnetic field of type mfield = np.array([Bx, By, Bz]).

  • self_tensor (ndarray with shape (3, 3)) – tensor of self-interaction of type IPI where I is bath spin.

  • detuning (float) – Additional term of d*Iz allowing to simulate different energy splittings of bath spins.

Returns:

Single bath spin term.

Return type:

ndarray with shape (n, n)

zeeman(ivec, gyro, mfield)

Function :param ivec: Spin vector of the spin in the full Hilbert space of the cluster. :type ivec: ndarray with shape (3, n, n) :param gyro: Gyromagnetic ratio of the spin. :type gyro: float or ndarray with shape (3, 3) :param mfield: Magnetic field at the position of the spin. :type mfield: ndarray with shape (3, )

Returns:

Zeeman interactions.

Return type:

ndarray with shape (n, n)

dd_tensor(coord_1, coord_2, g1, g2)

Generate dipole-dipole interaction tensor.

Parameters:
  • coord_1 (ndarray with shape (3,)) – Coordinates of the first spin.

  • coord_2 (ndarray with shape (3,)) – Coordinates of the second spin.

  • g1 (float or ndarray with shape (3, 3)) – Gyromagnetic ratio of the first spin.

  • g2 (float or ndarray with shape (3, 3)) – Gyromagnetic ratio of the second spin.

Returns:

Interaction tensor.

Return type:

ndarray with shape (3, 3)

dipole_dipole(coord_1, coord_2, g1, g2, ivec_1, ivec_2)

Compute dipole_dipole interactions between two bath spins.

Parameters:
  • coord_1 (ndarray with shape (3,)) – Coordinates of the first spin.

  • coord_2 (ndarray with shape (3,)) – Coordinates of the second spin.

  • g1 (float) – Gyromagnetic ratio of the first spin.

  • g2 (float) – Gyromagnetic ratio of the second spin.

  • ivec_1 (ndarray with shape (3, n, n)) – Spin vector of the first spin in the full Hilbert space of the cluster.

  • ivec_2 (ndarray with shape (3, n, n)) – Spin vector of the second spin in the full Hilbert space of the cluster.

Returns:

Dipole-dipole interactions.

Return type:

ndarray with shape (n, n)

gen_pos_tensor(coord_1, coord_2)

Generate positional tensor -(3*r @ r.T - r*r), used for hyperfine tensor (without gyro factor).

Parameters:
  • coord_1 (ndarray with shape (3,)) – Coordinates of the first spin.

  • coord_2 (ndarray with shape (3,)) – Coordinates of the second spin.

Returns:

Positional tensor.

Return type:

ndarray with shape (3, 3)

bath_interactions(nspin, ivectors)

Compute interactions between bath spins.

Parameters:
  • nspin (BathArray) – Array of the bath spins in the given cluster.

  • ivectors (array-like) – array of expanded spin vectors, each with shape (3, n, n).

Returns:

All intrabath interactions of bath spins in the cluster.

Return type:

ndarray with shape (n, n)

bath_mediated(hyperfines, ivectors, energy_state, energies, projections)

Compute all hyperfine-mediated interactions between bath spins.

Parameters:
  • hyperfines (ndarray with shape (n, 3, 3)) – Array of hyperfine tensors of the bath spins in the given cluster.

  • ivectors (array-like) – array of expanded spin vectors, each with shape (3, n, n).

  • energy_state (float) – Energy of the qubit state on which the interaction is conditioned.

  • energies (ndarray with shape (2s - 1,)) – Array of energies of all states of the central spin.

  • projections (ndarray with shape (2s - 1, 3)) –

    Array of vectors of the central spin matrix elements of form:

    \[[\bra{i}\hat{S}_x\ket{j}, \bra{i}\hat{S}_y\ket{j}, \bra{i}\hat{S}_z\ket{j}],\]

    where \(\ket{i}\) are different states of the central spin.

Returns:

Hyperfine-mediated interactions.

Return type:

ndarray with shape (n, n)

conditional_hyperfine(hyperfine_tensor, ivec, projections)

Compute conditional hyperfine Hamiltonian.

Parameters:
  • hyperfine_tensor (ndarray with shape (3, 3)) – Tensor of hyperfine interactions of the bath spin.

  • ivec (ndarray with shape (3, n, n)) – Spin vector of the bath spin in the full Hilbert space of the cluster.

  • projections (ndarray with shape (3,)) –

    Array of vectors of the central spin matrix elements of form:

    \[[\bra{i}\hat{S}_x\ket{j}, \bra{i}\hat{S}_y\ket{j}, \bra{i}\hat{S}_z\ket{j}],\]

    where \(\ket{j}\) are different states of the central spin. If \(\ket{i} = \ket{j}\), produces the usual conditioned hyperfine interactions and just equal to projections of \(\hat{S}_z\) of the central spin state \([\braket{\hat{S}_x}, \braket{\hat{S}_y}, \braket{\hat{S}_z}]\).

    If \(\ket{i} \neq \ket{j}\), gives second order perturbation.

Returns:

Conditional hyperfine interaction.

Return type:

ndarray with shape (n, n)

hyperfine(hyperfine_tensor, svec, ivec)

Compute hyperfine interactions between central spin and bath spin.

Parameters:
  • hyperfine_tensor (ndarray with shape (3, 3)) – Tensor of hyperfine interactions of the bath spin.

  • svec (ndarray with shape (3, n, n)) – Spin vector of the central spin in the full Hilbert space of the cluster.

  • ivec (ndarray with shape (3, n, n)) – Spin vector of the bath spin in the full Hilbert space of the cluster.

Returns:

Hyperfine interaction.

Return type:

ndarray with shape (n, n)

self_central(svec, mfield, tensor, gyro=-17608.59705, detuning=0)

Function to compute the central spin term in the Hamiltonian.

Parameters:
  • svec (ndarray with shape (3, n, n)) – Spin vector of the central spin in the full Hilbert space of the cluster.

  • mfield (ndarray wtih shape (3,) – Magnetic field of type mfield = np.array([Bx, By, Bz]).

  • tensor (ndarray with shape (3, 3)) – Zero Field Splitting tensor of the central spin.

  • gyro (float or ndarray with shape (3,3)) – gyromagnetic ratio of the central spin OR tensor corresponding to interaction between magnetic field and central spin.

  • detuning (float) – Energy detuning from the Zeeman splitting in kHz.

Returns:

Central spin term.

Return type:

ndarray with shape (n, n)

center_interactions(center, vectors)

Compute interactions between central spins.

Parameters:
  • center (CenterArray) – Array of central spins

  • vectors (ndarray with shape (x, 3, n, n)) – Array of spin vectors of central spins.

Returns:

Central spin Overhauser term.

Return type:

ndarray with shape (n, n)

overhauser_central(svec, others_hyperfines, others_state)

Compute Overhauser field term on the central spin from all other spins, not included in the cluster.

Parameters:
  • svec (ndarray with shape (3, n, n)) – Spin vector of the central spin in the full Hilbert space of the cluster.

  • others_hyperfines (ndarray with shape (m, 3, 3)) – Array of hyperfine tensors for all bath spins not included in the cluster.

  • others_state (ndarray with shape (m,) or (m, 3)) – Array of \(I_z\) projections for each bath spin outside of the given cluster.

Returns:

Central spin Overhauser term.

Return type:

ndarray with shape (n, n)

overhauser_bath(ivec, position, gyro, other_gyros, others_position, others_state)

Compute Overhauser field term on the bath spin in the cluster from all other spins, not included in the cluster.

Parameters:
  • ivec (ndarray with shape (3, n, n)) – Spin vector of the bath spin in the full Hilbert space of the cluster.

  • position (ndarray with shape (3,)) – Position of the bath spin.

  • gyro (float) – Gyromagnetic ratio of the bath spin.

  • other_gyros (ndarray with shape (m,)) – Array of the gyromagnetic ratios of the bath spins, not included in the cluster.

  • others_position (ndarray with shape (m, 3)) – Array of the positions of the bath spins, not included in the cluster.

  • others_state (ndarray with shape (m,) or (m, 3)) – Array of \(I_z\) projections for each bath spin outside of the given cluster.

Returns:

Bath spin Overhauser term.

Return type:

ndarray with shape (n, n)

overhauser_from_tensors(vec, tensors, projected_state)

Compute Overhauser field from array of tensors.

Parameters:
  • vec (ndarray with shape (3, n, n)) – Spin vector of the bath spin in the full Hilbert space of the cluster.

  • tensors (ndarray with shape (N, 3, 3)) – Array of interaction tensors.

  • projected_state (ndarray with shape (N, )) – Array of \(I_z\) projections of the spins outside of the given cluster..

Returns:

Bath spin Overhauser term.

Return type:

ndarray with shape (n, n)

projected_addition(vectors, bath, center, state)

Compute the first order addition of the interactions with the cental spin to the cluster Hamiltonian.

Parameters:
  • vectors (array-like) – Array of expanded spin vectors, each with shape (3, n, n).

  • bath (BathArray) – Array of bath spins.

  • center (CenterArray) – Array of central spins.

  • state (str, bool, or array-like) – Identificator of the qubit spin. 'alpha' or True for \(\ket{0}\) state, 'beta' of False for \(\ket{1}\) state.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (n, n)

center_external_addition(vectors, cluster, outer_spin, outer_state)

Compute the first order addition of the interactions between central spin and external bath spins to the cluster Hamiltonian.

Parameters:
  • vectors (array-like) – Array of expanded spin vectors, each with shape (3, n, n).

  • cluster (BathArray) – Array of cluster spins.

  • outer_spin (BathArray with shape (o, )) – Array of the spins outside the cluster.

  • outer_state (ndarray with shape (o, )) – Array of the \(S_z\) projections of the external bath spins.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (n, n)

bath_external_point_dipole(vectors, cluster, outer_spin, outer_state)

Compute the first order addition of the point-dipole interactions between cluster spins and external bath spins to the cluster Hamiltonian.

Parameters:
  • vectors (array-like) – Array of expanded spin vectors, each with shape (3, n, n).

  • cluster (BathArray) – Array of cluster spins.

  • outer_spin (BathArray with shape (o, )) – Array of the spins outside the cluster.

  • outer_state (ndarray with shape (o, )) – Array of the \(S_z\) projections of the external bath spins.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (n, n)

external_spins_field(vectors, indexes, bath, projected_state)

Compute the first order addition of the point-dipole interactions between cluster spins and external bath spins to the cluster Hamiltonian.

Parameters:
  • vectors (array-like) – Array of expanded spin vectors, each with shape (3, n, n).

  • indexes (ndarray with shape (n,)) – Array of indexes of bath spins inside the given cluster.

  • bath (BathArray with shape (N,)) – Array of all bath spins.

  • projected_state (ndarray with shape (N,) – Array of the \(S_z\) projections of all bath spins.

Returns:

Addition to the Hamiltonian.

Return type:

ndarray with shape (n, n)