-
-
Save TanMath/93f5f7b8b4f7dccd00aa to your computer and use it in GitHub Desktop.
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
from qutip import Qobj, Options, mesolve | |
import numpy as np | |
import scipy | |
from math import * | |
import matplotlib.pyplot as plt | |
hamiltonian = np.array([ | |
[215, -104.1, 5.1, -4.3, 4.7, -15.1, -7.8], | |
[-104.1, 220.0, 32.6, 7.1, 5.4, 8.3, 0.8], | |
[5.1, 32.6, 0.0, -46.8, 1.0, -8.1, 5.1], | |
[-4.3, 7.1, -46.8, 125.0, -70.7, -14.7, -61.5], | |
[4.7, 5.4, 1.0, -70.7, 450.0, 89.7, -2.5], | |
[-15.1, 8.3, -8.1, -14.7, 89.7, 330.0, 32.7], | |
[-7.8, 0.8, 5.1, -61.5, -2.5, 32.7, 280.0] | |
]) | |
recomb = np.zeros((7, 7), dtype=complex) | |
np.fill_diagonal(recomb, 33.33333333) | |
print recomb | |
recomb = recomb * -1j | |
trap = np.zeros((7, 7), complex) | |
trap[2][2] = -0.033333333333j | |
print trap | |
hamiltonian = recomb + trap + hamiltonian | |
H = Qobj(hamiltonian) | |
ground = Qobj(np.array([ | |
[0.0863685], | |
[0.17141713], | |
[-0.91780802], | |
[-0.33999268], | |
[-0.04835763], | |
[-0.01859027], | |
[-0.05006013] | |
])) | |
# I got this from H.groundstate() | |
# ground=H.groundstate()[1] | |
# Note the extra .0 on the end to convert to float | |
gamma = (2 * pi) * (296 * 0.695) * (35.0 / 150) | |
print gamma | |
L1 = np.array([ | |
[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L2 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L3 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L4 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L5 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L6 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]) | |
L7 = np.array([ | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 1] | |
]) | |
# Since our gamma variable cannot be directly applied onto | |
# the Lindblad operator, we must multiply it with | |
# the collapse operators: | |
rho0=L1 | |
L1 = Qobj(gamma * L1) | |
L2 = Qobj(gamma * L2) | |
L3 = Qobj(gamma * L3) | |
L4 = Qobj(gamma * L4) | |
L5 = Qobj(gamma * L5) | |
L6 = Qobj(gamma * L6) | |
L7 = Qobj(gamma * L7) | |
print [L1,L2,L3,L4,L5,L6,L7] | |
options = Options(nsteps=1000000, atol=1e-5) | |
bra3 = [[0, 0, 1, 0, 0, 0, 0]] | |
bra3q = Qobj(bra3) | |
ket3 = [[0], [0], [1], [0], [0], [0], [0]] | |
ket3q = Qobj(ket3) | |
# OK - lets try evolving the system over time | |
# and getting the number you want out ... | |
starttime = 0 | |
# this is effectively just a label - `mesolve` alwasys starts from `rho0` - | |
# it's just saying what we're going to call the time at t0 | |
endtime = 50 | |
# Arbitrary - this solves with the options above | |
# (max 1 million iterations to converge - tolerance 1e-10) | |
num_intermediate_state = 100 | |
state_evaluation_times = np.linspace( | |
starttime, | |
endtime, | |
num_intermediate_state | |
) | |
result = mesolve( | |
H, | |
rho0, | |
state_evaluation_times, | |
[L1, L2, L3, L4, L5, L6, L7], | |
[], | |
options=options | |
) | |
#number_of_interest = bra3q * (result.states * ket3q) | |
number_of_interest = result.states.tr() | |
points_to_plot = [] | |
for number in number_of_interest: | |
if number == number_of_interest[0]: | |
points_to_plot.append(0) | |
else: | |
points_to_plot.append(number.data.data.real[0]) | |
plt.plot(state_evaluation_times, points_to_plot) | |
plt.show() | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment