pyiron_atomistics icon indicating copy to clipboard operation
pyiron_atomistics copied to clipboard

Lammps box tilt large in interactive mode

Open Leimeroth opened this issue 2 years ago • 5 comments

When calculating energies and forces for many structures using lammps in interactive mode I got a box skew too large error. This could be fixed by adding "box tilt large" too the control.inp file For this purpose I tried to add block_dict["box_commands"] = "box" at the start of the block_dict of lammps control.

This however leads to the following error: Exception: ERROR: Box command after simulation box is defined

exemplary code of what I am trying to do:

lmp = pr.create.job.Lammps("InteractiveEF")
  lmp.server.run_mode.interactive = True
  lmp.interactive_enforce_structure_reset = True
  lmp.potential = potential
  ids = []
  energies = []
  forces = []
  for structure in structure_list:
      lmp.structure = structure
      lmp.input.control["neigh_modify"] = "page 100000 one 10000"
      lmp.run()
      energies.append(lmp.interactive_energy_pot_getter())
      forces.append(lmp.interactive_forces_getter())

  lmp.interactive_close()

Is there any way to correctly apply "box tilt large" in interactive mode?

Leimeroth avatar May 18 '22 13:05 Leimeroth

I've ran into this before. My workaround is to apply this function

def structure_to_lammps(structure):
    """
    Converts a structure to the Lammps coordinate frame

    Args:
        structure (pyiron.atomistics.structure.atoms.Atoms): Structure to convert.

    Returns:
        pyiron.atomistics.structure.atoms.Atoms: Structure with the LAMMPS coordinate frame.
    """
    prism = UnfoldingPrism(structure.cell)
    lammps_structure = structure.copy()
    lammps_structure.set_cell(prism.A)
    lammps_structure.positions = np.matmul(structure.positions, prism.R)
    return lammps_structure

before setting the structure to the interactive job. This the logic that gets applied when setting a structure to a normal job, but for some reason is not correctly applied when the job is interactive. I tried to put this in but got frustrated by the interactive class hierarchy, so I left it for now.

pmrv avatar May 18 '22 13:05 pmrv

For the energy it should not matter, but can you retrieve correct forces for the old positions from this?

Leimeroth avatar May 18 '22 13:05 Leimeroth

I have never checked, but given that new and the old structure should be equivalent and that the ordering of the atoms doesn't change, I don't see why not.

pmrv avatar May 18 '22 13:05 pmrv

Maybe we could add a flag to the lammps interactive mode which automatically applies this transformation, as I have the feeling this issue comes up from time to time again.

jan-janssen avatar May 18 '22 14:05 jan-janssen

Maybe we could add a flag to the lammps interactive mode which automatically applies this transformation, as I have the feeling this issue comes up from time to time again.

This sounds like a good idea

Leimeroth avatar May 18 '22 17:05 Leimeroth