def test_overlap(testdir): """Test equality with and without overlap""" atoms = H2Morse() name = 'rrmorse' nstates = 3 with ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator, exkwargs={'nstates': nstates}, overlap=lambda x, y: x.overlap(y), name=name, txt='-') as rmc: rmc.run() om = 1 gam = 0.1 with Profeta(atoms, H2MorseExcitedStates, exkwargs={'nstates': nstates}, approximation='Placzek', overlap=True, name=name, txt='-') as po: poi = po.get_absolute_intensities(omega=om, gamma=gam)[-1] with Profeta(atoms, H2MorseExcitedStates, exkwargs={'nstates': nstates}, approximation='Placzek', name=name, txt=None) as pr: pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] print('overlap', pri, poi, poi / pri) assert pri == pytest.approx(poi, 1e-4)
def test_profeta_run(): atoms = H2Morse() name = 'profeta' pr = Profeta(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, txt='-') pr.run()
def test_compare_placzek_implementation_intensities(): """Intensities of different Placzek implementations should be similar""" atoms = H2Morse() name = 'placzek' pz = Placzek(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, txt=None) pz.run() om = 1 pzi = pz.absolute_intensity(omega=om)[-1] # Profeta using frozenset pr = Profeta(atoms, H2MorseExcitedStatesAndCalculator, approximation='Placzek', gsname=name, exname=name, txt=None) pri = pr.absolute_intensity(omega=om)[-1] assert pzi == pytest.approx(pri, 1e-3) # Profeta using overlap name = 'profeta' pr = Profeta(atoms, H2MorseExcitedStatesAndCalculator, approximation='Placzek', gsname=name, exname=name, overlap=lambda x, y: x.overlap(y), txt=None) pr.run() pro = pr.absolute_intensity(omega=om)[-1] assert pro == pytest.approx(pri, 1e-3)
def test_overlap(): """Test equality with and without overlap""" atoms = H2Morse() name = 'profeta' name = 'rrmorse' nstates = 3 po = Profeta(atoms, H2MorseExcitedStatesAndCalculator, exkwargs={'nstates': nstates}, approximation='Placzek', overlap=lambda x, y: x.overlap(y), gsname=name, exname=name, txt='-') po.run() om = 1 poi = po.absolute_intensity(omega=om)[-1] pr = Profeta(atoms, H2MorseExcitedStatesAndCalculator, exkwargs={'nstates': nstates}, approximation='Placzek', gsname=name, exname=name, txt=None) pri = pr.absolute_intensity(omega=om)[-1] print('overlap', pri, poi, poi / pri) assert pri == pytest.approx(poi, 1e-4)
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_compare_placzek_implementation_intensities(testdir): """Intensities of different Placzek implementations should be similar""" atoms = H2Morse() name = 'placzek' rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator, overlap=lambda x, y: x.overlap(y), name=name, txt='-') rmc.run() om = 1 gam = 0.1 pz = Placzek(atoms, H2MorseExcitedStates, name=name, txt=None) pzi = pz.get_absolute_intensities(omega=om, gamma=gam)[-1] print(pzi, 'Placzek') # Profeta using frozenset pr = Profeta(atoms, H2MorseExcitedStates, approximation='Placzek', name=name, txt=None) pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] print(pri, 'Profeta using frozenset') assert pzi == pytest.approx(pri, 1e-3) # Profeta using overlap pr = Profeta(atoms, H2MorseExcitedStates, approximation='Placzek', overlap=True, name=name, txt=None) pro = pr.get_absolute_intensities(omega=om, gamma=gam)[-1] print(pro, 'Profeta using overlap') assert pro == pytest.approx(pri, 1e-3)
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)
# on different nodes #overlap=lambda x, y: Overlap(x).full(y)[0], overlap=lambda x, y: Overlap(x).pseudo(y)[0], txt=txt) pz.run() # --------------------------------------------------- # check """Different Placzeck implementations should agree""" om = 5 pz = Placzek(H2, KSSingles, gsname=gsname, exname=exname, txt=txt) pzi = pz.absolute_intensity(omega=om)[-1] 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]