Note
This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.
T2* Ramsey Characterization¶
The purpose of the T2Hahn
,
Since the detuning frequency is relatively small, we add a phase gate to the circuit to
enable better measurement. The actual frequency measured is the sum of the detuning
frequency and the user induced oscillation frequency (osc_freq
parameter).
import numpy as np
import qiskit
from qiskit_experiments.library import T2Ramsey
The circuits used for the experiment comprise the following steps:
Hadamard gate
Delay
RZ gate that rotates the qubit in the x-y plane
Hadamard gate
Measurement
The user provides as input a series of delays (in seconds) and the
oscillation frequency (in Hz). During the delay, we expect the qubit to
precess about the z-axis. If the p gate and the precession offset each
other perfectly, then the qubit will arrive at the
qubit = 0
# set the desired delays
delays = list(np.arange(1e-6, 50e-6, 2e-6))
# Create a T2Ramsey experiment. Print the first circuit as an example
exp1 = T2Ramsey((qubit,), delays, osc_freq=1e5)
print(exp1.circuits()[0])
┌────┐┌─────────────────┐┌─────────┐ ░ ┌────┐ ░ ┌─┐
q: ┤ √X ├┤ Delay(1e-06[s]) ├┤ Rz(π/5) ├─░─┤ √X ├─░─┤M├
└────┘└─────────────────┘└─────────┘ ░ └────┘ ░ └╥┘
c: 1/═════════════════════════════════════════════════╩═
0
We run the experiment on a simulated backend using Qiskit Aer with a pure T1/T2 relaxation noise model.
Note
This manual requires the qiskit-aer
package to run simulations.
You can install it with python -m pip install qiskit-aer
.
# A T1 simulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel
# Create a pure relaxation noise model for AerSimulator
noise_model = NoiseModel.from_backend(
FakePerth(), thermal_relaxation=True, gate_error=False, readout_error=False
)
# Create a fake backend simulator
backend = AerSimulator.from_backend(FakePerth(), noise_model=noise_model)
The resulting graph will have the form:
# Set scheduling method so circuit is scheduled for delay noise simulation
exp1.set_transpile_options(scheduling_method='asap')
# Run experiment
expdata1 = exp1.run(backend=backend, shots=2000, seed_simulator=101)
expdata1.block_for_results() # Wait for job/analysis to finish.
# Display the figure
display(expdata1.figure(0))

# Print results
for result in expdata1.analysis_results():
print(result)
AnalysisResult
- name: @Parameters_T2RamseyAnalysis
- value: CurveFitResult:
- fitting method: least_squares
- number of sub-models: 1
* F_cos_decay(x) = amp * exp(-x / tau) * cos(2 * pi * freq * x + phi) + base
- success: True
- number of function evals: 48
- degree of freedom: 20
- chi-square: 12.875308615638016
- reduced chi-square: 0.6437654307819007
- Akaike info crit.: -6.589110211475962
- Bayesian info crit.: -0.4947310871349586
- init params:
* amp = 0.5
* tau = 0.00011299749992597643
* freq = 100000.0000000005
* phi = 1.5707963267948966
* base = 0.4768115942028985
- fit params:
* amp = 0.49141199016366127 ± 0.004915858654154686
* tau = 0.00010193005363941936 ± 4.4571061722469855e-06
* freq = 99948.42508452105 ± 82.7408286040535
* phi = 0.003757315552205406 ± 0.012639852794697988
* base = 0.5011282571781465 ± 0.0018216291036850965
- correlations:
* (freq, phi) = -0.8231765129863903
* (amp, tau) = -0.8136993299350425
* (freq, base) = -0.17104974814176943
* (amp, freq) = -0.1153625082744436
* (tau, phi) = -0.11249152702506908
* (amp, base) = -0.01973646888776725
* (tau, base) = 0.036721454772491655
* (tau, freq) = 0.06159352447687412
* (amp, phi) = 0.16164323802270328
* (phi, base) = 0.16350494475620683
- quality: good
- device_components: ['Q0']
- verified: False
AnalysisResult
- name: Frequency
- value: (9.995+/-0.008)e+04
- χ²: 0.6437654307819007
- quality: good
- extra: <1 items>
- device_components: ['Q0']
- verified: False
AnalysisResult
- name: T2star
- value: 0.000102+/-0.000004
- χ²: 0.6437654307819007
- quality: good
- extra: <1 items>
- device_components: ['Q0']
- verified: False
Providing initial user estimates¶
The user can provide initial estimates for the parameters to help the
analysis process. Because the curve is expected to decay toward
t2ramsey
and f
are the parameters of interest. Good estimates for them are values
computed in previous experiments on this qubit or a similar values
computed for other qubits.
user_p0={
"A": 0.5,
"T2star": 20e-6,
"f": 110000,
"phi": 0,
"B": 0.5
}
exp_with_p0 = T2Ramsey((qubit,), delays, osc_freq=1e5)
exp_with_p0.analysis.set_options(p0=user_p0)
exp_with_p0.set_transpile_options(scheduling_method='asap')
expdata_with_p0 = exp_with_p0.run(backend=backend, shots=2000, seed_simulator=101)
expdata_with_p0.block_for_results()
# Display fit figure
display(expdata_with_p0.figure(0))

# Print results
for result in expdata_with_p0.analysis_results():
print(result)
AnalysisResult
- name: @Parameters_T2RamseyAnalysis
- value: CurveFitResult:
- fitting method: least_squares
- number of sub-models: 1
* F_cos_decay(x) = amp * exp(-x / tau) * cos(2 * pi * freq * x + phi) + base
- success: True
- number of function evals: 99
- degree of freedom: 20
- chi-square: 12.875308615639284
- reduced chi-square: 0.6437654307819642
- Akaike info crit.: -6.589110211473496
- Bayesian info crit.: -0.49473108713249303
- init params:
* amp = 0.5
* tau = 0.00011299749992597643
* freq = 80000.0000000005
* phi = 0.0
* base = 0.4768115942028985
- fit params:
* amp = 0.49141198624690124 ± 0.004915858642924717
* tau = 0.00010193005794487302 ± 4.45710654181553e-06
* freq = 99948.42509448028 ± 82.74082794739074
* phi = 0.0037573135040063336 ± 0.012639852697629132
* base = 0.5011282572233688 ± 0.0018216291040071982
- correlations:
* (freq, phi) = -0.823176511385811
* (amp, tau) = -0.8136993318625318
* (freq, base) = -0.17104974923435995
* (amp, freq) = -0.11536250638372342
* (tau, phi) = -0.11249152792280535
* (amp, base) = -0.01973646865983497
* (tau, base) = 0.03672145434002577
* (tau, freq) = 0.061593523657976774
* (amp, phi) = 0.16164323710382486
* (phi, base) = 0.16350494553763645
- quality: good
- device_components: ['Q0']
- verified: False
AnalysisResult
- name: Frequency
- value: (9.995+/-0.008)e+04
- χ²: 0.6437654307819642
- quality: good
- extra: <1 items>
- device_components: ['Q0']
- verified: False
AnalysisResult
- name: T2star
- value: 0.000102+/-0.000004
- χ²: 0.6437654307819642
- quality: good
- extra: <1 items>
- device_components: ['Q0']
- verified: False
See also¶
API documentation:
T2Ramsey