def test_multiples(rrname, atoms): """Run multiple vibrational excitations""" om = 1 gam = 0.1 ao = Albrecht(atoms, H2MorseExcitedStates, name=rrname, overlap=True, combinations=2, approximation='Albrecht A', txt=None) aoi = ao.intensity(omega=om, gamma=gam) assert len(aoi) == 27
def test_summary(testdir, rrname, atoms): om = 1 gam = 0.1 with Albrecht(atoms, H2MorseExcitedStates, name=rrname, overlap=True, approximation='Albrecht B', txt=None) as ao: ao.summary(om, gam) with Albrecht(atoms, H2MorseExcitedStates, name=rrname, overlap=True, combinations=2, approximation='Albrecht A', txt=None) as ao: ao.extended_summary(om, gam)
def test_all_states(testdir, rrname, atoms): """Include degenerate states""" om = 1 gam = 0.1 with Albrecht(atoms, H2MorseExcitedStates, name=rrname, overlap=True, approximation='Albrecht A', txt=None) as ao: aoi = ao.get_absolute_intensities(omega=om, gamma=gam)[-1] with Albrecht(atoms, H2MorseExcitedStates, name=rrname, approximation='Albrecht A', txt=None) as al: ali = al.get_absolute_intensities(omega=om, gamma=gam)[-1] assert ali == pytest.approx(aoi, 1e-5)
def test_one_state(testdir, rrname, atoms): om = 1 gam = 0.1 with Albrecht(atoms, H2MorseExcitedStates, exkwargs={'nstates': 1}, name=rrname, overlap=True, approximation='Albrecht A', txt=None) as ao: aoi = ao.get_absolute_intensities(omega=om, gamma=gam)[-1] with Albrecht(atoms, H2MorseExcitedStates, exkwargs={'nstates': 1}, name=rrname, approximation='Albrecht A', txt=None) as al: ali = al.get_absolute_intensities(omega=om, gamma=gam)[-1] assert ali == pytest.approx(aoi, 1e-9)
def test_compare_placzek_albrecht_intensities(testdir): atoms = H2Morse() name = 'rrmorse' rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator, overlap=lambda x, y: x.overlap(y), name=name, txt='-') rmc.run() om = 1 gam = 0.1 pri, ali = 0, 0 """Albrecht A and P-P are approximately equal""" pr = Profeta(atoms, H2MorseExcitedStates, name=name, overlap=True, approximation='p-p', txt=None) pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] al = Albrecht(atoms, H2MorseExcitedStates, name=name, overlap=True, approximation='Albrecht A', txt=None) ali = al.get_absolute_intensities(omega=om, gamma=gam)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2) """Albrecht B+C and Profeta are approximately equal""" pr.approximation = 'Profeta' pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] al.approximation = 'Albrecht BC' ali = al.get_absolute_intensities(omega=om, gamma=gam)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2) """Albrecht and Placzek are approximately equal""" pr.approximation = 'Placzek' pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] al.approximation = 'Albrecht' ali = al.get_absolute_intensities(omega=om, gamma=gam)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2)
def test_compare_placzek_albrecht_intensities(): atoms = H2Morse() name = 'rrmorse' pr = Profeta(atoms, H2MorseExcitedStatesAndCalculator, approximation='Placzek', gsname=name, exname=name, overlap=lambda x, y: x.overlap(y), txt=None) pr.run() om = 1 pri, ali = 0, 0 """Albrecht A and P-P are approximately equal""" pr.approximation = 'p-p' pri = pr.absolute_intensity(omega=om)[-1] al = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, overlap=True, approximation='Albrecht A', txt=None) ali = al.absolute_intensity(omega=om)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2) """Albrecht B+C and Profeta are approximately equal""" pr.approximation = 'Profeta' pri = pr.absolute_intensity(omega=om)[-1] al.approximation = 'Albrecht BC' ali = al.absolute_intensity(omega=om)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2) """Albrecht and Placzek are approximately equal""" pr.approximation = 'Placzek' pri = pr.absolute_intensity(omega=om)[-1] al.approximation = 'Albrecht' ali = al.absolute_intensity(omega=om)[-1] print('pri, ali', pri, ali) assert pri == pytest.approx(ali, 1e-2)
def test_overlap(): name = 'rrmorse' atoms = H2Morse() om = 1 ao = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, overlap=lambda x, y: x.overlap(y), approximation='Albrecht A', txt=None) ao.run() """One state only""" ao = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, exkwargs={'nstates': 1}, gsname=name, exname=name, overlap=True, approximation='Albrecht A', txt=None) aoi = ao.absolute_intensity(omega=om)[-1] al = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, exkwargs={'nstates': 1}, gsname=name, exname=name, approximation='Albrecht A', txt=None) ali = al.absolute_intensity(omega=om)[-1] assert ali == pytest.approx(aoi, 1e-9) """Include degenerate states""" ao = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, overlap=True, approximation='Albrecht A', txt=None) aoi = ao.absolute_intensity(omega=om)[-1] al = Albrecht(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, approximation='Albrecht A', txt=None) ali = al.absolute_intensity(omega=om)[-1] # XXX this test sometimes fails for 1e-5 XXX # print(ali, aoi) assert ali == pytest.approx(aoi, 1e-2)
exkwargs=exkwargs, overlap=lambda x, y: Overlap(x).pseudo(y)) pz.run() # check size kss = KSSingles('rraman-d0.010.eq.ex.gz') assert (len(kss) == 1) om = 5 # Does Albrecht A work at all ? # ----------------------------- al = Albrecht(H2, KSSingles, gsname=gsname, exname=exname, verbose=True, overlap=True) ai = al.absolute_intensity(omega=om)[-1] i = al.intensity(omega=om)[-1] # parallel if world.size > 1 and world.rank == 0: # single core comm = DummyMPI() pzsi = Albrecht(H2, KSSingles, gsname=gsname, exname=exname, comm=comm,
pr = Profeta(H2, KSSingles, gsname=gsname, exname=exname, approximation='Placzek', txt=txt) pri = pr.absolute_intensity(omega=om)[-1] equal(pzi, pri, 0.1) pr = Profeta(H2, KSSingles, gsname=gsname, exname=exname, overlap=True, approximation='Placzek', txt=txt) pri = pr.absolute_intensity(omega=om)[-1] equal(pzi, pri, 0.1) """Albrecht and Placzek are approximately equal""" al = Albrecht(H2, KSSingles, gsname=gsname, exname=exname, overlap=True, approximation='Albrecht', txt=txt) ali = al.absolute_intensity(omega=om)[-1] equal(pzi, ali, 1.5) """Albrecht A and P-P are approximately equal""" pr = Profeta(H2, KSSingles, gsname=gsname, exname=exname, overlap=True, approximation='P-P', txt=txt) pri = pr.absolute_intensity(omega=om)[-1] al = Albrecht(H2, KSSingles, gsname=gsname, exname=exname, overlap=True, approximation='Albrecht A', txt=txt) ali = al.absolute_intensity(omega=om)[-1]