Skip to content

Read bond types from CIF file. #76

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lipelopesoliveira
Copy link

@lipelopesoliveira lipelopesoliveira commented Apr 22, 2025

Dear developers,

This PR introduces several updates that I found useful for setting up workflows involving LAMMPS simulations of crystal structures. I believe the community might find these changes valuable as well.

I’ve done my best to maintain backward compatibility and to modify only the minimum necessary parts of the code to avoid breaking existing functionality.

New features

Using bond types from CIF files instead of recalculating them.

Previously, although bond connectivity could be read from the CIF file, the bond types were always recalculated. This behavior could lead to undesired results in some applications. This PR adds a new option, bond_types_from_cif, when reading the cif file, which forces the code to use the bond types specified in the CIF file.

Example of use:

par = Parameters(os.path.join(cif_path, cif_name))
par.dump_lammpstrj = dump_lammpstrj

sim = LammpsSimulation(par)
cell, graph = from_CIF(par.cif_file, bond_types_from_cif=True)

When bond_types_from_cif=True, the bond_types_from_cif function is skipped. Additionally, a few modifications to the compute_init_typing function were also required to ensure that the atom hybridization is detected correctly.

Dump the final structure after minimization or relax simulations.

The LAMMPS input now contains a dump after minimization or relax simulations, creating a data.optimized file at the end of the simulation. This is especially convenient for parsing the optimized structure with the ASE library.

Optional check for small distances

The class MolecularGraph now has a check_distances attribute, which is True by default but can be set to False, allowing the user to force the creation of the LAMMPS input even if there are atoms to close.

Example of use:

par = Parameters(os.path.join(cif_path, cif_name))
par.dump_lammpstrj = dump_lammpstrj

sim = LammpsSimulation(par)
cell, graph = from_CIF(par.cif_file, bond_types_from_cif=True, check_distances=False)

Read CIF files with the ASE library

The ase_from_CIF function is now fully implemented, allowing users to read CIF files - including those with non-P1 symmetries - using ASE's read function as described in #5 .

Note

Due to ASE limitations, information about partial charges, custom atom types, and bond connectivity is not preserved when using this function. Still, it can be useful in many scenarios.

Example of use:

par = Parameters(os.path.join(cif_path, cif_name))
par.dump_lammpstrj = dump_lammpstrj

sim = LammpsSimulation(par)
cell, graph = ase_from_CIF(par.cif_file, check_distances=True)

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

Successfully merging this pull request may close these issues.

1 participant