Central Spins
CenterArray
Documentation for the pycce.CenterArray - class which stores the properties of the set of central spins.
- class pycce.center.CenterArray(size=None, position=None, spin=None, D=0, E=0, gyro=-17608.59705, imap=None, alpha=None, beta=None, detuning=0)
Class, containing properties of all central spins. The properties of the each separate spin can be accessed as elements of the object directly. Each element of the array is an instance of the
Centerclass.Examples:
Generate array of 2 electron central spins:
>>> import numpy as np >>> ca = CenterArray(2, spin=0.5) # Array of size 2 with spins-1/2 >>> print(ca) CenterArray (s: [0.5 0.5], xyz: [[0. 0. 0.] [0. 0. 0.]], zfs: [[[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]]], gyro: [[[-17608.59705 -0. -0. ] [ -0. -17608.59705 -0. ] [ -0. -0. -17608.59705]] [[-17608.59705 -0. -0. ] [ -0. -17608.59705 -0. ] [ -0. -0. -17608.59705]]])
Set first two eigenstates of the combined central spin Hamiltonian as a singlie qubit state:
>>> ca.alpha = 0 >>> ca.beta = 1
Change gyromagnetic ratio of the first spin:
>>> ca[0].gyro = np.eye(3) * 1000 >>> print(ca[0]) Center (s: 0.5, xyz: [0. 0. 0.], zfs: [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]], gyro: 1000.0)
- Args:
size (int): Number of central spins.
- spin (ndarray with shape (size,)):
Total spins of the central spins.
Note
All center spin properties are broadcasted to the total size of the center array, provided by
sizeargument, or inferred fromspin,positionarguments.- position (ndarray with shape (size, 3)):
Cartesian coordinates in Angstrom of the central spins. Default (0., 0., 0.).
- D (ndarray with shape (size, ) or ndarray with shape (n, 3, 3)):
D (longitudinal splitting) parameters of central spins in ZFS tensor of central spin in kHz.
OR
Total ZFS tensor. Default 0.
- E (ndarray with shape (size, )):
E (transverse splitting) parameters of central spins in ZFS tensor of central spin in kHz. Default 0. Ignored if
Dis None or tensor.- gyro (ndarray with shape (size, ) or ndarray with shape (size, 3, 3))):
Gyromagnetic ratios of the central spins in rad / ms / G.
OR
Tensors describing central spins interactions with the magnetic field.
Default -17608.597050 kHz * rad / G - gyromagnetic ratio of the free electron spin.
- imap (dict or InteractionMap or ndarray with shape (3, 3)):
Dict-like object containing interaction tensors between the central spins of the structure {(i, j): T_ij}. Where i, j are positional indexes of the central spins. If provided as an ndarray with shape (3, 3), assumes the same interactions between all pairs of central spins in the array. If provided with shape (size * (size - 1) / 2, 3, 3), assigns the interactions to the ordered pairs:
{(0, 1): imap[0], (0, 2): imap[1] ... (size - 2, size - 1): imap[-1]}- alpha (int or ndarray with shape (S, )):
\(\ket{0}\) state of the qubit in the product space of all central spins, or the index of eigenstate to be used as one.
Default is None.
- beta (int or ndarray with shape (S, )):
\(\ket{1}\) state of the qubit in the product space of all central spins, or the index of eigenstate to be used as one.
Default is None.
- detuning (ndarray with shape (size, )): Energy detunings from the Zeeman splitting in kHz,
included as an extra \(+\omega \hat S_z\) term in the Hamiltonian, where \(\omega\) is the detuning.
Default is 0.
- add_interaction(i, j, tensor)
Add interactions tensor between bath spins with indexes
iandj.- Args:
- i (int or ndarray (n,) ):
Index of the first spin in the pair or array of the indexes of the first spins in n pairs.
- j (int or ndarray with shape (n,)):
Index of the second spin in the pair or array of the indexes of the second spins in n pairs.
- tensor (ndarray with shape (3,3) or (n, 3,3)):
Interaction tensor between the spins i and j or array of tensors.
- add_single_jump(operator, rate=1, units='rad', square_root=False, which=None)
Add single-spin jump operator for the spin to be used in the Lindbladian master equation CCE.
- Args:
- operator (str or ndarray with shape (dim, dim)): Definition of the operator. Can be either of the following:
Pair of integers defining the Sven operator.
String where each symbol corresponds to the spin matrix or operation between them. Allowed symbols:
xyz+. If there is nothing between symbols, assume multiplication of the operators. If there is a+symbol, assume summation between terms. For example,xx+zwould correspond to the operator \(\hat S_x \hat S_x + \hat S_z\).String equal to
A. Then assumes that the correct matrix form of the operator has been provided by the user.
rate (float): Rate associated with the given jump operator. By default, is given in rad ms^-1. units (str): Units of the rate, can be either rad (for radial frequency units) or deg
(for rotational frequency).
- square_root (bool): True if the rate is given as a square root of the rate (to match how one sets up
collapse operators in Qutip). Default False.
- which (int): For which central spin in the center array add the jump operator. Default is None - if
there is only one central spin then the jump operator is added, otherwise the exception is raised.
- property alpha
ndarray or int: \(\ket{0}\) qubit state of the central spin in \(S_z\) basis
OR index of the energy state to be considered as one.
If not provided in the
CentralArrayinstance, returns the tensor product of allalphastates of each element of the array. If there are undefinedalphastates of the elements of the array, raises an error.Examples:
>>> ca = CenterArray(2, spin=0.5) # Array of size 2 with spins-1/2 >>> ca[0].alpha = [0,1] >>> ca[1].alpha = [1,0] >>> print(ca.alpha) [0.+0.j 0.+0.j 1.+0.j 0.+0.j]
- property beta
ndarray or int: \(\ket{1}\) qubit state of the central spin in \(S_z\) basis
OR index of the energy state to be considered as one.
- energies
ndarray with shape (n, ): Energy of each eingenstate of the central spin Hamiltonian.
- energy_alpha
float: Energy of the alpha state. Generated by
.generate_projectionscall ifsecond_order=True.
- energy_beta
float: Energy of the beta state. Generated by
.generate_projectionscall ifsecond_order=True.
- generate_projections(second_order=False, level_confidence=0.95)
Generate vectors with the spin projections of the spin states:
\[[\bra{a}\hat{S}_x\ket{a}, \bra{a}\hat{S}_y\ket{a}, \bra{a}\hat{S}_z\ket{a}],\]where \(\ket{a}\) and is alpha or beta qubit state. They are stored in the
.projections_alphaand.projections_betarespectively.If
second_orderis set toTrue, also generates matrix elements of qubit states and all other eigenstates of the central spin Hamiltonian, used in computing second order couplings between bath spins:\[[\bra{a}\hat{S}_x\ket{b}, \bra{a}\hat{S}_y\ket{b}, \bra{a}\hat{S}_z\ket{b}],\]where \(\ket{a}\) is qubit level and \(\ket{b}\) are all other energy levels.
This function is called in the
CCEroutine.Note
if qubit state are not eigenstates and
second_orderset toTrue, for each qubit state finds a close eigenstate (with minimal fidelity between two states set bylevel_confidencekeyword) and uses that one instead of user provided.- Args:
second_order (bool): True if generate properties, necessary for second order corrections. level_confidence (float):
Minimum fidelity between an eigenstate and provided qubit level for them to be considered the same. Used only if
second_order == True.
- generate_sigma()
Generate Pauli matrices of the qubit in \(S_z\) basis.
- generate_states(magnetic_field=None, bath=None, projected_bath_state=None)
Compute eigenstates of the central spin Hamiltonian.
- Args:
magnetic_field (ndarray with shape (3,)): Array containing external magnetic field as (Bx, By, Bz). bath (BathArray with shape (m,) or ndarray with shape (m, 3, 3):
Array of all bath spins or array of hyperfine tensors.
- projected_bath_state (ndarray with shape (m,) or (m, 3)):
Array of \(I_z\) projections for each bath spin.
- get_energy(which)
Get energy of the qubit state.
- Args:
which (str):
alphafor \(\ket{0}\) qubit state,betafor \(\ket{1}\) qubit state.- Returns:
float: Energy of the qubit state.
- property gyro
- ndarray with shape (3,3 ) or (n, 3, 3): Tensor describing central spin interactions
with the magnetic field or array of spins.
Default -17608.597050 rad / ms / G - gyromagnetic ratio of the free electron spin.
- property imap
InteractionMap: dict-like object, which contains interactions between central spins.
- point_dipole()
Using point-dipole approximation, generate interaction tensors between central spins.
- set_gyro(gyro)
Set gyromagnetic ratio of the central spin.
- Args:
gyro (float or ndarray with shape (3, 3)): Gyromagnetic ratio of central spin in rad / ms / G.
OR
Tensor describing central spin interactions with the magnetic field.
Default -17608.597050 kHz * rad / G - gyromagnetic ratio of the free electron spin.
- set_zfs(D=0, E=0)
Set Zero Field Splitting of the central spin from longitudinal ZFS D and transverse ZFS E.
- Args:
- D (float or ndarray with shape (3, 3)): D (longitudinal splitting) parameter of central spin
in ZFS tensor of central spin in kHz.
OR
Total ZFS tensor. Default 0.
- E (float): E (transverse splitting) parameter of central spin in ZFS tensor of central spin in kHz.
Default 0. Ignored if
Dis None or tensor.
- property state
ndarray: Initial state of the qubit in gCCE simulations. Assumed to be \(\frac{1}{\sqrt{2}}(\ket{0} + \ket{1})\) unless provided.
Center
Documentation for the pycce.Center class - inner class, containing properties of a single central spin.
- class pycce.center.Center(position=None, spin=0, D=0, E=0, gyro=-17608.59705, alpha=None, beta=None, detuning=0)
Class, which contains the properties of the single central spin. Should not be initialized directly - use
CenterArrayinstead.- Args:
- position (ndarray with shape (3, )):
Cartesian coordinates in Angstrom of the central spin. Default (0., 0., 0.).
spin (float): Total spin of the central spin.
- D (float or ndarray with shape (3, )): D (longitudinal splitting) parameter of central spin
in ZFS tensor of central spin in kHz.
OR
Total ZFS tensor. Default 0.
- E (float): E (transverse splitting) parameter of central spin in ZFS tensor of central spin in kHz.
Default 0. Ignored if
Dis None or tensor.
gyro (float or ndarray with shape (3, 3))): Gyromagnetic ratio of central spin in rad / ms / G.
OR
Tensor describing central spin interactions with the magnetic field.
Default -17608.597050 kHz * rad / G - gyromagnetic ratio of the free electron spin.
- alpha (int or ndarray with shape (2*spin + 1, )):
\(\ket{0}\) state of the qubit in \(S_z\) basis or the index of eigenstate to be used as one.
Default is None.
- beta (int or ndarray with shape (2*spin + 1, )):
\(\ket{1}\) state of the qubit in \(S_z\) basis or the index of eigenstate to be used as one.
Default is None.
- detuning (float): Energy detuning from the zeeman splitting in kHz,
included as an extra \(+\omega \hat S_z\) term in the Hamiltonian, where \(\omega\) is the detuning.
Default 0.
- add_single_jump(operator, rate=1, units='rad', square_root=False, which=None)
Add single-spin jump operator for the spin to be used in the Lindbladian master equation CCE.
- Args:
- operator (str or ndarray with shape (dim, dim)): Definition of the operator. Can be either of the following:
Pair of integers defining the Sven operator.
String where each symbol corresponds to the spin matrix or operation between them. Allowed symbols:
xyz+. If there is nothing between symbols, assume multiplication of the operators. If there is a+symbol, assume summation between terms. For example,xx+zwould correspond to the operator \(\hat S_x \hat S_x + \hat S_z\).String equal to
A. Then assumes that the correct matrix form of the operator has been provided by the user.
rate (float): Rate associated with the given jump operator. By default, is given in rad ms^-1. units (str): Units of the rate, can be either rad (for radial frequency units) or deg
(for rotational frequency).
- square_root (bool): True if the rate is given as a square root of the rate (to match how one sets up
collapse operators in Qutip). Default False.
- which (int): For which central spin in the center array add the jump operator. Default is None - if
there is only one central spin then the jump operator is added, otherwise the exception is raised.
- property alpha
ndarray or int: \(\ket{0}\) qubit state of the central spin in \(S_z\) basis
OR
index of the energy state to be considered as one.
- alpha_index
int: Index of the central spin Hamiltonian eigen state, chosen as alpha state of the qubit.
- property beta
ndarray or int: \(\ket{1}\) qubit state of the central spin in \(S_z\) basis
OR
index of the energy state to be considered as one.
- beta_index
int: Index of the central spin Hamiltonian eigen state, chosen as beta state of the qubit.
- property detuning
ndarray with shape (3, ): Position of the central spin in Cartesian coordinates.
- property dim
int or ndarray with shape (n, ): Dimensions of the central spin or array of spins.
- eigenvectors
ndarray with shape (2s-1, 2s-1): Eigenstates of the central spin Hamiltonian. Each i-th column of the array is an eigenvector of the corresponding i-th energy value.
- energies
ndarray with shape (2s-1,): Array of the central spin Hamiltonian eigen energies.
- generate_hamiltonian(magnetic_field=None, bath=None, projected_bath_state=None)
Generate central spin Hamiltonian.
- Args:
- magnetic_field (ndarray with shape (3, ) or func):
Magnetic field of type
magnetic_field = np.array([Bx, By, Bz])or callable with signaturemagnetic_field(pos), whereposis ndarray with shape (3, ) with the position of the spin.- bath (BathArray with shape (n,) or ndarray with shape (n, 3, 3)):
Array of bath spins or hyperfine tensors.
projected_bath_state (ndarray with shape (n, )): \(S_z\) projections of the bath spin states.
- Returns:
- Hamiltonian: Central spin Hamiltonian, including
first order contributions from the bath spins.
- generate_sigma()
Generate Pauli matrices of the qubit in \(S_z\) basis.
- generate_states(magnetic_field=None, bath=None, projected_bath_state=None)
Compute eigenstates of the central spin Hamiltonian.
- Args:
magnetic_field (ndarray with shape (3,)): Array containing external magnetic field as (Bx, By, Bz). bath (BathArray with shape (m,) or ndarray with shape (m, 3, 3):
Array of all bath spins or array of hyperfine tensors.
- projected_bath_state (ndarray with shape (m,) or (m, 3)):
Array of \(I_z\) projections for each bath spin.
- property gyro
- ndarray with shape (3,3 ) or (n, 3, 3): Tensor describing central spin interactions
with the magnetic field or array of spins.
Default -17608.597050 rad / ms / G - gyromagnetic ratio of the free electron spin.
- property h
dict: Dictionary with additional spin Hamiltonian parameters. Key denotes the product of spin operators as:
Either a string containing
x, y, z, +, -where each symbol is a corresponding spin operator:x== \(S_x\)y== \(S_y\)z== \(S_z\)p== \(S_+\)m== \(S_-\)
Several symbols is a product of those spin operators.
Or a tuple with indexes (k, q) for Stevens operators (see https://www.easyspin.org/documentation/stevensoperators.html).
The item is the coupling parameter in float.
Examples:
d['pm'] = 2000corresponds to the Hamiltonian term \(\hat H_{add} = A \hat S_+ \hat S_-\) with \(A = 2\) MHz.d[2, 0] = 1.5e6corresponds to Stevens operator \(B^q_k \hat O^q_k = 3 \hat S_z - s(s+1) \hat I\) with \(k = 2\), \(q = 0\), and \(B^q_k = 1.5\) GHz.
- hamiltonian
Hamiltonian: Central spin Hamiltonian.
- projections_alpha
ndarray with shape (3,): Vector with spin operator matrix elements of type \([\bra{0}\hat S_x\ket{0}, \bra{0}\hat S_y\ket{0}, \bra{0}\hat S_z\ket{0}]\), where \(\ket{0}\) is the alpha qubit state. Generated by
CenterArray.
- projections_alpha_all
- ndarray with shape (2s-1, 3):
Array of vectors of the central spin matrix elements of form:
\[[\bra{0}\hat{S}_x\ket{j}, \bra{0}\hat{S}_y\ket{j}, \bra{0}\hat{S}_z\ket{j}],\]where \(\ket{0}\) is the alpha qubit state, and \(\ket{j}\) are all states.
- projections_beta
ndarray with shape (3,): Vector with spin operator matrix elements of type \([\bra{1}\hat S_x\ket{1}, \bra{1}\hat S_y\ket{1}, \bra{1}\hat S_z\ket{1}]\), where \(\ket{1}\) is the beta qubit state. Generated by
CenterArray.
- projections_beta_all
- ndarray with shape (2s-1, 3):
Array of vectors of the central spin matrix elements of form:
\[[\bra{1}\hat{S}_x\ket{j}, \bra{1}\hat{S}_y\ket{j}, \bra{1}\hat{S}_z\ket{j}],\]where \(\ket{1}\) is the beta qubit state, and \(\ket{j}\) are all states.
- property s
float or ndarray with shape (n, ): Total spin of the central spin or array of spins.
- set_gyro(gyro)
Set gyromagnetic ratio of the central spin.
- Args:
gyro (float or ndarray with shape (3, 3)): Gyromagnetic ratio of central spin in rad / ms / G.
OR
Tensor describing central spin interactions with the magnetic field.
Default -17608.597050 kHz * rad / G - gyromagnetic ratio of the free electron spin.
- set_zfs(D=0, E=0)
Set Zero Field Splitting of the central spin from longitudinal ZFS D and transverse ZFS E.
- Args:
- D (float or ndarray with shape (3, 3)): D (longitudinal splitting) parameter of central spin
in ZFS tensor of central spin in kHz.
OR
Total ZFS tensor. Default 0.
- E (float): E (transverse splitting) parameter of central spin in ZFS tensor of central spin in kHz.
Default 0. Ignored if
Dis None or tensor.
- property sigma
dict: Dictionary with Pauli matrices of the qubit in \(S_z\) basis.
- transform(rotation=None, style='col')
Apply coordinate transformation to the central spin.
- Args:
rotation (ndarray with shape (3, 3)): Rotation matrix. style (str): Can be ‘row’ or ‘col’. Determines how rotation matrix is initialized.
- property xyz
ndarray with shape (3, ): Position of the central spin in Cartesian coordinates.
- property zfs
ndarray with shape (3, 3) or (n, 3, 3): Zero field splitting tensor of the central spin or array of spins.