Пример #1
0
    def calculate_one(self, tc):

        tt2 = self.t2axis.data[tc]
        Nr1 = self.t1axis.length
        Nr3 = self.t3axis.length
        #
        # Initialize response storage
        #
        resp_r = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_n = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')

        # FIXME: on which axis we should be looking for it2 ???
        (it2, err) = self.t1axis.locate(tt2)
        self._vprint("t2 = " + str(tt2) + "fs (it2 = " + str(it2) + ")")
        #tc = it2

        #
        # calcute response
        #
        self._vprint("calculating response: ")

        t1 = time.time()

        self._vprint(" - ground state bleach")
        # GSB

        resp_Rgsb = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_Ngsb = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        nr3td.nr3_r3g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_Rgsb)
        nr3td.nr3_r4g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_Ngsb)

        self._vprint(" - stimulated emission")
        # SE

        resp_Rse = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_Nse = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        nr3td.nr3_r2g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_Rse)
        nr3td.nr3_r1g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_Nse)

        self._vprint(" - excited state absorption")
        # ESA

        resp_Resa = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_Nesa = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        nr3td.nr3_r1fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                       self.rmin, resp_Resa)
        nr3td.nr3_r2fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                       self.rmin, resp_Nesa)

        #
        # Transfer
        #
        Utr = self.Uee[:, :,
                       self.tc] - self.Uc0[:, :,
                                           self.tc]  #-Uc1[:,:,tc]-Uc2[:,:,tc]
        self.sys.set_population_propagation_matrix(Utr)

        self._vprint(" - stimulated emission with transfer")
        # SE

        resp_Rsewt = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_Nsewt = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        nr3td.nr3_r2g_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                            self.rwa, self.rmin, resp_Rsewt)
        nr3td.nr3_r1g_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                            self.rwa, self.rmin, resp_Nsewt)

        self._vprint(" - excited state absorption with transfer")
        # ESA

        resp_Resawt = numpy.zeros((Nr1, Nr3),
                                  dtype=numpy.complex128,
                                  order='F')
        resp_Nesawt = numpy.zeros((Nr1, Nr3),
                                  dtype=numpy.complex128,
                                  order='F')
        nr3td.nr3_r1fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                             self.rwa, self.rmin, resp_Resawt)
        nr3td.nr3_r2fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                             self.rwa, self.rmin, resp_Nesawt)

        t2 = time.time()
        self._vprint("... calculated in " + str(t2 - t1) + " sec")

        resp_r = resp_Rgsb + resp_Rse + resp_Resa + resp_Rsewt + resp_Resawt
        resp_n = resp_Ngsb + resp_Nse + resp_Nesa + resp_Nsewt + resp_Nesawt

        #
        # Calculate corresponding 2D spectrum
        #
        onetwod = TwoDResponse()

        # pad is set to 0 by default. if changed in the bootstrap,
        # responses are padded with 0s and the time axis is lengthened
        t13Pad = TimeAxis(self.t1axis.start, self.t1axis.length + self.pad,
                          self.t1axis.step)
        if self.pad > 0:
            self._vprint('padding by - ' + str(self.pad))

            t13Pad.atype = 'complete'
            t13PadFreq = t13Pad.get_FrequencyAxis()
            t13PadFreq.data += self.rwa
            t13PadFreq.start += self.rwa

            onetwod.set_axis_1(t13PadFreq)
            onetwod.set_axis_3(t13PadFreq)

            # Sloping the end of the data down to 0 to there isn't a hard cutoff at the end of the data
            from scipy import signal as sig
            window = 20
            tuc = sig.tukey(window * 2, 1, sym=False)
            for k in range(len(resp_r)):
                resp_r[len(resp_r) - window:, k] *= tuc[window:]
                resp_r[k, len(resp_r) - window:] *= tuc[window:]
                resp_n[len(resp_n) - window:, k] *= tuc[window:]
                resp_n[k, len(resp_n) - window:] *= tuc[window:]

            resp_r = numpy.hstack(
                (resp_r, numpy.zeros((resp_r.shape[0], self.pad))))
            resp_r = numpy.vstack(
                (resp_r, numpy.zeros((self.pad, resp_r.shape[1]))))
            resp_n = numpy.hstack(
                (resp_n, numpy.zeros((resp_n.shape[0], self.pad))))
            resp_n = numpy.vstack(
                (resp_n, numpy.zeros((self.pad, resp_n.shape[1]))))

        else:
            onetwod.set_axis_1(self.oa1)
            onetwod.set_axis_3(self.oa3)

        if self.keep_resp:
            resp = {
                'time': self.t1axis.data,
                'time_pad': t13Pad.data,
                'rTot': resp_r,
                'nTot': resp_n,
                'rGSB': resp_Rgsb,
                'nGSB': resp_Ngsb,
                'rSE': resp_Rse,
                'nSE': resp_Nse,
                'rESA': resp_Resa,
                'nESA': resp_Nesa,
                'rSEWT': resp_Rsewt,
                'nSEWT': resp_Nsewt,
                'rESAWT': resp_Resawt,
                'nESAWT': resp_Nesawt
            }
            self.responses.append(resp)

        if self.write_resp:
            numpy.savez('./' + self.write_resp + '/respT' + str(int(tt2)) +
                        '.npz',
                        time=self.t1axis.data,
                        time_pad=t13Pad.data,
                        rTot=resp_r,
                        nTot=resp_n,
                        rGSB=resp_Rgsb,
                        nGSB=resp_Ngsb,
                        rSE=resp_Rse,
                        nSE=resp_Nse,
                        rESA=resp_Resa,
                        nESA=resp_Nesa,
                        rSEWT=resp_Rsewt,
                        nSEWT=resp_Nsewt,
                        rESAWT=resp_Resawt,
                        nESAWT=resp_Nesawt)

        ftresp = numpy.fft.fft(resp_r, axis=1)
        ftresp = numpy.fft.ifft(ftresp, axis=0)
        reph2D = numpy.fft.fftshift(ftresp)

        ftresp = numpy.fft.ifft(resp_n, axis=1)
        ftresp = numpy.fft.ifft(ftresp, axis=0) * ftresp.shape[1]
        nonr2D = numpy.fft.fftshift(ftresp)

        onetwod.set_resolution("signals")
        onetwod._add_data(reph2D, dtype=signal_REPH)
        onetwod._add_data(nonr2D, dtype=signal_NONR)

        onetwod.set_t2(self.t2axis.data[tc])

        return onetwod
