def test_of_fa_location_in_different_units(self): """Testing location of value in different units """ ta = TimeAxis(0.0, 1000, 0.1) ta.atype='complete' wa = ta.get_FrequencyAxis() with energy_units("1/cm"): val = 10000.0 nsni = numpy.int(numpy.floor((val-wa.start)/wa.step)) i1 = wa.locate(10000.0) self.assertEqual(nsni, i1[0]) #with h5py.File("test_file_ValueAxes",driver="core", # backing_store=False) as f: with tempfile.TemporaryFile() as f: wa.save(f, test=True) tb = FrequencyAxis() tb = tb.load(f, test=True) numpy.testing.assert_array_equal(wa.data,tb.data)
def test_of_population_evolution_2(self): """Testing population evolution matrix 2x2 starting from t > 0""" KK = numpy.array([[-1.0 / 100.0, 1.0 / 100.0], [1.0 / 100.0, -1.0 / 100.0]]) U0 = numpy.eye(2) Ntd = 10 t = TimeAxis(0.0, 1000, 1.0) prop = PopulationPropagator(t, rate_matrix=KK) td = TimeAxis(2.0, Ntd, 10.0) U = prop.get_PropagationMatrix(td) # analytical result Ucheck = numpy.zeros((2, 2, Ntd)) Ucheck[0, 0, :] = 0.5 * (1.0 + numpy.exp(2.0 * KK[0, 0] * td.data)) Ucheck[1, 1, :] = Ucheck[0, 0, :] Ucheck[1, 0, :] = 0.5 * (1.0 - numpy.exp(2.0 * KK[0, 0] * td.data)) Ucheck[0, 1, :] = Ucheck[1, 0, :] for n in range(Ntd): numpy.testing.assert_allclose(U[:, :, n], Ucheck[:, :, n])
def test_of_fa_location_in_different_units(self): """Testing location of value in different units """ ta = TimeAxis(0.0, 1000, 0.1) ta.atype = 'complete' wa = ta.get_FrequencyAxis() with energy_units("1/cm"): val = 10000.0 nsni = numpy.int(numpy.floor((val - wa.start) / wa.step)) i1 = wa.locate(10000.0) self.assertEqual(nsni, i1[0]) #with h5py.File("test_file_ValueAxes",driver="core", # backing_store=False) as f: with tempfile.TemporaryFile() as f: wa.save(f, test=True) tb = FrequencyAxis() tb = tb.load(f, test=True) numpy.testing.assert_array_equal(wa.data, tb.data)
def test_TwoDSpectrumCalculator(self): """Testing basic functions of the TwoDSpectrumCalculator class """ t1 = TimeAxis(0.0, 1000, 1.0) t3 = TimeAxis(0.0, 1000, 1.0) t2 = TimeAxis(30, 10, 10.0) twod_calc = TwoDSpectrumCalculator(t1, t2, t3)
def get_Aggregate_with_environment(self, name="dimer-1_env", timeaxis=None): if name == "dimer-1_env": agg = self.get_Aggregate(name="dimer-1") agg.name = name elif name == "trimer-1_env": agg = self.get_Aggregate(name="trimer-1") agg.name = name if timeaxis is None: time = TimeAxis(0, 5000, 1.0) else: time = timeaxis with energy_units("1/cm"): params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) print(time) cf = CorrelationFunction(time, params) m1 = self.molecules[0] m1.set_transition_environment((0, 1), cf) m2 = self.molecules[1] m2.set_transition_environment((0, 1), cf) m3 = self.molecules[2] m3.set_transition_environment((0, 1), cf) elif name == "pentamer-1_env": agg = self.get_Aggregate(name="pentamer-1") agg.name = name if timeaxis is None: time = TimeAxis(0, 5000, 1.0) else: time = timeaxis with energy_units("1/cm"): params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) cf = CorrelationFunction(time, params) for m in self.molecules: m.set_transition_environment((0, 1), cf) else: raise Exception("Unknown model name %s" % name) return agg
def test_(self): """Testing FrequencyAxis values """ ta = TimeAxis(0.0, 1000, 0.1) ta.atype='complete' wa = ta.get_FrequencyAxis() # in internal units wadata = 2.0*numpy.pi*\ numpy.fft.fftshift(numpy.fft.fftfreq(ta.length,d=ta.step)) numpy.testing.assert_allclose(wa.data, wadata, atol=1.0e-12)
def test_(self): """Testing FrequencyAxis values """ ta = TimeAxis(0.0, 1000, 0.1) ta.atype = 'complete' wa = ta.get_FrequencyAxis() # in internal units wadata = 2.0*numpy.pi*\ numpy.fft.fftshift(numpy.fft.fftfreq(ta.length,d=ta.step)) numpy.testing.assert_allclose(wa.data, wadata, atol=1.0e-12)
def test_of_fa_location_in_different_units(self): """Testing location of value in different units """ ta = TimeAxis(0.0, 1000, 0.1) ta.atype='complete' wa = ta.get_FrequencyAxis() with energy_units("1/cm"): val = 10000.0 nsni = numpy.int(numpy.floor((val-wa.start)/wa.step)) i1 = wa.locate(10000.0) self.assertEqual(nsni, i1[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)
def test_of_time_axis_creation(self): """Testing TimeAxis creation """ ta = TimeAxis(0.0, 1000, 0.1) self.assertEqual(ta.min, ta.data[0]) self.assertEqual(ta.max, ta.data[ta.length - 1])
def setUp(self, verbose=False): abss = AbsSpectrumBase() with energy_units("1/cm"): f = FrequencyAxis(10000.0, 2000, 1.0) a = self._spectral_shape(f, [1.0, 11000.0, 100.0]) abss.axis = f abss.data = a self.abss = abss self.axis = abss.axis time = TimeAxis(0.0, 1000, 1.0) with energy_units("1/cm"): mol1 = Molecule(elenergies=[0.0, 12000.0]) params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) mol1.set_dipole(0, 1, [0.0, 1.0, 0.0]) cf = CorrelationFunction(time, params) mol1.set_transition_environment((0, 1), cf) abs_calc = AbsSpectrumCalculator(time, system=mol1) abs_calc.bootstrap(rwa=12000) abs1 = abs_calc.calculate() self.abs1 = abs1
def setUp(self): self.en = [0.0, 1.0, 2.0] self.m = Molecule(name="Molecule", elenergies=self.en) time = TimeAxis(0, 1000, 1.0) params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) with energy_units("1/cm"): fc = CorrelationFunction(time, params) self.m.set_transition_environment((0, 1), fc) self.fc = fc
def time_interval(self, time_step, nsteps): """Matching the following #begin_feature Given time interval from zero with time step <time_step> fs and <nsteps> steps #end_feature """ world.time = TimeAxis(0.0, int(nsteps), float(time_step))
def time_interval_sub(self, time_step, nsteps): """Matching the following #begin_feature And a subset time interval from zero with time step <time_step_2> fs and <nsteps_2> steps #end_feature """ world.time_sub = TimeAxis(0.0, int(nsteps), float(time_step))
def upper_half_time_axis(self): for row in self.hashes: start = float(row['start']) Ns = int(row['number_of_steps']) dt = float(row['step']) print("TimeAxis", start, Ns, dt) # upper-half is default world.ta = TimeAxis(start, Ns, dt) tc = TestCase() tc.assertEqual(world.ta.atype, "upper-half")
def complete_time_axis(self): for row in self.hashes: start = float(row['start']) Ns = int(row['number_of_steps']) dt = float(row['step']) print("TimeAxis", start, Ns, dt, "atype='complete'") # upper-half is default world.ta = TimeAxis(start, Ns, dt, atype="complete") tc = TestCase() tc.assertEqual(world.ta.atype, "complete")
def test_reorganization_energy_consistence(self): """(CorrelationFunction) Checking that reorganization energy is represented consistently """ t = TimeAxis(0.0, 2000, 1.0) params1 = dict(ftype="OverdampedBrownian", reorg = 30.0, cortime = 100.0, T = 300.0) params2 = dict(ftype="OverdampedBrownian", reorg = 40.0, cortime = 100.0, T = 300.0) params3 = dict(ftype="OverdampedBrownian", reorg = 15.0, cortime = 200.0, T = 300.0) params4 = dict(ftype="OverdampedBrownian", reorg = 10.0, cortime = 50.0, T = 300.0) with energy_units("1/cm"): f1 = CorrelationFunction(t, params1) f2 = CorrelationFunction(t, params2) f3 = CorrelationFunction(t, params3) f4 = CorrelationFunction(t, params4) l1 = f1.measure_reorganization_energy() l2 = f1.lamb #print(l1, l2, abs(l1-l2)/(l1+l2)) l1 = f3.measure_reorganization_energy() l2 = f3.lamb #print(l1, l2, abs(l1-l2)/(l1+l2)) self.assertTrue(f1.reorganization_energy_consistent()) self.assertTrue(f2.reorganization_energy_consistent()) self.assertTrue(f3.reorganization_energy_consistent()) self.assertTrue(f4.reorganization_energy_consistent()) for i in range(5): f1 += f1 self.assertTrue(f1.reorganization_energy_consistent()) for i in range(5): f3 += f2 self.assertTrue(f3.reorganization_energy_consistent())
def test_if_time_axis_is_saveable(self): """Testing the Saveability of TimeAxis """ with h5py.File("test_file_ValueAxes", driver="core", backing_store=False) as f: ta = TimeAxis(0.0, 1000, 0.1) ta.save(f, test=True) tb = TimeAxis() tb.load(f, test=True) numpy.testing.assert_array_equal(ta.data, tb.data)
def test_thermal_density_matrix_finite_temp(self): """Thermal density matrix: molecule with one mode, finite temperature """ timeAxis = TimeAxis(0.0, 1000, 1.0) params = { "ftype": "OverdampedBrownian", "T": 300, "reorg": 30, "cortime": 100 } with energy_units("1/cm"): cfcion = CorrelationFunction(timeAxis, params) self.m.set_egcf((0, 1), cfcion) rho_eq = self.m.get_thermal_ReducedDensityMatrix() # Check if the matrix is diagonal dat = rho_eq.data.copy() for i in range(dat.shape[0]): dat[i, i] = 0.0 zer = numpy.zeros(dat.shape, dtype=numpy.float) self.assertTrue(numpy.allclose(dat, zer)) # Check if diagonal is a thermal population pop = numpy.zeros(dat.shape[0]) # get temperature from the molecule T = self.m.get_temperature() self.assertTrue(T == 300.0) # get density matrix rpop = rho_eq.get_populations() # get Hamiltonian H = self.m.get_Hamiltonian() if numpy.abs(T) < 1.0e-10: pop[0] = 1.0 else: # thermal populations psum = 0.0 for n in range(pop.shape[0]): pop[n] = numpy.exp(-H.data[n, n] / (kB_intK * T)) psum += pop[n] pop *= 1.0 / psum self.assertTrue(numpy.allclose(pop, rpop))
def setUp(self, verbose=False): self.verbose = verbose time = TimeAxis(0.0, 1000, 1.0) with energy_units("1/cm"): params = { "ftype": "OverdampedBrownian", "reorg": 30.0, "T": 300.0, "cortime": 100.0 } cf1 = CorrelationFunction(time, params) cf2 = CorrelationFunction(time, params) sd = SpectralDensity(time, params) cm1 = CorrelationFunctionMatrix(time, 2, 1) cm1.set_correlation_function(cf1, [(0, 0), (1, 1)]) cm2 = CorrelationFunctionMatrix(time, 2, 1) cm2.set_correlation_function(cf2, [(0, 0), (1, 1)]) K11 = numpy.array([[1.0, 0.0], [0.0, 0.0]], dtype=numpy.float) K21 = numpy.array([[1.0, 0.0], [0.0, 0.0]], dtype=numpy.float) K12 = K11.copy() K22 = K21.copy() KK11 = Operator(data=K11) KK21 = Operator(data=K21) KK12 = Operator(data=K12) KK22 = Operator(data=K22) self.sbi1 = SystemBathInteraction([KK11, KK21], cm1) self.sbi2 = SystemBathInteraction([KK12, KK22], cm2) with energy_units("1/cm"): h1 = [[0.0, 100.0], [100.0, 0.0]] h2 = [[0.0, 100.0], [100.0, 0.0]] self.H1 = Hamiltonian(data=h1) self.H2 = Hamiltonian(data=h2) #sd.convert_2_spectral_density() with eigenbasis_of(self.H1): de = self.H1.data[1, 1] - self.H1.data[0, 0] self.c_omega_p = sd.at(de, approx="spline") #interp_data(de) self.c_omega_m = sd.at(-de, approx="spline") #interp_data(-de)
def test_comparison_with_and_without_vib(self): """Testing ElectronicLindbladForm in propagation """ # Lindblad forms LT = ElectronicLindbladForm(self.ham, self.sbi, as_operators=False) vLT = ElectronicLindbladForm(self.vham, self.vsbi, as_operators=False) # Propagators time = TimeAxis(0.0, 1000, 1.0) el_prop = ReducedDensityMatrixPropagator(time, self.ham, LT) vib_prop = ReducedDensityMatrixPropagator(time, self.vham, vLT) # electronic initial condition rho0 = ReducedDensityMatrix(dim=self.ham.dim) rho0.data[2, 2] = 1.0 # vibronic intial condition vrho0 = ReducedDensityMatrix(dim=self.vham.dim) agg = self.vsbi.system Nin = agg.vibindices[2][0] vrho0.data[Nin, Nin] = 1.0 # propagations rhot = el_prop.propagate(rho0) vrhot = vib_prop.propagate(vrho0) # averaging over vibrational level at t=0 Nel = agg.Nel aver_vrhot0 = agg.trace_over_vibrations(vrho0) # Test numpy.testing.assert_array_equal(rhot._data[0, :, :], rho0._data) numpy.testing.assert_array_equal(rhot._data[0, :, :], aver_vrhot0._data) aver_vrhot10 = agg.trace_over_vibrations(vrhot, 10) numpy.testing.assert_array_equal(rhot._data[10, :, :], aver_vrhot10._data) aver_vrhot800 = agg.trace_over_vibrations(vrhot, 800) numpy.testing.assert_array_equal(rhot._data[800, :, :], aver_vrhot800._data)
def test_of_correlation_function_as_Saveable(self): """(CorrelationFunction) Testing of saving """ t = TimeAxis(0.0, 1000, 1.0) params1 = dict(ftype="OverdampedBrownian", reorg = 30.0, cortime = 100.0, T = 300.0) params2 = dict(ftype="OverdampedBrownian", reorg = 40.0, cortime = 100.0, T = 300.0) with energy_units("1/cm"): f1 = CorrelationFunction(t, params1) f2 = CorrelationFunction(t, params2) import tempfile with tempfile.TemporaryFile() as f: #with h5py.File("test_file_1",driver="core", # backing_store=False) as f: f1.save(f)#, test=True) f.seek(0) f1_loaded = CorrelationFunction() f1_loaded = f1_loaded.load(f) #, test=True) with tempfile.TemporaryFile() as f: #with h5py.File("test_file_2",driver="core", # backing_store=False) as f: f2.save(f) #, test=True) f.seek(0) f2_loaded = CorrelationFunction() f2_loaded = f2_loaded.load(f) #, test=True) numpy.testing.assert_array_equal(f1.data, f1_loaded.data) numpy.testing.assert_array_equal(f1.axis.data, f1_loaded.axis.data) numpy.testing.assert_array_equal(f2.data, f2_loaded.data) numpy.testing.assert_array_equal(f2.axis.data, f2_loaded.axis.data)
def test_of_correlation_function_addition_T(self): """CorrelationFunction addition with different temperatures raises Exception """ t = TimeAxis(0.0, 1000, 1.0) params1 = dict(ftype="OverdampedBrownian", reorg = 30.0, cortime = 100.0, T = 300.0) params2 = dict(ftype="OverdampedBrownian", reorg = 40.0, cortime = 100.0, T = 100.0) f1 = CorrelationFunction(t, params1) f2 = CorrelationFunction(t, params2) self.assertRaises(Exception, f = f1 + f2)
def test_thermal_density_matrix_finite_temp_nondiag(self): """Thermal density matrix: finite temperature, non-diagonal Hamiltonian """ timeAxis = TimeAxis(0.0, 1000, 1.0) params = { "ftype": "OverdampedBrownian", "T": 300.0, "reorg": 30, "cortime": 100 } cfcion = CorrelationFunction(timeAxis, params) self.m2.set_egcf((0, 1), cfcion) self.m2.set_egcf((0, 2), cfcion) rho_eq = self.m2.get_thermal_ReducedDensityMatrix() pop = numpy.zeros(rho_eq._data.shape[0]) # get temperature from the molecule T = self.m2.get_temperature() self.assertTrue(numpy.abs(T - 300.0) < 1.0e-10) # get Hamiltonian H = self.m2.get_Hamiltonian() with eigenbasis_of(H): # get density matrix rpop = rho_eq.get_populations() if numpy.abs(T) < 1.0e-10: pop[0] = 1.0 else: # thermal populations psum = 0.0 for n in range(pop.shape[0]): pop[n] = numpy.exp(-H.data[n, n] / (kB_intK * T)) psum += pop[n] pop *= 1.0 / psum self.assertTrue(numpy.allclose(pop, rpop))
def setUp(self, verbose=False): lindichs = LinDichSpectrumBase() with energy_units("1/cm"): f = FrequencyAxis(10000.0, 2000, 1.0) a = self._spectral_shape(f, [1.0, 11000.0, 100.0]) lindichs.axis = f lindichs.data = a self.lindichs = lindichs self.axis = lindichs.axis #make a single-molecule system time = TimeAxis(0.0, 1000, 1.0) self.ta = time with energy_units("1/cm"): mol1 = Molecule(elenergies=[0.0, 12000.0]) mol2 = Molecule(elenergies=[0.0, 12000.0]) params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) mol1.set_dipole(0, 1, [0.0, 1.0, 0.0]) mol2.set_dipole(0, 1, [0.0, 1.0, 0.0]) cf = CorrelationFunction(time, params) mol1.set_transition_environment((0, 1), cf) mol2.set_transition_environment((0, 1), cf) mol1.position = [0, 0, 0] mol2.position = [10, 10, 10] agg = Aggregate(name="tester_dim", molecules=[mol1, mol2]) agg.build() lindich_calc = LinDichSpectrumCalculator(time, system=agg, \ vector_perp_to_membrane=numpy.array((0,1,0))) lindich_calc.bootstrap(rwa=12000) lindich1 = lindich_calc.calculate() self.lindich1 = lindich1
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)
def test_of_correlation_function_addition_T(self): """(CorrelationFunction) Testing that addition with different temperatures raises Exception """ t = TimeAxis(0.0, 1000, 1.0) params1 = dict(ftype="OverdampedBrownian", reorg = 30.0, cortime = 100.0, T = 300.0) params2 = dict(ftype="OverdampedBrownian", reorg = 40.0, cortime = 100.0, T = 100.0) with energy_units("1/cm"): f1 = CorrelationFunction(t, params1) f2 = CorrelationFunction(t, params2) with self.assertRaises(Exception): f = f1 + f2
def setUp(self): m1 = Molecule(name="Molecule 1", elenergies=[0.0, 1.0]) m2 = Molecule(name="Molecule 2", elenergies=[0.0, 1.0]) time = TimeAxis(0.0, 1000, 1.0) params = dict(ftype="OverdampedBrownian", reorg=20, cortime=100, T=300) with energy_units("1/cm"): fc = CorrelationFunction(time, params) m1.set_transition_environment((0, 1), fc) m1.position = [0.0, 0.0, 0.0] m1.set_dipole(0, 1, [10.0, 0.0, 0.0]) m2.set_transition_environment((0, 1), fc) m2.position = [10.0, 0.0, 0.0] m2.set_dipole(0, 1, [10.0, 0.0, 0.0]) self.agg = Aggregate(name="TestAgg", molecules=[m1, m2]) self.agg.set_coupling_by_dipole_dipole() self.agg.build() m3 = Molecule(name="Molecule 1", elenergies=[0.0, 1.0]) m4 = Molecule(name="Molecule 2", elenergies=[0.0, 1.0]) m3.add_Mode(Mode(0.01)) m4.add_Mode(Mode(0.01)) mod3 = m3.get_Mode(0) mod4 = m4.get_Mode(0) mod3.set_nmax(0, 4) mod3.set_nmax(1, 4) mod3.set_HR(1, 0.1) mod4.set_nmax(0, 4) mod4.set_nmax(1, 4) mod4.set_HR(1, 0.3) self.vagg = Aggregate(molecules=[m3, m4]) self.vagg.build()
# Plot spectral density with energy_units("1/cm"): #cF1.plot(show=False) #cF1e.plot(show=False) cF1o.plot(show=False) sd1.plot(show=False) sd.plot(axis=[-1000,1000,-0.008,0.008]) df = numpy.max(numpy.abs(cF1o.data-sd1.data)) print(df) mx = numpy.max(numpy.abs(sd1.data)) print(mx) print(df/mx) with energy_units("eV"): tm = TimeAxis(0.0,100,1.0) wm = tm.get_FrequencyAxis() with energy_units("eV"): print(wm.data[1]-wm.data[0]) print(wm.step) ftc = sd1.get_FTCorrelationFunction() if _show_plots_: cF1.plot(show=False) ftc.plot(axis=[-0.1,0.1,0,0.06])
# 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") LFa.convert_2_tensor() print(LFa.data[1, 1, 2, 2]) print(LFa.data[1, 2, 1, 2]) # # VIBRONIC Aggregate of two molecules # m1v = Molecule([0.0, 1.0]) m2v = Molecule([0.0, 1.1])
from quantarhei.spectroscopy.twod2 import TwoDSpectrumCalculator from quantarhei.spectroscopy.twod2 import TwoDSpectrumContainer from quantarhei.spectroscopy.twod2 import TwoDSpectrum from aceto.lab_settings import lab_settings from quantarhei import Manager print(Manager().version) t_fstart = time.time() # Time axis for t1 and t3 times Nr = 1000 ta = TimeAxis(0.0, Nr, 2.0) ############################################################################### # # Define problem # ############################################################################### # # define molecules # 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
from quantarhei.core.units import kB_int import numpy """ """ print("\n") print("*****************************************************************") print("* *") print("* Demo of the quantarhei CorrelationFunction *") print("* and Spectral Density classes *") print("* *") print("*****************************************************************") # time interval om which functions will be defined ta = TimeAxis(0.0, 1000, 1.0) temperature = 300.0 # parameters of the correlation function params = { "ftype": "OverdampedBrownian", "reorg": 20.0, "cortime": 100.0, "T": temperature, "matsubara": 20 } # here we create the correlation function assuming that the energy parameters # are given in 1/cm with energy_units("1/cm"): cf = CorrelationFunction(ta, params)
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)