# How to redefine lattice by pymatgen

I am looking for a function or class in pymatgen that can redefine a lattice. For example, if the original lattice vectors of a structure are [[1, 0, 0], [0, 1, 0], [0, 0, 1]], I would like to transform them to [[1, 1, 0], [-1, 1, 0], [0, 0, 1]].

A straightforward approach might be to create a new lattice first and then add atoms into it. While creating the new lattice vectors is simple, I find it challenging to correctly place the atoms in the new structure. Could someone provide some guidance on how to achieve this?

Hi @jchddd, you’re probably looking for something like `pymatgen.transformations.standard_transformations.DeformStructureTransformation`. This function takes in a transformation matrix to alter the lattice and will update the ionic positions accordingly.

In your specific example, going from simple cubic (lattice = identity matrix) to the altered lattice matrix, the transformation matrix is `[[1, 1, 0], [-1, 1, 0], [0, 0, 1]]`, so you’d do (putting random atoms / sites so you can see the effect clearly):

``````from pymatgen.transformations.standard_transformations import DeformStructureTransformation
from pymatgen.core import Structure, Lattice
import numpy as np

s_cubic = Structure(
Lattice.cubic(3),
["Na","Li","Cl","F"],
[np.random.rand(3) for _ in range(4)]
)

dst = DeformStructureTransformation([[1.,1.,0], [-1.,1.,0], [0,0,1.]])
s_trans = dst.apply_transformation(s_cubic)
``````

Thanks for the help!! This is exactly what I need.