-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from pyiron/refactor_bindings
Refactor bindings
- Loading branch information
Showing
8 changed files
with
563 additions
and
328 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
85 changes: 85 additions & 0 deletions
85
pyiron_atomistics/atomistics/structure/factories/aimsgb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# coding: utf-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 aimsgb import GrainBoundary, Grain, GBInformation | ||
from pyiron_base import Settings | ||
from pyiron_atomistics.atomistics.structure.atoms import pyiron_to_pymatgen, pymatgen_to_pyiron | ||
|
||
__author__ = "Ujjal Saikia" | ||
__copyright__ = ( | ||
"Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - " | ||
"Computational Materials Design (CM) Department" | ||
) | ||
__version__ = "1.0" | ||
__maintainer__ = "Liam Huber" | ||
__email__ = "huber@mpie.de" | ||
__status__ = "production" | ||
__date__ = "Feb 26, 2021" | ||
|
||
s = Settings() | ||
|
||
|
||
class AimsgbFactory: | ||
@staticmethod | ||
def info(axis, max_sigma): | ||
""" | ||
Provides a list of possible GB structures for a given rotational axis and upto the given maximum sigma value. | ||
Args: | ||
axis : Rotational axis for the GB you want to construct (for example, axis=[1,0,0]) | ||
max_sigma (int) : The maximum value of sigma upto which you want to consider for your | ||
GB (for example, sigma=5) | ||
Returns: | ||
A list of possible GB structures in the format: | ||
{sigma value: {'theta': [theta value], | ||
'plane': the GB planes") | ||
'rot_matrix': array([the rotational matrix]), | ||
'csl': [array([the csl matrix])]}} | ||
To construct the grain boundary select a GB plane and sigma value from the list and pass it to the | ||
GBBuilder.gb_build() function along with the rotational axis and initial bulk structure. | ||
""" | ||
return GBInformation(axis=axis, max_sigma=max_sigma) | ||
|
||
@staticmethod | ||
def build( | ||
axis, | ||
sigma, | ||
plane, | ||
initial_struct, | ||
to_primitive=False, | ||
delete_layer='0b0t0b0t', | ||
add_if_dist=0.0 | ||
): | ||
""" | ||
Generate a grain boundary structure based on the aimsgb.GrainBoundary module. | ||
Args: | ||
axis : Rotational axis for the GB you want to construct (for example, axis=[1,0,0]) | ||
sigma (int) : The sigma value of the GB you want to construct (for example, sigma=5) | ||
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 pyiron | ||
structure object). | ||
delete_layer : 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 | ||
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 | ||
Returns: | ||
:class:`.Atoms`: final grain boundary structure | ||
""" | ||
basis_pymatgen = pyiron_to_pymatgen(initial_struct) | ||
grain_init = Grain(basis_pymatgen.lattice, basis_pymatgen.species, basis_pymatgen.frac_coords) | ||
gb_obj = GrainBoundary(axis=axis, sigma=sigma, plane=plane, initial_struct=grain_init) | ||
|
||
return pymatgen_to_pyiron(gb_obj.build_gb(to_primitive=to_primitive, delete_layer=delete_layer, | ||
add_if_dist=add_if_dist)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# coding: utf-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 functools import wraps | ||
from inspect import getmodule | ||
from ase.build import cut as ase_cut, stack as ase_stack, bulk as ase_bulk | ||
from ase.io import read as ase_read | ||
from ase.spacegroup import crystal as ase_crystal | ||
from pyiron_atomistics.atomistics.structure.atoms import ase_to_pyiron | ||
from pyiron_atomistics.atomistics.structure.pyironase import publication as publication_ase | ||
from pyiron_base import Settings | ||
|
||
__author__ = "Ali Zendegani" | ||
__copyright__ = ( | ||
"Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - " | ||
"Computational Materials Design (CM) Department" | ||
) | ||
__version__ = "1.0.1" | ||
__maintainer__ = "Liam Huber" | ||
__email__ = "huber@mpie.de" | ||
__status__ = "production" | ||
__date__ = "Feb 26, 2021" | ||
|
||
s = Settings() | ||
|
||
|
||
def _ase_header(ase_func): | ||
chain = getmodule(ase_func).__name__ | ||
name = chain.split('.')[-1] | ||
return f""" | ||
Returns an ASE's {name} result as a `pyiron_atomistics.atomstic.structure.atoms.Atoms`. | ||
{chain} docstring: | ||
""" | ||
|
||
|
||
def _ase_wraps(ase_func): | ||
def decorator(func): | ||
@wraps(ase_func) | ||
def wrapper(*args, **kwargs): | ||
s.publication_add(publication_ase()) | ||
return func(*args, **kwargs) | ||
wrapper.__doc__ = _ase_header(ase_func) + wrapper.__doc__ | ||
return wrapper | ||
return decorator | ||
|
||
|
||
class AseFactory: | ||
@_ase_wraps(ase_bulk) | ||
def bulk(self, *args, **kwargs): | ||
return ase_to_pyiron(ase_bulk(*args, **kwargs)) | ||
|
||
@_ase_wraps(ase_cut) | ||
def cut(self, *args, **kwargs): | ||
return ase_cut(*args, **kwargs) | ||
|
||
@_ase_wraps(ase_stack) | ||
def stack(self, *args, **kwargs): | ||
return ase_stack(*args, **kwargs) | ||
|
||
@_ase_wraps(ase_crystal) | ||
def crystal(self, *args, **kwargs): | ||
return ase_to_pyiron(ase_crystal(*args, **kwargs)) | ||
|
||
@_ase_wraps(ase_read) | ||
def read(self, *args, **kwargs): | ||
return ase_to_pyiron(ase_read(*args, **kwargs)) |
Oops, something went wrong.