Problem with simulation of non linear adiabatic process

55 views
Skip to first unread message

Yonato

unread,
Aug 27, 2016, 4:17:57 PM8/27/16
to QuTiP: Quantum Toolbox in Python
I am trying to model a non linear adiabatic process using the Qutip library and ran into some problems.

My work is based on the paper by Roland and Cerf http://arxiv.org/abs/quant-ph/0107015 where in they describe an adiabatic process that takes for T\ge \frac{\pi}{2\epsilon}{\sqrt{N}} for computing Grover's algorithm, an improvement over the naive process which takes T\ge \frac{N} {\epsilon}.

To do this - they change the relation between the hamiltonian coupling and the time, from linear, to a function that maximizes the time spent in small gaps.

I've been trying to model this process using the Qutip sesolve and got unexpected results - it seems like the computed hamiltonians and eigenvalues are correct, but the evolution of the initial states is wrong.

I've created a notebook where you can see this behavior, Comparing the evolution in a slower implementation I've wrote (adiabatic_sim.py) to that given in a sample of the samples in the documentation (LH_tools.py:simulate_adiabatic_process2)

As you can see in the notebook - in the linear evolution case - both implementations yield the same results, however in the non linear case - they differ.

I'm not sure if this is a bug in the library, or mistake in my programming.

nonher...@gmail.com

unread,
Aug 27, 2016, 11:01:48 PM8/27/16
to qu...@googlegroups.com
Can you tell us what version you have? Also did you try the mcsolve function or the mesolve function with the state vector cast to a density matrix?  They should all return the same expectation values. 

-P
--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yonato

unread,
Aug 28, 2016, 3:41:49 AM8/28/16
to QuTiP: Quantum Toolbox in Python
Version 3.1 

I've been using sesolve and mesolve, they both yield the same results.

Using mcsolve I get this error:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-37-aaccd8b3342c> in <module>()
      4       [H_1, '1/2*(1-(np.sqrt(N - 1) * np.tan((2 * t * epsilon * np.sqrt(N - 1) - N * np.arctan(np.sqrt(N - 1))) / N))/(1-N))']]
      5 args = {'t_max':tmax, 'N':N, 'epsilon': eps}
----> 6 P_mat,EV_mat,psis_qutip = LH_tools.simulate_adiabatic_process2(tlist, h_s, args ,psi0, False)
      7 f = LH_tools.plot_PandEV(P_mat,EV_mat,tlist)
      8 plt.show()

.../qutip/LH_tools.py in simulate_adiabatic_process2(tlist, h_t, args, rho0, draw, options)
    159                      e_ops=process_rho,
    160                      args=args,
--> 161                      options=options)
    162     # rc('font', family='serif')
    163     # rc('font', size='10')

.../qutip/lib/python3.5/site-packages/qutip/mcsolve.py in mcsolve(H, psi0, tlist, c_ops, e_ops, ntraj, args, options, progress_bar, map_func, map_kwargs)
    269         # Configure data
    270         _mc_data_config(H, psi0, h_stuff, c_ops, c_stuff, args, e_ops,
--> 271                         options, config)
    272 
    273         # compile and load cython functions if necessary

.../qutip/lib/python3.5/site-packages/qutip/mcsolve.py in _mc_data_config(H, psi0, h_stuff, c_ops, c_stuff, args, e_ops, options, config)
   1034 
   1035     # take care of expectation values, if any
-> 1036     if any(e_ops):
   1037         config.e_num = len(e_ops)
   1038         for op in e_ops:

TypeError: 'function' object is not iterable

nonher...@gmail.com

unread,
Aug 28, 2016, 9:07:30 AM8/28/16
to qu...@googlegroups.com
Try the latest developer version. Also the mesolve calls sesolve if the input state is not a density matrix. 
Message has been deleted

Yonato

unread,
Aug 28, 2016, 10:11:50 AM8/28/16
to QuTiP: Quantum Toolbox in Python
Using 3.2.0.dev0+3deae74 I get the same results.

nonher...@gmail.com

unread,
Aug 28, 2016, 10:14:53 AM8/28/16
to qu...@googlegroups.com
Can you rewrite the problem so that all of the qutip calls are visible. For example, I cannot see the expect ops list. 

On Aug 28, 2016, at 08:11, Yonato <or.yo...@gmail.com> wrote:


Tried using 3.2.0.dev0+3deae74, the results are the same.

Yonatan oren

unread,
Aug 28, 2016, 10:17:33 AM8/28/16
to qu...@googlegroups.com
Oh sorry ,you can see the full source here : https://github.com/oryonatan/qutip

