How to have scale_atoms=True, but scale the atoms only in the xy plane?

Hi,
Consider a cubic unit cell of size, say 5 Angstroms. I now need to build a unit cell of size 5.5 Angstroms, for which I use set_cell routine with scale_atoms=True. But I do not want the atoms to be scaled along the z direction. Is there a way to turn off scale_atoms along a particular direction?
Thank you.

Hi,
If you mean that you want to expand the atoms only in the xy plane but fix the positions at z axis, you could try these two steps.

  • First, use atoms.set_cell([5.5, 5.5, 5.0], scale_atoms=True) to change the first two axes.
  • Second, create an empty cell with a 5.5 Angstroms z axis by atoms = Atoms(cell=[5.5, 5.5, 5.5]). Then you can use append method of Atoms instances to add atoms to the new created Atoms instance from the old one.

Example codes:

from ase import Atoms
# suppose A is your current structure
A.set_cell([5.5, 5.5, 5.0], scale_atoms=True)`
# B is the new one with a larger z axis
B = Atoms(cell=[5.5, 5.5, 5.5])
for atom in A:
    B.append(atom)

One can also do A.cell[2, 2] = 5.5 after the set_cell() in the above example. That directly edits the cell vector coordinate without changing the positions, and it won’t be necessary to build a new atoms object.

1 Like