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

Feature Request: Integration with ASE #6

Closed
ichibha opened this issue Jan 30, 2024 · 6 comments
Closed

Feature Request: Integration with ASE #6

ichibha opened this issue Jan 30, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@ichibha
Copy link

ichibha commented Jan 30, 2024

It would be greatly appreciated if structures could be obtained as an array of ASE's Atoms. Since VASP is frequently paired with ASE, implementing this feature could lead to wider application of SHRY.

@kousuke-nakano kousuke-nakano self-assigned this Jan 30, 2024
@kousuke-nakano kousuke-nakano added the enhancement New feature or request label Jan 30, 2024
@kousuke-nakano
Copy link
Contributor

Dear @ichibha, thank you for your request. I will try to implement it.

@kousuke-nakano
Copy link
Contributor

Dear @ichibha, I have an idea for implementing this. Would you help me?

I need a function to convert a pymatgen structure to the corresponding ASE atoms such as:

from pymatgen_struct_to_ase_atoms(structure: pymatgen's structure) -> atoms: ASE's atoms

Would you try to implement it?

@ichibha
Copy link
Author

ichibha commented Jan 30, 2024

@kousuke-nakano Thank you for your willingness to work on this issue. The pymatgen Structure object can be converted into an ASE Atoms object using the following function:

from pymatgen.core import Structure
from ase import Atoms


def pymatgen_struct_to_ase_atoms(structure: Structure) -> Atoms:
    return Atoms(
        symbols=[specie.symbol for specie in structure.species],
        positions=structure.cart_coords,
        cell=structure.lattice.matrix,
        pbc=True,
    )


if __name__ == "__main__":
    for label in ["cartesian", "fractional"]:
        structure = Structure.from_file(f"{label}.vasp")
        atoms = convert_structure_to_atoms(structure)
        atoms.write(f"{label}_converted.vasp")

I attach the files used to verify the code.

submit.zip

@kousuke-nakano
Copy link
Contributor

Dear @ichibha, Thanks. I have implemented it. Would you have a look at my pull request #7? I have added a new example example5.py. I would appreciate if you would confirm that SHRY works as you expected.

@ichibha
Copy link
Author

ichibha commented Jan 31, 2024

Dear @kousuke-nakano, Thank you for your correspondence. The code works as I expected. I will make a suggestion with my expected behavior from the next time.

@kousuke-nakano
Copy link
Contributor

Dear @ichibha, thanks. We will include this feature to the next release.

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