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_names(testdir): """Test different gs vs excited name. Tests also default names.""" # do a Vibrations calculation first atoms = H2Morse() vib = Vibrations(atoms) vib.run() assert '0x-' in vib.cache # do a Resonant Raman calculation rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator, verbose=True) rmc.run() # excitation files should reside in the same directory as cache files assert (Path(rmc.name) / ('ex.eq' + rmc.exext)).is_file() # XXX does this still make sense? # remove the corresponding pickle file, # then Placzek can not anymore use it for vibrational properties key = '0x-' assert key in rmc.cache del rmc.cache[key] # make sure this is not used om = 1 gam = 0.1 pz = Placzek(atoms, H2MorseExcitedStates, name='vib', exname='raman') pzi = pz.get_absolute_intensities(omega=om, gamma=gam)[-1] parprint(pzi, 'Placzek') # check that work was distributed correctly assert len(pz.myindices) <= -(-6 // world.size)
def test_summary(testdir): atoms = H2Morse() rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator) rmc.run() pz = Placzek(atoms, H2MorseExcitedStates) pz.summary(1.)
def test_names(): """Test different gs vs excited name. Tests also default names.""" # do a Vibrations calculation first atoms = H2Morse() Vibrations(atoms).run() assert os.path.isfile('vib.0x-.pckl') # do a Resonant Raman calculation rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator, verbose=True) rmc.run() # remove the corresponding pickle file, # then Placzek can not anymore use it for vibrational properties assert os.path.isfile('raman.0x-.pckl') os.remove('raman.0x-.pckl') # make sure this is not used om = 1 gam = 0.1 pz = Placzek(atoms, H2MorseExcitedStates, name='vib', exname='raman') pzi = pz.get_absolute_intensities(omega=om, gamma=gam)[-1] parprint(pzi, 'Placzek') # check that work was distributed correctly assert len(pz.myindices) <= -(-6 // world.size)
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_placzek_run(): atoms = H2Morse() name = 'placzek' pz = Placzek(atoms, H2MorseExcitedStatesAndCalculator, gsname=name, exname=name, txt='-') pz.run()
R = 0.7 # approx. experimental bond length a = 4.0 c = 5.0 H2 = Atoms([ Atom('H', (a / 2, a / 2, (c - R) / 2)), Atom('H', (a / 2, a / 2, (c + R) / 2)) ], cell=(a, a, c)) calc = GPAW(xc=xc, nbands=3, spinpol=False, eigensolver='rmm-diis', txt=txt) H2.set_calculator(calc) H2.get_potential_energy() gsname = exname = 'rraman' exkwargs = {'eps': 0.0, 'jend': 1} pz = Placzek(H2, KSSingles, gsname=gsname, exname=exname, exkwargs=exkwargs) pz.run() # --------------------------------------------------- # check # check size kss = KSSingles('rraman-d0.010.eq.ex.gz') assert (len(kss) == 1) om = 5 pz = Placzek( H2, KSSingles, gsname=gsname, exname=exname,
gsname = exname = 'rraman' exkwargs={'eps':0.0, 'jend':3} if 1: calc = GPAW(xc=xc, nbands=7, convergence={'bands':3}, spinpol=False, #eigensolver='rmm-diis', txt=txt) H2.set_calculator(calc) #H2.get_potential_energy() pz = Placzek(H2, KSSingles, gsname=gsname, exname=exname, exkwargs=exkwargs, # XXX full does not work in parallel due to boxes # 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,