def build_aggregate_2(settings): """Example function for building aggregate no. 2""" mol_l = [] mod_l = [] with qr.energy_units("1/cm"): for ind in range(settings["Nmol"]): mol = Molecule([0.0, settings["E1"]]) # mol1.set_dipole(0,1,[1.0, 0.0, 0.0]) # mol1.set_transition_width((0,1), width) mod = Mode(settings["omega"]) mol.add_Mode(mod) mod.set_nmax(0, settings["Nvib_0"]) mod.set_nmax(1, settings["Nvib_1"]) mod.set_HR(1, settings["HR"]) mol_l.append(mol) mod_l.append(mod) agg = Aggregate(molecules=mol_l) for ind in range(settings["Nmol"] - 1): agg.set_resonance_coupling(ind, ind + 1, settings["JJ"]) # agg.set_resonance_coupling(settings["Nmol"]-1, 0, settings["JJ"]) agg.build(mult=1) return agg
def homochain_aggregate(self): molecules = [] time = world.time #TimeAxis(0.0, 10000, 1.0) k = 0 couplings = [] temp = 0.0 for row in self.hashes: tenergy = float(row['tr_energy']) coupling = float(row['neighbor_coupling']) ftype_abbv = row['corfce'] if ftype_abbv == "OB": ftype = "OverdampedBrownian" reorg = float(row['reorg']) e_units = row['e_units'] ctime = float(row['ctime']) tempp = float(row['temperature']) matsu = int(row['matsubara']) if temp == 0.0: temp = tempp else: if temp != tempp: raise Exception( "Temperatures must be the same for all molecules") params = dict(ftype=ftype, cortime=ctime, reorg=reorg, T=temp, matsubara=matsu) with energy_units(e_units): m = Molecule(name="", elenergies=[0.0, tenergy]) cf = CorrelationFunction(time, params) m.set_transition_environment((0, 1), cf) molecules.append(m) couplings.append(coupling) k += 1 agg = Aggregate(name="", molecules=molecules) with energy_units("1/cm"): for i in range(k): if i + 1 < k: agg.set_resonance_coupling(i, i + 1, couplings[i]) else: agg.set_resonance_coupling(i, 0, couplings[i]) agg.build() world.temperature = temp world.aggregate = agg world.time = time world.N = k + 1
def setUp(self,verbose=False): self.verbose = verbose # # PURE ELECTRONIC AGGREGATE # m1 = Molecule([0.0, 1.0]) m2 = Molecule([0.0, 1.0]) agg = Aggregate(molecules=[m1, m2]) agg.set_resonance_coupling(0,1, 0.1) agg.build() self.ham = agg.get_Hamiltonian() KK12 = ProjectionOperator(1, 2, dim=self.ham.dim) KK21 = ProjectionOperator(2, 1, dim=self.ham.dim) self.rates = (1.0/100.0, 1.0/200.0) self.sbi = SystemBathInteraction([KK12,KK21], rates=self.rates) self.sbi.set_system(agg) # # VIBRONIC AGGREGATE # vm1 = Molecule([0.0, 1.0]) vm2 = Molecule([0.0, 1.0]) mod1 = Mode(0.01) mod2 = Mode(0.01) vm1.add_Mode(mod1) vm2.add_Mode(mod2) mod1.set_nmax(0, 3) mod1.set_nmax(1, 3) mod2.set_nmax(0, 3) mod2.set_nmax(1, 3) vagg = Aggregate(molecules=[vm1, vm2]) vagg.set_resonance_coupling(0, 1, 0.1) vagg.build() self.vham = vagg.get_Hamiltonian() self.vsbi = SystemBathInteraction([KK12, KK21], rates=self.rates) self.vsbi.set_system(vagg)
def setUp(self, verbose=False): self.verbose = verbose # # PURE ELECTRONIC AGGREGATE # m1 = Molecule([0.0, 1.0]) m2 = Molecule([0.0, 1.0]) agg = Aggregate(molecules=[m1, m2]) agg.set_resonance_coupling(0, 1, 0.1) agg.build() self.ham = agg.get_Hamiltonian() KK12 = ProjectionOperator(1, 2, dim=self.ham.dim) KK21 = ProjectionOperator(2, 1, dim=self.ham.dim) self.rates = (1.0 / 100.0, 1.0 / 200.0) self.sbi = SystemBathInteraction([KK12, KK21], rates=self.rates) self.sbi.set_system(agg) # # VIBRONIC AGGREGATE # vm1 = Molecule([0.0, 1.0]) vm2 = Molecule([0.0, 1.0]) mod1 = Mode(0.01) mod2 = Mode(0.01) vm1.add_Mode(mod1) vm2.add_Mode(mod2) mod1.set_nmax(0, 3) mod1.set_nmax(1, 3) mod2.set_nmax(0, 3) mod2.set_nmax(1, 3) vagg = Aggregate(molecules=[vm1, vm2]) vagg.set_resonance_coupling(0, 1, 0.1) vagg.build() self.vham = vagg.get_Hamiltonian() self.vsbi = SystemBathInteraction([KK12, KK21], rates=self.rates) self.vsbi.set_system(vagg)
def homochain_aggregate(self): molecules = [] time = world.time #TimeAxis(0.0, 10000, 1.0) k = 0 couplings = [] temp = 0.0 for row in self.hashes: tenergy = float(row['tr_energy']) coupling = float(row['neighbor_coupling']) ftype_abbv = row['corfce'] if ftype_abbv == "OB": ftype = "OverdampedBrownian" reorg = float(row['reorg']) e_units = row['e_units'] ctime = float(row['ctime']) tempp = float(row['temperature']) matsu = int(row['matsubara']) if temp == 0.0: temp = tempp else: if temp != tempp: raise Exception("Temperatures must be the same for all molecules") params = dict(ftype=ftype, cortime=ctime, reorg=reorg, T=temp, matsubara=matsu) with energy_units(e_units): m = Molecule([0.0, tenergy]) cf = CorrelationFunction(time, params) m.set_transition_environment((0,1), cf) molecules.append(m) couplings.append(coupling) k += 1 agg = Aggregate(molecules=molecules) with energy_units("1/cm"): for i in range(k): if i+1 < k: agg.set_resonance_coupling(i,i+1,couplings[i]) else: agg.set_resonance_coupling(i,0,couplings[i]) agg.build() world.temperature = temp world.aggregate = agg world.time = time world.N = k+1
def build_testing_aggregate(): """Testing aggregate for unit tests.""" # Number of molecules Nmol = 2 # energy of molecule one E1 = 12500.0 # energy gap to molecule two Edelta = 100.0 # coupling between the two molecules JJ = 30.0 # frequency of the vibrational mode omega = 110.0 # Huan-Rhys factor HR = 0.01 # transition width width = 80 # max nvib states Nvib_0 = 3 Nvib_1 = 3 mol_l = [] mod_l = [] with qr.energy_units("1/cm"): for ind in range(Nmol): mol = Molecule([0.0, E1]) mol.set_dipole(0, 1, [1.0, 0.0, 0.0]) mol.set_transition_width((0, 1), width) mod = Mode(omega) mol.add_Mode(mod) mod.set_nmax(0, Nvib_0) mod.set_nmax(1, Nvib_1) mod.set_HR(1, HR) mol_l.append(mol) mod_l.append(mod) agg = Aggregate(molecules=mol_l) for ind in range(Nmol - 1): agg.set_resonance_coupling(ind, ind + 1, JJ) agg.set_resonance_coupling(Nmol - 1, 0, JJ) agg.build(mult=1) return agg
def hamiltonian_is_created(self): # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule([0.0, en], "mol1") m2 = Molecule([0.0, en], "mol2") agg = Aggregate(name="Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) with energy_units(world.r_units): agg.set_resonance_coupling(0, 1, world.r_coupl) agg.build() world.HH = agg.get_Hamiltonian()
def hamiltonian_is_created(self): # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule([0.0, en], "mol1") m2 = Molecule([0.0, en], "mol2") agg = Aggregate(name="Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) with energy_units(world.r_units): agg.set_resonance_coupling(0,1,world.r_coupl) agg.build() world.HH = agg.get_Hamiltonian()
cf = CorrelationFunction(tsbi, params) mol1.set_transition_environment((0, 1), cf) mol2.set_transition_environment((0, 1), cf) mol3.set_transition_environment((0, 1), cf) mol4.set_transition_environment((0, 1), cf) # # Creating aggregate # agg = Aggregate(molecules=molecules) #agg = Aggregate("Dimer", molecules=[mol1, mol2, mol3]) if True: with energy_units("1/cm"): agg.set_resonance_coupling(0, 1, 60.0) agg.set_resonance_coupling(1, 2, 60.0) agg.set_resonance_coupling(0, 2, 30.0) agg.set_resonance_coupling(1, 3, 30.0) pass #agg.set_coupling_by_dipole_dipole() agg.build(mult=2) with energy_units("1/cm"): rwa_cm = agg.get_RWA_suggestion() rwa = agg.get_RWA_suggestion() # # Calculate 2D spectra
# -*- coding: utf-8 -*- _show_plots_ = False from quantarhei import Molecule, Aggregate #from quantarhei import energy_units en = [0.0, 1.0] m1 = Molecule(name="Mol1", elenergies=en) m2 = Molecule(name="Mol2", elenergies=en) ag = Aggregate(name="Homodimer") ag.add_Molecule(m1) ag.add_Molecule(m2) ag.set_resonance_coupling(0, 1, 0.1) ag.build(mult=1) H = ag.get_Hamiltonian() #with energy_units("1/cm"): # print(H)
plt.axis([0.0, 100.0, 0.0, 1.1]) plt.show() # # Molecular dimer without vibrations # from quantarhei import Aggregate mol1 = Molecule("Mol 1", [0.0, 1.0]) mol2 = Molecule("Mol 2", [0.0, 1.0]) agg = Aggregate("Dimer") agg.add_Molecule(mol1) agg.add_Molecule(mol2) agg.set_resonance_coupling(0, 1, 0.01) agg.build() H = agg.get_Hamiltonian() print(H) psi = StateVector(3) psi.data[2] = 1.0 dimer_propagator = StateVectorPropagator(time, H) psi_t = dimer_propagator.propagate(psi) psi_t.plot(ptype="square", show=False) #dat = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.01], [0.0, 0.01, 1.1]]
plt.show() # # Molecular dimer without vibrations # from quantarhei import Aggregate mol1 = Molecule(name="Mol 1", elenergies=[0.0, 1.0]) mol2 = Molecule(name="Mol 2", elenergies=[0.0, 1.0]) agg = Aggregate(name="Dimer") agg.add_Molecule(mol1) agg.add_Molecule(mol2) agg.set_resonance_coupling(0,1,0.01) agg.build() H = agg.get_Hamiltonian() print(H) psi = StateVector(3) psi.data[2] = 1.0 dimer_propagator = StateVectorPropagator(time, H) psi_t = dimer_propagator.propagate(psi) psi_t.plot(ptype="square", show=False) #dat = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.01], [0.0, 0.01, 1.1]]
m1.set_dipole(0,1,[1.0, 0.0, 0.0]) time = TimeAxis(0.0, 1000, 1.0) bath_params = dict(ftype="OverdampedBrownian", T=300, cortime=100, reorg=30.0) with energy_units("1/cm"): cf = CorrelationFunction(time, bath_params) m1.set_transition_environment((0,1),cf) m2.set_transition_environment((0,1),cf) m3.set_transition_environment((0,1),cf) ag = Aggregate("Homodimer") ag.add_Molecule(m1) ag.add_Molecule(m2) ag.add_Molecule(m3) ag.set_resonance_coupling(0,1,0.1) mult = 2 ag.build(mult=mult,sbi_for_higher_ex=False) # # Look at its various components # H = ag.get_Hamiltonian() print("Shape of the operators") print(H.data.shape) with energy_units("1/cm"): print(H)
def redfield_relaxation(self): print("Redfield rate calculation") # # Correlation function # params = {"ftype": world.ctype, "reorg": world.reorg, "cortime": world.ctime, "T": world.temp, "matsubara":world.mats} # FIXME: also time_units, temperature_units with energy_units(world.e_units): cf = CorrelationFunction(world.ta,params) # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule([0.0, en],"mol1") m2 = Molecule([0.0, en], "mol2") # m3 = Molecule("mol2", [0.0, en]) m1.set_egcf((0,1), cf) m2.set_egcf((0,1), cf) # m3.set_egcf((0,1), cf) agg = Aggregate(name="Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) # agg.add_Molecule(m3) # with energy_units("1/cm"): # Hm = m1.get_Hamiltonian() # print(Hm) # print(m.convert_energy_2_current_u(Hm._data)) with energy_units(world.r_units): agg.set_resonance_coupling(0,1,world.r_coupl) # agg.set_resonance_coupling(1,2,world.r_coupl) agg.build() H = agg.get_Hamiltonian() # with energy_units("1/cm"): # print(H) # print(m.convert_energy_2_current_u(H._data)) sbi = agg.get_SystemBathInteraction() RRM = RedfieldRateMatrix(H, sbi) world.K12 = numpy.real(RRM.data[1,2]) dim = H.dim rates_M = numpy.zeros(dim*dim) k = 0 for i in range(dim): for j in range(dim): rates_M[k] = RRM.data[i,j] k += 1 world.rates_M = rates_M
def redfield_relaxation(self): print("Redfield rate calculation") # # Correlation function # params = { "ftype": world.ctype, "reorg": world.reorg, "cortime": world.ctime, "T": world.temp, "matsubara": world.mats } # FIXME: also time_units, temperature_units with energy_units(world.e_units): cf = CorrelationFunction(world.ta, params) # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule([0.0, en], "mol1") m2 = Molecule([0.0, en], "mol2") # m3 = Molecule("mol2", [0.0, en]) m1.set_egcf((0, 1), cf) m2.set_egcf((0, 1), cf) # m3.set_egcf((0,1), cf) agg = Aggregate(name="Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) # agg.add_Molecule(m3) # with energy_units("1/cm"): # Hm = m1.get_Hamiltonian() # print(Hm) # print(m.convert_energy_2_current_u(Hm._data)) with energy_units(world.r_units): agg.set_resonance_coupling(0, 1, world.r_coupl) # agg.set_resonance_coupling(1,2,world.r_coupl) agg.build() H = agg.get_Hamiltonian() # with energy_units("1/cm"): # print(H) # print(m.convert_energy_2_current_u(H._data)) sbi = agg.get_SystemBathInteraction() RRM = RedfieldRateMatrix(H, sbi) world.K12 = numpy.real(RRM.data[1, 2]) dim = H.dim rates_M = numpy.zeros(dim * dim) k = 0 for i in range(dim): for j in range(dim): rates_M[k] = RRM.data[i, j] k += 1 world.rates_M = rates_M
def redfield_tensor(self): print("Redfield tensor calculation") # # Correlation function # params = { "ftype": world.ctype, "reorg": world.reorg, "cortime": world.ctime, "T": world.temp, "matsubara": world.mats } # FIXME: also time_units, temperature_units with energy_units(world.e_units): cf = CorrelationFunction(world.ta, params) # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule("mol1", [0.0, en]) m2 = Molecule("mol2", [0.0, en]) m1.set_egcf((0, 1), cf) m2.set_egcf((0, 1), cf) agg = Aggregate("Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) # m = Manager() ## # with energy_units("1/cm"): # Hm = m1.get_Hamiltonian() # print(Hm) # print(m.convert_energy_2_current_u(Hm._data)) with energy_units(world.r_units): agg.set_resonance_coupling(0, 1, world.r_coupl) agg.build() H = agg.get_Hamiltonian() world.HH = H ## # with energy_units("1/cm"): # print(H) # print(m.convert_energy_2_current_u(H._data)) sbi = agg.get_SystemBathInteraction() H.protect_basis() with eigenbasis_of(H): RRT = RedfieldRelaxationTensor(H, sbi) dim = H.dim rates_T = numpy.zeros(dim * dim) k = 0 world.K12 = numpy.real(RRT.data[1, 1, 2, 2]) for i in range(dim): for j in range(dim): rates_T[k] = numpy.real(RRT.data[i, i, j, j]) k += 1 world.rates_T = rates_T
def redfield_tensor(self): print("Redfield tensor calculation") # # Correlation function # params = {"ftype": world.ctype, "reorg": world.reorg, "cortime": world.ctime, "T": world.temp, "matsubara":world.mats} # FIXME: also time_units, temperature_units with energy_units(world.e_units): cf = CorrelationFunction(world.ta,params) # # Homodimer # with energy_units(world.h_units): en = world.senergy m1 = Molecule([0.0, en], "mol1") m2 = Molecule([0.0, en], "mol2") m1.set_egcf((0,1), cf) m2.set_egcf((0,1), cf) agg = Aggregate(name="Homodimer") agg.add_Molecule(m1) agg.add_Molecule(m2) # m = Manager() ## # with energy_units("1/cm"): # Hm = m1.get_Hamiltonian() # print(Hm) # print(m.convert_energy_2_current_u(Hm._data)) with energy_units(world.r_units): agg.set_resonance_coupling(0,1,world.r_coupl) agg.build() H = agg.get_Hamiltonian() world.HH = H ## # with energy_units("1/cm"): # print(H) # print(m.convert_energy_2_current_u(H._data)) sbi = agg.get_SystemBathInteraction() H.protect_basis() with eigenbasis_of(H): RRT = RedfieldRelaxationTensor(H, sbi) dim = H.dim rates_T = numpy.zeros(dim*dim) k = 0 world.K12 = numpy.real(RRT.data[1,1,2,2]) for i in range(dim): for j in range(dim): rates_T[k] = numpy.real(RRT.data[i,i,j,j]) k += 1 world.rates_T = rates_T