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

sanitize_non_periodic_structure does not update the lattice vectors of the cell #415

Open
bananenpampe opened this issue Jul 13, 2022 · 0 comments

Comments

@bananenpampe
Copy link

bananenpampe commented Jul 13, 2022

Heyhey,
I don't know, if this function is still in use, but:
The helperfunction rascal.neighbourlist.structure_manager.sanitize_non_periodic_structure is intended to wrap nonperiodic structures and calculate lattice cell vectors for a unit cell that wraps up the whole molecule, but then does not update the cell parameters.

    def sanitize_non_periodic_structure(structure):
    """
    Rascal expects a unit cell that contains all the atoms even if the
    structure is not periodic.
    If the cell is set to 0 and the structure is not periodic then it
    is adapted to contain the atoms and the atoms are shifted inside the unit
    cell.
    Parameters
    ----------
    structure : a valid structure as per is_valid_structure
    Returns
    -------
    a valid structure as per is_valid_structure
        cell and positions have been modified if structure is not periodic
    """

    if np.all(structure["pbc"] == 0):
        cell = structure["cell"]
        if np.allclose(cell, np.zeros((3, 3))):
            pos = structure["positions"]
            bounds = np.array([pos.min(axis=1), pos.max(axis=1)])
            bounding_box_lengths = (bounds[1] - bounds[0]) * 1.05
            print(bounding_box_lengths)
            new_cell = np.diag(bounding_box_lengths)
            CoM = pos.mean(axis=1)
            disp = 0.5 * bounding_box_lengths - CoM
            new_pos = pos + disp[:, None]
            structure["positions"] = new_pos
            #update cell parameters here
    return structure
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

1 participant