QuaCCAToo Modules#
QSys#
This module contains the plot_energy_B0 function, the QSys class part of QuaCCAToo package.
- class quaccatoo.QSys.QSys.QSys(H0, rho0=None, c_ops=None, observable=None, units_H0=None)[source]#
The QSys class defines a general quantum system and contains a method for plotting the energy levels of the Hamiltonian.
- Attributes:
- H0Qobj or numpy.ndarray
Time-independent internal Hamiltonian of the system.
- rho0Qobj, numpy.ndarray, or int
Initial state of the system.
- c_opsQobj or list of Qobj
List of collapse operators.
- observableQobj or list of Qobj
Observable to be measured.
- units_H0str
Units of the Hamiltonian.
- energy_levelsnumpy.ndarray
Energy levels of the Hamiltonian.
- eigenstatesnumpy.ndarray of Qobj
Eigenstates of the Hamiltonian.
- dim_add_spinint
Dimension of the added spin if the add_spin method is used.
Methods
plot_energy
([figsize, energy_lim])Plots the energy levels of the Hamiltonian defined in the system.
Construct the QSys class. It initializes the system with the Hamiltonian, the initial state, the collapse operators and the observable. Checking all inputs and calculating the energy levels of the Hamiltonian.
- Parameters:
- H0Qobj/array
time-independent internal Hamiltonian of the system
- rho0Qobj/array/int
initial state of the system. Can be a Qobj, an array or an index number indicating the system eigenstates
- c_opslist(Qobj)
list of collapse operators
- observableQobj or list(Qobj)
observable to be measured
- units_H0str
units of the Hamiltonian
Methods
add_spin
(H_spin)Adds another spin to the system's Hamiltonian, given a Hamiltonian for the new spin.
plot_energy
([figsize, energy_lim])Plots the energy levels of the Hamiltonian defined in the system.
save
- quaccatoo.QSys.QSys.plot_energy_B0(B0, H0, figsize=(6, 4), energy_lim=None, xlabel='Magnetic Field', ylabel='Energy (MHz)')[source]#
Plots the energy levels of a Hamiltonian as a function of a magnetic field B0.
- Parameters:
- B0list or numpy.ndarray
List of magnetic fields.
- H0list of Qobj
List of Hamiltonians.
- figsizetuple
Size of the figure.
- energy_limtuple
Limits of the energy levels.
- xlabelstr
Label of the x-axis.
- ylabelstr
Label of the y-axis.
NVSys#
This module contains NV class, which is a subclass of QSys.
- class quaccatoo.QSys.NVSys.NV(B0, N, c_ops=None, units_B0=None, theta=0, phi_r=0, units_angles='deg', temp=None, units_temp='K', E=0)[source]#
NN class contains attributes and methods to simulate the nitrogen vacancy center in diamond.
- Attributes:
- B0float
magnetic field
- N15, 14, 0 or None
nitrogen isotope, or 0 for no nuclear spin
- units_B0str
units of the magnetic field (T, mT or G)
- thetafloat
angle of the magnetic field with respect to the NV axis
- phi_rfloat
azimutal angle of the magnetic field with the NV axis
- units_anglesstr
units of the angles (deg or rad)
- tempfloat or None
temperature
- units_tempstr
temperature units ‘C’ or ‘K’
- energy_levelslist
list of energy levels of the Hamiltonian
- MW_freqsnumpy.ndarray
microwave frequencies
- RF_freqsnumpy.ndarray
RF frequencies
- MW_H1Qobj
microwave Hamiltonian
- RF_H1Qobj
RF Hamiltonian
Methods
rho0_lowT
(temp[, units_temp])Calculates the initial state of the system at low temperatures using the Boltzmann distribution.
Sets the standard resonant microwave frequencies for the NV center corresponding to the electronic spin transitions.
Sets the standard resonant RF frequencies for the NV center corresponding to the nuclear spin transitions.
Sets the standard microwave Hamiltonian for the NV center corresponding to the electronic spin transitions.
Sets the standard RF Hamiltonian for the NV center corresponding to the nuclear spin transitions.
_ZeroField
()Get the NV Hamiltonian term accounting for zero field splitting.
_ElectronZeeman
()Get the NV hamiltonian term accounting for the electron Zeeman effect.
_NuclearZeeman
()Get the NV hamiltonian term accounting for the nuclear (Nitrogen) Zeeman effect.
_HyperfineN
()Get the NV hamiltonian term accounting for the hyperfine coupling with Nitrogen.
Constructor for the NV class. Takes the nitrogen isotope, the magnetic field intensity and angles with the quantization axis as inputs and calculates the energy levels of the Hamiltonian.
- Parameters:
- B0float
magnetic field
- N15/14/0/None
nitrogen isotope, or 0 for no nuclear spin
- c_opslist(Qobj)
list of collapse operators
- units_B0str
units of the magnetic field (T, mT or G)
- thetafloat
angle of the magnetic field with respect to the NV axis
- phi_rfloat
angle of the magnetic field in the xy plane
- units_anglesstr
units of the angles (deg or rad)
- tempfloat
temperature
- units_tempstr
temperature units (‘C’/’K’)
- Efloat
perpedicular component of the zero field splitting
Methods
add_spin
(H_spin)Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes
plot_energy
([figsize, energy_lim])Plots the energy levels of the Hamiltonian defined in the system.
rho0_lowT
(temp[, units_temp])Calculates the initial state of the system at low temperatures using the Boltzmann distribution.
Sets the standard microwave Hamiltonian for the NV center corresponding to the electronic spin transitions.
Sets the standard resonant microwave frequencies for the NV center corresponding to the electronic spin transitions.
Sets the standard RF Hamiltonian for the NV center corresponding to the nuclear spin transitions.
Sets the standard resonant RF frequencies for the NV center corresponding to the nuclear spin transitions.
save
- add_spin(H_spin)[source]#
Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes
- Parameters:
- H_spinQobj
Hamiltonian of the extra spin
- rho0_lowT(temp, units_temp='K')[source]#
Calculates the initial state of the system at low temperatures using the Boltzmann distribution. At room temperatures and moderate fields, the initial state of the nuclear spins is simply an identity matrix.
- Parameters:
- Tfloat
temperature
- units_tempstr
units of the temperature (K or C)
- Returns:
- rho0Qobj
initial state of the system
- set_MW_H1()[source]#
Sets the standard microwave Hamiltonian for the NV center corresponding to the electronic spin transitions.
- set_MW_freqs()[source]#
Sets the standard resonant microwave frequencies for the NV center corresponding to the electronic spin transitions.
PulsedSim#
This module contains the PulsedSim class that is used to define a general pulsed experiment with a sequence of pulses and free evolution operations, part of the QuaCAAToo package.
- class quaccatoo.PulsedSim.PulsedSim.PulsedSim(system, H2=None)[source]#
The PulsedSim class is used to define a general pulsed experiment with a sequence of pulses and free evolution operations. The class contains methods to add pulses and free evolution operations to the sequence of operations, run the experiment, plot the pulse profiles and results of the experiment. By default the Hamiltonian is in frequency units and the time is in time units.
- Attributes:
- systemQSys
quantum system object representing the quantum system
- H2list(Qobj, function)
time dependent sensing Hamiltonian of the system in the form [Qobj, function]
- H0_H2list
list of Hamiltonians for the pulse operation in the form [H0, H2]
- total_timefloat
total time of the experiment
- variablenp.array
variable of the experiment which the results depend on
- variable_namestr
name of the variable
- pulse_profiles :list
list of pulse profiles for plotting purposes, where each element is a list [H1, tarray, pulse_shape, pulse_params]
- resultslist
results of the experiment to be later generated in the run method
- sequencecallable
parallel sequence of operations to be overwritten in PredefSeqs and PredefDDSeqs, or defined by the user
- time_stepsint
number of time steps for the pulses
Methods
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, title])Plots the pulse profiles of the experiment by iterating over the pulse_profiles list and plotting each pulse profile and free evolution.
pulse
updates the total time of the experiment, sets the phase for the pulse and calls mesolve from QuTip to perform the pulse operation
save
saves the experiment
Initializes a general PulsedSim object with a quantum system, time dependent Hamiltonian and collapse operators.
- Parameters:
- systemQSys
quantum system object representing the quantum system
- H2Qobj
time dependent sensing Hamiltonian of the system
Methods
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, title])Plots the pulse profiles of the experiment by iterating over the pulse_profiles list and plotting each pulse profile and free evolution.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- add_free_evolution(duration, options={})[source]#
Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
- Parameters:
- durationfloat or int
duration of the free evolution
- optionsdict
options for the Qutip solver
- add_pulse(duration, H1, phi_t=0, pulse_shape=<function square_pulse>, pulse_params={}, time_steps=100, options={})[source]#
Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
- Parameters:
- durationfloat or int
duration of the pulse
- H1Qobj or list(Qobj)
control Hamiltonian of the system
- phi_tfloat
time phase of the pulse representing the rotation axis in the rotating frame
- pulse_shapecallable or list(callable)
pulse shape function or list of pulse shape functions representing the time modulation of t H1
- pulse_paramsdict
dictionary of parameters for the pulse_shape functions
- time_stepsint
number of time steps for the pulses
- optionsdict
options for the Qutip solver
- free_evolution(duration)[source]#
Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator. This method should be used internally by other methods, as it does not perform any checks on the input parameters for better performance.
- Parameters:
- durationfloat or int
duration of the free evolution
- free_evolution_H2(duration, options={})[source]#
Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
- Parameters:
- durationfloat or int
duration of the free evolution
- optionsdict
options for the Qutip solver
- measure(observable=None)[source]#
Measures the observable after the sequence of operations and returns the expectation value of the observable.
- Parameters:
- observableQobj
observable to be measured after the sequence of operations
- Returns:
- results of the experiment
- plot_pulses(figsize=(6, 4), xlabel=None, ylabel='Pulse Intensity', title='Pulse Profiles')[source]#
Plots the pulse profiles of the experiment by iterating over the pulse_profiles list and plotting each pulse profile and free evolution.
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- xlabelstr
label of the x-axis
- ylabelstr
label of the y-axis
- titlestr
title of the plot
- run(variable=None, sequence=None, map_kw={'num_cpus': None})[source]#
Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
- Parameters:
- variablenp.array
xaxis variable of the plot representing the parameter being changed in the experiment
- sequencecallable
sequence of operations to be performed in the experiment
- map_kwdict
dictionary of options for the parallel_map function from QuTip
PredefSeqs#
This module contains predefined basic pulsed experiments inheriting from the PulsedSim class as part of the QuaCCAToo package.
Classes#
Rabi: resonant pulse of varying duration, such that the quantum system will undergo periodical transitions between the excited and ground states.
PMR: Pulsed Magnetic Resonance (PMR) experiment, composed by a single pulse where the frequency is changed such that when it corresponds to a transition in the Hamiltonian of the system, the observable will be affected.
Ramsey: Ramsey experiment, consisting of a free evolution that causes a phase accumulation between states in the system which can be used for interferometry.
Hahn: Hahn echo experiment, consisting of two free evolutions with a pi pulse in the middle, in order to cancel out dephasings. The Hahn echo is usually used to measure the coherence time of a quantum system, however it can also be used to sense coupled spins.
- class quaccatoo.PulsedSim.PredefSeqs.Hahn(free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
A class containing Hahn echo experiments, inheriting from the PulsedSimulation class.
The Hahn echo sequence consists of two free evolutions with a pi pulse in the middle, in order to cancel out dephasings. The Hahn echo is usually used to measure the coherence time of a quantum system, however it can also be used to sense coupled spins.
- Attributes:
- free_durationnumpy.ndarray
Time array of the free evolution times to run the simulation.
- pi_pulse_durationfloat or int
Duration of the pi pulse.
- projection_pulsebool
Boolean to determine if a final pi/2 pulse is to be included in order to project the measurement in the Sz basis.
Methods
hahn_sequence(tau)
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor, returning the final density matrix. The sequence is to be called by the parallel_map method of QuTip.
hahn_sequence_proj(tau)
Defines the Hahn echo sequence with a final pi/2 pulse, in order to project the result into the Sz basis.
hahn_sequence_H2(tau)
Defines the Hahn echo sequence considering time-dependent H2 or collapse operators.
hahn_sequence_proj_H2(tau)
Defines the Hahn echo sequence considering time-dependent H2 or collapse operators and a final pi/2 pulse.
(Inherited from PulsedSimulation)
Constructor for the Hahn echo pulsed experiment class, taking a specific free_duration to run the simulation and the pi_pulse_duration.
- Parameters:
- free_durationnumpy.ndarray
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation.
- systemQSys
Quantum system object containing the initial density matrix, internal Hamiltonian and collapse operators.
- H1Qobj or list of Qobj
Control Hamiltonian of the system.
- pi_pulse_durationfloat or int
Duration of the pi pulse.
- H2Qobj or list of Qobj
Time dependent sensing Hamiltonian of the system.
- projection_pulsebool
Boolean to determine if the measurement is to be performed in the Sz basis or not. If True, a final pi/2 pulse is included in order to project the result into the Sz basis, as done for the most color centers.
- pulse_shapeFunctionType or list of FunctionType
Pulse shape function or list of pulse shape functions representing the time modulation of H1.
- pulse_paramsdict
Dictionary of parameters for the pulse_shape functions.
- time_stepsint
Number of time steps in the pulses for the simulation.
- optionsdict
Dictionary of solver options from Qutip.
Methods
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the Hahn echo sequence for a given tau.
hahn_sequence
(tau)Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
hahn_sequence_H2
(tau)Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
hahn_sequence_proj
(tau)Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the Hahn echo sequence for a given tau and then plot them.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- get_pulse_profiles(tau=None)[source]#
Generates the pulse profiles for the Hahn echo sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
- Parameters:
- taufloat
Free evolution variable or pulse spacing for the Hahn echo sequence.
- hahn_sequence(tau)[source]#
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
The sequence consists of an initial pi/2 pulse and two free evolutions with a pi pulse between them. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- hahn_sequence_H2(tau)[source]#
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
The sequence consists of an initial pi/2 pulse and two free evolutions with a pi pulse between them. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- hahn_sequence_proj(tau)[source]#
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
The sequence consists of a pi/2 pulse, a free evolution time tau, a pi pulse and another free evolution time tau followed by a pi/2 pulse. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- hahn_sequence_proj_H2(tau)[source]#
Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.
The sequence consists of a pi/2 pulse, a free evolution time tau, a pi pulse and another free evolution time tau followed by a pi/2 pulse. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- plot_pulses(figsize=(6, 6), xlabel='Time', ylabel='Pulse Intensity', title='Pulse Profiles', tau=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the Hahn echo sequence for a given tau and then plot them.
- Parameters:
- taufloat
Free evolution time for the Hahn echo sequence. Contrary to the run method, the free evolution must be a single number in order to plot the pulse profiles.
- figsizetuple
Size of the figure to be passed to matplotlib.pyplot.
- xlabelstr
Label of the x-axis.
- ylabelstr
Label of the y-axis.
- titlestr
Title of the plot.
- class quaccatoo.PulsedSim.PredefSeqs.PMR(frequencies, pulse_duration, system, H1, H2=None, pulse_shape=<function square_pulse>, pulse_params={}, time_steps=100, options={})[source]#
A class containing Pulsed Magnetic Resonance (PMR) experiments where the frequency is the variable being changed, inheriting from the PulsedSim class.
The PMR consists of a single pulse of fixed length and changing frequency. If the frequency matches a resonance of the system, it will undergo some transition which will affect the observable. This way, the differences between energy levels can be determined with the linewidth usually limited by the pulse length. Here we make reference to optical detection as it is the most common detection scheme of pulsed magnetic resonance in color centers, however the method can be more general.
- Attributes:
- frequenciesnumpy.ndarray
Array of frequencies to run the simulation.
- pulse_durationfloat or int
Duration of the pulse.
Methods
PMR_sequence(f)
Defines the Pulsed Magnetic Resonance (PMR) sequence for a given frequency of the pulse. To be called by the parallel_map in run method.
(Inherited from PulsedSimulation)
Constructor for the PMR pulsed experiment class.
- Parameters:
- frequenciesnumpy.ndarray
Array of frequencies to run the simulation.
- pulse_durationfloat or int
Duration of the pulse.
- systemQSys
Quantum system object containing the initial density matrix, internal Hamiltonian and collapse operators.
- H1Qobj or list(Qobj)
Control Hamiltonian of the system.
- H2Qobj or list(Qobj)
Time-dependent sensing Hamiltonian of the system.
- pulse_shapeFunctionType or list(FunctionType)
Pulse shape function or list of pulse shape functions representing the time modulation of H1.
- pulse_paramsdict
Dictionary of parameters for the pulse_shape functions.
- time_stepsint
Number of time steps in the pulses for the simulation.
- optionsdict
Dictionary of solver options from Qutip.
Methods
PMR_sequence
(f)Defines the Pulsed Magnetic Resonance (PMR) sequence for a given frequency of the pulse.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first define a pulse frequency to be plotted.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- PMR_sequence(f)[source]#
Defines the Pulsed Magnetic Resonance (PMR) sequence for a given frequency of the pulse. To be called by the parallel_map in run method.
- Parameters:
- ffloat
Frequency of the pulse.
- Returns:
- rhoQobj
Final density matrix.
- plot_pulses(figsize=(6, 4), xlabel='Time', ylabel='Pulse Intensity', title='Pulse Profiles', f_pulse=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first define a pulse frequency to be plotted.
- Parameters:
- f_pulsefloat or int
Frequency of the pulse to be plotted.
- (Inherited from PulsedSimulation.plot_pulses)
- class quaccatoo.PulsedSim.PredefSeqs.Rabi(pulse_duration, system, H1, H2=None, pulse_shape=<function square_pulse>, pulse_params={}, options={})[source]#
A class containing Rabi experiments, inheriting from the PulsedSimulation class.
A Rabi sequence is composed of a resonant pulse of varying duration, such that the quantum system will undergo periodical transitions between the excited and ground states.
- Attributes:
- pulse_durationnumpy.ndarray
Time array for the simulation representing the pulse duration to be used as the variable for the simulation.
Methods
PulsedSimulation
Constructor for the Rabi pulsed experiment class.
- Parameters:
- pulse_durationnumpy.ndarray
Time array for the simulation representing the pulse duration to be used as the variable for the simulation.
- systemQSys
Quantum system object containing the initial density matrix, internal Hamiltonian and collapse operators.
- H1Qobj or list(Qobj)
Control Hamiltonian of the system.
- H2Qobj or list(Qobj)
Time-dependent sensing Hamiltonian of the system.
- pulse_shapeFunctionType or list(FunctionType)
Pulse shape function or list of pulse shape functions representing the time modulation of H1.
- pulse_paramsdict
Dictionary of parameters for the pulse_shape functions.
- optionsdict
Dictionary of solver options from Qutip.
Methods
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, title])Plots the pulse profiles of the experiment by iterating over the pulse_profiles list and plotting each pulse profile and free evolution.
run
()Overwrites the run method of the parent class.
save
- run()[source]#
Overwrites the run method of the parent class. Runs the simulation and stores the results in the results attribute. If the system has no initial density matrix, the propagator is calcualated. If an observable is given, the expectation values are stored in the results attribute. For the Rabi sequence, the calculation is optimally performed sequentially instead of in parallel over the pulse lengths, thus the run method from the parent class is overwritten.
- class quaccatoo.PulsedSim.PredefSeqs.Ramsey(free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
A class containing Ramsey experiments, inheriting from the PulsedSimulation class.
- Attributes:
- free_durationnumpy.ndarray
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation.
- pi_pulse_durationfloat or int
Duration of the pi pulse.
- projection_pulsebool
Boolean to determine if a final pi/2 pulse is to be included in order to project the measurement in the Sz basis.
Methods
ramsey_sequence(tau)
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse and a single free evolution. The sequence is to be called by the parallel_map method of QuTip.
ramsey_sequence_proj(tau)
Defines the Ramsey sequence with final pi/2 pulse to project into the Sz basis.
ramsey_sequence_H2(tau)
Defines the Ramsey sequence considering time-dependent H2 or collapse operators.
ramsey_sequence_proj_H2(tau)
Defines the Ramsey sequence considering time-dependent H2 or collapse operators and a final pi/2 pulse.
get_pulse_profiles(tau)
Generates the pulse profiles for the Ramsey sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
(Inherited from PulsedSimulation)
Class constructor for the Ramsey pulsed experiment class.
- Parameters:
- free_durationnumpy.ndarray
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation.
- systemQSys
Quantum system object containing the initial density matrix, internal Hamiltonian and collapse operators.
- H1Qobj or list(Qobj)
Control Hamiltonian of the system.
- pi_pulse_durationfloat or int
Duration of the pi pulse.
- H2Qobj or list(Qobj)
Time-dependent sensing Hamiltonian of the system.
- projection_pulsebool
Boolean to determine if the measurement is to be performed in the Sz basis or not. If True, a final pi/2 pulse is included in order to project the result into the Sz basis, as for most color centers.
- pulse_shapeFunctionType or list(FunctionType)
Pulse shape function or list of pulse shape functions representing the time modulation of H1.
- pulse_paramsdict
Dictionary of parameters for the pulse_shape functions.
- time_stepsint
Number of time steps in the pulses for the simulation.
- optionsdict
Dictionary of solver options from Qutip.
Methods
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the Ramsey sequence for a given tau.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the Ramsey sequence for a given tau and then plot them.
ramsey_sequence
(tau)Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.
ramsey_sequence_H2
(tau)Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.
ramsey_sequence_proj
(tau)Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- get_pulse_profiles(tau=None)[source]#
Generates the pulse profiles for the Ramsey sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
- Parameters:
- taufloat
Free evolution variable or pulse spacing for the Hahn echo sequence.
- plot_pulses(figsize=(6, 4), xlabel='Time', ylabel='Pulse Intensity', title='Pulse Profiles of Ramsey Sequence', tau=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the Ramsey sequence for a given tau and then plot them.
- Parameters:
- taufloat
Free evolution time for the Hahn echo sequence. Contrary to the run method, the free evolution must be a single number in order to plot the pulse profiles.
- figsizetuple
Size of the figure to be passed to matplotlib.pyplot.
- xlabelstr
Label of the x-axis.
- ylabelstr
Label of the y-axis.
- titlestr
Title of the plot.
- ramsey_sequence(tau)[source]#
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse and a single free evolution. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- ramsey_sequence_H2(tau)[source]#
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse and a single free evolution. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- ramsey_sequence_proj(tau)[source]#
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse, a single free evolution, and a final pi/2 pulse to project the result into the Sz basis. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
- ramsey_sequence_proj_H2(tau)[source]#
Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse, a single free evolution, and a final pi/2 pulse to project the result into the Sz basis. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time.
- Returns:
- rhoQobj
Final density matrix.
PredefDDSeqs#
This module contains dynamical decoupling pulse sequences, used in quantum sensing and for extending coherence of quantum systems.
- class quaccatoo.PulsedSim.PredefDDSeqs.CPMG(M, free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
This class contains a Carr-Purcell-Meiboom-Gill sequence used in quantum sensing experiments, inheriting from the PulsedSim class. The CPMG sequence consists of a series of pi pulses and free evolution times, such that these periodicals inversions will cancel out oscillating noises except for frequencies corresponding to the pulse separation.
- Attributes:
- Mint
order of the CPMG sequence
- free_durationnumpy array
time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- pi_pulse_durationfloat or int
duration of the pi pulse
- projection_pulsebool
boolean to determine if a final pi/2 pulse is to be included in order to project the measurement into the Sz basis
Methods
CPMG_sequence
(tau)Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor.
CPMG_sequence_proj
(tau)Defines the CPMG sequence, but with a final pi/2 pulse in order to project the result into the Sz basis.
CPMG_sequence_H2
(tau)Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor.
Defines the CPMG sequence, but with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis.
get_pulse_profiles
([tau])Generates the pulse profiles for the CPMG sequence for a given tau.
Class constructor for the Carr-Purcell-Meiboom-Gill sequence
- Parameters:
- Mint
order of the CPMG sequence
- free_durationnumpy array
time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- systemQSys
quantum system object containing the initial density matrix, internal time independent Hamiltonian and collapse operators
- H1Qobj or list(Qobj)
control Hamiltonian of the system
- pi_pulse_durationfloat or int
duration of the pi pulse
- H2list(Qobj or function)
time dependent sensing Hamiltonian of the system
- projection_pulsebool
boolean to determine if a final pi/2 pulse is to be included in order to project the measurement into the Sz basis
- pulse_shapeFunctionType or list(FunctionType)
pulse shape function or list of pulse shape functions representing the time modulation of H1
- pulse_paramsdict
dictionary of parameters for the pulse_shape functions
- time_stepsint
number of time steps in the pulses for the simulation
Methods
CPMG_sequence
(tau)Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor.
CPMG_sequence_H2
(tau)Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor.
CPMG_sequence_proj
(tau)Defines the CPMG sequence, but with a final pi/2 pulse in order to project the result into the Sz basis.
Defines the CPMG sequence, but with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the CPMG sequence for a given tau.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the CPMG sequence for a given tau and then plot them.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- CPMG_sequence(tau)[source]#
Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of an initial pi/2 pulse, and M pi-pulses separated by free evolution time tau. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
free evolution time
- Returns:
- rhoQobj
final density matrix
- CPMG_sequence_H2(tau)[source]#
Defines the CPMG sequence for a given free evolution time tau and the set of attributes defined in the constructor. The sequence consists of a pi pulse and free evolution time tau repeated M times. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
free evolution time
- Returns:
- rhoQobj
final density matrix
- CPMG_sequence_proj(tau)[source]#
Defines the CPMG sequence, but with a final pi/2 pulse in order to project the result into the Sz basis. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
free evolution time
- Returns:
- rhoQobj
final density matrix
- CPMG_sequence_proj_H2(tau)[source]#
Defines the CPMG sequence, but with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
free evolution time
- Returns:
- rhoQobj
final density matrix
- get_pulse_profiles(tau=None)[source]#
Generates the pulse profiles for the CPMG sequence for a given tau.
- Parameters:
- taufloat
Free evolution variable or pulse spacing for the Hahn echo sequence.
- plot_pulses(figsize=(6, 6), xlabel=None, ylabel='Expectation Value', title='Pulse Profiles', tau=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the CPMG sequence for a given tau and then plot them.
- Parameters:
- taufloat
Free evolution time for the Hahn echo sequence. Contrary to the run method, the free evolution must be a single number in order to plot the pulse profiles.
- figsizetuple
Size of the figure to be passed to matplotlib.pyplot
- xlabelstr
Label of the x-axis
- ylabelstr
Label of the y-axis
- titlestr
Title of the plot
- class quaccatoo.PulsedSim.PredefDDSeqs.RXY8(M, free_duration, pi_pulse_duration, system, H1, H2=None, c_ops=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
This contains the RXY8-M sequence, inheriting from XY8. The RXY8-M is a further improvement from the XY8-M sequence, where a random phase is added in each XY8 block in order to improve noise suppression and pulse errors.
- Attributes:
- same as XY8
Methods
RXY8_sequence(tau)
Defines the RXY8 sequence for a given free evolution time tau and the set of attributes defined in the constructor, returning the final density matrix. The sequence is to be called by the parallel_map method of QuTip.
RXY8_sequence_proj(tau)
RXY8 sequence with projection pulse.
RXY8_sequence_H2(tau)
RXY8 sequence with time dependent H2 or collapse operators.
RXY8_sequence_proj_H2(tau)
RXY8 sequence with time dependent H2 or collapse operators and a final pi/2 pulse.
Class constructor for the RXY8 sequence
- Parameters:
- same as XY8
Methods
RXY8_sequence
(tau)Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
RXY8_sequence_H2
(tau)Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, in the precence of H2 the free evolutions are called with mesolve instead of the expm method.
RXY8_sequence_proj
(tau)Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, plus the projection pulse.
Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, plus the projection pulse.
XY8_sequence
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_H2
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_proj
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_proj_H2
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the XY-M sequence for a given tau.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the XY8-M sequence for a given tau and then plot them.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- RXY8_sequence(tau)[source]#
Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. A random phase is added in each XY8 block. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- RXY8_sequence_H2(tau)[source]#
Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, in the precence of H2 the free evolutions are called with mesolve instead of the expm method. A random phase is added in each XY8 block. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- RXY8_sequence_proj(tau)[source]#
Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, plus the projection pulse. A random phase is added in each XY8 block. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- RXY8_sequence_proj_H2(tau)[source]#
Defines the RXY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times, plus the projection pulse. A random phase is added in each XY8 block. In the presence of the H2 term, the free evolutions are called with mesolve instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- class quaccatoo.PulsedSim.PredefDDSeqs.XY(M, free_duration, pi_pulse_duration, system, H1, H2=None, c_ops=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
This class contains the XY-M pulse sequence, inheriting from PulsedSim class. The sequence is composed of intercalated X and Y pi pulses and free evolutions repeated M times. It acts similar to the CPMG sequence, but the alternation of the pulse improves noise suppression on different axis.
- Attributes:
- Mint
Order of the XY sequence
- free_durationnumpy array
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- pi_pulse_durationfloat, int
Duration of the pi pulse
- projection_pulsebool
Boolean to determine if a final pi/2 pulse is to be included in order to project the measurement into the Sz basis
Methods
XY_sequence(tau)
Defines the XY sequence for a given free evolution time tau and the set of attributes defined in the constructor, returning the final density matrix. The sequence is to be called by the parallel_map method of QuTip.
XY_sequence_proj(tau)
XY sequence with projection pulse.
XY_sequence_H2(tau)
XY sequence with time dependent H2 or collapse operators.
XY_sequence_proj_H2(tau)
XY sequence with time dependent H2 or collapse operators and a final pi/2 pulse.
get_pulse_profiles(tau)
Generates the pulse profiles for the XY-M sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
Class constructor for the XY sequence
- Parameters:
- Mint
Order of the XY sequence
- free_durationnumpy array
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- systemQSys
Quantum system object containing the initial density matrix, internal time independent Hamiltonian and collapse operators
- H1Qobj, list(Qobj)
Control Hamiltonian of the system
- pi_pulse_durationfloat, int
Duration of the pi pulse
- H2Qobj, list(Qobj), optional
Time dependent sensing Hamiltonian of the system
- pulse_shapeFunctionType, list(FunctionType), optional
Pulse shape function or list of pulse shape functions representing the time modulation of H1
- pulse_paramsdict, optional
Dictionary of parameters for the pulse_shape functions
- time_stepsint, optional
Number of time steps in the pulses for the simulation
- optionsdict, optional
Dictionary of solver options
Methods
XY_sequence
(tau)Defines the XY-M composed of intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY_sequence_H2
(tau)Defines the XY-M composed of intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY_sequence_proj
(tau)Defines the XY-M sequence with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis.
XY_sequence_proj_H2
(tau)Defines the XY-M sequence with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the XY-M sequence for a given tau.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the XY-M sequence for a given tau and then plot them.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- XY_sequence(tau)[source]#
Defines the XY-M composed of intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY_sequence_H2(tau)[source]#
Defines the XY-M composed of intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY_sequence_proj(tau)[source]#
Defines the XY-M sequence with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY_sequence_proj_H2(tau)[source]#
Defines the XY-M sequence with an initial pi/2 pulse and a final pi/2 pulse in order to project the measurement in the Sz basis. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- get_pulse_profiles(tau=None)[source]#
Generates the pulse profiles for the XY-M sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
- Parameters:
- taufloat
free evolution variable or pulse spacing for the Hahn echo sequence
- plot_pulses(figsize=(6, 6), xlabel=None, ylabel='Expectation Value', title='Pulse Profiles', tau=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the XY-M sequence for a given tau and then plot them.
- Parameters:
- taufloat
Free evolution time for the Hahn echo sequence. Contrary to the run method, the free evolution must be a single number in order to plot the pulse profiles.
- figsizetuple
Size of the figure to be passed to matplotlib.pyplot
- xlabelstr
Label of the x-axis
- ylabelstr
Label of the y-axis
- titlestr
Title of the plot
- class quaccatoo.PulsedSim.PredefDDSeqs.XY8(M, free_duration, pi_pulse_duration, system, H1, H2=None, c_ops=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params={}, options={}, time_steps=100)[source]#
This contains the XY8-M sequence, inheriting from Pulsed Simulation. The XY8-M is a further improvement from the XY-M sequence, where the X and Y pulses are group antisymmetrically in pairs of 4 as X-Y-X-Y-Y-X-Y-X, in order to improve noise suppression and pulse errors.
- Attributes:
- Mint
Order of the XY sequence
- free_durationnumpy array
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- pi_pulse_durationfloat, int
Duration of the pi pulse
- projection_pulsebool
Boolean to determine if a final pi/2 pulse is to be included in order to project the measurement in the Sz basis
Methods
XY8_sequence(tau)
Defines the XY8 sequence for a given free evolution time tau and the set of attributes defined in the constructor, returning the final density matrix. The sequence is to be called by the parallel_map method of QuTip.
XY8_sequence_proj(tau)
XY8 sequence with projection pulse.
XY8_sequence_H2(tau)
XY8 sequence with time dependent H2 or collapse operators.
XY8_sequence_proj_H2(tau)
XY8 sequence with time dependent H2 or collapse operators and a final pi/2 pulse.
get_pulse_profiles(tau)
Generates the pulse profiles for the XY8-M sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
Class constructor for the XY8 sequence
- Parameters:
- Mint
Order of the XY sequence
- free_durationnumpy array
Time array for the simulation representing the free evolution time to be used as the variable attribute for the simulation
- systemQSys
Quantum system object containing the initial density matrix, internal time independent Hamiltonian and collapse operators
- H1Qobj, list(Qobj)
Control Hamiltonian of the system
- pi_pulse_durationfloat, int
Duration of the pi pulse
- H2Qobj, list(Qobj), optional
Time dependent sensing Hamiltonian of the system
- pulse_shapeFunctionType, list(FunctionType), optional
Pulse shape function or list of pulse shape functions representing the time modulation of H1
- pulse_paramsdict, optional
Dictionary of parameters for the pulse_shape functions
- time_stepsint, optional
Number of time steps in the pulses for the simulation
- optionsdict, optional
Dictionary of solver options from Qutip
Methods
XY8_sequence
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_H2
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_proj
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
XY8_sequence_proj_H2
(tau)Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.
add_free_evolution
(duration[, options])Adds a free evolution operation to the sequence of operations of the experiment for a given duration of the free evolution by calling the free_evolution method.
add_pulse
(duration, H1[, phi_t, ...])Perform variables checks and adds a pulse operation to the sequence of operations of the experiment for a given duration of the pulse, control Hamiltonian H1, pulse phase, pulse shape function, pulse parameters and time steps by calling the pulse method.
free_evolution
(duration)Updates the total time of the experiment and applies the time-evolution operator to the initial density matrix to perform the free evolution operation with the exponential operator.
free_evolution_H2
(duration[, options])Same as free_evolution but using mesolve for the time dependent Hamiltonian or collapse operators.
get_pulse_profiles
([tau])Generates the pulse profiles for the XY-M sequence for a given tau.
measure
([observable])Measures the observable after the sequence of operations and returns the expectation value of the observable.
plot_pulses
([figsize, xlabel, ylabel, ...])Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the XY8-M sequence for a given tau and then plot them.
run
([variable, sequence, map_kw])Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.
save
- XY8_sequence(tau)[source]#
Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY8_sequence_H2(tau)[source]#
Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY8_sequence_proj(tau)[source]#
Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- XY8_sequence_proj_H2(tau)[source]#
Defines the XY8-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times. With H2, the free evolutions are calculated with mesolve method instead of the expm method. The sequence is to be called by the parallel_map method of QuTip.
- Parameters:
- taufloat
Free evolution time
- Returns:
- rhoQobj
Final density matrix
- get_pulse_profiles(tau=None)[source]#
Generates the pulse profiles for the XY-M sequence for a given tau. The pulse profiles are stored in the pulse_profiles attribute of the object.
- Parameters:
- taufloat
free evolution variable or pulse spacing for the Hahn echo sequence
- plot_pulses(figsize=(6, 6), xlabel=None, ylabel='Expectation Value', title='Pulse Profiles', tau=None)[source]#
Overwrites the plot_pulses method of the parent class in order to first generate the pulse profiles for the XY8-M sequence for a given tau and then plot them.
- Parameters:
- taufloat
Free evolution time for the Hahn echo sequence. Contrary to the run method, the free evolution must be a single number in order to plot the pulse profiles.
- figsizetuple
Size of the figure to be passed to matplotlib.pyplot
- xlabelstr
Label of the x-axis
- ylabelstr
Label of the y-axis
- titlestr
Title of the plot
PulseShapes#
This module contains pulse shape functions to be used in the PulsedSim classes as part of the QuaCAAToo package.
- quaccatoo.PulsedSim.PulseShapes.gaussian_pulse(t, **pulse_params)[source]#
Gaussian pulse envelope modulation
- Parameters:
- tfloat
time parameter
- t_midfloat
middle point of the pulse
- sigmafloat
width of the pulse
- f_pulse float): frequency of the pulse
- phi_t (float): phase of the pulse
Analysis#
This module contains the Analysis class as part of the QuaCCAToo package.
- class quaccatoo.Analysis.Analysis.Analysis(experiment)[source]#
The Analysis class contains several methods for data Analysis, such as FFT, fitting and plotting.
- Attributes:
- experimentPulsedSim or ExpData
experiment object to be analyzed containing the results and variable attributes
- FFT_valuestuple
tuple with the frequency values and the FFT values
- FFT_peaksarray
array with the peaks of the FFT values
- fit_functionlist
list with the fit function for each result
- fitlist
list with the fitted parameters for each result
- fit_covlist
list with the covariance of the fitted parameters for each result
- pearsonfloat
Pearson correlation coefficient between two experiments
- exp_comparisonPulsedSim or ExpData
experiment to be compared with the first one
Methods
compare_with
(exp_comparison[, ...])Loads a second experiment to compare with the first one.
plot_comparison
([figsize, xlabel, ylabel, title])Plots the results of the experiment and the comparison experiment.
run_FFT
()Run the real fast Fourier transform for the results and variable attributes of the PulsedSimulation object.
get_peaks_FFT
(**find_peaks_args)Find the peaks of the FFT values calculated by the run_FFT method.
plot_FFT
([freq_lim, figsize, xlabel, ...])Plots the FFT
run_fit
(fit_function[, results_index, ...])Run the curve_fit method from scipy.optimize to fit the results of the experiment with a given fit function, guess for the initial parameters and bounds for the parameters.
plot_fit
([figsize, xlabel, ylabel, title])Plot the results of the experiment with the fitted function.
plot_results
([figsize, xlabel, ylabel, title])Plots the results of the experiment
plot_bloch
([figsize])Plot the results of the experiment in a Bloch sphere if the quantum system has dimension of two.
Class constructor for Analysis. It takes a PulsedSim or ExpData object as input and checks if the results and variable attributes are not empty and have the same length.
- Parameters:
- experimentPulsedSim or ExpData
experiment object to be analyzed containing the results and variable attributes
Methods
compare_with
(exp_comparison[, ...])Loads a second experiment to compare with the first one.
get_peaks_FFT
(**find_peaks_args)Find the peaks of the FFT values calculated by the run_FFT method.
plot_FFT
([freq_lim, figsize, xlabel, ...])Plots the FFT
plot_bloch
([figsize])Plot the results of the experiment in a Bloch sphere if the quantum system has dimension of two.
plot_comparison
([figsize, xlabel, ylabel, title])Plots the results of the experiment and the comparison experiment.
plot_fit
([figsize, xlabel, ylabel, title])Plot the results of the experiment with the fitted function.
plot_results
([figsize, xlabel, ylabel, title])Plots the results of the experiment
run_FFT
()Run the real fast Fourier transform for the results and variable attributes of the PulsedSimulation object.
run_fit
(fit_function[, results_index, ...])Run the curve_fit method from scipy.optimize to fit the results of the experiment with a given fit function, guess for the initial parameters and bounds for the parameters.
save
- compare_with(exp_comparison, results_index=0, comparison_index=0, linear_fit=True)[source]#
Loads a second experiment to compare with the first one. If linear_fit is True, a linear fit is performed between the two data sets, which is common for optical experiments. Otherwise the Pearson correlation coefficient without linear fit is calculated between the two data sets.
- Parameters:
- exp_comparisonPulsedSim or ExpData
experiment to be compared with the first one
- results_indexint
index of the results to be compared if the results attribute is a list
- comparison_indexint
index of the results to be compared if the results attribute of the exp_comparison is a list
- linear_fitbool
boolean indicating whether or not to perform a linear fit between the two data sets
- Returns:
- rfloat
Pearson correlation coefficient between the two experiments
- get_peaks_FFT(**find_peaks_args)[source]#
Find the peaks of the FFT values calculated by the run_FFT method.
- Parameters:
- find_peaks_argsdict
dictionary with the arguments to be passed to the scipy.signal.find_peaks function
- Returns:
- FFT_peaksarray
array with the peaks of the FFT values
- plot_FFT(freq_lim=None, figsize=(6, 4), xlabel=None, ylabel='FFT Intensity', title='FFT of the Results')[source]#
Plots the FFT
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- xlabelstr
label of the x-axis
- ylabelstr
label of the y-axis
- titlestr
title of the plot
- plot_bloch(figsize=(6, 4))[source]#
Plot the results of the experiment in a Bloch sphere if the quantum system has dimension of two.
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- plot_comparison(figsize=(6, 4), xlabel=None, ylabel='Observable', title='Results Comparisons')[source]#
Plots the results of the experiment and the comparison experiment.
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- xlabelstr
label of the x-axis
- ylabelstr
label of the y-axis
- titlestr
title of the plot
- plot_fit(figsize=(6, 4), xlabel=None, ylabel='Expectation Value', title='Pulsed Result')[source]#
Plot the results of the experiment with the fitted function.
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- xlabelstr
label of the x-axis
- ylabelstr
label of the y-axis
- titlestr
title of the plot
- plot_results(figsize=(6, 4), xlabel=None, ylabel='Observable', title='Results')[source]#
Plots the results of the experiment
- Parameters:
- figsizetuple
size of the figure to be passed to matplotlib.pyplot
- xlabelstr
label of the x-axis
- ylabelstr
label of the y-axis
- titlestr
title of the plot
- run_FFT()[source]#
Run the real fast Fourier transform for the results and variable attributes of the PulsedSimulation object. The results are centered around the mean value before the FFT is calculated in order to remove the DC component.
- Returns:
- FFT_valuestuple
tuple with the frequency values and the FFT values
- run_fit(fit_function, results_index=0, guess=None, bounds=(-inf, inf))[source]#
Run the curve_fit method from scipy.optimize to fit the results of the experiment with a given fit function, guess for the initial parameters and bounds for the parameters.
- Parameters:
- fit_functionfunction
function to be used to fit the results
- results_indexint
index of the results to be fitted if the results attribute is a list
- guesslist
initial guess for the parameters of the fit function
- boundslist
bounds for the parameters of the fit function
- Returns:
- fitarray
array with the fitted parameters
- fit_covarray
array with the covariance of the fitted parameters
FitFunctions#
Fit functions to be used in the Analysis class as part of the QuaCAAToo package.
- quaccatoo.Analysis.FitFunctions.fit_exp_decay(t, A, C, Tc)[source]#
Fit a simple exponential decay function.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the exponential decay.
- Cfloat
Offset of the exponential decay.
- Tcfloat
Decay time constant.
- quaccatoo.Analysis.FitFunctions.fit_exp_decay_n(t, A, C, Tc, n)[source]#
Fit an exponential decay function with power n.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the exponential decay.
- Cfloat
Offset of the exponential decay.
- Tcfloat
Decay time constant.
- nfloat
Power of the exponential decay.
- quaccatoo.Analysis.FitFunctions.fit_five_sinc2(f, A1, A2, A3, A4, A5, gamma1, gamma2, gamma3, gamma4, gamma5, f01, f02, f03, f04, f05, C)[source]#
Fit two symmetric sinc functions.
- Parameters:
- farray_like
Frequency values.
- Afloat
Amplitude of the sinc functions.
- gammafloat
Width of the sinc functions.
- f_meanfloat
Mean frequency of the sinc functions.
- f_deltafloat
Frequency difference between the sinc functions.
- Cfloat
Offset of the sinc functions.
- quaccatoo.Analysis.FitFunctions.fit_gaussian(f, A, sigma, f0, C)[source]#
Fit a Gaussian peak.
- Parameters:
- farray_like
Frequency values.
- Afloat
Amplitude of the peak.
- sigmafloat
Standard deviation (width) of the Gaussian.
- f0float
Central frequency of the peak.
- Cfloat
Offset of the peak.
- quaccatoo.Analysis.FitFunctions.fit_hahn_mod(t, A, B, C, f1, f2)[source]#
Fit a Hahn echo with modulation function with 2 frequencies.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the echo.
- Bfloat
Amplitude of the modulation.
- Cfloat
Offset of the echo.
- f1float
First modulation frequency.
- f2float
Second modulation frequency.
- quaccatoo.Analysis.FitFunctions.fit_hahn_mod_decay(t, A, B, C, f1, f2, Tc, n)[source]#
Fit a Hahn echo with modulation function with 2 frequencies and exponential decay.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the echo.
- Bfloat
Amplitude of the modulation.
- Cfloat
Offset of the echo.
- f1float
First modulation frequency.
- f2float
Second modulation frequency.
- Tcfloat
Decay time constant.
- nfloat
Power of the exponential decay.
- quaccatoo.Analysis.FitFunctions.fit_lorentz(f, A, gamma, f0, C)[source]#
Fit a Lorentzian peak.
- Parameters:
- farray_like
Frequency values.
- Afloat
Amplitude of the peak.
- gammafloat
Width of the peak.
- f0float
Central requency of the peak.
- Cfloat
Offset of the peak.
- quaccatoo.Analysis.FitFunctions.fit_rabi(t, A, Tpi, C, phi)[source]#
Fit a cosine function to Rabi oscillations.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the cosine function.
- Tpifloat
Pi-pulse duration (half the period of the cosine function).
- Cfloat
Offset of the cosine function.
- phifloat
Phase of the cosine function.
- quaccatoo.Analysis.FitFunctions.fit_rabi_decay(t, A, Tpi, phi, C, Tc, n)[source]#
Fit a cosine function with exponential decay to Rabi oscillations.
- Parameters:
- tarray_like
Time values.
- Afloat
Amplitude of the cosine function.
- Tpifloat
Pi-pulse duration (half the period of the cosine function).
- phifloat
Phase of the cosine function.
- Cfloat
Offset of the cosine function.
- Tcfloat
Decay time constant.
- nfloat
Power of the exponential decay.
- quaccatoo.Analysis.FitFunctions.fit_sinc2(f, A, gamma, f0, C)[source]#
Fit a sinc function.
- Parameters:
- farray_like
Frequency values.
- Afloat
Amplitude of the sinc function.
- gammafloat
Width of the sinc function.
- f0float
Central frequency of the sinc function.
- Cfloat
Offset of the sinc function.
- quaccatoo.Analysis.FitFunctions.fit_two_lorentz(f, A1, A2, gamma1, gamma2, f01, f02, C)[source]#
Fit two symmetric Lorentzian peaks.
- Parameters:
- farray_like
Frequency values.
- A1float
Amplitude of the first peak.
- A2float
Amplitude of the second peak.
- gamma1float
Width of the first peak.
- gamma2float
Width of the second peak.
- f01float
Central frequency of the first peak.
- f02float
Central frequency of the second peak.
- Cfloat
Offset of the peaks.
- quaccatoo.Analysis.FitFunctions.fit_two_lorentz_sym(f, A, gamma, f_mean, f_delta, C)[source]#
Fit two symmetric Lorentzian peaks.
- Parameters:
- farray_like
Frquency values.
- Afloat
Amplitude of the peaks.
- gammafloat
Width of the peaks.
- f_meanfloat
Mean frequency of the peaks.
- f_deltafloat
Frequency difference between the peaks.
- Cfloat
Offset of the peaks.
- quaccatoo.Analysis.FitFunctions.fit_two_sinc2_sym(f, A, gamma, f_mean, f_delta, C)[source]#
Fit two symmetric sinc functions.
- Parameters:
- farray_like
Frequency values.
- Afloat
Amplitude of the sinc functions.
- gammafloat
Width of the sinc functions.
- f_meanfloat
Mean frequency of the sinc functions.
- f_deltafloat
Frequency difference between the sinc functions.
- Cfloat
Offset of the sinc functions.
ExpData#
This module contains the ExpData class as part of the QuaCCAToo package.
- class quaccatoo.ExpData.ExpData.ExpData(file_path, variable_column=0, results_columns=1, variable_name='Time', result_name='Expectation Value', plot=False, figsize=(6, 4), figtitle='Experimental Data', **loadtxt_args)[source]#
Class to load experimental data and perform basic data processing.
- Attributes:
- variablenp.ndarray
array containing the variable data
- resultsnp.ndarray or list of np.ndarray
array or list of arrays containing the results data
- variable_namestr
name of the variable
- result_namestr
name of the results
Methods
subtract_results_columns:
subtracts the results of the negative column from the positive column
offset_correction:
substracts a background value from the results
rescale_correction:
multiplies the results by a rescale value
poly_baseline_correction:
performs a polynomial baseline correction to the results
plot_exp_data:
plots the experimental data
Constructor of the ExpData class. It loads experimental data from a file and sets the variable and results attributes according with the specified column arguments.
- Parameters:
- file_pathstr
path to the file containing the experimental data
- variable_columnint
column index of the variable
- results_columnsint or list of int
column index of the results
- variable_namestr
name of the variable
- result_namestr
name of the results
- plotbool
if True, plot the experimental data
- figsizetuple
size of the figure for the plot
- figtitlestr
title of the figure for the plot
- **loadtxt_argsdict
additional arguments for the np.loadtxt function
Methods
offset_correction
(background_value[, plot, ...])Overwrites the results attribute substracting the background value from the results.
plot_exp_data
([figsize, figtitle])Plots the experimental data.
poly_base_correction
([x_start, x_end, ...])Overwrites the results attribute performing a polynomial baseline correction.
rescale_correction
(rescale_value[, plot, ...])Overwrites the results attribute multiplying the results by the rescale value.
subtract_results_columns
([pos_col, neg_col, ...])Overwrites the results attribute substracting the results of the negative column from the positive column.
save
- offset_correction(background_value, plot=False, figsize=(6, 4), figtitle='Expt. Data with Offset Correction')[source]#
Overwrites the results attribute substracting the background value from the results.
- Parameters:
- background_valueint or float
value to be substracted from the results
- plotbool
if True, plot the experimental data
- figsizetuple
size of the figure for the plot
- figtitlestr
title of the figure for the plot
- plot_exp_data(figsize=(6, 4), figtitle='Experimental Data')[source]#
Plots the experimental data.
- Parameters:
- figsizetuple
size of the figure for the plot
- figtitlestr
title of the figure for the plot
- poly_base_correction(x_start=None, x_end=None, poly_order=2, plot=False, figsize=(6, 4), figtitle='Expt. Data with Polynomial Baseline Correction')[source]#
Overwrites the results attribute performing a polynomial baseline correction. The baseline is fitted to the data between x_start and x_end, representing the start and end of the xaxis index.
- Parameters:
- x_startint or list of int
start index of the x axis for the baseline fit
- x_endint or list of int
end index of the x axis for the baseline fit
- poly_orderint
order of the polynomial to fit the baseline
- plotbool
if True, plot the experimental data
- figsizetuple
size of the figure for the plot
- figtitlestr
title of the figure for the plot
- rescale_correction(rescale_value, plot=False, figsize=(6, 4), figtitle='Expt. Data with Rescale Correction')[source]#
Overwrites the results attribute multiplying the results by the rescale value.
- Parameters:
- rescale_valueint or float
value to be multiplied by the results
- plotbool
if True, plot the experimental data
- figsizetuple
size of the figure for the plot
- figtitlestr
title of the figure for the plot
- subtract_results_columns(pos_col=0, neg_col=1, plot=False, figsize=(6, 4), figtitle='Subtracted Expt. Data')[source]#
Overwrites the results attribute substracting the results of the negative column from the positive column.
- Parameters:
- pos_col: int
index of the positive column
- neg_col: int
index of the negative column
- plot: bool
if True, plot the experimental data
- figsize: tuple
size of the figure for the plot
- figtitle: str
title of the figure for the plot