bloch_redfield_solve fails with: can't convert complex to float

294 views
Skip to first unread message

Muir Kumph

unread,
Jul 12, 2018, 9:40:20 AM7/12/18
to QuTiP: Quantum Toolbox in Python
When using the Bloch Redfield solver (Qutip 4.2.0) sometimes the subroutine fails with "can't convert complex to float".  The work-around is to pass expectation operators e_ops=[] so that the routine just returns the state vector and then post-evaluate the expectation values with expect().  Maybe this will help someone else with the same problem.  If anyone knows why, I would be curious to hear why.

SoftwareVersion
QuTiP4.2.0
Numpy1.13.1
SciPy0.19.1
matplotlib2.0.2
Cython0.26
Number of CPUs8
BLAS InfoINTEL MKL
IPython6.1.0
Python3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)]
OSnt [win32]

koon...@gmail.com

unread,
Feb 26, 2019, 3:57:07 AM2/26/19
to QuTiP: Quantum Toolbox in Python
Hi Muir,

I got the same problem today: I was trying to pass an imaginary term into the Hamiltonian (something like an abs(erf(1+1j*t)) etc.).
It first gives me the error with :Cannot assign type 'double complex' to 'double',
then I change all the 1j*t term to complex(0,t), and it gives me this error.
I tried your solution but it is not working though. Will you mind if I ask if you are trying to parse complex term into your Hamiltonian as well when you are calculating the Bloch-Redfield master equation? If so, do you have any tips/tricks for incorporating complex term into the Bloch-redfield master equation ?

Zak

Paul Nation

unread,
Feb 26, 2019, 5:20:23 AM2/26/19
to qu...@googlegroups.com
Erf only supports real number inputs. You can use np.erf to do complex
--
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.

koon...@gmail.com

unread,
Feb 26, 2019, 6:48:04 AM2/26/19
to QuTiP: Quantum Toolbox in Python
Hi Paul,

It works. Thank you. 

Zak

ahmed ghareeb

unread,
Feb 26, 2019, 2:52:32 PM2/26/19
to qu...@googlegroups.com

koon...@gmail.com

unread,
Feb 26, 2019, 7:58:58 PM2/26/19
to QuTiP: Quantum Toolbox in Python
Hi Ahmed and Paul,

It turns out the result for the simulation does not match up with the same simulation using mesolve if I use np.erf (no additional time dependent a_op terms of course).
How would you suggest to use scipy.special.erf into the time dependent Hamiltonian ?

Obviously, simply putting scipy.special.erf into the string input of the time dependent Hamiltonian does not work, hence is there any way of adding scipy or specifically scipy.special into cython code?

Zak 

Paul Nation

unread,
Feb 27, 2019, 6:06:10 AM2/27/19
to qu...@googlegroups.com
The erf function needs to be updated to support complex. Not really that hard. Let me see if i can get it done in the next day or so

Paul Nation

unread,
Feb 28, 2019, 11:18:49 AM2/28/19
to QuTiP: Quantum Toolbox in Python
See PR #960 that introduces the zerf

Alex Pitchford

unread,
Mar 6, 2019, 1:00:23 PM3/6/19
to QuTiP: Quantum Toolbox in Python
PR #960 just merged. So zerf now available in dev branch.
If the users here want to try and report back, that would be great.

Thanks

Alex

koon...@gmail.com

unread,
Mar 6, 2019, 5:42:00 PM3/6/19
to QuTiP: Quantum Toolbox in Python
Hi guys,

The function zerf works properly now. I got the same behaviour as the result I get using the function based method. Thanks.

Zak
Reply all
Reply to author
Forward
0 new messages