Пример #2
0
    def calculate(self, rwa=0.0, verbose=False):
        """Returns 2D spectrum
        
        Calculates and returns TwoDSpectrumContainer containing 2D spectrum
        based on the parameters specified in this object.
        
        
        """
        self.verbose = verbose
        
        try:
            
            import aceto.nr3td as nr3td 
            from aceto.lab_settings import lab_settings
            from aceto.band_system import band_system            
            self._have_aceto = True
            
        except:
            #
            # FIXME: There should be an optional warning and a fall back onto
            # quantarhei.implementations.aceto module
            #
            raise Exception("Aceto not available")
            
            from ..implementations.aceto import nr3td
            
            self._have_aceto = False
    
    
        if self._have_aceto:
            
            # calculate 2D spectrum using aceto library

            ###############################################################################
            #
            # Create band_system from quantarhei classes
            #
            ###############################################################################
            
            if isinstance(self.system, Aggregate):
            
                pass
            
            else:
                
                raise Exception("Molecule 2D not implememted")
                
            agg = self.system
            
            #
            # hamiltonian and transition dipole moment operators
            #
            H = agg.get_Hamiltonian()
            D = agg.get_TransitionDipoleMoment()
            
            #
            # Construct band_system object
            #
            Nb = 3
            Ns = numpy.zeros(Nb, dtype=numpy.int)
            Ns[0] = 1
            Ns[1] = agg.nmono
            Ns[2] = Ns[1]*(Ns[1]-1)/2
            sys = band_system(Nb, Ns)
            
            
            #
            # Set energies
            #
            en = numpy.zeros(sys.Ne, dtype=numpy.float64)
            #if True:
            with eigenbasis_of(H):
                for i in range(sys.Ne):
                    en[i] = H.data[i,i]
                sys.set_energies(en)
            
                #
                # Set transition dipole moments
                #
                dge_wr = D.data[0:Ns[0],Ns[0]:Ns[0]+Ns[1],:]
                def_wr = D.data[Ns[0]:Ns[0]+Ns[1],
                                (Ns[0]+Ns[1]):(Ns[0]+Ns[1]+Ns[2]),:]
            
                dge = numpy.zeros((3,Ns[0],Ns[1]), dtype=numpy.float64)
                deff = numpy.zeros((3,Ns[1],Ns[2]), dtype=numpy.float64)
                
                for i in range(3):
                    dge[i,:,:] = dge_wr[:,:,i]
                    deff[i,:,:] = def_wr[:,:,i]
                sys.set_dipoles(0,1,dge)
                sys.set_dipoles(1,2,deff)
            
            
            #
            # Relaxation rates
            #
            KK = agg.get_RedfieldRateMatrix()
            
            # relaxation rate in single exciton band
            Kr = KK.data[Ns[0]:Ns[0]+Ns[1],Ns[0]:Ns[0]+Ns[1]]*10.0
            #print(1.0/Kr)
            
            sys.init_dephasing_rates()
            sys.set_relaxation_rates(1,Kr)
            
            
            #
            # Lineshape functions
            #
            sbi = agg.get_SystemBathInteraction()
            cfm = sbi.CC
            cfm.create_double_integral()
            
            
            #
            # Transformation matrices
            #
            SS = H.diagonalize()
            SS1 = SS[1:Ns[1]+1,1:Ns[1]+1]
            SS2 = SS[Ns[1]+1:,Ns[1]+1:]
            H.undiagonalize()
            
            sys.set_gofts(cfm._gofts)    # line shape functions
            sys.set_sitep(cfm.cpointer)  # pointer to sites
            sys.set_transcoef(1,SS1)  # matrix of transformation coefficients  
            sys.set_transcoef(2,SS2)  # matrix of transformation coefficients  

            #
            # Finding population evolution matrix
            #
            prop = PopulationPropagator(self.t1axis, Kr)
            Uee, Uc0 = prop.get_PropagationMatrix(self.t2axis,
                                                  corrections=True)


            #
            # define lab settings
            #
            lab = lab_settings(lab_settings.FOUR_WAVE_MIXING)
            X = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64)
            lab.set_laser_polarizations(X, X, X, X)
            
            #
            # Other parameters
            #
            
            #dt = self.t1axis.step
            t1s = self.t1axis.data 
            t3s = self.t3axis.data 

            Nr1 = self.t1axis.length
            Nr3 = self.t3axis.length

            atype = self.t1axis.atype
            self.t1axis.atype = 'complete'
            oa1 = self.t1axis.get_FrequencyAxis() 
            oa1.data += rwa
            oa1.start += rwa
            self.t1axis.atype = atype
            
            atype = self.t3axis.atype
            self.t3axis.atype = 'complete'
            oa3 = self.t3axis.get_FrequencyAxis() 
            oa3.data += rwa
            oa3.start += rwa
            self.t3axis.atype = atype
            
            tc = 0
            twods = []
            
            teetoos = self.t2axis.data
            for tt2 in teetoos:

                #
                # Initialize response storage
                #
                resp_r = numpy.zeros((Nr1, Nr3), 
                                     dtype=numpy.complex128, order='F')
                resp_n = numpy.zeros((Nr1, Nr3), 
                                     dtype=numpy.complex128, order='F')

                # FIXME: which on axis we should be looking for it2 ??? 
                (it2, err) = self.t1axis.locate(tt2) 
                self._vprint("t2 = "+str(tt2)+"fs (it2 = "+str(it2)+")")
            
                #
                # calcute response
                #
                self._vprint("calculating response: ")
                rmin = 0.0001
                t1 = time.time()
                
                self._vprint(" - ground state bleach")
                # GSB
                nr3td.nr3_r3g(lab, sys, it2, t1s, t3s, rwa, rmin, resp_r) 
                nr3td.nr3_r4g(lab, sys, it2, t1s, t3s, rwa, rmin, resp_n)
            
                self._vprint(" - stimulated emission")
                # SE
                nr3td.nr3_r1g(lab, sys, it2, t1s, t3s, rwa, rmin, resp_n)
                nr3td.nr3_r2g(lab, sys, it2, t1s, t3s, rwa, rmin, resp_r)
                
                self._vprint(" - excited state absorption")
                # ESA
                nr3td.nr3_r1fs(lab, sys, it2, t1s, t3s, rwa, rmin, resp_r)
                nr3td.nr3_r2fs(lab, sys, it2, t1s, t3s, rwa, rmin, resp_n)
                
                # Transfer
                sys.set_population_propagation_matrix(Uee[:,:,tc]-Uc0[:,:,tc])
                
                self._vprint(" - stimulated emission with transfer")    
                # SE
                nr3td.nr3_r1g_trans(lab, sys, it2, t1s, t3s, rwa, rmin, resp_n)
                nr3td.nr3_r2g_trans(lab, sys, it2, t1s, t3s, rwa, rmin, resp_r)
            
                self._vprint(" - excited state absorption with transfer") 
                # ESA
                nr3td.nr3_r1fs_trans(lab, sys, it2, t1s, t3s, rwa, rmin, resp_r)
                nr3td.nr3_r2fs_trans(lab, sys, it2, t1s, t3s, rwa, rmin, resp_n)
                
                
                t2 = time.time()
                self._vprint("... calculated in "+str(t2-t1)+" sec")
    
    
                #
                # Calculate corresponding 2D spectrum
                #
                
                ftresp = numpy.fft.fft(resp_r,axis=1)
                ftresp = numpy.fft.ifft(ftresp,axis=0)
                reph2D = numpy.fft.fftshift(ftresp)
                
                ftresp = numpy.fft.ifft(resp_n,axis=1)
                ftresp = numpy.fft.ifft(ftresp,axis=0)*ftresp.shape[1]
                nonr2D = numpy.fft.fftshift(ftresp)
        
        
                onetwod = TwoDSpectrumContainer()
                onetwod.set_axis_1(oa1)
                onetwod.set_axis_3(oa3)
                onetwod.set_data(reph2D, dtype="Reph")
                onetwod.set_data(nonr2D, dtype="Nonr")
                
                twods.append(onetwod)
                tc += 1    
            
            return twods
        
        else:
            
            # fall bakc on quantarhei's own implementation
        
            ret = TwoDSpectrumContainer()
            
        
        return ret
    
    
    
        
        
