Skip to content

Commit

Permalink
Merge pull request #144 from pyscal/add_aimsgb
Browse files Browse the repository at this point in the history
add aimsgb
  • Loading branch information
srmnitc authored Jul 17, 2024
2 parents 497519e + fb3943c commit 3ee4941
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.5
current_version = 0.9.6
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ url: 'https://atomrdf.pyscal.org'
license: "MIT"
repository-code: https://github.com/pyscal/atomRDF
type: software
version: 0.9.5
version: 0.9.6
166 changes: 164 additions & 2 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,170 @@ def _make_dislocation(
return output_structure, disc
return output_structure


def _make_grain_boundary(
axis,
sigma,
gb_plane,
structure=None,
element=None,
lattice_constant=1,
ca_ratio=1.633,
repetitions=(1, 1, 1),
overlap=0.0,
vacuum=0.0,
delete_layer="0b0t0b0t",
tolerance= 0.25,
primitive=False,
uc_a=1,
uc_b=1,
graph=None,
names=False,
label=None,
backend='aimsgb'
):
if backend == 'aimsgb':
return _make_grain_boundary_aimsgb(
axis,
sigma,
gb_plane,
structure=structure,
element=element,
lattice_constant=lattice_constant,
ca_ratio=ca_ratio,
repetitions=repetitions,
overlap=overlap,
vacuum=vacuum,
delete_layer=delete_layer,
tolerance= tolerance,
primitive=primitive,
uc_a=uc_a,
uc_b=uc_b,
graph=graph,
names=names,
label=label,
)
else:
return _make_grain_boundary_inbuilt(
axis,
sigma,
gb_plane,
structure=structure,
element=element,
lattice_constant=lattice_constant,
repetitions=repetitions,
overlap=overlap,
graph=graph,
names=names,
label=label,
)

def _make_grain_boundary_aimsgb(
axis,
sigma,
gb_plane,
structure=None,
element=None,
lattice_constant=1,
ca_ratio=1.633,
repetitions=(1, 1, 1),
overlap=0.0,
vacuum=0.0,
delete_layer="0b0t0b0t",
tolerance= 0.25,
primitive=False,
uc_a=1,
uc_b=1,
graph=None,
names=False,
label=None,
):
try:
from pymatgen.io.ase import AseAtomsAdaptor
from aimsgb import GrainBoundary as AIMSGrainBoundary
from aimsgb import Grain as AIMSGrain
except ImportError:
raise ImportError("This function requires the aimsgb and pymatgen packages to be installed")


if structure is not None:
# create a structure with the info
init_sys = _make_crystal(
structure,
lattice_constant=_declass(lattice_constant),
repetitions=repetitions,
ca_ratio=_declass(ca_ratio),
noise=0,
element=element,
primitive=primitive,
)
elif element is not None:
if element in element_dict.keys():
structure = element_dict[element]["structure"]
lattice_constant = element_dict[element]["lattice_constant"]
else:
raise ValueError("Please provide structure")
init_sys = _make_crystal(
structure,
lattice_constant=_declass(lattice_constant),
repetitions=repetitions,
ca_ratio=_declass(ca_ratio),
noise=0,
element=element,
primitive=primitive,
)
else:
raise ValueError("Provide either structure or element")

sdict = copy.deepcopy(init_sys._structure_dict)

asesys = init_sys.write.ase()
pmsys = AseAtomsAdaptor().get_structure(atoms=asesys)
grain = AIMSGrain(pmsys.lattice, pmsys.species, pmsys.frac_coords)
gb = AIMSGrainBoundary(axis=axis, sigma=sigma,
plane=gb_plane,
initial_struct=grain,
uc_a=uc_a,
uc_b=uc_b)
gb_struct = AIMSGrain.stack_grains(
grain_a = gb.grain_a,
grain_b = gb.grain_b,
vacuum = vacuum,
gap=overlap,
direction = gb.direction,
delete_layer=delete_layer,
tol=tolerance,
to_primitive=primitive,
)
asestruct = AseAtomsAdaptor().get_atoms(structure=gb_struct)
sys = System.read.ase(asestruct, graph=graph, names=names, label=label)
sys.atoms._lattice = structure
sys.atoms._lattice_constant = _declass(lattice_constant)
sys._structure_dict = sdict
sys.label = label
sys.to_graph()
sys.add_property_mappings(lattice_constant, mapping_quantity='lattice_constant')
sys.add_property_mappings(ca_ratio, mapping_quantity='lattice_constant')

try:
gb_inb = GrainBoundary()
gb_inb.create_grain_boundary(axis=axis, sigma=sigma, gb_plane=gb_plane)
gb_type = gb_inb.find_gb_character()
except:
gb_type = None

gb_dict = {
"GBPlane": " ".join(np.array(gb_plane).astype(str)),
"RotationAxis": axis,
"MisorientationAngle": gb.theta[0],
"GBType": gb_type,
"sigma": gb.sigma,
}
sys.add_gb(gb_dict)
return sys



def _make_grain_boundary_inbuilt(
axis,
sigma,
gb_plane,
Expand Down Expand Up @@ -2095,7 +2257,7 @@ def add_gb(self, gb_dict):
return

if gb_dict["GBType"] is None:
plane_defect = self.graph.create_node(f"{self._name}_GrainBoundary")
plane_defect = self.graph.create_node(f"{self._name}_GrainBoundary", PLDO.GrainBoundary)

elif gb_dict["GBType"] == "Twist":
plane_defect = self.graph.create_node(
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ dependencies:
#- atomman
- mp-api
- sqlalchemy
- aimsgb
- pymatgen
- pip:
- "git+https://github.com/RDFLib/rdflib-sqlalchemy.git@develop"
Loading

0 comments on commit 3ee4941

Please sign in to comment.