ptrace throws error: Qobj data must be in fast_scr format

94 views
Skip to first unread message

Pu ZHANG

unread,
Mar 14, 2017, 8:57:44 AM3/14/17
to qu...@googlegroups.com
Hi, all! 

I generate a density matrix and would like to get the partial trace. In older versions it works, but with the dev. version it gives this error. How can I fix this? Thanks! 

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China

Pu ZHANG

unread,
Mar 14, 2017, 9:32:38 AM3/14/17
to qu...@googlegroups.com
It seems to be a bug in the Dev. version. The error does not occur in the official release. 

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China

Alex Pitchford

unread,
Mar 14, 2017, 10:37:53 AM3/14/17
to qu...@googlegroups.com
The latest official release 4.1 is exactly the same as the dev version, so this would seem pretty strange.

Could you post the actual line of line of code that causes the error

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Nation

unread,
Mar 14, 2017, 12:24:33 PM3/14/17
to QuTiP Group
We do 130 randomized tests against the old ptrace, so it should be working.  

Pu ZHANG

unread,
Mar 14, 2017, 11:10:01 PM3/14/17
to qu...@googlegroups.com
Thanks for the reply! 

Here's the piece of script: 
#################
from numpy import *
from scipy import *
from qutip import *

taus = linspace(0,17500,1750)

excited = basis(3,1)
state2 = basis(3,2)
w_exc = 1.2398
w_2 = 3.0

N = 20

sigma_ge = tensor(qeye(N), ground * excited.dag())
sigma_g2 = tensor(qeye(N), ground * state2.dag())

a = tensor(destroy(N), qeye(3))
ada = tensor(num(N), qeye(3))

c_ops = []
kappa = 0.04
c_ops.append(sqrt(kappa) * a)

g = 1e-1

Omega = 13 * kappa
w_p = w_2
w_p2 = w_2 - w_exc

H0 = g * (sigma_ge.dag() * a + a.dag() * sigma_ge) + 0.5 * Omega * (sigma_g2 + sigma_g2.dag())
H1 = g * a.dag() * sigma_ge.dag()
H2 = g * a * sigma_ge
H3 = Omega / 2 * sigma_g2.dag()
H4 = Omega / 2 * sigma_g2
args = {'w_p': w_p, 'w_p2': w_p2}
H = [H0, [H1, 'exp(2j * (w_p - w_p2) * t)'], [H2, 'exp(-2j * (w_p - w_p2) * t)'], [H3, 'exp(2j * w_p * t)'], [H4, 'exp(-2j * w_p * t)']]

rho0 = tensor(fock_dm(N, 0), fock_dm(3, 0))
opts = Options()
opts.store_final_state = True

solution = mesolve(H, rho0, taus, c_ops, [ada], options = opts, args = args)
nSP = solution.expect[0]
dmFinal = solution.final_state
#################

Then I use the command ptrace to calculate the partial trace: rho_SP = dmFinal.ptrace(0). 

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China

Pu ZHANG

unread,
Mar 14, 2017, 11:11:59 PM3/14/17
to qu...@googlegroups.com
I forgot the system info: 

QuTiP version: 4.1.0.dev0
System info: 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 12:22:00) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on cu11

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China

Paul Nation

unread,
Mar 15, 2017, 12:00:05 AM3/15/17
to qu...@googlegroups.com

I can not reproduce the error with the latest dev version. Here is my simplified version:

from qutip import *

a = tensor(destroy(2), qeye(2))
b = tensor(qeye(2), destroy(2))

H = a.dag()*a + b.dag()*b

c_ops = []
c_ops.append(0.1*a)

rho0 = tensor(fock(2, 1), fock(2, 0))
opts = Options()
opts.store_final_state = True

solution = mesolve(H, rho0, [0,1], c_ops, [a.dag()*a], options = opts)
expt = solution.expect[0]
Final = solution.final_state

rho_SP = Final.ptrace(0)

March 14, 2017 at 21:11
I forgot the system info: 

QuTiP version: 4.1.0.dev0
System info: 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 12:22:00) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on cu11

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China


--
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.
March 14, 2017 at 21:09
--
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.
March 14, 2017 at 08:37
The latest official release 4.1 is exactly the same as the dev version, so this would seem pretty strange.

Could you post the actual line of line of code that causes the error


--
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.
March 14, 2017 at 07:32
It seems to be a bug in the Dev. version. The error does not occur in the official release. 

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China


--
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.
March 14, 2017 at 06:57
Hi, all! 

I generate a density matrix and would like to get the partial trace. In older versions it works, but with the dev. version it gives this error. How can I fix this? Thanks! 

Best regards, Pu Zhang

--
Faculty at School of Physics, Huazhong University of Science and Technology
Room 819 (N.), Yifu Science and Technology Building
1037 Luoyu Road, Wuhan, China
--
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.

Paul Nation

unread,
Mar 15, 2017, 12:02:14 AM3/15/17
to qu...@googlegroups.com

The conversion to fast_csr for the last state is also explicitly there:

if opt.store_final_state:
        rho.data = dense2D_to_fastcsr_fmode(vec2mat(r.y), rho.shape[0], rho.shape[1])
        output.final_state = Qobj(rho, dims=rho0.dims, isherm=True)

March 14, 2017 at 22:00

Reply all
Reply to author
Forward
0 new messages