Exemplo n.º 1
0
    def test_propagation_in_different_basis(self):
        """(LINDBLAD) Testing comparison of propagations in different bases

        """

        LT1 = LindbladForm(self.H1, self.sbi1, as_operators=True)
        LT2 = LindbladForm(self.H1, self.sbi1, as_operators=False)

        time = TimeAxis(0.0, 1000, 1.0)

        prop1 = ReducedDensityMatrixPropagator(time, self.H1, LT1)
        prop2 = ReducedDensityMatrixPropagator(time, self.H1, LT2)

        rho0 = ReducedDensityMatrix(dim=self.H1.dim)
        rho0.data[1, 1] = 1.0

        with eigenbasis_of(self.H1):
            rhot1_e = prop1.propagate(rho0)

        with eigenbasis_of(self.H1):
            rhot2_e = prop2.propagate(rho0)

        rhot1_l = prop1.propagate(rho0)
        rhot2_l = prop2.propagate(rho0)

        numpy.testing.assert_allclose(rhot1_l.data, rhot1_e.data)
        numpy.testing.assert_allclose(rhot2_l.data, rhot2_e.data)
        numpy.testing.assert_allclose(rhot1_e.data,
                                      rhot2_e.data)  #, rtol=1.0e-2)
Exemplo n.º 2
0
    def test_transformation_in_different_basis(self):
        """(LINDBLAD) Testing transformations into different bases

        """
        #Manager().warn_about_basis_change = True
        #Manager().warn_about_basis_changing_objects = True

        LT1 = LindbladForm(self.H1, self.sbi1, as_operators=True, name="LT1")
        LT2 = LindbladForm(self.H1, self.sbi1, as_operators=False, name="LT2")

        rho0 = ReducedDensityMatrix(dim=self.H1.dim, name="ahoj")
        with eigenbasis_of(self.H1):
            rho0.data[1, 1] = 0.7
            rho0.data[0, 0] = 0.3

        with eigenbasis_of(self.H1):
            rhot1_e = LT1.apply(rho0, copy=True)

        with eigenbasis_of(self.H1):
            rhot2_e = LT2.apply(rho0, copy=True)

        rhot1_l = LT1.apply(rho0, copy=True)
        rhot2_l = LT2.apply(rho0, copy=True)

        numpy.testing.assert_allclose(rhot1_l.data, rhot1_e.data)
        numpy.testing.assert_allclose(rhot2_l.data, rhot2_e.data)
        numpy.testing.assert_allclose(rhot1_e.data,
                                      rhot2_e.data)  #, rtol=1.0e-2)
Exemplo n.º 3
0
    def test_comparison_of_rates(self):
        """Testing that Lindblad tensor and rate matrix are compatible
        
        
        """
        tensor = True
        #        matrix = True

        dim = self.H1.dim
        KT = numpy.zeros((dim, dim), dtype=numpy.float64)
        KM = numpy.zeros((dim, dim), dtype=numpy.float64)

        if tensor:
            #print(self.H1)
            LT = LindbladForm(self.H1, self.sbi1, as_operators=False)

            for n in range(2):
                for m in range(2):
                    #print(n,m,numpy.real(RT.data[n,n,m,m]))
                    KT[n, m] = numpy.real(LT.data[n, n, m, m])

        KM = numpy.zeros((dim, dim))
        KM[0, 0] = -self.rates[1]
        KM[1, 1] = -self.rates[0]
        KM[0, 1] = self.rates[0]
        KM[1, 0] = self.rates[1]

        numpy.testing.assert_allclose(KT, KM, rtol=1.0e-2)
Exemplo n.º 4
0
    def test_comparison_of_dynamics(self):
        """Testing site basis dynamics by Lindblad

        """

        LT1 = LindbladForm(self.H1, self.sbi1, as_operators=True)
        LT2 = LindbladForm(self.H1, self.sbi1, as_operators=False)

        time = TimeAxis(0.0, 1000, 1.0)

        prop1 = ReducedDensityMatrixPropagator(time, self.H1, LT1)
        prop2 = ReducedDensityMatrixPropagator(time, self.H1, LT2)

        rho0 = ReducedDensityMatrix(dim=self.H1.dim)
        rho0.data[1, 1] = 1.0

        rhot1 = prop1.propagate(rho0)
        rhot2 = prop2.propagate(rho0)

        numpy.testing.assert_allclose(rhot1.data, rhot2.data)  #, rtol=1.0e-2)
