File: no_spin_and_spin.py

package info (click to toggle)
python-ase 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,192 kB
  • ctags: 8,112
  • sloc: python: 93,375; sh: 99; makefile: 94
file content (19 lines) | stat: -rw-r--r-- 486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from ase.build import molecule
from ase import io
from gpaw import GPAW

txt = 'out.txt'
if 1:
    calculator = GPAW(h=0.3, txt=txt)
    atoms = molecule('H2', calculator=calculator)
    atoms.center(vacuum=3)
    atoms.get_potential_energy()

    atoms.set_initial_magnetic_moments([0.5, 0.5])
    calculator.set(charge=1)
    atoms.get_potential_energy()

# read again
t = io.read(txt, index=':')
assert isinstance(t, list)
assert abs(t[1].get_magnetic_moments() - 0.5).sum() < 1e-14