Try to use Bloch3d

293 views
Skip to first unread message

Andre Bolle

unread,
Dec 5, 2018, 8:57:24 AM12/5/18
to QuTiP: Quantum Toolbox in Python
Hi,

Please help.

In running the following code to display a 3d bloch sphere I run the following.

from qutip import *

b = Bloch3d()
up = basis(2,0)
b.add_states(up)

b.show()

I get TraitError: The 'input' trait of a PolyDataMapper instance is 'read only'. Full error output is here.

---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
<ipython-input-1-662542992c82> in <module>
      5 b.add_states(up)
      6 
----> 7 b.show()

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\qutip\bloch3d.py in show(self)
    493         """
    494         from mayavi import mlab
--> 495         self.make_sphere()
    496         mlab.view(azimuth=self.view[0], elevation=self.view[1], distance=5)
    497         if self.fig:

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\qutip\bloch3d.py in make_sphere(self)
    466         # add data to sphere
    467         self.plot_points()
--> 468         self.plot_vectors()
    469 
    470         # #add labels

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\qutip\bloch3d.py in plot_vectors(self)
    353                                    radius=self.vector_head_radius,
    354                                    resolution=100)
--> 355             cone_mapper = tvtk.PolyDataMapper(input=cone.output)
    356             prop = tvtk.Property(opacity=self.vector_alpha, color=color)
    357             cc = tvtk.Actor(mapper=cone_mapper, property=prop)

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\tvtk\tvtk_classes.zip\tvtk_classes\poly_data_mapper.pyc in __init__(self, obj, update, **traits)

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\tvtk\tvtk_base.py in __init__(self, klass, obj, update, **traits)
    333         # anyway.
    334         self._in_set = 1
--> 335         super(TVTKBase, self).__init__(**traits)
    336         self._in_set = 0
    337 

c:\users\andre\appdata\local\programs\python\python36\lib\site-packages\traits\trait_handlers.py in _read_only(object, name, value)
    102 def _read_only ( object, name, value ):
    103     raise TraitError("The '%s' trait of %s instance is 'read only'." % (
--> 104                       name, class_of( object ) ))
    105 
    106 def _undefined_get ( object, name ):

TraitError: The 'input' trait of a PolyDataMapper instance is 'read only'.

Other info which may help ...

Windows 10 64-bit

python --version
Python 3.6.7

vtk                      8.1.2
qutip                    4.3.1
mayavi                   4.6.2

Thanks,
Andre





Andre Bolle

unread,
Dec 5, 2018, 9:02:42 AM12/5/18
to QuTiP: Quantum Toolbox in Python
FYI,

Without the lines

up = basis(2,0)
b.add_states(up)

it actually produces an interactive Bloch3d window.

Andre

Andre Bolle

unread,
Dec 5, 2018, 9:31:03 AM12/5/18
to QuTiP: Quantum Toolbox in Python
More info:

from qutip.ipynbtools import version_table

version_table()


SoftwareVersion
QuTiP4.3.1
Numpy1.15.3
SciPy1.1.0
matplotlib3.0.1
Cython0.29.1
Number of CPUs2
BLAS InfoOPENBLAS
IPython7.1.1
Python3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 13:35:33) [MSC v.1900 64 bit (AMD64)]
OSnt [win32]
Wed Dec 05 14:29:30 2018 GMT Standard Time
Reply all
Reply to author
Forward
0 new messages