Last active
May 26, 2023 10:57
-
-
Save JesusCastroFernandez/39bcbd3d2a51c2c173812837e6ee9b87 to your computer and use it in GitHub Desktop.
Ejemplo de código para la simulación cuántica en QuTiP. Este código simula la evolución temporal de un qubit en el Hamiltoniano definido. La evolución se grafica al final..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python | |
import numpy as np | |
from qutip import * | |
# Definir los estados de la base | |
up = basis(2, 0) | |
down = basis(2, 1) | |
# Definir los operadores de Pauli | |
sigma_x = sigmax() | |
sigma_y = sigmay() | |
sigma_z = sigmaz() | |
# Definir el Hamiltoniano | |
H = 0.5 * np.pi * (sigma_x + sigma_y + sigma_z) | |
# Evolución temporal del estado inicial | |
tlist = np.linspace(0, 1, 100) | |
result = mesolve(H, up, tlist, [], [up * up.dag(), down * down.dag()]) | |
# Graficar los resultados | |
import matplotlib.pyplot as plt | |
plt.plot(result.times, result.expect[0], label="up") | |
plt.plot(result.times, result.expect[1], label="down") | |
plt.legend() | |
plt.show() | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment