Central spins
CenterArray
Documentation for the pycce.CenterArray
- class which stores the properties of the set of central spins.
- class 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
Center
class.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)
- Parameters
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
size
argument, or inferred fromspin
,position
arguments.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
D
is 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.
- energy_alpha
Energy of the alpha state. Generated by
.generate_projections
call ifsecond_order=True
.- Type
float
- energy_beta
Energy of the beta state. Generated by
.generate_projections
call ifsecond_order=True
.- Type
float
- energies
Energy of each eingenstate of the central spin Hamiltonian.
- Type
ndarray with shape (n, )
- property imap
dict-like object, which contains interactions between central spins.
- Type
- property alpha
\(\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
CentralArray
instance, returns the tensor product of allalpha
states of each element of the array. If there are undefinedalpha
states 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]
- Type
ndarray or int
- property beta
\(\ket{1}\) qubit state of the central spin in \(S_z\) basis
OR index of the energy state to be considered as one.
- Type
ndarray or int
- property state
Initial state of the qubit in gCCE simulations. Assumed to be \(\frac{1}{\sqrt{2}}(\ket{0} + \ket{1})\) unless provided.
- Type
ndarray
- property gyro
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.
- Type
ndarray with shape (3,3 ) or (n, 3, 3)
- set_zfs(D=0, E=0)
Set Zero Field Splitting of the central spin from longitudinal ZFS D and transverse ZFS E.
- Parameters
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
D
is None or tensor.
- set_gyro(gyro)
Set gyromagnetic ratio of the central spin.
- Parameters
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.
- point_dipole()
Using point-dipole approximation, generate interaction tensors between central spins.
- generate_states(magnetic_field=None, bath=None, projected_bath_state=None)
Compute eigenstates of the central spin Hamiltonian.
- Parameters
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.
- 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_alpha
and.projections_beta
respectively.If
second_order
is 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
CCE
routine.Note
if qubit state are not eigenstates and
second_order
set toTrue
, for each qubit state finds a close eigenstate (with minimal fidelity between two states set bylevel_confidence
keyword) and uses that one instead of user provided.- Parameters
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
.
- get_energy(which)
Get energy of the qubit state.
- Parameters
which (str) –
alpha
for \(\ket{0}\) qubit state,beta
for \(\ket{1}\) qubit state.- Returns
Energy of the qubit state.
- Return type
float
- generate_sigma()
Generate Pauli matrices of the qubit in \(S_z\) basis.
- add_interaction(i, j, tensor)
Add interactions tensor between bath spins with indexes
i
andj
.- Parameters
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.
Center
Documentation for the pycce.Center
class - inner class, containing properties of a single central spin.
- class 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
CenterArray
instead.- Parameters
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
D
is 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.
- projections_alpha
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
.- Type
ndarray with shape (3,)
- projections_beta
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
.- Type
ndarray with shape (3,)
- 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_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.
- energies
Array of the central spin Hamiltonian eigen energies.
- Type
ndarray with shape (2s-1,)
- eigenvectors
Eigen states of the central spin Hamiltonian.
- Type
ndarray
- hamiltonian
Central spin Hamiltonian.
- Type
- alpha_index
Index of the central spin Hamiltonian eigen state, chosen as alpha state of the qubit.
- Type
int
- beta_index
Index of the central spin Hamiltonian eigen state, chosen as beta state of the qubit.
- Type
int
- property xyz
Position of the central spin in Cartesian coordinates.
- Type
ndarray with shape (3, )
- property gyro
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.
- Type
ndarray with shape (3,3 ) or (n, 3, 3)
- property zfs
Zero field splitting tensor of the central spin or array of spins.
- Type
ndarray with shape (3, 3) or (n, 3, 3)
- property s
Total spin of the central spin or array of spins.
- Type
float or ndarray with shape (n, )
- property h
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'] = 2000
corresponds to the Hamiltonian term \(\hat H_{add} = A \hat S_+ \hat S_-\) with \(A = 2\) MHz.d[2, 0] = 1.5e6
corresponds 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.
- Type
dict
- property detuning
Position of the central spin in Cartesian coordinates.
- Type
ndarray with shape (3, )
- set_zfs(D=0, E=0)
Set Zero Field Splitting of the central spin from longitudinal ZFS D and transverse ZFS E.
- Parameters
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
D
is None or tensor.
- set_gyro(gyro)
Set gyromagnetic ratio of the central spin.
- Parameters
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.
- property alpha
\(\ket{0}\) qubit state of the central spin in \(S_z\) basis
OR
index of the energy state to be considered as one.
- Type
ndarray or int
- property beta
\(\ket{1}\) qubit state of the central spin in \(S_z\) basis
OR
index of the energy state to be considered as one.
- Type
ndarray or int
- property dim
Dimensions of the central spin or array of spins.
- Type
int or ndarray with shape (n, )
- generate_sigma()
Generate Pauli matrices of the qubit in \(S_z\) basis.
- property sigma
Dictionary with Pauli matrices of the qubit in \(S_z\) basis.
- Type
dict
- generate_states(magnetic_field=None, bath=None, projected_bath_state=None)
Compute eigenstates of the central spin Hamiltonian.
- Parameters
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.
- generate_hamiltonian(magnetic_field=None, bath=None, projected_bath_state=None)
Generate central spin Hamiltonian.
- Parameters
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)
, wherepos
is 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
- Central spin Hamiltonian, including
first order contributions from the bath spins.
- Return type
- transform(rotation=None, style='col')
Apply coordinate transformation to the central spin.
- Parameters
rotation (ndarray with shape (3, 3)) – Rotation matrix.
style (str) – Can be ‘row’ or ‘col’. Determines how rotation matrix is initialized.