ulissigroup / vasp-interactive

GNU Lesser General Public License v2.1
53 stars 11 forks source link

Prevent wrong energy / force when system symmetry changes #17

Closed alchem0x2A closed 2 years ago

alchem0x2A commented 2 years ago

A serious and hidden bug in VaspInteractive is when the initial symmetry of the input atoms decreases in further inputs. In some cases the VASP wavefunction still converges but the energy and force outputs are erroneous.

Two possible solutions:

  1. Always use ISYM=0 in the input file as recommended in VASP for MD simulations
  2. make internal check of symmetry deterioration in VaspInteractive. However can be tricky.

Current work is to make ISYM=0 as default and test speed / robustness

alchem0x2A commented 2 years ago

A simple testing case: perfect graphene lattice --> distorted

from ase.build import graphene
from vasp_interactive import VaspInteractive
from ase.calculators.vasp import Vasp
gr = graphene(vacuum=10)
gr.pbc = True
print("Testing VaspInter with reducing symmetry")
vasp_params = dict(xc="pbe", kpts=(5, 5, 1), gamma=True)
calc1 = VaspInteractive(directory="gr", **vasp_params)
with calc1:
    gr1 = gr.copy()
    gr1.calc = calc1
    print(gr1.get_potential_energy())
    gr1[-1].x += 0.5
    print(gr1.get_potential_energy())

print("Testing Normal VASP with reducing symmetry")
calc2 = Vasp(directory="gr-vasp", **vasp_params)
gr2 = gr.copy()
gr2.calc = calc2
print(gr2.get_potential_energy())
gr2[-1].x += 0.5
print(gr2.get_potential_energy())

print("Testing VaspInteractive with disabled symmetry setting")
with calc1:
    calc1.set(isym=0)
    gr3 = gr.copy()
    gr3.calc = calc1
    print(gr3.get_potential_energy())
    gr3[-1].x += 0.5
    print(gr3.get_potential_energy())

Output is

Testing VaspInter with reducing symmetry
-18.43911914
-26.98397736
Testing Normal VASP with reducing symmetry
-18.43912066
-11.27409555
Testing VaspInteractive with disabled symmetry setting
-18.43890405
-11.27436128