예제 #1
0
def compare_spectral_dens_to_analytical(self, fctype):
    m = Manager()
    i = 0
    sd_data = numpy.zeros((world.sd.axis.data.shape[0], 2))
    wa = world.ta.get_FrequencyAxis()
    with energy_units("int"):
        sd_data[:, 0] = wa.data
        omega = wa.data
    with energy_units(world.e_units):
        lamb = m.convert_energy_2_internal_u(world.reorg)
    ctime = world.ctime

    if fctype == "OverdampedBrownian":
        # Analytical for for the overdamped Brownian spectral density
        sd_data[:, 1] = (2.0 * lamb / ctime) * omega / (omega**2 +
                                                        (1.0 / ctime)**2)
    else:
        raise Exception()

    data = numpy.zeros((world.sd.axis.data.shape[0], 2))
    for t in world.sd.axis.data:
        data[i, 0] = t
        data[i, 1] = numpy.real(world.sd.data[i])
        #data[i,2] = numpy.imag(world.cf.data[i])
        i += 1
    numpy.testing.assert_allclose(sd_data, data, rtol=1.0e-7)
예제 #2
0
def compare_rates_analytical(self, rtols):
    
    print("Comparison of redfield rates with analytical results")
    m = Manager()
    
    rtol = float(rtols)

    with energy_units(world.r_units):
        J = m.convert_energy_2_internal_u(world.r_coupl)
    with energy_units(world.e_units):
        lamb = m.convert_energy_2_internal_u(world.reorg) 
    tauc = world.ctime
    kBT = kB_int*world.temp
    
    #print(world.temp, lamb, tauc, J)    
    
    K12 = ((lamb*J/2.0)
            *(1.0 + 1.0/numpy.tanh(J/kBT))/((J**2)*tauc + 1.0/(4.0*tauc)))
    
    print(K12, 1.0/K12)
    print(world.K12, 1.0/world.K12)
    
    print(K12/world.K12)
    
    numpy.testing.assert_allclose(K12, world.K12 ,rtol=rtol) #,atol=atol)    
예제 #3
0
def compare_rates_analytical(self, rtols):

    print("Comparison of redfield rates with analytical results")
    m = Manager()

    rtol = float(rtols)

    with energy_units(world.r_units):
        J = m.convert_energy_2_internal_u(world.r_coupl)
    with energy_units(world.e_units):
        lamb = m.convert_energy_2_internal_u(world.reorg)
    tauc = world.ctime
    kBT = kB_int * world.temp

    #print(world.temp, lamb, tauc, J)

    K12 = ((lamb * J / 2.0) * (1.0 + 1.0 / numpy.tanh(J / kBT)) /
           ((J**2) * tauc + 1.0 / (4.0 * tauc)))

    print(K12, 1.0 / K12)
    print(world.K12, 1.0 / world.K12)

    print(K12 / world.K12)

    numpy.testing.assert_allclose(K12, world.K12, rtol=rtol)  #,atol=atol)
예제 #4
0
 def setUp(self,verbose=False):
     
     fluors = FluorSpectrumBase()
     with energy_units("1/cm"):
         f = FrequencyAxis(10000.0,2000, 1.0)
         a = self._spectral_shape(f, [1.0, 11000.0, 100.0])
         fluors.axis = f
         fluors.data = a
     self.fluors = fluors
     self.axis = fluors.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])
         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)
         
         fluor_calc = FluorSpectrumCalculator(time, system=mol1)
         fluor_calc.bootstrap(rwa=12000)
         
     fluor1 = fluor_calc.calculate()
     
     self.fluor1 = fluor1
def compare_spectral_dens_to_analytical(self, fctype):
    m = Manager()
    i = 0
    sd_data = numpy.zeros((world.sd.axis.data.shape[0],2))
    wa = world.ta.get_FrequencyAxis()
    with energy_units("int"):
        sd_data[:,0] = wa.data
        omega = wa.data
    with energy_units(world.e_units):
        lamb = m.convert_energy_2_internal_u(world.reorg)
    ctime = world.ctime
        
    if fctype == "OverdampedBrownian":
        # Analytical for for the overdamped Brownian spectral density
        sd_data[:,1] = (2.0*lamb/ctime)*omega/(omega**2 + (1.0/ctime)**2)
    else:
        raise Exception()
    
    data = numpy.zeros((world.sd.axis.data.shape[0],2))
    for t in world.sd.axis.data:
        data[i,0] = t
        data[i,1] = numpy.real(world.sd.data[i])
        #data[i,2] = numpy.imag(world.cf.data[i])
        i += 1
    diff = numpy.amax(numpy.abs(sd_data[:,1]-data[:,1]))
    maxv = numpy.amax(numpy.abs(sd_data[:,1]))
    print("Difference: ", diff, " on ", maxv)
    numpy.testing.assert_allclose(sd_data,data,rtol=1.0e-3,atol=1.0e-3)
예제 #6
0
    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
