def bloch_plot(self, points=None, F=None):
        """
        Plot the current state on the Bloch sphere using
        qutip. 
        """
        # create instance of 3d plot
        bloch = Bloch(figsize=[9, 9])
        bloch.add_vectors([0, 0, 1])
        bloch.xlabel = ['$<F_x>$', '']
        bloch.ylabel = ['$<F_y>$', '']
        bloch.zlabel = ['$<F_z>$', '']
        if self.spin == 'half':
            if points is None:
                # convert current state into density operator
                rho = np.outer(self.state.H, self.state)
                # get Bloch vector representation
                points = self.get_bloch_vec(rho)
                # Can only plot systems of dimension 2 at this time
                assert len(
                    points
                ) == 3, "System dimension must be spin 1/2 for Bloch sphere plot"
                # create instance of 3d plot
            bloch = Bloch(figsize=[9, 9])
        elif self.spin == 'one':
            #points is list of items in format [[x1,x2],[y1,y2],[z1,z2]]
            if points is None:
                points = [getStars(self.state)]
            bloch.point_color = ['g', 'r',
                                 'b']  #ensures point and line are same colour
            bloch.point_marker = ['o', 'd', 'o']
            #bloch.point_color  = ['g','r'] #ensures point and line are same colour
            #bloch.point_marker = ['o','d']
            for p in points:
                bloch.add_points([p[0][0], p[1][0], p[2][0]])
                bloch.add_points([p[0][1], p[1][1], p[2][1]])
                bloch.add_points(p, meth='l')
            '''

            bloch.point_color = ['b','b'] #ensures point and line are same colour
            bloch.point_marker = ['o','o']
            for p in points:
                bloch.add_points(p)
                bloch.add_points(p, meth='l')
            '''
        # add state
        #bloch.render(bloch.fig, bloch.axes)
        #bloch.fig.savefig("bloch.png",dpi=600, transparent=True)
        bloch.show()
 def maj_vid(self, points):
     #takes screenshots of majorana stars over time to produce vid
     if points is None:
         points = [getStars(self.state)]
     i = 0
     for p in points:
         bloch = Bloch(figsize=[9, 9])
         bloch.xlabel = ['$<F_x>$', '']
         bloch.ylabel = ['$<F_y>$', '']
         bloch.zlabel = ['$<F_z>$', '']
         bloch.point_color = ['g', 'r',
                              'b']  #ensures point and line are same colour
         bloch.point_marker = ['o', 'd', 'o']
         bloch.add_points([p[0][0], p[1][0], p[2][0]])
         bloch.add_points([p[0][1], p[1][1], p[2][1]])
         bloch.add_points(p, meth='l')
         bloch.render(bloch.fig, bloch.axes)
         bloch.fig.savefig(
             "bloch" + str(i).zfill(int(np.ceil(np.log10(len(points))))) +
             ".png",
             dpi=600,
             transparent=False)
         i += 1
Exemple #3
0
# %% -2-
# hinzufuegen eines Vektor
#  x,y,z
v = [1, 0, 0]  # dazu geben wir einen Vektor in die x-Richtung an
b.add_vectors(
    v)  # mit b.add_vectors wird der Vektor v der Blochkugel hinzugefuegt
b.show()
print('-2-')
input('Press ENTER to continue.')

# %% -3-
# Achsen koennen auch umbenannt werden
# dazu kann Latex-Code verwendet werden jedoch muss beachtet werden,
# dass fuer Latex-Code \ --> \\ verwendet werden sollte
b.xlabel = ["$\\left|45^\\circ \\right>$", "$\\left|-45^\\circ \\right>$"]
b.ylabel = ["$\\left|\\sigma^+\\right>$", "$\\left|\\sigma^- \\right>$"]
b.zlabel = ["$\\left|H\\right>$", "$\\left|V\\right>$"]
b.show()
print('-3-')
input('Press ENTER to continue.')

# %% -4-
b.clear()  # Loescht alle Zustaende auf der Blochkugel
# behaltet jedoch Einstellungen wie z.B. Achsenbeschriftung

# Normierung eines Vektors
v = [1 / math.sqrt(3), 1 / math.sqrt(3), -1 / math.sqrt(3)]
w = [1, -1, 1] / np.sqrt(3)

# automatische Normierung eines Vektors