def twod_setup(self, ax2, ax13, pad = 0, name = 'place_holder'): ax13 = ax13 self.t2_axis = ax2 #self.centre = qr.convert(instance.rwa, 'int', '1/cm') self.centre = 12500 init = AggregateInstance() init.get_molecules_circular(nM = 2, verbose = False) init.assign_spec_dens() init.assign_energies() init.build_agg(mult = 2) a_0 = np.array([1.0, 0.0, 0.0], dtype=np.float64) lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) lab.set_laser_polarizations(a_0,a_0,a_0,a_0) init.twod_setup(ax2 = self.t2_axis, ax13 = ax13) init.twod_calculate(lab = lab, pad = pad, name = name) self.spectra_data.update({name: []}) for i, time in enumerate(self.t2_axis.data): spec = init.spec_cont_dict[name].get_spectrum(time) self.spectra_data[name].append(spec) self.spectra_data[name][i].add_data(-spec.data)
if _test_: energies1 = [energy] * num_mol energies2 = [energy - (100 * num_mol / 2)\ + i * 100 for i in range(num_mol)] myFuncs.test_dynamics(agg_list=for_agg, energies=energies1) myFuncs.test_dynamics(agg_list=for_agg, energies=energies2) ####################################################################### # Setup of the calculation ####################################################################### # Arrays for the direction on the laser plane a_0 = np.array([1.0, 0.0, 0.0], dtype=np.float64) a_90 = np.array([0.0, 1.0, 0.0], dtype=np.float64) # Aceto lab setup (for twod calculator) lab_para = lab_settings(lab_settings.FOUR_WAVE_MIXING) lab_para.set_laser_polarizations(a_0, a_0, a_0, a_0) lab_perp = lab_settings(lab_settings.FOUR_WAVE_MIXING) lab_perp.set_laser_polarizations(a_0, a_0, a_90, a_90) labs = [lab_para, lab_perp] las_pol = ['para', 'perp'] def calcTwoD(n_loopsum): # ''' Caculates a 2d spectrum for both perpendicular and parael lasers using aceto bands and accurate lineshapes''' resp_container = [] #energies0 = [energy - (100 * num_mol / 2) + i * 100 for i in range(num_mol)] #energies0 = [energy] * num_mol
# with energy_units("1/cm"): mol1 = Molecule(elenergies=[0.0, 12300.0]) mol2 = Molecule(elenergies=[0.0, 12000.0]) mol1.position = [0.0, 0.0, 0.0] # dimer 1 mol2.position = [0.0, 6.0, 0.0] ## dimer 2 #mol2.position = [0.0, 0.0, 6.0] mol1.set_dipole(0, 1, [4.0, 2.0, 0.0]) mol2.set_dipole(0, 1, [1.0, 2.0, 0.0]) # # Setting up laboratory # lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) a_0 = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64) lab.set_laser_polarizations(a_0, a_0, a_0, a_0) # # System-bath interaction # tsbi = TimeAxis(0.0, 3 * Nr, 2.0) params = dict(ftype="OverdampedBrownian", T=300, reorg=70.0, cortime=100.0) with energy_units('1/cm'): cf = CorrelationFunction(tsbi, params) params2 = dict(ftype="UnderdampedBrownian", T=300, reorg=10.0, freq=150.0,
def bootstrap(self, rwa=0.0, pad=0, lab=None, verbose=False, write_resp=False, keep_resp=False): """Sets up the environment for 2D calculation write_resp takes a string, creates a directory with the name of the string and saves the respoonses and time axis as a npz file keep_resp saves the responses as a list of dictionaries. The list goes through the time points in t2. """ self.verbose = verbose self.pad = pad self.write_resp = write_resp self.keep_resp = keep_resp if self.write_resp: try: os.mkdir(write_resp) except OSError: print("Creation of the directory failed, it either already " "exists or you didn't give a string") if True: # 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 agg.diagonalize() # # 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 self.sys = band_system(Nb, Ns) # # Set energies # en = numpy.zeros(self.sys.Ne, dtype=numpy.float64) #if True: with eigenbasis_of(H): for i in range(self.sys.Ne): en[i] = H.data[i, i] self.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] self.sys.set_dipoles(0, 1, dge) self.sys.set_dipoles(1, 2, deff) # # Relaxation rates # if not self._has_rate_matrix: KK = agg.get_RedfieldRateMatrix() else: KK = self._rate_matrix # 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/KK.data) self.sys.init_dephasing_rates() self.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() self.sys.set_gofts(cfm._gofts) # line shape functions self.sys.set_sitep(cfm.cpointer) # pointer to sites self.sys.set_transcoef( 1, SS1) # matrix of transformation coefficients self.sys.set_transcoef( 2, SS2) # matrix of transformation coefficients # # Finding population evolution matrix # # KIERAN ADDED: fine step for the axis for calculating dynamics t1Len = int(( (self.t1axis.length + self.pad - 1) * self.t1axis.step) + 1) t2propAxis = TimeAxis(0.0, t1Len, 1) #prop = PopulationPropagator(self.t1axis, Kr) prop = PopulationPropagator(t2propAxis, Kr) # Uee, Uc0 = prop.get_PropagationMatrix(self.t2axis, # corrections=True) self.Uee, cor = prop.get_PropagationMatrix(self.t2axis, corrections=3) # FIXME: Order of transfer is set by hand here - needs to be moved # to some reasonable place #Ucor = Uee self.Uc0 = cor[0] #for ko in range(No+1): # print("Subtracting ", ko) # Ucor[:,:,tc] -= cor[ko] # # define lab settings # if lab is None: self.lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) X = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64) self.lab.set_laser_polarizations(X, X, X, X) else: self.lab = lab # # Other parameters # #dt = self.t1axis.step self.rmin = 0.0001 self.t1s = self.t1axis.data self.t3s = self.t3axis.data self.rwa = rwa atype = self.t1axis.atype self.t1axis.atype = 'complete' self.oa1 = self.t1axis.get_FrequencyAxis() self.oa1.data += self.rwa self.oa1.start += self.rwa self.t1axis.atype = atype atype = self.t3axis.atype self.t3axis.atype = 'complete' self.oa3 = self.t3axis.get_FrequencyAxis() self.oa3.data += self.rwa self.oa3.start += self.rwa self.t3axis.atype = atype else: raise Exception("So far, no 2D outside aceto") self.tc = 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
def bootstrap(self,rwa=0.0, lab=None, verbose=False): """Sets up the environment for 2D calculation """ self.verbose = verbose if True: # 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 self.sys = band_system(Nb, Ns) # # Set energies # en = numpy.zeros(self.sys.Ne, dtype=numpy.float64) #if True: with eigenbasis_of(H): for i in range(self.sys.Ne): en[i] = H.data[i,i] self.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] self.sys.set_dipoles(0,1,dge) self.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) self.sys.init_dephasing_rates() self.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() self.sys.set_gofts(cfm._gofts) # line shape functions self.sys.set_sitep(cfm.cpointer) # pointer to sites self.sys.set_transcoef(1,SS1) # matrix of transformation coefficients self.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) self.Uee, cor = prop.get_PropagationMatrix(self.t2axis, corrections=3) # FIXME: Order of transfer is set by hand here - needs to be moved # to some reasonable place #Ucor = Uee self.Uc0 = cor[0] #for ko in range(No+1): # print("Subtracting ", ko) # Ucor[:,:,tc] -= cor[ko] # # define lab settings # if lab is None: self.lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) X = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64) self.lab.set_laser_polarizations(X,X,X,X) else: self.lab = lab # # Other parameters # #dt = self.t1axis.step self.rmin = 0.0001 self.t1s = self.t1axis.data self.t3s = self.t3axis.data self.rwa = rwa atype = self.t1axis.atype self.t1axis.atype = 'complete' self.oa1 = self.t1axis.get_FrequencyAxis() self.oa1.data += self.rwa self.oa1.start += self.rwa self.t1axis.atype = atype atype = self.t3axis.atype self.t3axis.atype = 'complete' self.oa3 = self.t3axis.get_FrequencyAxis() self.oa3.data += self.rwa self.oa3.start += self.rwa self.t3axis.atype = atype else: raise Exception("So far, no 2D outside aceto") self.tc = 0
# with energy_units("1/cm"): mol1 = Molecule(elenergies=[0.0, 12300.0]) mol2 = Molecule(elenergies=[0.0, 12000.0]) mol1.position = [0.0, 0.0, 0.0] # dimer 1 mol2.position = [0.0, 6.0, 0.0] ## dimer 2 #mol2.position = [0.0, 0.0, 6.0] mol1.set_dipole(0,1,[4.0, 2.0, 0.0]) mol2.set_dipole(0,1,[1.0, 2.0, 0.0]) # # Setting up laboratory # lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) a_0 = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64) lab.set_laser_polarizations(a_0,a_0,a_0,a_0) # # System-bath interaction # tsbi = TimeAxis(0.0, 3*Nr, 2.0) params = dict(ftype="OverdampedBrownian", T=300, reorg=70.0, cortime=100.0) with energy_units('1/cm'): cf = CorrelationFunction(tsbi, params) params2 = dict(ftype="UnderdampedBrownian", T=300, reorg=10.0, freq=150.0, gamma=1.0/10000.0) with energy_units('1/cm'): cf2 = CorrelationFunction(tsbi, params2)
# -*- coding: utf-8 -*-
def bootstrap(self, rwa=0.0, lab=None, verbose=False): """Sets up the environment for 2D calculation """ self.verbose = verbose if True: # 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 self.sys = band_system(Nb, Ns) # # Set energies # en = numpy.zeros(self.sys.Ne, dtype=numpy.float64) #if True: with eigenbasis_of(H): for i in range(self.sys.Ne): en[i] = H.data[i, i] self.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] self.sys.set_dipoles(0, 1, dge) self.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) self.sys.init_dephasing_rates() self.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() self.sys.set_gofts(cfm._gofts) # line shape functions self.sys.set_sitep(cfm.cpointer) # pointer to sites self.sys.set_transcoef( 1, SS1) # matrix of transformation coefficients self.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) self.Uee, cor = prop.get_PropagationMatrix(self.t2axis, corrections=3) # FIXME: Order of transfer is set by hand here - needs to be moved # to some reasonable place #Ucor = Uee self.Uc0 = cor[0] #for ko in range(No+1): # print("Subtracting ", ko) # Ucor[:,:,tc] -= cor[ko] # # define lab settings # if lab is None: self.lab = lab_settings(lab_settings.FOUR_WAVE_MIXING) X = numpy.array([1.0, 0.0, 0.0], dtype=numpy.float64) self.lab.set_laser_polarizations(X, X, X, X) else: self.lab = lab # # Other parameters # #dt = self.t1axis.step self.rmin = 0.0001 self.t1s = self.t1axis.data self.t3s = self.t3axis.data self.rwa = rwa atype = self.t1axis.atype self.t1axis.atype = 'complete' self.oa1 = self.t1axis.get_FrequencyAxis() self.oa1.data += self.rwa self.oa1.start += self.rwa self.t1axis.atype = atype atype = self.t3axis.atype self.t3axis.atype = 'complete' self.oa3 = self.t3axis.get_FrequencyAxis() self.oa3.data += self.rwa self.oa3.start += self.rwa self.t3axis.atype = atype else: raise Exception("So far, no 2D outside aceto") self.tc = 0