예제 #7
0
def test_dynamics(agg_list, energies):
    # Adding the energies to the molecules. Neeed to be done before agg
    with qr.energy_units("1/cm"):
        for i, mol in enumerate(agg_list):
            mol.set_energy(1, energies[i])

    # Creation of the aggregate for dynamics. multiplicity can be 1
    agg = qr.Aggregate(molecules=agg_list)
    agg.set_coupling_by_dipole_dipole(epsr=1.21)
    agg.build(mult=1)
    agg.diagonalize()
    with qr.energy_units('1/cm'):
        print(agg.get_Hamiltonian())

    # Creating a propagation axis length t13_ax plus padding with intervals 1
    t1_len = int(((t13_ax.length + padding - 1) * t13_ax.step) + 1)
    t2_prop_axis = qr.TimeAxis(0.0, t1_len, 1)

    # Generates the propagator to describe motion in the aggregate
    prop_Redfield = agg.get_ReducedDensityMatrixPropagator(
        t2_prop_axis,
        relaxation_theory="stR",
        time_dependent=False,
        secular_relaxation=True)

    # Obtaining the density matrix
    shp = agg.get_Hamiltonian().dim
    rho_i1 = qr.ReducedDensityMatrix(dim=shp, name="Initial DM")
    # Setting initial conditions
    rho_i1.data[shp - 1, shp - 1] = 1.0
    # Propagating the system along the t13_ax_ax time axis
    rho_t1 = prop_Redfield.propagate(rho_i1, name="Redfield evo from agg")
    rho_t1.plot(coherences=False, axis=[0, t1_len, 0, 1.0], show=True)
예제 #8
0
    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
예제 #9
0
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
예제 #10
0
def absorption_spectrum_trimer(self):

    dd1 = [0.0, 3.0, 0.0]
    dd2 = [0.0, 1.0, 2.0]
    dd3 = [0.0, 1.0, 1.0]

    cf = world.cf

    with energy_units("1/cm"):
        m1 = Molecule([0.0, 12100])
        m1.set_dipole(0, 1, dd1)
        m1.set_transition_environment((0, 1), cf)
        m2 = Molecule([0.0, 11800])
        m2.set_dipole(0, 1, dd2)
        m2.set_transition_environment((0, 1), cf)
        m3 = Molecule([0.0, 12500])
        m3.set_dipole(0, 1, dd3)
        m3.set_transition_environment((0, 1), cf)

    m1.position = [0.0, 0.0, 0.0]
    m2.position = [5.0, 0.0, 0.0]
    m3.position = [0.0, 5.0, 0.0]

    AG = Aggregate(name="TestAggregate")

    AG.add_Molecule(m1)
    AG.add_Molecule(m2)
    AG.add_Molecule(m3)

    AG.set_coupling_by_dipole_dipole(epsr=3.0)

    AG.build()

    (RRr,
     hamr) = AG.get_RelaxationTensor(world.ta,
                                     relaxation_theory="standard_Redfield",
                                     time_dependent=True)
    ac = AbsSpectrumCalculator(world.ta,
                               AG,
                               relaxation_tensor=RRr,
                               effective_hamiltonian=hamr)

    with energy_units("1/cm"):
        ac.bootstrap(rwa=12000)
        a1 = ac.calculate()

    with energy_units("1/cm"):
        world.abs = numpy.zeros((len(a1.data), 2))
        for kk in range(len(a1.data)):
            world.abs[kk, 0] = a1.axis.data[kk]  #frequency[kk]
            world.abs[kk, 1] = a1.data[kk]