Пример #3
0
    def calculate_one(self, tc):

        tt2 = self.t2axis.data[tc]        
        Nr1 = self.t1axis.length
        Nr3 = self.t3axis.length        
        #
        # Initialize response storage
        #
        resp_r = numpy.zeros((Nr1, Nr3), 
                             dtype=numpy.complex128, order='F')
        resp_n = numpy.zeros((Nr1, Nr3), 
                             dtype=numpy.complex128, order='F')

        # FIXME: on which axis we should be looking for it2 ??? 
        (it2, err) = self.t1axis.locate(tt2) 
        self._vprint("t2 = "+str(tt2)+"fs (it2 = "+str(it2)+")")
        #tc = it2
    
        #
        # calcute response
        #
        self._vprint("calculating response: ")

        t1 = time.time()
        
        self._vprint(" - ground state bleach")
        # GSB
        nr3td.nr3_r3g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_r) 
        nr3td.nr3_r4g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_n)
    
        self._vprint(" - stimulated emission")
        # SE
        nr3td.nr3_r1g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_n)
        nr3td.nr3_r2g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_r)
        
        self._vprint(" - excited state absorption")
        # ESA
        nr3td.nr3_r1fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_r)
        nr3td.nr3_r2fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_n)
        
        # Transfer
        
        Utr = self.Uee[:,:,self.tc]-self.Uc0[:,:,self.tc] #-Uc1[:,:,tc]-Uc2[:,:,tc]
        self.sys.set_population_propagation_matrix(Utr) 
        
        self._vprint(" - stimulated emission with transfer")    
        # SE
        nr3td.nr3_r1g_trans(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_n)
        nr3td.nr3_r2g_trans(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_r)
        
