QuaCCAToo modules

qsys

This module contains the plot_energy_B0 function, compose_sys function and 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

_get_energy_levels()

Calculates the eigenenergies of the Hamiltonian and subtract the ground state energy from all of them to get the lowest level at 0.

plot_energy([figsize, energy_lim])

Plots the energy levels of the Hamiltonian defined in the system.

add_spin(H_spin)

Adds another spin to the system's Hamiltonian, given a Hamiltonian for the new spin.

truncate(indexes)

Truncantes the quantum system by removing the states specified by the indexes from the Hamiltonian, the initial state, the observable and the collapse operators.

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.

truncate(indexes)

Truncantes the quantum system by removing the states specified by the indexes from the Hamiltonian, the initial state, the observable and the collapse operators.

add_spin(H_spin)[source]

Adds another spin to the system’s Hamiltonian, given a Hamiltonian for the new spin. Updates the time-independent Hamiltonian, the energy levels, the initial state, the observable and the collapse operators accordingly.

Parameters:
H_spinQobj

Hamiltonian of the new spin

plot_energy(figsize=(2, 6), energy_lim=None)[source]

Plots the energy levels of the Hamiltonian defined in the system.

Parameters:
figsizetuple

size of the figure.

energy_limlist

limits of the energy levels.

truncate(indexes)[source]

Truncantes the quantum system by removing the states specified by the indexes from the Hamiltonian, the initial state, the observable and the collapse operators. For example, if S=1 and the user wants to remove the ms=-1 state, the indexes is set to 0 and the qsys is truncated to the ms=0 and ms=+1 subspace. The method uses the numpy.delete function to remove the specified indexes from the Hamiltonian and the initial state.

Parameters:
indexesint or list of int

Index or list of indexes to be removed from the system.

quaccatoo.qsys.qsys.compose_sys(qsys1, qsys2)[source]

Takes two quantum systems and returns the composed system by performing tensor products of the two, after checking if all parameters are valid.

Parameters:
qsys1QSys

First quantum system.

qsys2QSys

Second quantum system.

Returns:
qsys1 X qsys2QSys

Composed quantum system.

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.

NV_Sys

This module contains NV class, which is a subclass of QSys.

class quaccatoo.qsys.NV_sys.NV(B0, N, c_ops=None, units_B0=None, theta=0.0, phi_r=0.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.

_set_MW_freqs()

Sets the standard resonant microwave frequencies for the NV center corresponding to the electronic spin transitions.

_set_RF_freqs()

Sets the standard resonant RF frequencies for the NV center corresponding to the nuclear spin transitions.

_set_MW_H1()

Sets the standard microwave Hamiltonian for the NV center corresponding to the electronic spin transitions.

_set_RF_H1()

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.

_Quadrupole()

Get the quadrupole term

add_spin(H_spin)

Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes

truncate([mS, mI])

Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes.

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.

truncate([mS, mI])

Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes.

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

truncate(mS=None, mI=None)[source]

Overwrites the parent class method by calling it and updating MW_H1 and RF_H1 attributes. The indexes to be removed are calculated according to the mS and mI parameters.

Parameters:
indexeslist(int)

list of indexes to remove in the system

pulsed_sim

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.pulsed_sim.pulsed_sim.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[, pulse_shape, ...])

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, options)

Updates the total time of the experiment and applies the time-evolution operator to the initial state.