예제 #11
0
def absorption_spectrum_trimer(self):
    
    dd1 = [0.0,3.0,0.0]
    dd2 = [0.0,1.0,2.0]
    dd3 = [0.0,1.0,1.0]
    
    cf = world.cf

    with energy_units("1/cm"):
        m1 = Molecule([0.0, 12100])
        m1.set_dipole(0,1,dd1)
        m1.set_transition_environment((0,1), cf)
        m2 = Molecule([0.0, 11800])
        m2.set_dipole(0,1,dd2)
        m2.set_transition_environment((0,1), cf)
        m3 = Molecule([0.0, 12500])
        m3.set_dipole(0,1,dd3)  
        m3.set_transition_environment((0,1), cf)
        

    m1.position = [0.0,0.0,0.0]
    m2.position = [5.0,0.0,0.0] 
    m3.position = [0.0,5.0,0.0] 
    
    
    AG = Aggregate(name="TestAggregate")

    AG.add_Molecule(m1)
    AG.add_Molecule(m2)
    AG.add_Molecule(m3)
    
    AG.set_coupling_by_dipole_dipole(epsr=3.0)

    AG.build()

    (RRr,hamr) = AG.get_RelaxationTensor(world.ta,
                                   relaxation_theory="standard_Redfield",
                                   time_dependent=True)    
    ac = AbsSpectrumCalculator(world.ta,AG, 
                  relaxation_tensor=RRr,
                  effective_hamiltonian=hamr)
    
    with energy_units("1/cm"):
        ac.bootstrap(rwa=12000)
        a1 = ac.calculate(raw=True)
    
    with energy_units("1/cm"):
        world.abs = numpy.zeros((len(a1.data),2))
        for kk in range(len(a1.data)):
            world.abs[kk,0] = a1.axis.data[kk] #frequency[kk]
            world.abs[kk,1] = a1.data[kk]  
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
예제 #13
0
    def assign_spec_dens(self, sd_type = 'OverdampedBrownian', high_freq = True):

        t_ax_sd = qr.TimeAxis(0.0, 10000, 1)
        db = SpectralDensityDB()

        # Parameters for spectral density. ODBO, Renger or Silbey
        params = {
            "ftype": sd_type,
            "alternative_form": True,
            "reorg": self.reorg,
            "T": self.temp,
            "cortime": self.cor_time
            }
        with qr.energy_units('1/cm'):
            sd_low_freq = qr.SpectralDensity(t_ax_sd, params)

        if high_freq:
            # Adding the high freq modes
            sd_high_freq = db.get_SpectralDensity(t_ax_sd, "Wendling_JPCB_104_2000_5825")
            ax = sd_low_freq.axis
            sd_high_freq.axis = ax
            sd_tot = sd_low_freq + sd_high_freq

            cf = sd_tot.get_CorrelationFunction(temperature=self.temp, ta=t_ax_sd)
            # Assigning the correlation function to the list of molecules
        else:
            cf = sd_low_freq.get_CorrelationFunction(temperature=self.temp, ta=t_ax_sd)

        for mol in self.mol_list:
            mol.set_transition_environment((0,1),cf)
예제 #14
0
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
예제 #15
0
    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)
예제 #16
0
def correlation_function_of_type(self, ctype):
    print("correlation function type ", ctype)
    world.ctype = ctype

    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)

    i = 0
    data = numpy.zeros((world.ta.data.shape[0], 3))
    for t in world.ta.data:
        data[i, 0] = t
        data[i, 1] = numpy.real(cf.data[i])
        data[i, 2] = numpy.imag(cf.data[i])
        i += 1

    world.cf = cf
예제 #17
0
    def get_SpectralDensity(self, axis):

        # Calling the spec dens calculated from b777 in rengers paper
        # alternative_form gives the polynomial version of the same spec dens
        # Jang, Newton, Silbey, J Chem Phys. 2007.
        params = {
            "ftype": "B777",
            "reorg": 102.0,
            "alternative_form": True,
            "T": 300,
            "cortime": 100
        }

        # can vary the paramaters, values from the paper are set by default
        params.update({
            "freq1": 0.56,
            "freq2": 1.9,
            's1': 0.8,
            's2': 0.5,
            'om1': 170,
            'om2': 34,
            'om3': 69,
        })

        with energy_units("1/cm"):
            sd = SpectralDensity(axis, params)

        return sd
예제 #18
0
    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)
예제 #19
0
    def test_units_management(self):
        """Testing that Hamiltonian is EnergyUnitsManaged
        
        
        """
        cm2int = 2.0 * const.pi * const.c * 1.0e-13
        self.assertEquals(self.H.unit_repr(), "2pi/fs")

        if self.verbose:
            print("In internal:")
            print(self.H.data)

        with energy_units("1/cm"):
            self.assertEquals(self.H.unit_repr(), "1/cm")
            self.assertEquals(self.H.data[0, 1], 1.0 / cm2int)
            if self.verbose:
                print("In 1/cm:")
                print(self.H.data)

            H2 = Hamiltonian(data=[[1000.0, 0.0], [0.0, 2000.0]])

            self.assertAlmostEqual(H2.data[0, 0], 1000.0)
            self.assertAlmostEqual(H2.data[1, 1], 2000.0)

        self.assertAlmostEqual(H2.data[0, 0], 1000.0 * cm2int)
        self.assertAlmostEqual(H2.data[1, 1], 2000.0 * cm2int)

        if self.verbose:
            print("In internal:")
            print(self.H.data)
예제 #20
0
def calcTwoDMock(loopNum):
    ''' Calculates a2d spectrum container for all time points on t2 axis
    for both perpendicular and parallel lasers. Uses quantarhei only and
    speeds up runtime by using simple lineshapes'''

    container = []

    agg = qr.Aggregate(forAggregateMock)

    with qr.energy_units('1/cm'):
        for i in range(len(forAggregateMock)):
            agg.monomers[i].set_energy(1, random.gauss(energy, staticDis))

    agg.set_coupling_by_dipole_dipole()
    agg.build(mult=2)
    agg.diagonalize()

    rT = agg.get_RelaxationTensor(t2s, relaxation_theory='stR')
    eUt = qr.EvolutionSuperOperator(t2s, rT[1], rT[0]) # rT[1] = Hamiltonian
    eUt.set_dense_dt(t2Step)
    eUt.calculate(show_progress=False)

    mscPara = qr.MockTwoDResponseCalculator(t13, t2s, t13)
    mscPara.bootstrap(rwa=rwa, shape="Gaussian")
    contPara = mscPara.calculate_all_system(agg, eUt, labParaMock, show_progress=True)
    cont2DPara = contPara.get_TwoDSpectrumContainer(stype=qr.signal_TOTL)
    container.append(cont2DPara)

    mscPerp = qr.MockTwoDResponseCalculator(t13, t2s, t13)
    mscPerp.bootstrap(rwa=rwa, shape="Gaussian")
    contPerp = mscPerp.calculate_all_system(agg, eUt, labPerpMock, show_progress=True)
    cont2DPerp = contPerp.get_TwoDSpectrumContainer(stype=qr.signal_TOTL)
    container.append(cont2DPerp)

    return container
