First, we specify which rotation-axis, Σ value, and structure we will be using for the mixed grain boundary.
from aimsgb import GrainBoundary, Grain, Lattice axis = [0, 0, 1] sigma = 5 initial_struct = Grain.from_file("POSCAR_MgO")
Next, we create supercells of tilt and twist grain boundaries which will later be combined together to create the mixed grain boundary. To do this, we create grain boundary structures then convert them to grain objects for subsequent structural manipulations.
gb_tilt = GrainBoundary(axis, sigma, [1,2,0], initial_struct) gb_twist = GrainBoundary(axis, sigma, [0,0,1], initial_struct) grain_tilt = Grain.from_sites(gb_tilt.build_gb(to_primitive=False)[:]) grain_tilt.make_supercell([1,1,2]) grain_twist = Grain.from_sites(gb_twist.build_gb(to_primitive=False)[:]) grain_twist.make_supercell([1,2,1])
Once the supercells are created, we need to update the lattice parameters to create space for the atoms of the other cell to fit into each cell. Essentially, an empty space is created once the lattice parameters are increased. The atoms of the other cell will fill this empty space once the two cells are combined. Once the new lattice is obtained, it is used to update the fractional coordinates of the tilt and twist grain boundaries. In the case of the twist grain, we shift the cartesian coordinates over by the lattice parameter of the tilt grain so that the atoms do not overlap when the cells are combined. Once the fractional coordinates and lattice parameters are obtained, they are used to create Grain objects.
abc_tilt = list(grain_tilt.lattice.abc) abc_twist, angles = list(grain_twist.lattice.lengths_and_angles) abc_tilt += abc_twist new_lat = Lattice.from_lengths_and_angles(abc_tilt, angles) twist_fcoords = new_lat.get_fractional_coords( grain_twist.cart_coords + [grain_tilt.lattice.abc,0,0]) tilt_fcoords = new_lat.get_fractional_coords(grain_tilt.cart_coords) grain_tilt = Grain(new_lat, grain_tilt.species, tilt_fcoords) grain_twist = Grain(new_lat, grain_twist.species, twist_fcoords)
Finally, the Grain objects are used to create the mixed grain boundary structure. This mixed grain boundary structure can then be written to a file.
abc_tilt = list(grain_tilt.lattice.abc) grain_mixed = Grain.from_sites(grain_tilt[:] + grain_twist[:]) grain_mixed = grain_mixed.get_sorted_structure() grain_mixed.to(filename="grain_mixed.vasp",fmt="poscar")