numpy - Integration not successful in Python QuTiP -
i have been trying use qutip solve quantum mechanics matrix differential equation (a lindblad equation). here code:
from qutip import * matplotlib import * import numpy np 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]]) h=qobj(hamiltonian) ground=qobj(np.array([[ 0.0863685 ], [ 0.17141713], [-0.91780802], [-0.33999268], [-0.04835763], [-0.01859027], [-0.05006013]])) rho0 = ground*ground.dag() scipy.constants import * ktuple=physical_constants['boltzmann constant in ev/k'] k = ktuple[0]* 8065.6 htuple = physical_constants['planck constant in ev s'] hbar = (htuple[0]* 8065.6)/(2*pi) gamma=(2*pi)*((k*300)/hbar)*(35/(150*hbar)) l1 = qobj(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 = qobj(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 = qobj(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 = qobj(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 = qobj(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 = qobj(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 = qobj(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 directly applied onto lindblad operator, must multiply collapse operators: l1=gamma*l1 l2=gamma*l2 l3=gamma*l3 l4=gamma*l4 l5=gamma*l5 l6=gamma*l6 l7=gamma*l7 options = options(nsteps=100000) results = mesolve(h, rho0, np.linspace(0.0, 1000, 20),[l1,l2,l3,l4,l5,l6,l7],[],options=options) print results
this code supposed solve following equation:
where l_i matrices (in list: [l1,l2,l3,l4,l5,l6,l7]), h hamiltonian, matrix, density matrix, ,
constant equal
t temperature, k boltzmann constant, ,
, h planck's constant.
every time run code, gives me following error:
zvode-- @ t (=r1) , step size h (=r2), corrector convergence failed repeatedly or abs(h) = hmin in above, r1 = 0.0000000000000d+00 r2 = 0.1202322246215d-36 /usr/local/lib/python2.7/dist-packages/scipy/integrate/_ode.py:853: userwarning: zvode: repeated convergence failures. (perhaps bad jacobian supplied or wrong choice of mf o r tolerances.) 'unexpected istate=%s' % istate)) traceback (most recent call last): file "lindbladqutip.py", line 48, in <module> results = mesolve(h, rho0, np.linspace(0.0, 1000, 20),[l1,l2,l3,l4,l5,l6,l7],[],options=options) file "/projects/d6138712-e5f4-4d85-9d4d-77ce0a7b4a61/.local/lib/python2.7/site-packages/qutip/mesolve.py", line 264, in mesolve progress_bar) file "/projects/d6138712-e5f4-4d85-9d4d-77ce0a7b4a61/.local/lib/python2.7/site-packages/qutip/mesolve.py", line 692, in _mesolve_const return _generic_ode_solve(r, rho0, tlist, e_ops, opt, progress_bar) file "/projects/d6138712-e5f4-4d85-9d4d-77ce0a7b4a61/.local/lib/python2.7/site-packages/qutip/mesolve.py", line 866, in _generic_ode_solve raise exception("ode integration error: try increase " exception: ode integration error: try increase allowed number of substeps increasing nsteps parameter in options class.
after doing debugging analysis, seems first or second integration fails. error tells me increase nsteps parameter, have tried. fails. changing list of times (the np.linspace function makes list of times) has no effect.
i desperate know can fix error. please comment if need more details.
thanks help!
from programming point of view, problem appears value of gamma
, therefore size of collapse operators. print out gamma
- of order 10**25
- seems preventing solver converging.
just testing (i'm engineer, not quantum physicist...), put in smaller value of gamma
(e.g. 0.1), solver seems work , gives apparently reasonable output in results.states
i don't quite understand gamma
- seems have units of cm-1s-2 have set up. wonder if want divide hbar
once, maybe. say, i'm not quantum physicist, i'm guessing here based on makes programming hang combined bit of dimensional analysis.
edit
op indicates in comments wrong order of magnitude / units gamma
seem programming issue (i.e. preventing numerical calculus converging), isn't totally clear on how calculate gamma. @ stage, may worth posting question @ either http://physics.stackexchange.com or http://math.stackexchange.com - referencing 1 context if necessary.
edit 2
i note asked related question on physics site. makes clear the expression gamma comes from , thereby clarifies constant terms presented 30
, 150
in question have units (energy , frequency respectively). changes dimensional analysis - units of gamma s-1 or, appropriate conversion, cm-1.
it shows value mention in comments - 300 cm-1.
Comments
Post a Comment