예제 #21
0
    def test_set_resonance_coupling_matrix(self):
        """(Aggregate) Testing setting the whole resonance coupling matrix
        
        """
        agg = TestAggregate(name="dimer-2-env")

        mat = [[0.0, 1.0],
               [1.0, 0.0]]
        
        agg.set_resonance_coupling_matrix(mat)
        self.assertAlmostEqual(agg.resonance_coupling[1,0], 1.0)
        self.assertAlmostEqual(agg.resonance_coupling[0,1], 1.0)
        self.assertAlmostEqual(agg.resonance_coupling[0,0], 0.0)
        self.assertAlmostEqual(agg.resonance_coupling[1,1], 0.0)

        mat = ((0.0, 500.0),
               (500.0, 0.0))
        
        with qr.energy_units("1/cm"):
            agg.set_resonance_coupling_matrix(mat)

        inint = qr.convert(500, "1/cm", "int")
        self.assertAlmostEqual(agg.resonance_coupling[1,0], inint)
        self.assertAlmostEqual(agg.resonance_coupling[0,1], inint)
        self.assertAlmostEqual(agg.resonance_coupling[0,0], 0.0)
        self.assertAlmostEqual(agg.resonance_coupling[1,1], 0.0)
예제 #22
0
def calcTwoD(loopNum):
    ''' Caculates a 2d spectrum for both perpendicular and parael lasers
    using aceto bands and accurate lineshapes'''

    container = []
    agg = qr.Aggregate(molecules=forAggregate)

    with qr.energy_units('1/cm'):
        for i in range(len(forAggregate)):
            agg.monomers[i].set_energy(1, random.gauss(energy, staticDis))

    agg.set_coupling_by_dipole_dipole(epsr=1.21)
    agg.build(mult=2)
    agg.diagonalize()

    tcalc_para = qr.TwoDResponseCalculator(t1axis=t13, t2axis=t2s, t3axis=t13, system=agg)
    tcalc_para.bootstrap(rwa, pad=padding, verbose=True, lab=labPara, printEigen=False, printResp='paraResp')#, printResp='paraResp'
    twods_para = tcalc_para.calculate()
    paraContainer = twods_para.get_TwoDSpectrumContainer()
    container.append(paraContainer)

    tcalc_perp = qr.TwoDResponseCalculator(t1axis=t13, t2axis=t2s, t3axis=t13, system=agg)
    tcalc_perp.bootstrap(rwa, pad=padding, verbose=True, lab=labPerp, printEigen=False)#, printResp='perpResp'
    twods_perp = tcalc_perp.calculate()
    perpContainer = twods_perp.get_TwoDSpectrumContainer()
    container.append(perpContainer)

    return container
예제 #23
0
    def test_abs_difference_formula(self):
        """Testing formula for calculation of difference between abs spectra
        
        """

        #
        #  Test difference formula
        #
        par = [1.0, 10900.0, 100.0]
        with energy_units("1/cm"):
            f2 = self._spectral_shape(self.abss.axis, par)

            abss2 = AbsSpectrumBase(axis=self.abss.axis, data=f2)
            ad = AbsSpectrumDifference(target=self.abss,
                                       optfce=abss2,
                                       bounds=(10100.0, 11900.0))
        d = ad.difference()

        #with energy_units("1/cm"):
        if True:
            target = self.abss.data[ad.nl:ad.nu]
            secabs = abss2.data[ad.nl:ad.nu]
            x = self.abss.axis.data[ad.nl:ad.nu]
            d2 = 1000.0 * numpy.sum(
                numpy.abs((target - secabs)**2 / (x[len(x) - 1] - x[0])))

        self.assertAlmostEqual(d, d2)
예제 #24
0
def set_cor_func(for_agg, params, ax_len = 10000):

    ax_length = ax_len
    # Needs to have small step for the dynamics to converge
    t_ax_sd = qr.TimeAxis(0.0, ax_length, 1)
    db = SpectralDensityDB()

    # Parameters for spectral density. ODBO, Renger or Silbey
    params = params
    with qr.energy_units('1/cm'):
        sd_low_freq = qr.SpectralDensity(t_ax_sd, params)

    reorg = qr.convert(sd_low_freq.measure_reorganization_energy(), "int", "1/cm")
    print("spectral density reorg -", reorg)

    # Adding the high freq modes
    sd_high_freq = db.get_SpectralDensity(t_ax_sd, "Wendling_JPCB_104_2000_5825")
    ax = sd_low_freq.axis
    sd_high_freq.axis = ax
    sd_tot = sd_low_freq + sd_high_freq

    cf = sd_tot.get_CorrelationFunction(temperature=params['T'], ta=t_ax_sd)
    # Assigning the correlation function to the list of molecules
    for mol in for_agg:
        mol.set_transition_environment((0,1),cf)
예제 #25
0
 def test_units_management(self):
     """Testing that Hamiltonian is EnergyUnitsManaged
     
     
     """        
     cm2int = 2.0*const.pi*const.c*1.0e-13
     self.assertEquals(self.H.unit_repr(),"1/fs")
     
     if self.verbose:
         print("In internal:")
         print(self.H.data)
     
     with energy_units("1/cm"):
         self.assertEquals(self.H.unit_repr(),"1/cm")
         self.assertEquals(self.H.data[0,1],1.0/cm2int)
         if self.verbose:
             print("In 1/cm:")
             print(self.H.data)
             
         H2 = Hamiltonian(data=[[1000.0, 0.0],[0.0, 2000.0]])
         
         self.assertAlmostEqual(H2.data[0,0],1000.0)
         self.assertAlmostEqual(H2.data[1,1],2000.0)
         
     self.assertAlmostEqual(H2.data[0,0],1000.0*cm2int)
     self.assertAlmostEqual(H2.data[1,1],2000.0*cm2int)
         
     if self.verbose:
         print("In internal:")
         print(self.H.data)        
예제 #26
0
    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)
예제 #27
0
def absorption_spectrum_dimer(self):
    
    dd1 = [0.0,3.0,0.0]
    dd2 = [0.0,1.0,1.0]
    
    cf = world.cf
    #cm = CorrelationFunctionMatrix(world.ta,2,1)
    #cm.set_correlation_function(cf,[(1,1),(0,0)])

    with energy_units("1/cm"):
        m1 = Molecule([0.0, 12100])
        m1.set_dipole(0,1,dd1)
        m1.set_transition_environment((0,1), cf)
        m2 = Molecule([0.0, 12000])
        m2.set_dipole(0,1,dd2)
        m2.set_transition_environment((0,1), cf)
        
   #m1.set_egcf([0,1],cf)
    #m2.set_egcf([0,1],cf)
    #m1.set_egcf_mapping((0,1),cm,0)
    #m2.set_egcf_mapping((0,1),cm,1)
    m1.position = [0.0,0.0,0.0]
    m2.position = [5.0,0.0,0.0] 
    
    AG = Aggregate(name="TestAggregate")
    #AG.set_egcf_matrix(cm)

    AG.add_Molecule(m1)
    AG.add_Molecule(m2)


    AG.set_coupling_by_dipole_dipole()

    AG.build()

    ac = AbsSpectrumCalculator(world.ta,AG)
    with energy_units("1/cm"):
        ac.bootstrap(rwa=12000)
        a1 = ac.calculate(raw=True)
    
    with energy_units("1/cm"):
        world.abs = numpy.zeros((len(a1.data),2))
        for kk in range(len(a1.data)):
            world.abs[kk,0] = a1.axis.data[kk] #frequency[kk]
            world.abs[kk,1] = a1.data[kk]    
예제 #28
0
 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
예제 #29
0
 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=qr.REAL)
     K21 = numpy.array([[1.0, 0.0],[0.0, 0.0]],dtype=qr.REAL)
     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)
예제 #30
0
    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
예제 #31
0
 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
예제 #32
0
def absorption_spectrum_molecule(self):

    dd = [0.0, 1.0, 0.0]
    cf = world.cf

    with energy_units("1/cm"):
        m = Molecule("Mol", [0.0, 12000])
    m.set_dipole(0, 1, dd)

    m.set_egcf([0, 1], cf)

    a1 = AbsSpect(world.ta, m)
    a1.calculate(rwa=m.elenergies[1])

    with energy_units("1/cm"):
        world.abs = numpy.zeros((len(a1.data), 2))
        for kk in range(len(a1.data)):
            world.abs[kk, 0] = a1.axis.data[kk]  #frequency[kk]
            world.abs[kk, 1] = a1.data[kk]
예제 #33
0
 def exciton_report(self, start=1, stop=None, Nrep=5, criterium=None):
     """Prints a report on excitonic properties of the aggregate
     
     Parameters
     ----------
     
     start : int (default = 1)
         First state to report on. Because 0 is often the ground state,
         it is skipped. For systems with molecular vibrations, first mixed
         states start with an index different from 1.
         
     stop : int (default = None)
         Where to stop the report. if Nono, all states are reported
         
     Nrep : int (default = 5)
         How many sites of the exciton decomposition we should list    
     
     """
     
     start_at = start
     stop_at = stop
     
     print("Report on excitonic properties")
     print("------------------------------\n")
     N01 = self.Nb[0]+self.Nb[1]
     for Nst in range(N01):
         
         if stop_at is None:
             stop_at = N01 + 1
             
         if (Nst >= start_at) and (Nst <= stop_at):
             
             tre = self.get_state_energy(Nst) - self.get_state_energy(0)
             dip = self.get_transition_dipole(0, Nst)
             
             if criterium is not None:
                 cond = criterium([tre, dip])
                 
             else:
                 cond = True
             
             if cond:
                 txt = "Exciton "+str(Nst)
                 Nlength = len(txt)
                 line = "="*Nlength
                 print(txt)
                 print(line)
                 print("")
                 with qr.energy_units("1/cm"):
                     print("Transition energy        : ", tre
                           , "1/cm")
                     print("Transition dipole moment : ", dip
                           , "D")
                 self.report_on_expansion(Nst, N=Nrep)
                 print("")
예제 #34
0
    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
예제 #35
0
    def get_point_list(self, point, name = 'place_holder'):

        points = np.empty(len(self.spectra_data[name]))

        for i, time in enumerate(self.spectra_data[name]):
            with qr.energy_units('1/cm'):
                points[i] = time.get_value_at(point, point).real

        if not name in self.point_list.keys():
            self.point_list.update({name: {}})
        self.point_list[name].update({'max': points})
예제 #36
0
    def print_spectra(self, name = 'place_holder'):#, spread = 700

        for i, tt2 in enumerate(self.resp_calc.t2axis.data):
            twod = self.spec_cont_dict[name].get_spectrum(self.resp_calc.t2axis.data.data[i])
            #max_val = twod.get_max_value()
            with qr.energy_units('1/cm'):
                twod.plot()
                plt.xlim(11400, 13100)
                plt.ylim(11400, 13100)
                plt.title(name + str(int(tt2)))
                plt.show()
예제 #37
0
def absorption_spectrum_molecule(self):

    dd = [0.0,1.0,0.0]
    cf = world.cf
 
    with energy_units("1/cm"):
        m = Molecule([0.0, 12000])
    m.set_dipole(0,1,dd)
    
    m.set_egcf([0,1],cf)
    
    ac = AbsSpectrumCalculator(world.ta,m)
    ac.bootstrap(rwa=m.elenergies[1])
    a1 = ac.calculate(raw=True)
    
    with energy_units("1/cm"):
        world.abs = numpy.zeros((len(a1.data),2))
        for kk in range(len(a1.data)):
            world.abs[kk,0] = a1.axis.data[kk] #frequency[kk]
            world.abs[kk,1] = a1.data[kk]
예제 #38
0
    def save_spec(self, disp_range = 1000, location = '.', name = 'place_holder'):

        window = [self.centre - disp_range, self.centre + disp_range,\
         self.centre - disp_range, self.centre + disp_range]

        location = self._make_data_dir(location)

        for i, time in enumerate(self.t2_axis.data):
            with qr.energy_units('1/cm'):
                self.spectra_data[name][i].plot(window = window)#
                plt.title(name + str(int(time)))
                plt.savefig(location + name + str(int(time)) + '.png')
예제 #39
0
    def get_SpectralDensity(self, axis):

        #
        # Data from the paper
        #
        omegas = [
            36, 70, 117, 173, 185, 195, 237, 260, 284, 327, 365, 381, 479, 541,
            565, 580, 635, 714, 723, 730, 747, 759, 768, 777, 819, 859, 896,
            1158, 1176, 1216
        ]
        fcfs = [
            0.01, 0.01, 0.0055, 0.008, 0.008, 0.011, 0.005, 0.0025, 0.005,
            0.0015, 0.002, 0.002, 0.001, 0.001, 0.002, 0.001, 0.003, 0.002,
            0.003, 0.001, 0.002, 0.002, 0.004, 0.0015, 0.002, 0.0025, 0.002,
            0.004, 0.003, 0.002
        ]

        #
        # Guessed dephasing times of the oscillators
        #
        gammas = [1.0 / 3000.0] * 30

        data = []
        for i in range(len(omegas)):
            data.append((omegas[i], fcfs[i], gammas[i]))

        #
        # All contributions consist of underdamped harmonic oscillators
        #
        params = dict(ftype="UnderdampedBrownian")

        #
        # Create and sum-up spectral densities
        #
        k = 0
        for d in data:

            params["freq"] = d[0]
            params["reorg"] = d[0] * d[1]
            params["gamma"] = d[2]  #1.0/3000.0

            with energy_units("1/cm"):
                sd = SpectralDensity(axis, params)

            if k == 0:
                ret = sd
                ax = sd.axis
            else:
                sd.axis = ax
                ret += sd
            k += 1

        return ret
예제 #40
0
    def get_point_list(self, point, name = 'place_holder'):

        points = np.empty(len(self.resp_calc.t2axis.data))

        for i, tt2 in enumerate(self.resp_calc.t2axis.data):
            twod = self.spec_cont_dict[name].get_spectrum(self.resp_calc.t2axis.data.data[i])
            with qr.energy_units('1/cm'):
                points[i] = twod.get_value_at(point, point).real
        
        if not name in self.point_list.keys():
            self.point_list.update({name: {}})
        self.point_list[name].update({str(point): points})
예제 #41
0
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()
예제 #42
0
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()
예제 #43
0
    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
예제 #44
0
    def test_dipole_dipole_coupling(self):
        """(Aggregate) Testing dipole-dipole coupling calculation

        """
        agg = TestAggregate(name="dimer-2-env")

        coup1 = agg.dipole_dipole_coupling(0,1)
        coup2 = agg.dipole_dipole_coupling(0,1, epsr=2.0)
        self.assertAlmostEqual(coup1, coup2*2.0)
        
        with qr.energy_units("1/cm"):
            coup = agg.dipole_dipole_coupling(0,1)
        self.assertAlmostEqual(qr.convert(coup1,"int","1/cm"), coup)
예제 #45
0
    def test_get_resonance_coupling(self):
        """(Aggregate) Testing resonance coupling retrieval in different units
        
        """
        agg = TestAggregate(name="dimer-2-env")
        agg.init_coupling_matrix()        
        agg.set_resonance_coupling(0, 1, 1.0)

        coup = agg.get_resonance_coupling(1,0)
        self.assertAlmostEqual(coup, 1.0)

        with qr.energy_units("1/cm"):
            coup = agg.get_resonance_coupling(1,0)
        self.assertAlmostEqual(coup, qr.convert(1.0, "int", "1/cm"))
        
        with qr.energy_units("eV"):
            coup = agg.get_resonance_coupling(1,0)
        self.assertAlmostEqual(coup, qr.convert(1.0, "int", "eV"))
        
        with qr.energy_units("THz"):
            coup = agg.get_resonance_coupling(1,0)
        self.assertAlmostEqual(coup, qr.convert(1.0, "int", "THz"))
def spectral_density_of_type(self, ctype):
    print("spectral density type ", ctype)
    world.ctype = ctype

    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):
        sd = SpectralDensity(world.ta, params) 
    world.sd = sd   
def spectral_dens_from_corrfce(self):
    #params = world.params
    
    params = {"ftype":    world.ctype,
              "reorg":    world.reorg,
              "cortime":  world.ctime,
              "T":        world.temp,
              "matsubara":world.mats}
    ta = world.ta
    
    with energy_units(world.e_units):
        cf = CorrelationFunction(ta,params)
        
    world.sd = cf.get_SpectralDensity()
예제 #48
0
    def get_SpectralDensity(self, axis):

        #
        # Data from the paper
        #
        omegas = [36,   70,   117, 173, 185, 195, 237, 260, 284, 327,
                  365, 381, 479, 541, 565, 580, 635, 714, 723, 730,
                  747, 759, 768, 777, 819, 859, 896, 1158, 1176, 1216]
        fcfs   = [0.01, 0.01, 0.0055, 0.008, 0.008, 0.011, 0.005, 
                  0.0025, 0.005, 0.0015,
                  0.002, 0.002, 0.001, 0.001, 0.002, 0.001, 0.003,
                  0.002, 0.003, 0.001, 0.002, 0.002, 0.004, 0.0015,
                  0.002, 0.0025, 0.002, 0.004, 0.003, 0.002]
        
        #
        # Guessed dephasing times of the oscillators
        #
        gammas = [1.0/3000.0]*len(omegas)
        
        data = []
        for i in range(len(omegas)):
            data.append((omegas[i],fcfs[i],gammas[i]))
            
        #
        # All contributions consist of underdamped harmonic oscillators
        #
        params = dict(ftype="UnderdampedBrownian")
        
        #
        # Create and sum-up spectral densities
        #
        k = 0
        for d in data:
            
            params["freq"] = d[0]
            params["reorg"] = d[0]*d[1]
            params["gamma"] = d[2] #1.0/3000.0
            
            with energy_units("1/cm"):
                sd = SpectralDensity(axis, params)
                
            if k == 0:
                ret = sd
                ax = sd.axis
            else:
                sd.axis = ax
                ret = ret + sd
            k +=1

        return ret
예제 #49
0
    def test_calculate_resonance_coupling(self):
        """(Aggregate) Testing resonance coupling calculation by various methods
        
        """
        agg = TestAggregate(name="dimer-2-env")
        
        agg.calculate_resonance_coupling(method="dipole-dipole")        
        coup1 = agg.dipole_dipole_coupling(0,1)
        
        self.assertEqual(coup1, agg.resonance_coupling[1,0])
        
        with qr.energy_units("1/cm"):
            agg.calculate_resonance_coupling(method="dipole-dipole")        

        self.assertEqual(coup1, agg.resonance_coupling[1,0])
