# A $$T_1$$ experiment¶

In a $$T_1$$ experiment, we measure an excited qubit after a delay. Due to decoherence processes (e.g. amplitude damping channel), it is possible that, at the time of measurement, after the delay, the qubit will not be excited anymore. The larger the delay time is, the more likely is the qubit to fall to the ground state. The goal of the experiment is to characterize the decay rate of the qubit towards the ground state.

We start by fixing a delay time $$t$$ and a number of shots $$s$$. Then, by repeating $$s$$ times the procedure of exciting the qubit, waiting, and measuring, we estimate the probability to measure $$|1\rangle$$ after the delay. We repeat this process for a set of delay times, resulting in a set of probability estimates.

In the absence of state preparation and measurement errors, the probability to measure |1> after time $$t$$ is $$e^{-t/T_1}$$, for a constant $$T_1$$ (the coherence time), which is our target number. Since state preparation and measurement errors do exist, the qubit’s decay towards the ground state assumes the form $$Ae^{-t/T_1} + B$$, for parameters $$A, T_1$$, and $$B$$, which we deduce form the probability estimates. To this end, the $$T_1$$ experiment internally calls the curve_fit method of scipy.optimize.

The following code demonstrates a basic run of a $$T_1$$ experiment for qubit 0.

import numpy as np
from qiskit_experiments.framework import ParallelExperiment
from qiskit_experiments.library import T1

# A T1 simulator
from qiskit.test.mock import FakeVigo
from qiskit.providers.aer import AerSimulator
from qiskit.providers.aer.noise import NoiseModel

# Create a pure relaxation noise model for AerSimulator
noise_model = NoiseModel.from_backend(
FakeVigo(), thermal_relaxation=True, gate_error=False, readout_error=False
)

# Create a fake backend simulator
backend = AerSimulator.from_backend(FakeVigo(), noise_model=noise_model)

# Look up target T1 of qubit-0 from device properties
qubit0_t1 = backend.properties().t1(0)

# Time intervals to wait before measurement
delays = np.arange(1e-6, 3 * qubit0_t1, 3e-5)
# Create an experiment for qubit 0
# with the specified time intervals
exp = T1(qubit=0, delays=delays)

# Set scheduling method so circuit is scheduled for delay noise simulation
exp.set_transpile_options(scheduling_method='asap')

# Run the experiment circuits and analyze the result
exp_data = exp.run(backend=backend, seed_simulator=101).block_for_results()

# Print the result
display(exp_data.figure(0))
for result in exp_data.analysis_results():
print(result)

<Figure size 800x500 with 1 Axes>

DbAnalysisResultV1
- name: @Parameters_T1Analysis
- value: [1.0045563641435789, -0.005035353390199059, 0.00012472228052670155]
- χ²: 1.0838245182659694
- quality: good
- extra: <4 items>
- device_components: ['Q0']
- verified: False
DbAnalysisResultV1
- name: T1
- value: 0.000125+/-0.000004
- χ²: 1.0838245182659694
- quality: good
- extra: <2 items>
- device_components: ['Q0']
- verified: False


## Parallel $$T_1$$ experiments on multiple qubits¶

To measure $$T_1$$ of multiple qubits in the same experiment, we create a parallel experiment:

# Create a parallel T1 experiment
parallel_exp = ParallelExperiment([T1(qubit=i, delays=delays) for i in range(2)])
parallel_exp.set_transpile_options(scheduling_method='asap')
parallel_data = parallel_exp.run(backend, seed_simulator=101).block_for_results()

# View result data
for result in parallel_data.analysis_results():
print(result)


### Viewing sub experiment data¶

The experiment data returned from a batched experiment also contains individual experiment data for each sub experiment which can be accessed using child_data

# Print sub-experiment data
for i, sub_data in enumerate(parallel_data.child_data()):
print("Component experiment",i)
display(sub_data.figure(0))
for result in sub_data.analysis_results():
print(result)

Component experiment 0

<Figure size 800x500 with 1 Axes>

DbAnalysisResultV1
- name: @Parameters_T1Analysis
- value: [0.9948326419095151, 0.006283342670648204, 0.00012121686758718036]
- χ²: 1.3810153394070848
- quality: good
- extra: <4 items>
- device_components: ['Q0']
- verified: False
DbAnalysisResultV1
- name: T1
- value: 0.000121+/-0.000004
- χ²: 1.3810153394070848
- quality: good
- extra: <2 items>
- device_components: ['Q0']
- verified: False
Component experiment 1

<Figure size 800x500 with 1 Axes>

DbAnalysisResultV1
- name: @Parameters_T1Analysis
- value: [1.0054206765266893, -0.006052662850585891, 0.00011436715545514078]
- χ²: 0.5095073517136448
- quality: good
- extra: <4 items>
- device_components: ['Q1']
- verified: False
DbAnalysisResultV1
- name: T1
- value: 0.0001144+/-0.0000031
- χ²: 0.5095073517136448
- quality: good
- extra: <2 items>
- device_components: ['Q1']
- verified: False

import qiskit.tools.jupyter
%qiskit_copyright


### This code is a part of Qiskit

© Copyright IBM 2017, 2022.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.