File: test_nwchem_broken_symmetry.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (50 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Check if we can deal with spin-broken symmetries."""
from numpy import array
import pytest
from ase import Atoms


@pytest.mark.calculator('nwchem')
def test_main(factory):
    """Perform C_{\\inf v} calculation on Cr_2."""
    # PBE from
    # J. Chem. Phys. 112 , 5576 (2000)
    # https://doi.org/10.1063/1.481183
    e_literature = -1.34

    names = ['Cr2_sp_up.mos',
             'Cr2_sp_down.mos']
    fragment_energies = array([.0] * 2)
    cr_atom = Atoms('Cr', positions=[(0, 0, 0)], pbc=False)
    for orientation in range(2):    # create two fragments
        imm = 6 * (-1)**orientation
        cr_atom.set_initial_magnetic_moments([imm])
        calc = factory.calc(
            task='energy', xc='pbe', theory='dft',
            dft=dict(convergence=dict(energy=1e-3,
                                      density=1e-2,
                                      gradient=5e-2),
                     vectors='input atomic output {}'
                     .format(names[orientation])),
            charge=0,
            basis='"DZVP2 (DFT Orbital)"'
        )
        cr_atom.calc = calc
        fragment_energies[orientation] = cr_atom.get_potential_energy()
    cr_dimer = Atoms('Cr2', positions=[(0, 0, 0), (0, 0, 1.93)], pbc=False)
    cr_dimer.set_initial_magnetic_moments([0, 0])
    calc = factory.calc(
        task='energy', xc='pbe', theory='dft',
        dft=dict(convergence=dict(energy=1e-3,
                                  density=1e-2,
                                  gradient=5e-2),
                 odft=None,
                 vectors='input fragment {} output Cr2_AF.mos'
                 .format(' '.join(names))),
        basis='"DZVP2 (DFT Orbital)"',
        charge=0
    )
    cr_dimer.calc = calc
    e_dimer = cr_dimer.get_potential_energy()
    e_tot = e_dimer - fragment_energies.sum()
    assert abs(e_tot - e_literature) < 0.01