예제 #50
0
    def test_set_coupling_by_dipole_dipole(self):
        """(Aggregate) Testing dipole-dipole coupling calculation for the whole agregate
        
        """
        agg = TestAggregate(name="dimer-2-env")
        agg.set_coupling_by_dipole_dipole()

        coup1 = agg.dipole_dipole_coupling(0,1)
        self.assertAlmostEqual(coup1, agg.resonance_coupling[0,1])
        
        with qr.energy_units("1/cm"):
            agg.set_coupling_by_dipole_dipole()
            
        coup1 = agg.dipole_dipole_coupling(0,1)
        self.assertAlmostEqual(coup1, agg.resonance_coupling[0,1])
예제 #51
0
    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))
예제 #52
0
 def test_using_different_units(self):
     """Testing that 'energy_units' context manager works
     
     """
     # set value in 1/cm
     with energy_units("1/cm"):
         val = 100.0
         val2 = 50.0
         self.u.set_value(val)
         
         w = UnitsManagedObject()
         w.set_value(val2)
         
     # compare it in internal units
     self.assertEqual(self.u.value,val*cm2int)
     self.assertEqual(w.value,val2*cm2int)
예제 #53
0
 def test_set_resonance_coupling(self):        
     """(Aggregate) Testing resonance coupling setting with different units
     
     """
     agg = TestAggregate(name="dimer-2-env")
     agg.init_coupling_matrix()        
     
     agg.set_resonance_coupling(0, 1, 1.0)
     self.assertAlmostEqual(1.0, agg.resonance_coupling[0,1])
     self.assertAlmostEqual(1.0, agg.resonance_coupling[1,0])
     
     with qr.energy_units("1/cm"):
         agg.set_resonance_coupling(0, 1, 100.0)
     self.assertAlmostEqual(qr.convert(100.0, "1/cm", "int"),
                            agg.resonance_coupling[0,1])
     self.assertAlmostEqual(qr.convert(100.0, "1/cm", "int"),
                            agg.resonance_coupling[1,0])
예제 #54
0
    def get_SpectralDensity(self, axis):
    
        # Calling the spec dens calculated from b777 in rengers paper
        # alternative_form gives the polynomial version of the same spec dens
        # Jang, Newton, Silbey, J Chem Phys. 2007.
        params = {"ftype": "B777",
                  "reorg": 102.0,
                  "alternative_form": False}

        # Option of varying the paramaters of the Renger spec dens
        # values from the paper are set by default
        params.update({"freq1": 0.56,
                       "freq2": 1.9,
                        's1':   0.8,
                        's2':   0.5})

        with energy_units("1/cm"):
            sd = SpectralDensity(axis, params)

        return sd
예제 #55
0
 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()
예제 #56
0
def main():
    
    with qr.energy_units("1/cm"):
        mol1 = qr.Molecule([0.0, 12000.0])
        mol2 = qr.Molecule([0.0, 12100.0])
        mol3 = qr.Molecule([0.0, 12100.0])
        
        agg = qr.Aggregate([mol1, mol2, mol3])
    
        m1 = qr.Mode(100)
        mol1.add_Mode(m1)
        
        m2 = qr.Mode(100)
        mol2.add_Mode(m2)

        m3 = qr.Mode(100)
        mol3.add_Mode(m3)
        
    agg.build(mult=1)
    
    print(agg.Ntot)
예제 #57
0
def correlation_function_of_type(self, ctype):
    print("correlation function type ", ctype)
    world.ctype = ctype

    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) 
        
    i = 0
    data = numpy.zeros((world.ta.data.shape[0],3))
    for t in world.ta.data:
        data[i,0] = t
        data[i,1] = numpy.real(cf.data[i])
        data[i,2] = numpy.imag(cf.data[i])
        i += 1
    
    world.cf = cf
*
*
*          Evolution superoperator demo
*
*
***********************************************************
""")


import quantarhei as qr

qr.Manager().gen_conf.legacy_relaxation = True

print("Preparing a model system:")

with qr.energy_units("1/cm"):
    mol1 = qr.Molecule([0.0, 12000])
    mol2 = qr.Molecule([0.0, 12000])
    mol3 = qr.Molecule([0.0, 12100])
    mol4 = qr.Molecule([0.0, 12100])

agg = qr.Aggregate([mol1, mol2, mol3, mol4])
agg.set_resonance_coupling(2,3,qr.convert(100.0,"1/cm","int"))
agg.set_resonance_coupling(1,3,qr.convert(100.0,"1/cm","int"))

with tempfile.TemporaryDirectory() as tdir:
    path = os.path.join(tdir,"agg.qrp")
    qr.save_parcel(agg,path)
    agg2 = qr.load_parcel(path)
agg2.build()
 def _spectral_shape(self, f, par):
     a = par[0]
     fd = par[1]
     sig = par[2]
     with energy_units("1/cm"):
         return a*numpy.exp(-((f.data-fd)/sig)**2)