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

anyway to read energy, force and stress from extxyz? #87

Closed
thangckt opened this issue Sep 11, 2024 · 7 comments
Closed

anyway to read energy, force and stress from extxyz? #87

thangckt opened this issue Sep 11, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@thangckt
Copy link
Contributor

thangckt commented Sep 11, 2024

Dear Developers,

I try to use SevenNet with initial data in extxyz format.
The problem is that I cannot process the data when your implemetation eventually required an ase.calculator to compute quantities.

You may be awared that extxyz can store per-config and per-atom properties like energy, stress, forces,..

So my question is anyway to read such properties without need to compute with an ase.calculator? (I know how to get them from ase.Atoms. This link is the way they are read in MACE suit)

Thanks.

@YutackPark
Copy link
Member

Have you tried sevenn_inference? Currently the sevenn_inference does not save the result (what SevenNet predicted) to .extxyz format but it gives '.csv' files and does not require ase.calculator to evaluate. sevenn_inference can be used vai command line interface only.

Before using sevenn_inference, you may need to convert .extxyz to POSCAR, or you should download a the latest version of SevenNet (in main branch)

or if this is not the answer you wanted could you explain in more detail?

@thangckt
Copy link
Contributor Author

hi @YutackPark

I mean I have a dataset in extxyz format (already contains energy and atomic forces from DFT calculations). How to feed it into 7Net to train model.

Thanks

@YutackPark
Copy link
Member

Hi, SevenNet can directly read .extxyz files for training.

https://github.com/MDIL-SNU/SevenNet/blob/main/sevenn%2Fpresets%2Fbase.yaml

You can put your .extxyz files into load_dataset_path in the above example. As it will try to preprocessing the data first, which might be time-consuming, you may want to separate preprocessing step using sevenn_graph_build.

@thangckt
Copy link
Contributor Author

thangckt commented Sep 12, 2024

hi @YutackPark

Thank you for your guide.
I did exactly what you figure out.

I as understand, sevenn_graph_build will use ase.io.read to read extxyz file into ase.Atoms. After that, convert them into 7Net dataset.
And the problem may come from this part of your code.

    try:
        y_energy = atoms.get_potential_energy(force_consistent=True)
    except NotImplementedError:
        y_energy = atoms.get_potential_energy()
    y_force = atoms.get_forces(apply_constraint=False)
    try:
        # xx yy zz xy yz zx order
        # We expect this is eV/A^3 unit
        # (ASE automatically converts vasp kB to eV/A^3)
        # So we restore it
        y_stress = -1 * atoms.get_stress()
        y_stress = np.array([y_stress[[0, 1, 2, 5, 3, 4]]])
    except RuntimeError:
        y_stress = None

function atoms.get_potential_energy() will require a calculator, and throw error if atoms have no one.

May I wrong?

@YutackPark
Copy link
Member

YutackPark commented Sep 12, 2024

I understood what you want to do. If that's the case, there is no direct way to achieve what you are trying to do, as SevenNet doesn't know how the extxyz stored their energy, force, and stress that is not stored with a calculator.

To make things work, a python script is needed to re-stored the data into atoms object, this time with the SinglePointCalculator. It might seem tricky for the first time, but we have related issue and example below.

Check my first answer of this issue: #61

You can store your EFS with the SinglePointCalculator. Then you save your atoms objects into .extxyz again, and feed it to the SevenNet. Note that you need to put extra care in its units and sign of stress.

@YutackPark
Copy link
Member

While #89 is merged, it is limited to sevenn_graph_build. Similar functionality should be developed for sevenn_inference and the training. This may be done during #86.

@YutackPark
Copy link
Member

#98

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

No branches or pull requests

2 participants