Exemplo n.º 5
0
    def test_transformation_in_different_basis(self):
        """(LINDBLAD) Testing transformations into different bases

        """
        #Manager().warn_about_basis_change = True
        #Manager().warn_about_basis_changing_objects = True
        
        LT1 = LindbladForm(self.H1, self.sbi1, as_operators=True, name="LT1")
        LT2 = LindbladForm(self.H1, self.sbi1, as_operators=False, name="LT2")

        rho0 = ReducedDensityMatrix(dim=self.H1.dim, name="ahoj")
        with eigenbasis_of(self.H1):
            rho0.data[1,1] = 0.7
            rho0.data[0,0] = 0.3
                
          
        with eigenbasis_of(self.H1):
            rhot1_e = LT1.apply(rho0, copy=True)
            
        with eigenbasis_of(self.H1):
            rhot2_e = LT2.apply(rho0, copy=True)

        rhot1_l = LT1.apply(rho0, copy=True)
        rhot2_l = LT2.apply(rho0, copy=True)
            
        numpy.testing.assert_allclose(rhot1_l.data, rhot1_e.data)
        numpy.testing.assert_allclose(rhot2_l.data, rhot2_e.data)
        numpy.testing.assert_allclose(rhot1_e.data, rhot2_e.data) #, rtol=1.0e-2) 
Exemplo n.º 6
0
K.data[1, 2] = 1.0

#
# System bath interaction with prescribed rate
#
from quantarhei.qm import SystemBathInteraction

sbi = SystemBathInteraction(sys_operators=[K], rates=(1.0 / 100, ))
agg.set_SystemBathInteraction(sbi)

#
# Corresponding Lindblad form
#
from quantarhei.qm import LindbladForm

LF = LindbladForm(HH, sbi, as_operators=False)

print(LF.data[1, 1, 2, 2])
print(LF.data[1, 2, 1, 2])

#
# We can get it also from the aggregate
#

from quantarhei import TimeAxis

time = TimeAxis()

# time is not used here at all
LFa, ham = agg.get_RelaxationTensor(time,
                                    relaxation_theory="electronic_Lindblad")
Exemplo n.º 7
0
    def test_comparison_of_exciton_dynamics(self):
        """Testing exciton basis dynamics by Lindblad

        """

        # site basis form to be compared with
        LT1 = LindbladForm(self.H1, self.sbi1, as_operators=True)

        # exciton basis forms
        LT13 = LindbladForm(self.H3, self.sbi3, as_operators=True)
        LT23 = LindbladForm(self.H3, self.sbi3, as_operators=False)

        LT4e = LindbladForm(self.H4, self.sbi4e, as_operators=True)
        LT4s = LindbladForm(self.H4s, self.sbi4s, as_operators=True)

        time = TimeAxis(0.0, 1000, 1.0)

        #
        # Propagators
        #
        prop0 = ReducedDensityMatrixPropagator(time, self.H1, LT1)
        prop1 = ReducedDensityMatrixPropagator(time, self.H3, LT13)
        prop2 = ReducedDensityMatrixPropagator(time, self.H3, LT23)
        prop4e = ReducedDensityMatrixPropagator(time, self.H4, LT4e)
        prop4s = ReducedDensityMatrixPropagator(time, self.H4s, LT4s)

        #
        # Initial conditions
        #
        rho0 = ReducedDensityMatrix(dim=self.H3.dim)
        rho0c = ReducedDensityMatrix(dim=self.H1.dim)  # excitonic
        with eigenbasis_of(self.H3):
            rho0c.data[1, 1] = 1.0
        rho0.data[1, 1] = 1.0

        rho04e = ReducedDensityMatrix(dim=self.H4.dim)
        rho04s = ReducedDensityMatrix(dim=self.H4.dim)
        with eigenbasis_of(self.H4):
            rho04e.data[2, 2] = 1.0
        rho04s.data[2, 2] = 1.0

        #
        # Propagations
        #
        rhotc = prop0.propagate(rho0c)
        rhot1 = prop1.propagate(rho0)
        rhot2 = prop2.propagate(rho0)

        rhot4e = prop4e.propagate(rho04e)
        rhot4s = prop4s.propagate(rho04s)

        # propagation with operator- and tensor forms should be the same
        numpy.testing.assert_allclose(rhot1.data, rhot2.data)  #, rtol=1.0e-2)

        #
        # Population time evolution by Lindblad is independent
        # of the level structure and basis, as long as I compare
        # populations in basis in which the Lindblad form was defined
        #

        P = numpy.zeros((2, time.length))
        Pc = numpy.zeros((2, time.length))

        P4e = numpy.zeros((3, time.length))
        P4s = numpy.zeros((3, time.length))

        with eigenbasis_of(self.H3):
            for i in range(time.length):
                P[0, i] = numpy.real(rhot1.data[i, 0,
                                                0])  # population of exciton 0
                P[1, i] = numpy.real(rhot1.data[i, 1,
                                                1])  # population of exciton 1

        for i in range(time.length):
            Pc[0, i] = numpy.real(rhotc.data[i, 0,
                                             0])  # population of exciton 0
            Pc[1, i] = numpy.real(rhotc.data[i, 1,
                                             1])  # population of exciton 1

        # we compare populations
        numpy.testing.assert_allclose(Pc, P)  #, rtol=1.0e-2)

        with eigenbasis_of(self.H4):
            for i in range(time.length):
                P4e[0,
                    i] = numpy.real(rhot4e.data[i, 0,
                                                0])  # population of exciton 0
                P4e[1,
                    i] = numpy.real(rhot4e.data[i, 1,
                                                1])  # population of exciton 1
                P4e[2,
                    i] = numpy.real(rhot4e.data[i, 2,
                                                2])  # population of exciton 1

        for i in range(time.length):
            P4s[0, i] = numpy.real(rhot4s.data[i, 0,
                                               0])  # population of exciton 0
            P4s[1, i] = numpy.real(rhot4s.data[i, 1,
                                               1])  # population of exciton 1
            P4s[2, i] = numpy.real(rhot4s.data[i, 2,
                                               2])  # population of exciton 1