#                # This contributes only when No > 0
#                nr3td.nr3_r2g_trN(lab, sys, No, it2, t1s, t3s, rwa, rmin, resp_r)
#                
    
        self._vprint(" - excited state absorption with transfer") 
        # ESA
        nr3td.nr3_r1fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_r)
        nr3td.nr3_r2fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa, self.rmin, resp_n)
        
        
        t2 = time.time()
        self._vprint("... calculated in "+str(t2-t1)+" sec")


        #
        # Calculate corresponding 2D spectrum
        #
        
        ftresp = numpy.fft.fft(resp_r,axis=1)
        ftresp = numpy.fft.ifft(ftresp,axis=0)
        reph2D = numpy.fft.fftshift(ftresp)
        
        ftresp = numpy.fft.ifft(resp_n,axis=1)
        ftresp = numpy.fft.ifft(ftresp,axis=0)*ftresp.shape[1]
        nonr2D = numpy.fft.fftshift(ftresp)


        onetwod = TwoDResponse()
        onetwod.set_axis_1(self.oa1)
        onetwod.set_axis_3(self.oa3)
        onetwod.set_data(reph2D, dtype="Reph")
        onetwod.set_data(nonr2D, dtype="Nonr")
        
        onetwod.set_t2(self.t2axis.data[tc])
        
        
        return onetwod