run([variable, sequence, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

_get_results()

Gets the results of the experiment from the calculated rho, based on the observable of the system.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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.

_check_attr_predef_seqs(H1, pulse_shape, ...)

Checks the commom attributes of the PulsedSim object for the predefined sequences and sets them accordingly.

pulse

updates the total time of the experiment, sets the phase for the pulse and calls mesolve from QuTip to perform the pulse operation

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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

add_free_evolution(duration, options=None)[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, pulse_shape=<function square_pulse>, pulse_params=None, time_steps=100, options=None)[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

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

measure_qsys(observable=None, tol=None)[source]

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate of the observable. If no observable is given, the observable of the qsys is used.

Parameters:
observableQobj

observable to be measured after the sequence of operations

tolfloat

tolerance for the measurement, smallest value for the probabilities

Returns:
resultsfloat or list

measurement outcome of the observable, which can be a float or a list of floats if the observable is a list of Qobjs

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, sequence_kwargs=None, map_kw=None)[source]

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute. The rho attribute is updated.

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

sequence_kwargsdict

dictionary of arguments to be passed to the sequence function

map_kwdict

dictionary of options for the parallel_map function from QuTip

predef_seqs

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.pulsed_sim.predef_seqs.Hahn(free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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.

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.

_get_pulse_profiles([tau])

Generates the pulse profiles for the Hahn echo sequence for a given tau.

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.

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 state, 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[, pulse_shape, ...])

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.

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_proj(tau)

Defines the Hahn echo sequence for a given free evolution time tau and the set of attributes defined in the constructor.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state.

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 state.

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.pulsed_sim.predef_seqs.PMR(frequencies, pulse_duration, system, H1, H2=None, pulse_shape=<function square_pulse>, pulse_params=None, time_steps=100, options=None)[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.

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.

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 state, 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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state.

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.pulsed_sim.predef_seqs.Rabi(pulse_duration, system, H1, H2=None, pulse_shape=<function square_pulse>, pulse_params=None, options=None)[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.

Methods

run()

Overwrites the run method of the parent class.

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 state, 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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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.

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 state, 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.pulsed_sim.predef_seqs.Ramsey(free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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.

ramsey_sequence_proj(tau)

Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.

_get_pulse_profiles([tau])

Generates the pulse profiles for the Ramsey sequence for a given tau.

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.

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 state, 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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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_proj(tau)

Defines the Ramsey sequence for a given free evolution time tau and the set of attributes defined in the constructor.

run([variable, sequence, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state.

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 state.

predef_dd_seqs

This module contains dynamical decoupling pulse sequences, used in quantum sensing and for extending coherence of quantum systems.

class quaccatoo.pulsed_sim.predef_dd_seqs.CPMG(M, free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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

number of pulses (order) in 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.

_get_pulse_profiles([tau])

Generates the pulse profiles for the CPMG sequence for a given tau.

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.

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 state, 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_proj(tau)

Defines the CPMG sequence, but with a final pi/2 pulse in order to project the result into 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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state

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 state

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 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.pulsed_sim.predef_dd_seqs.RXY8(M, free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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-M composed of 8 intercalated pi pulses on X and Y axis with free evolutions of time tau repeated M times.

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.

_get_pulse_profiles([tau])

Generates the pulse profiles for the RXY8-M sequence for a given tau.

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.

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_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.

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_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.

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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state

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 state

class quaccatoo.pulsed_sim.predef_dd_seqs.XY(M, free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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-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.

_get_pulse_profiles([tau])

Generates the pulse profiles for the XY-M sequence for a given tau.

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 state, 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_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.

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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state

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 state

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 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.pulsed_sim.predef_dd_seqs.XY8(M, free_duration, pi_pulse_duration, system, H1, H2=None, projection_pulse=True, pulse_shape=<function square_pulse>, pulse_params=None, options=None, 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 state. 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 state, 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_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.

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[, pulse_shape, ...])

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.

measure_qsys([observable, tol])

Measures the observable over the system, storing the measurent outcome in the results attribute and collapsing rho in the corresponding eigenstate 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, sequence_kwargs, ...])

Runs the pulsed experiment by calling the parallel_map function from QuTip over the variable attribute.

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 state

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 state

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 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

pulse_shapes

This module contains pulse shape functions to be used in the PulsedSim classes as part of the QuaCAAToo package.

quaccatoo.pulsed_sim.pulse_shapes.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
quaccatoo.pulsed_sim.pulse_shapes.lorentzian_pulse(t, **pulse_params)[source]

Lorentzian pulse envelope modulation

Parameters:
tfloat

time parameter

t_midfloat

middle point of the pulse

gammafloat

width of the pulse

f_pulsefloat

frequency of the pulse

phi_tfloat

phase of the pulse

quaccatoo.pulsed_sim.pulse_shapes.square_pulse(t, **pulse_params)[source]

Square pulse envelope modulation

Parameters:
tfloat

time parameter

f_pulsefloat

frequency of the pulse

phi_tfloat

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_modellmfit.Model or list(lmfit.Model)

list with the fitting model for each result

fit_paramslist

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_kwargs)

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_model[, results_index, guess])

Run the fit method from lmfit to fit the results of the experiment with a given model, guess for the initial 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_kwargs)

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_model[, results_index, guess])

Run the fit method from lmfit to fit the results of the experiment with a given model, guess for the initial parameters.

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_kwargs)[source]

Find the peaks of the FFT values calculated by the run_FFT method.

Parameters:
find_peaks_kwargsdict

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_model, results_index=0, guess=None)[source]

Run the fit method from lmfit to fit the results of the experiment with a given model, guess for the initial parameters.

Parameters:
fit_modellmfit.Model

model to be used to fit the results

results_indexint

index of the results to be fitted if the results attribute is a list

guessdict

initial guess for the parameters of the model Takes a dictionary consisting of parameter names as the keys and their initial guess as the value. See the definitions of the models in the fit_functions.py file for details.

Returns:
fit_paramsdict

best fit parameter values of parameters as a dict with the parameter names as the keys

Examples

The typical usage scheme is to pass a model and optionally, a dictionary of initial values. The file fit_functions.py includes a bunch of predefined models and imports some commonly needed ones from lmfit which can be directly passed to the function and used. Alternatively, the Model function from lmfit takes a custom Python function and instantiates a model class object with it, which can then be used here.

>>> from lmfit import Model #needed for custom models
>>> # my_analysis_obj is an instance of the analysis class
>>> my_analysis_obj.run_fit(fit_model=RabiModel())
>>> my_analysis_obj.run_fit(
        fit_model=Model(fit_two_lorentz_sym),
        guess = {'A': 0.5, 'gamma': 0.2, 'f_mean':1749, 'f_delta':3,'C':1}
        )

In the snippet above, we showcase some ways to perform fits using this method. Using predefined models takes care of most of the stuff. One can still pass a guess dictionary to provide better initial values. The second example shows the usage with a custom model instantiated from a function along with user provided guesses. It’s important to note that the first parameter of these custom functions should be x. Moreover, the keys in the dictionary should correspond to the other parameters of the function (this holds true for the predefined models as well). The names of the parameters can be referred to from the source file (fit_functions.py).

fit_functions

Collection of in built fit models and functions.

The predefined model classes take a (fit) function and implement a guess subroutine for intelligent initial values.

The general mechanism is the same as that of lmfit. So a lot of functions have been taken from there. To create additional fit models, simply instantiate an lmfit model with the target fit function.

Refer to the documentation of analysis.run_fit for usage details.

quaccatoo.analysis.fit_functions.fit_rabi(x, amp=1, Tpi=10, phi=0, offset=0)[source]

Fit a cosine function to Rabi oscillations.

Parameters:
xarray_like

Time values.

ampfloat

Amplitude of the cosine function.

Tpifloat

Pi-pulse duration (half the period of the cosine function).

phifloat

Phase of the cosine function.

offsetfloat

Offset of the cosine function.

class quaccatoo.analysis.fit_functions.RabiModel(independent_vars=['x'], prefix='', nan_policy='raise', **kwargs)[source]

Modified from lmfit’s SineModel to include an offset as well

Takes the same parameters as the fit_rabi function.

Attributes:
components

Return components for composite model.

name

Return Model name.

param_names

Return the parameter names of the Model.

prefix

Return Model prefix.

Methods

copy(**kwargs)

DOES NOT WORK.

dump(fp, **kws)

Dump serialization of Model to a file.

dumps(**kws)

Dump serialization of Model as a JSON string.

eval([params])

Evaluate the model with supplied parameters and keyword arguments.

eval_components([params])

Evaluate the model with the supplied parameters.

fit(data[, params, weights, method, ...])

Fit the model to the data using the supplied Parameters.

guess(data, x, **kwargs)

load(fp[, funcdefs])

Load JSON representation of Model from a file-like object.

loads(s[, funcdefs])

Load Model from a JSON string.

make_funcargs([params, kwargs, strip])

Convert parameter values and keywords to function arguments.

make_params([verbose])

Create a Parameters object for a Model.

post_fit(fitresult)

function that is called just after fit, can be overloaded by subclasses to add non-fitting 'calculated parameters'

print_param_hints([colwidth])

Print a nicely aligned text-table of parameter hints.

set_param_hint(name, **kwargs)

Set hints to use when creating parameters with make_params().

quaccatoo.analysis.fit_functions.fit_exp_decay(x, amp=1, Tc=1, offset=0)[source]

Fit a simple exponential decay function.

Parameters:
xarray_like

Time values.

ampfloat

Amplitude of the exponential decay.

Tcfloat

Decay time constant.

offsetfloat

Offset of the exponential decay.

class quaccatoo.analysis.fit_functions.ExpDecayModel(independent_vars=['x'], prefix='', nan_policy='raise', **kwargs)[source]

Modified from lmfit’s ExponentialModel to include an offset as well

Takes the same parameters as the fit_exp_decay function.

Attributes:
components

Return components for composite model.

name

Return Model name.

param_names

Return the parameter names of the Model.

prefix

Return Model prefix.

Methods

copy(**kwargs)

DOES NOT WORK.

dump(fp, **kws)

Dump serialization of Model to a file.

dumps(**kws)

Dump serialization of Model as a JSON string.

eval([params])

Evaluate the model with supplied parameters and keyword arguments.

eval_components([params])

Evaluate the model with the supplied parameters.

fit(data[, params, weights, method, ...])

Fit the model to the data using the supplied Parameters.

guess(data, x, **kwargs)

load(fp[, funcdefs])

Load JSON representation of Model from a file-like object.

loads(s[, funcdefs])

Load Model from a JSON string.

make_funcargs([params, kwargs, strip])

Convert parameter values and keywords to function arguments.

make_params([verbose])

Create a Parameters object for a Model.

post_fit(fitresult)

function that is called just after fit, can be overloaded by subclasses to add non-fitting 'calculated parameters'

print_param_hints([colwidth])

Print a nicely aligned text-table of parameter hints.

set_param_hint(name, **kwargs)

Set hints to use when creating parameters with make_params().

quaccatoo.analysis.fit_functions.fit_rabi_decay(x, amp=1, Tpi=10, phi=0, offset=0, Tc=1)[source]

Fit a cosine function with exponential decay to Rabi oscillations.

Parameters:
xarray_like

Time values.

ampfloat

Amplitude of the cosine function.

Tpifloat

Pi-pulse duration (half the period of the cosine function).

phifloat

Phase of the cosine function.

offsetfloat

Offset of the cosine function.

Tcfloat

Decay time constant.

class quaccatoo.analysis.fit_functions.RabiDecayModel(independent_vars=['x'], prefix='', nan_policy='raise', **kwargs)[source]

Analogous to RabiModel, modulated with an exponential decay.

Takes the same parameters as the fit_rabi_decay function.

Attributes:
components

Return components for composite model.

name

Return Model name.

param_names

Return the parameter names of the Model.

prefix

Return Model prefix.

Methods

copy(**kwargs)

DOES NOT WORK.

dump(fp, **kws)

Dump serialization of Model to a file.

dumps(**kws)

Dump serialization of Model as a JSON string.

eval([params])

Evaluate the model with supplied parameters and keyword arguments.

eval_components([params])

Evaluate the model with the supplied parameters.

fit(data[, params, weights, method, ...])

Fit the model to the data using the supplied Parameters.

guess(data, x, **kwargs)

load(fp[, funcdefs])

Load JSON representation of Model from a file-like object.

loads(s[, funcdefs])

Load Model from a JSON string.

make_funcargs([params, kwargs, strip])

Convert parameter values and keywords to function arguments.

make_params([verbose])

Create a Parameters object for a Model.

post_fit(fitresult)

function that is called just after fit, can be overloaded by subclasses to add non-fitting 'calculated parameters'

print_param_hints([colwidth])

Print a nicely aligned text-table of parameter hints.

set_param_hint(name, **kwargs)

Set hints to use when creating parameters with make_params().

quaccatoo.analysis.fit_functions.fit_exp_decay_n(x, A=1, C=0, Tc=1, n=1)[source]

Fit an exponential decay function with power n.

Parameters:
xarray_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.fit_functions.fit_hahn_mod(x, A, B, C, f1, f2)[source]

Fit a Hahn echo with modulation function with 2 frequencies.

Parameters:
xarray_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.fit_functions.fit_hahn_mod_decay(x, A, B, C, f1, f2, Tc, n)[source]

Fit a Hahn echo with modulation function with 2 frequencies and exponential decay.

Parameters:
xarray_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.fit_functions.fit_lorentz(x, A, gamma, f0, C)[source]

Fit a Lorentzian peak.

Parameters:
xarray_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.fit_functions.fit_two_lorentz(x, A1=1, A2=1, gamma1=0.1, gamma2=0.1, f01=2870.0, f02=2870.0, C=0)[source]

Fit two symmetric Lorentzian peaks.

Parameters:
xarray_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.fit_functions.fit_two_lorentz_sym(x, A=1, gamma=1, f_mean=2870.0, f_delta=1, C=0)[source]

Fit two symmetric Lorentzian peaks.

Parameters:
xarray_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.fit_functions.fit_sinc2(x, A, gamma, f0, C)[source]

Fit a sinc function.

Parameters:
xarray_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.fit_functions.fit_two_sinc2_sym(x, A, gamma, f_mean, f_delta, C)[source]

Fit two symmetric sinc functions.

Parameters:
xarray_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.fit_functions.fit_five_sinc2(x, A1, A2, A3, A4, A5, gamma1, gamma2, gamma3, gamma4, gamma5, f01, f02, f03, f04, f05, C)[source]

Fit two symmetric sinc functions.

Parameters:
xarray_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.

exp_data

This module contains the ExpData class as part of the QuaCCAToo package.

class quaccatoo.exp_data.exp_data.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_kwargs)[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_kwargsdict

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.

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

utils

This module provides functions to save and load quaccatoo objects, such as instances from QSys, ExpData, Analysis and PulsedSim.

quaccatoo.utils.load(file_name)[source]

Loads the attributes of an object from a zip file, creates an instance of the object, and sets the attributes.

Parameters:
file_namestr

Path to the zip file where the attributes are saved.

Returns:
object

The loaded object.

quaccatoo.utils.save(object, file_name)[source]

Look for all the attributes of the object, save Qobj attributes to separate files, and save the rest of the attributes to a pickle file. Finally, create a zip file containing all the files.

Parameters:
objectquaccatoo object

The object to be saved.

file_namestr

Path to the file where the attributes will be saved.