# $T_1/T_2$ thermal relaxation example

The built in noise models in Qiskit have an example of $$T_1/2T_2$$ relaxation here. I have a couple of doubts; the notebook is not very clear in some of the steps.

Why does one need $$T_2\leq 2T_1$$? There's no reference on this, is it too obvious why it should be so? It is also defined time_u3 = 100 # (two X90 pulses), does this referes to the gate_length?

Answering your second question first, yes the time_u3 = 100 # (two X90 pulses) refers to the gate time. The function thermal_relaxation_error(t1, t2, time, excited_state_population=0) needs to know the timescale of the noise (t1, t2) relative to the total time for the gate to determine how "much" error occurs. This is ultimately due to how the noise is modeled phenomenologically, which naturally leads to your first question.
It is not really obvious to see why $$T_2 \leq 2T_1$$, because it follows from how the Kraus form for the noise channel is defined. The amplitude damping channel has the (non-unique) Kraus form \begin{align} \mathcal{E}(\rho) &= E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger \\ E_0 &= |0\rangle\langle 0| + \sqrt{1-\lambda}|1\rangle\langle 1|\\ E_1 &= \sqrt{\lambda}|0\rangle\langle 1| \end{align} where $$E_1$$ is a decay event, and $$E_0$$ is the absence of a decay event.
If you expand this out on an arbitrary density matrix, you get \begin{align} \mathcal{E}\Big(\begin{bmatrix} a & b\\ b^* & 1-a \end{bmatrix} \Big) = \begin{bmatrix} 1-(1-a)(1-\lambda) & b\sqrt{1-\lambda}\\ b^*\sqrt{1-\lambda} & (1-a)(1-\lambda) \end{bmatrix} \end{align}
Notice that if $$\lambda = 0$$ nothing happens, and if $$\lambda = 1$$ then the output of the channel is just the ground state $$|0\rangle$$. What makes this physical/phenomenological is that we just assume that $$\lambda = 1 - e^{-t/T_1}$$, meaning we interpret $$\lambda$$ as the probability that the qubit relaxes--the longer we wait, the more likely it should be that the qubit has relaxed (relaxation events are discrete, but we are averaging over many trials when working with density matrices). Notice that the off-diagonal matrix elements decay with a rate $$2T_1$$ whereas the excited population $$|1\rangle$$ decays with $$T_1$$. It turns out that if you add a second decay channel--dephasing noise--then the off-diagonals will decay with a rate that also depends on $$T_{\phi}$$, where $$T_{\phi}$$ refers to the decay caused by pure dephasing. $$T_2$$ is the decay rate that effectively combines both of these effects, and is derived by solving \begin{align} e^{-t/T_2} = e^{-t/2T_1}e^{-t/T_{\phi}} \end{align} leading to \begin{align} \frac{1}{T_2} = \frac{1}{2T_1} + \frac{1}{T_{\phi}} \end{align} Thus, in the absence of any pure dephasing (so $$T_{\phi} = \infty$$), $$T_2 = 2T_1$$, and the process of relaxation alone will upper bound the phase coherence of the qubit. If you want to control these effects independently, you should set $$T_1$$ and $$T_{\phi}$$, instead of $$T_1$$ and $$T_2$$.