Пример #4
0
    def calculate_one(self, tc):

        tt2 = self.t2axis.data[tc]
        Nr1 = self.t1axis.length
        Nr3 = self.t3axis.length
        #
        # Initialize response storage
        #
        resp_r = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')
        resp_n = numpy.zeros((Nr1, Nr3), dtype=numpy.complex128, order='F')

        # FIXME: on which axis we should be looking for it2 ???
        (it2, err) = self.t1axis.locate(tt2)
        self._vprint("t2 = " + str(tt2) + "fs (it2 = " + str(it2) + ")")
        #tc = it2

        #
        # calcute response
        #
        self._vprint("calculating response: ")

        t1 = time.time()

        self._vprint(" - ground state bleach")
        # GSB
        nr3td.nr3_r3g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_r)
        nr3td.nr3_r4g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_n)

        self._vprint(" - stimulated emission")
        # SE
        nr3td.nr3_r1g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_n)
        nr3td.nr3_r2g(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                      self.rmin, resp_r)

        self._vprint(" - excited state absorption")
        # ESA
        nr3td.nr3_r1fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                       self.rmin, resp_r)
        nr3td.nr3_r2fs(self.lab, self.sys, it2, self.t1s, self.t3s, self.rwa,
                       self.rmin, resp_n)

        #
        # Transfer
        #
        Utr = self.Uee[:, :,
                       self.tc] - self.Uc0[:, :,
                                           self.tc]  #-Uc1[:,:,tc]-Uc2[:,:,tc]
        self.sys.set_population_propagation_matrix(Utr)

        self._vprint(" - stimulated emission with transfer")
        # SE
        nr3td.nr3_r1g_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                            self.rwa, self.rmin, resp_n)
        nr3td.nr3_r2g_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                            self.rwa, self.rmin, resp_r)

        #                # This contributes only when No > 0
        #                nr3td.nr3_r2g_trN(lab, sys, No, it2, t1s, t3s, rwa, rmin, resp_r)
        #

        self._vprint(" - excited state absorption with transfer")
        # ESA
        nr3td.nr3_r1fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                             self.rwa, self.rmin, resp_r)
        nr3td.nr3_r2fs_trans(self.lab, self.sys, it2, self.t1s, self.t3s,
                             self.rwa, self.rmin, resp_n)

        t2 = time.time()
        self._vprint("... calculated in " + str(t2 - t1) + " sec")

        #
        # Calculate corresponding 2D spectrum
        #

        ftresp = numpy.fft.fft(resp_r, axis=1)
        ftresp = numpy.fft.ifft(ftresp, axis=0)
        reph2D = numpy.fft.fftshift(ftresp)

        ftresp = numpy.fft.ifft(resp_n, axis=1)
        ftresp = numpy.fft.ifft(ftresp, axis=0) * ftresp.shape[1]
        nonr2D = numpy.fft.fftshift(ftresp)

        onetwod = TwoDResponse()
        onetwod.set_axis_1(self.oa1)
        onetwod.set_axis_3(self.oa3)
        onetwod.set_resolution("signals")
        onetwod._add_data(reph2D, dtype=signal_REPH)
        onetwod._add_data(nonr2D, dtype=signal_NONR)
        #onetwod.set_data(reph2D, dtype="Reph")
        #onetwod.set_data(nonr2D, dtype="Nonr")

        onetwod.set_t2(self.t2axis.data[tc])

        return onetwod
Пример #5
0
# -*- coding: utf-8 -*-
Пример #6
0
# -*- coding: utf-8 -*-