‫בתאריך יום א׳, 28 באוג׳ 2016 ב-17:14 מאת <‪nonher...@gmail.com‬‏>:‬
You received this message because you are subscribed to a topic in the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qutip/EPd14-GliyY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qutip+un...@googlegroups.com.

nonher...@gmail.com

unread,
Aug 28, 2016, 10:27:39 AM8/28/16
to qu...@googlegroups.com
Well you are defining your eops as a function which is why the mcsolver does not work. It should be a list. If you input no eops then, for example The states returned by mcsolve and sesolve should be the same.  That is one check. Also the mesolver if given a dm as input will return the same state as a dm. That is one way to check. If the states are the same, then it is the eops that is causing the problem. I am actually surprised that it works at all given that it is not in the correct format. 
Message has been deleted

Yonato

unread,
Aug 28, 2016, 11:11:26 AM8/28/16
to QuTiP: Quantum Toolbox in Python
Hi

I tried using mesolve with e_ops = [], and got the same results. 

I still have problems running mcsolve 
AttributeError                            Traceback (most recent call last)
...
.../lib/python3.5/site-packages/qutip/mcsolve.py in <listcomp>(.0)
   1184             if options.tidy:
   1185                 H = np.array([H[k].tidyup(options.atol)
-> 1186                               for k in range(len_h)], dtype=object)
   1187             # construct data sets
   1188             config.h_data = [H[k].data.data for k in range(len_h)]

Maybe it has to do with using the string format in mcsolve ? or the fact that my hamiltonian doesn't have any constant term (it appears from the docs that mcsolve hamiltonian must have a constant term)

nonher...@gmail.com

unread,
Aug 28, 2016, 11:26:01 AM8/28/16
to qu...@googlegroups.com
Could be. But you can put
In an operator of all zeros. 

nonher...@gmail.com

unread,
Aug 28, 2016, 11:26:43 AM8/28/16
to qu...@googlegroups.com
You are you saying the output states are the same? Or are you still talking about expect values?

On Aug 28, 2016, at 09:10, Yonato <or.yo...@gmail.com> wrote:

Hi

I tried using mesolve with e_ops = [], and got the same results. 

I still have problems running mcsolve 
AttributeError                            Traceback (most recent call last)
...
.../lib/python3.5/site-packages/qutip/mcsolve.py in <listcomp>(.0)
   1184             if options.tidy:
   1185                 H = np.array([H[k].tidyup(options.atol)
-> 1186                               for k in range(len_h)], dtype=object)
   1187             # construct data sets
   1188             config.h_data = [H[k].data.data for k in range(len_h)]
Maybe it has to do with using the string format in mcsolve ? or the fact that my hamiltonian doesn't have any constant term (it appears from the docs that mcsolve hamiltonian must have a constant term)



Yonato

unread,
Aug 29, 2016, 11:16:25 AM8/29/16
to QuTiP: Quantum Toolbox in Python
Hi Paul  , I've simplified the code and removed the e_ops, an updated notebook with comparison of mesolve mcsolve and my implementation can be found here.
mcsolve and mesolve are always consistent with each other, however they only agree with my implementation only in the linear time case.

nonher...@gmail.com

unread,
Aug 29, 2016, 11:51:07 AM8/29/16
to qu...@googlegroups.com
So the states from all three qutip solvers are the same?  If this is indeed the case, then I would assume that it is a bug in your code somewhere. The alternative is that we have bugs in three different solvers. I might have some time to look this over tonight. 

Yonato

unread,
Aug 29, 2016, 12:24:39 PM8/29/16
to QuTiP: Quantum Toolbox in Python
Yes , though it it seems like the problem only occurs when the time list is not evenly-spaced.

nonher...@gmail.com

unread,
Aug 29, 2016, 12:35:46 PM8/29/16
to qu...@googlegroups.com
You mean you are requesting the output vectors at unevenly spaced time steps?  The mesolve and sesolve take only evenly spaced timesteps at present. 

Yonato

unread,
Aug 29, 2016, 12:54:41 PM8/29/16
to QuTiP: Quantum Toolbox in Python
Not only the output, I need the evolution itself to be in varying speed (although that may be the same thing)
Is there any simple way to fix that ?

nonher...@gmail.com

unread,
Aug 29, 2016, 2:18:44 PM8/29/16
to qu...@googlegroups.com
I dont know what you mean. However, the only limitation is on the input vector tlist. The steps must be evenly spaced. That is just the way it was coded a long time ago and no one has made an issue of it yet. 

nonher...@gmail.com

unread,
Aug 29, 2016, 2:23:47 PM8/29/16
to qu...@googlegroups.com
Mcsolve works for arbitrary  input tlists. 
Reply all
Reply to author
Forward
0 new messages