def test_static_run_correction(self): shutil.copy("OSZICAR.empty", "OSZICAR") s1 = Structure.from_file("POSCAR") incar = Incar.from_file("INCAR") # Test for NSW 0 incar.update({"NSW": 0}) incar.write_file("INCAR") h = VaspErrorHandler("vasp.out") self.assertEqual(h.check(), True) d = h.correct() self.assertEqual(d['errors'], ['zpotrf']) s2 = Structure.from_file("POSCAR") self.assertAlmostEqual(s2.volume, s1.volume, 3) self.assertEqual(Incar.from_file("INCAR")["ISYM"], 0) # Test for ISIF 0-2 incar.update({"NSW":99, "ISIF":2}) incar.write_file("INCAR") h = VaspErrorHandler("vasp.out") self.assertEqual(h.check(), True) d = h.correct() self.assertEqual(d['errors'], ['zpotrf']) s2 = Structure.from_file("POSCAR") self.assertAlmostEqual(s2.volume, s1.volume, 3) self.assertEqual(Incar.from_file("INCAR")["ISYM"], 0)
def test_first_step(self): shutil.copy("OSZICAR.empty", "OSZICAR") s1 = Structure.from_file("POSCAR") h = VaspErrorHandler("vasp.out") self.assertEqual(h.check(), True) d = h.correct() self.assertEqual(d['errors'], ['zpotrf']) s2 = Structure.from_file("POSCAR") self.assertAlmostEqual(s2.volume, s1.volume * 1.2 ** 3, 3)
def test_potim_correction(self): shutil.copy("OSZICAR.one_step", "OSZICAR") s1 = Structure.from_file("POSCAR") h = VaspErrorHandler("vasp.out") self.assertEqual(h.check(), True) d = h.correct() self.assertEqual(d['errors'], ['zpotrf']) s2 = Structure.from_file("POSCAR") self.assertAlmostEqual(s2.volume, s1.volume, 3) self.assertAlmostEqual(Incar.from_file("INCAR")['POTIM'], 0.25)
import numpy as np from pymatgen.io.vasp import Structure, Outcar s: Structure = Structure.from_file('POSCAR') out = Outcar('OUTCAR') pDown: Structure = Structure.from_file('POSCAR') pOrigin: Structure = Structure.from_file('test_POSCAR/POSCAR') e = 1.60217646e-19 v = s.volume pol = np.zeros(3) b = out.born for i in range(len(b)): pol += np.dot(b[i], pDown.cart_coords[i] - pOrigin.cart_coords[i]) print(pol * e / v * 1e+22) # uC/cm^2
'GGA_COMPAT': '.False.', 'ISMEAR': 0, 'SIGMA': 0.05, 'GGA': 'PE', 'ENCUT': '280.00 eV', 'MAGMOM': '6*0.0', 'NBANDS': 24, } larray = array([[0,.5,.5], [.5,0,.5], [.5,.5,0]]) lattice = Lattice(larray * 6.058) species = ['In', 'As'] coords = [[0,0,0],[.25,.25,.25]] structure = Structure(lattice, species, coords, coords_are_cartesian=False) poscar = Poscar(structure, 'fcc InAs').as_dict() #~ potcar = Potcar.from_file(sys.argv[2]).as_dict() from os.path import abspath potcar = abspath(sys.argv[2]) kpoints = { 'comment': 'fcc InAs - selfconsistent', 'generation_style': 'Gamma', 'kpoints': [[8,8,8]], 'usershift': [0,0,0], } code = Code.get_from_string('vasp') calc = code.new_calc()
from pymatgen.io.vasp import Structure from pymatgen.core.sites import PeriodicSite p: Structure = Structure.from_file('POSCAR') i: PeriodicSite = None for i in p.sites: if 0.16 < i.c < 0.37 or 0.53 < i.c < 0.77: i._properties = {'selective_dynamics': [True] * 3} else: i._properties = {'selective_dynamics': [False] * 3} p.to('POSCAR', 'POSCAR')