Hamiltonian Functions

Base class

class pycce.h.base.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.

Args:

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

Attributes:

dimensions (ndarray): array of the dimensions for each spin in the Hilbert space of the Hamiltonian. spins (ndarray): array of the spins, spanning the Hilbert space of the Hamiltonian. vectors (list): list with spin vectors of form [[Ix, Iy, Iz], [Ix, Iy, Iz], ...]. data (ndarray): matrix representation of the Hamiltonian.

Total Hamiltonian

pycce.h.total.bath_hamiltonian(bath, mfield)

Compute hamiltonian containing only the bath spins.

Args:
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: Hamiltonian of the given cluster without qubit.

pycce.h.total.central_hamiltonian(center, magnetic_field, hyperfine=None, bath_state=None)

Compute Hamiltonian, containing only central spin.

Args:

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:

Hamiltonian: Central spin Hamiltonian.

pycce.h.total.custom_hamiltonian(spins, dims=None, offset=0)

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

Args:

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:

ndarray with shape (N, N): Addition to the Hamiltonian.

pycce.h.total.custom_single(h, index, dims)

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

Args:

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:

ndarray with shape (N, N): Addition to the Hamiltonian.

pycce.h.total.total_hamiltonian(bath, center, mfield)

Compute total Hamiltonian of the given cluster.

Args:

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: hamiltonian of the given cluster, including central spin.

Separate terms

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

pycce.h.functions.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.

Args:

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:

ndarray with shape (n, n): Addition to the Hamiltonian.

pycce.h.functions.bath_interactions(nspin, ivectors)

Compute interactions between bath spins.

Args:

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:

ndarray with shape (n, n): All intrabath interactions of bath spins in the cluster.

pycce.h.functions.bath_mediated(hyperfines, ivectors, energy_state, energies, projections)

Compute all hyperfine-mediated interactions between bath spins.

Args:

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:

ndarray with shape (n, n): Hyperfine-mediated interactions.

pycce.h.functions.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.

Args:

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:

ndarray with shape (n, n): Addition to the Hamiltonian.

pycce.h.functions.center_interactions(center, vectors)

Compute interactions between central spins.

Args:

center (CenterArray): Array of central spins vectors (ndarray with shape (x, 3, n, n)): Array of spin vectors of central spins.

Returns:

ndarray with shape (n, n): Central spin Overhauser term.

pycce.h.functions.conditional_hyperfine(hyperfine_tensor, ivec, projections)

Compute conditional hyperfine Hamiltonian.

Args:

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:

ndarray with shape (n, n): Conditional hyperfine interaction.

pycce.h.functions.dd_tensor(coord_1, coord_2, g1, g2)

Generate dipole-dipole interaction tensor.

Args:

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:

ndarray with shape (3, 3): Interaction tensor.

pycce.h.functions.dipole_dipole(coord_1, coord_2, g1, g2, ivec_1, ivec_2)

Compute dipole_dipole interactions between two bath spins.

Args:

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:

ndarray with shape (n, n): Dipole-dipole interactions.

pycce.h.functions.expanded_single(ivec, gyro, mfield, self_tensor, detuning=0.0)

Function to compute the single bath spin term.

Args:

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:

ndarray with shape (n, n): Single bath spin term.

pycce.h.functions.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.

Args:

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:

ndarray with shape (n, n): Addition to the Hamiltonian.

pycce.h.functions.gen_pos_tensor(coord_1, coord_2)

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

Args:

coord_1 (ndarray with shape (3,)): Coordinates of the first spin. coord_2 (ndarray with shape (3,)): Coordinates of the second spin.

Returns:

ndarray with shape (3, 3): Positional tensor.

pycce.h.functions.hyperfine(hyperfine_tensor, svec, ivec)

Compute hyperfine interactions between central spin and bath spin.

Args:

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:

ndarray with shape (n, n): Hyperfine interaction.

pycce.h.functions.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.

Args:

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:

ndarray with shape (n, n): Bath spin Overhauser term.

pycce.h.functions.overhauser_central(svec, others_hyperfines, others_state)

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

Args:

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:

ndarray with shape (n, n): Central spin Overhauser term.

pycce.h.functions.overhauser_from_tensors(vec, tensors, projected_state)

Compute Overhauser field from array of tensors.

Args:

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:

ndarray with shape (n, n): Bath spin Overhauser term.

pycce.h.functions.projected_addition(vectors, bath, center, state)

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

Args:

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:

ndarray with shape (n, n): Addition to the Hamiltonian.

pycce.h.functions.self_central(svec, mfield, tensor, gyro=-17608.59705, detuning=0)

Function to compute the central spin term in the Hamiltonian.

Args:

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:

ndarray with shape (n, n): Central spin term.

pycce.h.functions.zeeman(ivec, gyro, mfield)

Function Args:

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

Returns:

ndarray with shape (n, n): Zeeman interactions.