openkim / kliff

KIM-based Learning-Integrated Fitting Framework for interatomic potentials.
https://kliff.readthedocs.io
GNU Lesser General Public License v2.1
34 stars 20 forks source link

Script to extract DFT data #49

Closed Rana-Phy closed 2 years ago

Rana-Phy commented 2 years ago

Dear Developers,

Thanks for Kliff. Would you shear the script to extract vasp data from outcar or xml file? I am seeing that etxyz file generated by ase is not working.

Waiting for reply.

Best regards, Rana

mjwen commented 2 years ago

Yes, the default extxyz file written by ASE may not work since it does not contain certain info needed by KLIFF.

KLIFF does not distribute scripts to parse VASP outputs. There are many existing excellent packages to do it, like ASE you've mentioned. Another widely used package is pymatgen, see its OUTCAR parser here.

To solve your problem, you can use ASE or pymatgen to parse VASP output, and then use the KLIFF write_extxyz function to write out to extxyz files.

Rana-Phy commented 2 years ago

Dear @mjwen ,

Thank you very much for your suggestions. Here I attached a tiny script. Just want to know, does PBC has any significance in training.

Best regards, Rana

from glob import glob import numpy as np from pathlib import Path from pymatgen.io.vasp.outputs import Vasprun from kliff.dataset import write_extxyz as wrk

mkdir kliff_data

working_dir = Path() count=0 for path in working_dir.glob("*/.xml"): data = Vasprun(path, exception_on_bad_xml=False) d=data.ionic_steps[-1]['structure'].as_dict() cell=d['lattice']['matrix'] coords=data.final_structure.cart_coords species=data.atomic_symbols energy=data.ionic_steps[-1]['e_wo_entrp'] forces=np.array(data.ionic_steps[-1]['forces']) PBC=[1, 1, 1] wrk('./kliff_data/hcpeos'+str(count)+'.xyz', cell, species, coords, PBC, energy, forces) count += 1 print(path)

print('finished')

mjwen commented 2 years ago

The above code seems fine to me that it will correctly create the extxyz files. In general, PBC should matter, you should use whatever PBC you used in your DFT calculation. Typically, DFT calculations use PBCs. Specifically, pymatgen assumes PBC is always on and thus it does not provide a PBC property in the Vasprun object. So the use of PBC=[1,1,1] has no problem.

LiMahappy commented 4 months ago

亲爱的 ,

非常感谢您的建议。在这里,我附上了一个小脚本。只是想知道,PBC在培训中有什么意义吗?

最好的问候,拉纳

from glob import glob import numpy as np from pathlib import Path from pymatgen.io.vasp.outputs import Vasprun from kliff.dataset import write_extxyz as wrk

mkdir kliff_data

working_dir = working_dir.glob(“*/.xml”) 中的路径 count=0: data = Vasprun(path, exception_on_bad_xml=False) d=data.ionic_steps[-1]['结构'].as_dict() cell=d['格子']['矩阵'] coords=data.final_structure.cart_coords 物种=data.atomic_symbols 能量=data.ionic_steps[-1]['e_wo_entrp'] 力=np.array(data.ionic_steps[-1]['力']) PBC=[1, 1, 1] wrk('./kliff_data/hcpeos'+str(count)+'.xyz', cell, species, coords, PBC, energy, forces) count += 1 print(path)

打印('完成')

Hello, I'm sorry for the disturbance. Could you please tell me how you parse the output from VASP? After I performed an AIMD calculation, running your script only resulted in a single file. As I am a beginner, could you inform me of the specific steps? I am looking forward to your reply.

mjwen commented 4 months ago

Hi @LiMahappy, you might find a way to do it here: https://github.com/openkim/kliff/issues/177