Пример #1
0
def test_summary(testdir):
    atoms = H2Morse()
    rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator)
    rmc.run()

    pz = Placzek(atoms, H2MorseExcitedStates)
    pz.summary(1.)
Пример #2
0
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)
Пример #3
0
def test_overlap():
    """Test equality with and without overlap"""
    atoms = H2Morse()
    name = 'rrmorse'
    nstates = 3
    rmc = ResonantRamanCalculator(atoms,
                                  H2MorseExcitedStatesCalculator,
                                  exkwargs={'nstates': nstates},
                                  overlap=lambda x, y: x.overlap(y),
                                  name=name,
                                  txt='-')
    rmc.run()

    om = 1
    gam = 0.1
    po = Profeta(atoms,
                 H2MorseExcitedStates,
                 exkwargs={'nstates': nstates},
                 approximation='Placzek',
                 overlap=True,
                 name=name,
                 txt='-')
    poi = po.get_absolute_intensities(omega=om, gamma=gam)[-1]

    pr = Profeta(atoms,
                 H2MorseExcitedStates,
                 exkwargs={'nstates': nstates},
                 approximation='Placzek',
                 name=name,
                 txt=None)
    pri = pr.get_absolute_intensities(omega=om, gamma=gam)[-1]

    print('overlap', pri, poi, poi / pri)
    assert pri == pytest.approx(poi, 1e-4)
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
def rrname(atoms):
    """Prepare the Resonant Raman calculation"""
    name = 'rrmorse'
    rmc = ResonantRamanCalculator(atoms, H2MorseExcitedStatesCalculator,
                                  overlap=lambda x, y: x.overlap(y),
                                  name=name, txt='-')
    rmc.run()
    return name
Пример #7
0
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)
Пример #8
0
from ase.calculators.h2morse import (H2Morse, H2MorseExcitedStatesCalculator)
from ase.vibrations.resonant_raman import ResonantRamanCalculator

atoms = H2Morse()
rmc = ResonantRamanCalculator(atoms,
                              H2MorseExcitedStatesCalculator,
                              overlap=lambda x, y: x.overlap(y))
rmc.run()
Пример #9
0
from ase.vibrations.resonant_raman import ResonantRamanCalculator

from gpaw.cluster import Cluster
from gpaw import GPAW, FermiDirac
from gpaw.lrtddft import LrTDDFT

h = 0.25
atoms = Cluster('relaxed.traj')
atoms.minimal_box(3.5, h=h)

# relax the molecule
calc = GPAW(h=h, occupations=FermiDirac(width=0.1),
            eigensolver='cg', symmetry={'point_group': False},
            nbands=10, convergence={'eigenstates': 1.e-5,
                                    'bands': 4})
atoms.calc = calc

# use only the 4 converged states for linear response calculation
rmc = ResonantRamanCalculator(atoms, LrTDDFT,
                              exkwargs={'restrict': {'jend': 3}})
rmc.run()
Пример #10
0
from gpaw.cluster import Cluster
from gpaw import GPAW, FermiDirac
from gpaw.lrtddft import LrTDDFT
from gpaw.analyse.overlap import Overlap

h = 0.25
atoms = Cluster('relaxed.traj')
atoms.minimal_box(3.5, h=h)

# relax the molecule
calc = GPAW(h=h,
            occupations=FermiDirac(width=0.1),
            symmetry={'point_group': False},
            nbands=10,
            convergence={
                'eigenstates': 1.e-5,
                'bands': 4
            })
atoms.calc = calc

# use only the 4 converged states for linear response calculation
rmc = ResonantRamanCalculator(atoms,
                              LrTDDFT,
                              name='rroverlap',
                              exkwargs={'restrict': {
                                  'jend': 3
                              }},
                              overlap=lambda x, y: Overlap(x).pseudo(y)[0])
rmc.run()