I am using the qutip package under anaconda. I simply call the function mcsolve
in my script. Now, when running under a Jupyter
notebook, the script runs fine in seconds with results. But when running within Spyder
, it gets stuck and never finishes. I Never had this problem with other functions within qutip.
Running this in Spyder prints 'aa' and then 'bb' but never gets to 'cc' line:
import qutip as qt
import numpy as np
import matplotlib.pyplot as plt
# Some constants
g = 100
delta = 10
Ka = g/2.5
Gamma = g/200
Gammap = g/50
Nu = 2*g
Delta_a = -4.12*g
Delta_c = Delta_a +delta*g
N = 4
sm = qt.tensor(qt.qeye(N),qt.sigmam())
sp = sm.dag()
a = qt.tensor(qt.destroy(N),qt.qeye(2))
adag = a.dag()
H = Delta_aspsm + Delta_cadaga + g*(adagsm+spa)+Nu*(sp+sm)
sz = qt.tensor(qt.qeye(N),qt.sigmaz())
C1 = np.sqrt(2*Ka)*a C2 = np.sqrt(Gamma)*sm
C3 = np.sqrt(Gammap/4.0)*(spsm-smsp)
rhoss = qt.steadystate(H,[C1,C2,C3])
print('aa')
times = np.linspace(0,10,1000)
IC = qt.tensor(qt.basis(N,0),qt.basis(2,1))
print('bb')
data = qt.mcsolve(H,IC,times,[C1,C2,C3],[adaga,spsm],ntraj = 1)
print('cc')
I modified your code so I can use for python 3, I am using the Eclipse IDE but the problem is not IDE (Spider/Jupyter) as I have the same problem.
ERROR Image
It is some multiprocessing problem, maybe your Jupyter notebook using different python interpreter. Here is the modified version of your code:
It seems there is something with the parallel processing, look here: https://github.com/pytorch/pytorch/issues/5858 I got the same error when I was running it. It does not have any safe way of dealing with it unless you ask the conda's developers. However, by monkey patching I managed to run it this is my console image:
Execution without error
Caution the solution is not stable and may cause some inconsistency Go to
Now add this at the very end of the script: