Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to extract DFT data #49

Closed
Rana-Phy opened this issue Apr 25, 2022 · 5 comments
Closed

Script to extract DFT data #49

Rana-Phy opened this issue Apr 25, 2022 · 5 comments

Comments

@Rana-Phy
Copy link

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
Copy link
Collaborator

mjwen commented Apr 26, 2022

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
Copy link
Author

Rana-Phy commented Jun 9, 2022

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/hcp_eos_'+str(count)+'.xyz', cell, species, coords, PBC, energy, forces)
count += 1
print(path)

print('finished')

@mjwen
Copy link
Collaborator

mjwen commented Jun 9, 2022

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.

@mjwen mjwen closed this as completed Jul 4, 2022
@LiMahappy
Copy link

亲爱的 ,

非常感谢您的建议。在这里,我附上了一个小脚本。只是想知道,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/hcp_eos_'+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
Copy link
Collaborator

mjwen commented May 9, 2024

Hi @LiMahappy, you might find a way to do it here: #177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants