From 7f4dfd4b783d66f691d468f1c790f11a6b002962 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Thu, 7 Sep 2023 10:41:42 -0700 Subject: [PATCH 1/4] Update to Grain.stack_grains per aimsgb deprecation warning Along with some signature and docstring updates --- structuretoolkit/build/aimsgb.py | 55 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/structuretoolkit/build/aimsgb.py b/structuretoolkit/build/aimsgb.py index 2842ca6a0..ae04a284f 100644 --- a/structuretoolkit/build/aimsgb.py +++ b/structuretoolkit/build/aimsgb.py @@ -2,6 +2,8 @@ # Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department # Distributed under the terms of "New BSD License", see the LICENSE file. +from warnings import warn + from structuretoolkit.common.pymatgen import ase_to_pymatgen, pymatgen_to_ase __author__ = "Ujjal Saikia" @@ -45,14 +47,17 @@ def grainboundary( sigma, plane, initial_struct, - to_primitive=False, - delete_layer="0b0t0b0t", - add_if_dist=0.0, uc_a=1, uc_b=1, + vacuum=0.0, + gap=0.0, + delete_layer="0b0t0b0t", + tol=0.25, + to_primitive=False, + add_if_dist=None, ): """ - Generate a grain boundary structure based on the aimsgb.GrainBoundary module. + Generate a grain boundary structure based on aimsgb. Args: axis : Rotational axis for the GB you want to construct (for example, axis=[1,0,0]) @@ -60,28 +65,39 @@ def grainboundary( plane: The grain boundary plane of the GB you want to construct (for example, plane=[2,1,0]) initial_struct : Initial bulk structure from which you want to construct the GB (a ase structure object). - delete_layer : To delete layers of the GB. For example, delete_layer='1b0t1b0t'. The first + uc_a (int): Number of unit cell of grain A. (Default is 1.) + uc_b (int): Number of unit cell of grain B. (Default is 1.) + vacuum (float): Adds space between the grains at _one_ of the two interfaces + that must exist due to periodic boundary conditions. (Default is 0.0.) + gap (float): Adds space between the grains at _both_ of the two interfaces + that must exist due to periodic boundary conditions. When used together with + `vacuum`, these spaces add at one of the two interfaces. (Default is 0.0.) + delete_layer (str) : To delete layers of the GB. For example, `delete_layer='1b0t1b0t'`. The first 4 characters is for first grain and the other 4 is for second grain. b means bottom layer and t means top layer. Integer represents the number of layers to be deleted. The first t and second b from the left hand side represents - the layers at the GB interface. Default value is delete_layer='0b0t0b0t', which + the layers at the GB interface. Default value is `delete_layer='0b0t0b0t'`, which means no deletion of layers. - add_if_dist : If you want to add extra interface distance, you can specify add_if_dist. - Default value is add_if_dist=0.0 - to_primitive : To generate primitive or non-primitive GB structure. Default value is - to_primitive=False - uc_a (int): Number of unit cell of grain A. Default to 1. - uc_b (int): Number of unit cell of grain B. Default to 1. + tol (float): Tolerance factor (in distance units) to determine whether two atoms + are in the same plane. (Default is 0.25.) + to_primitive : To generate primitive or non-primitive GB structure. (Default + value is False.) + add_if_dist (float): (Deprecated) Use `gap`. Returns: - :class:`.Atoms`: final grain boundary structure + :class:`ase.Atoms`: final grain boundary structure """ from aimsgb import GrainBoundary, Grain + + if add_if_dist is not None: + warn("`add_if_dist` is deprecated, please use `gap` instead.") + gap = add_if_dist + basis_pymatgen = ase_to_pymatgen(structure=initial_struct) grain_init = Grain( basis_pymatgen.lattice, basis_pymatgen.species, basis_pymatgen.frac_coords ) - gb_obj = GrainBoundary( + gb = GrainBoundary( axis=axis, sigma=sigma, plane=plane, @@ -91,9 +107,14 @@ def grainboundary( ) return pymatgen_to_ase( - structure=gb_obj.build_gb( - to_primitive=to_primitive, + structure=Grain.stack_grains( + gb.grain_a, + gb.grain_b, + vacuum=vacuum, + gap=gap, + direction=gb.direction, delete_layer=delete_layer, - add_if_dist=add_if_dist, + tol=tol, + to_primitive=to_primitive, ) ) From 8bbd43f9ac3c56e7b2ef3a5896e705572d78fa65 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Thu, 7 Sep 2023 10:47:15 -0700 Subject: [PATCH 2/4] Update module metadata --- structuretoolkit/build/aimsgb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/structuretoolkit/build/aimsgb.py b/structuretoolkit/build/aimsgb.py index ae04a284f..31e1bb82b 100644 --- a/structuretoolkit/build/aimsgb.py +++ b/structuretoolkit/build/aimsgb.py @@ -13,9 +13,9 @@ ) __version__ = "1.0" __maintainer__ = "Liam Huber" -__email__ = "huber@mpie.de" +__email__ = "liamhuber@greyhavensolutions.com" __status__ = "production" -__date__ = "Feb 26, 2021" +__date__ = "Sept 7, 2023" def get_grainboundary_info(axis, max_sigma): From 36ec749968f775891351aab3f6bff6e2b64d5bfa Mon Sep 17 00:00:00 2001 From: Liam Huber Date: Fri, 8 Sep 2023 09:46:48 -0700 Subject: [PATCH 3/4] Update structuretoolkit/build/aimsgb.py Co-authored-by: Jan Janssen --- structuretoolkit/build/aimsgb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/structuretoolkit/build/aimsgb.py b/structuretoolkit/build/aimsgb.py index 31e1bb82b..686ec0a0c 100644 --- a/structuretoolkit/build/aimsgb.py +++ b/structuretoolkit/build/aimsgb.py @@ -108,8 +108,8 @@ def grainboundary( return pymatgen_to_ase( structure=Grain.stack_grains( - gb.grain_a, - gb.grain_b, + grain_a=gb.grain_a, + grain_b=gb.grain_b, vacuum=vacuum, gap=gap, direction=gb.direction, From e13a46fd1c789de8e41bbb3bc1734f8641d4a327 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Mon, 11 Sep 2023 07:22:11 -0700 Subject: [PATCH 4/4] Force kwargs to be keyword only --- structuretoolkit/build/aimsgb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/structuretoolkit/build/aimsgb.py b/structuretoolkit/build/aimsgb.py index 686ec0a0c..2cf6634cc 100644 --- a/structuretoolkit/build/aimsgb.py +++ b/structuretoolkit/build/aimsgb.py @@ -47,6 +47,7 @@ def grainboundary( sigma, plane, initial_struct, + *, uc_a=1, uc_b=1, vacuum=0.0,