#        import matplotlib.pyplot as plt
#
#        plt.plot(time.data,P4s[0,:], "-r")
#        plt.plot(time.data,P4s[1,:], "-r")
#        plt.plot(time.data,P4s[2,:], "-r")
#        plt.plot(time.data,P4e[0,:], "-g")
#        plt.plot(time.data,P4e[1,:], "-g")
#        plt.plot(time.data,P4e[2,:], "-g")

#        plt.show()

        numpy.testing.assert_allclose(P4e, P4s, atol=1.0e-8)
    def test_Lindblad_dynamics_comp(self):
        """Compares Lindblad dynamics calculated from propagator and superoperator
        
        
        
        """
        # Aggregate
        import quantarhei as qr
        import quantarhei.models.modelgenerator as mgen

        time = qr.TimeAxis(0.0, 1000, 1.0)

        # create a model
        mg = mgen.ModelGenerator()

        agg = mg.get_Aggregate(name="trimer-1")

        agg.build()

        ham = agg.get_Hamiltonian()

        # calculate relaxation tensor

        with qr.eigenbasis_of(ham):

            #
            # Operator describing relaxation
            #
            from quantarhei.qm import Operator

            K = Operator(dim=ham.dim, real=True)
            K.data[1, 2] = 1.0

            #
            # System bath interaction with prescribed rate
            #
            from quantarhei.qm import SystemBathInteraction

            sbi = SystemBathInteraction(sys_operators=[K],
                                        rates=(1.0 / 100.0, ))
            agg.set_SystemBathInteraction(sbi)

            #
            # Corresponding Lindblad form
            #
            from quantarhei.qm import LindbladForm

            LF = LindbladForm(ham, sbi, as_operators=False)

            #
            # Evolution of reduced density matrix
            #
            prop = qr.ReducedDensityMatrixPropagator(time, ham, LF)

            #
            # Evolution by superoperator
            #

            eSO = qr.qm.EvolutionSuperOperator(time, ham, LF)
            eSO.set_dense_dt(5)
            eSO.calculate()

            # compare the two propagations
            pairs = [(1, 3), (3, 2), (3, 3)]
            for p in pairs:

                rho_i1 = qr.ReducedDensityMatrix(dim=ham.dim)
                rho_i1.data[p[0], p[1]] = 1.0

                rho_t1 = prop.propagate(rho_i1)

                exp_rho_t2 = eSO.data[:, :, :, p[0], p[1]]

                #import matplotlib.pyplot as plt

                #plt.plot(rho_t1.TimeAxis.data, numpy.real(rho_t1.data[:,p[0],p[1]]))
                #plt.plot(rho_t1.TimeAxis.data, numpy.real(exp_rho_t2[:,p[0],p[1]]))
                #plt.show()

                #numpy.testing.assert_allclose(RRT.data, rtd)
                numpy.testing.assert_allclose(numpy.real(rho_t1.data[:, :, :]),
                                              numpy.real(exp_rho_t2[:, :, :]),
                                              rtol=1.0e-7,
                                              atol=1.0e-6)