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)
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)
# 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, overlap=True, verbose=True) isi = pzsi.intensity(omega=om)[-1]