Skip to content

Commit

Permalink
Missed out on GB transformation.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Dec 14, 2018
1 parent 24ef7ae commit eb014d4
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions pymatgen/transformations/tests/test_advanced_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import warnings
import numpy as np

from pymatgen import Lattice, Structure, Specie, Element
from pymatgen import Lattice, Structure, Specie
from pymatgen.transformations.standard_transformations import \
OxidationStateDecorationTransformation, SubstitutionTransformation, \
OrderDisorderedStructureTransformation, AutoOxiStateDecorationTransformation
Expand All @@ -17,7 +17,8 @@
MultipleSubstitutionTransformation, ChargeBalanceTransformation, \
SubstitutionPredictorTransformation, MagOrderingTransformation, \
DopingTransformation, _find_codopant, SlabTransformation, \
MagOrderParameterConstraint, DisorderOrderedTransformation
MagOrderParameterConstraint, DisorderOrderedTransformation, \
GrainBoundaryTransformation
from monty.os.path import which
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.io.cif import CifParser
Expand All @@ -26,7 +27,6 @@
from pymatgen.analysis.gb.grain import GrainBoundaryGenerator
from pymatgen.util.testing import PymatgenTest
from pymatgen.core.surface import SlabGenerator

"""
Created on Jul 24, 2012
"""
Expand Down Expand Up @@ -99,12 +99,11 @@ def test_apply_transformation(self):

@unittest.skipIf(not enumlib_present, "enum_lib not present.")
def test_apply_transformation_mult(self):
#Test returning multiple structures from each transformation.
# Test returning multiple structures from each transformation.
disord = Structure(np.eye(3) * 4.209, [{"Cs+": 0.5, "K+": 0.5}, "Cl-"],
[[0, 0, 0], [0.5, 0.5, 0.5]])
disord.make_supercell([2, 2, 1])


tl = [EnumerateStructureTransformation(),
OrderDisorderedStructureTransformation()]
t = SuperTransformation(tl, nstructures_per_trans=10)
Expand Down Expand Up @@ -576,23 +575,26 @@ def test_apply_transformation(self):
self.assertArrayAlmostEqual(slab_from_gen.cart_coords,
slab_from_trans.cart_coords)

from pymatgen.transformations.advanced_transformations import GrainBoundaryTransformation


class GrainBoundaryTransformationTest(PymatgenTest):
def test_apply_transformation(self):
Li_bulk = Structure.from_spacegroup("Im-3m", Lattice.cubic(2.96771),
["Li"], [[0, 0, 0]])
gb_gen_params_s3 = {"rotation_axis": [1, 1, 1], "rotation_angle": 60.0,
"expand_times": 2, "vacuum_thickness": 0.0, "normal": True,
"ratio": None, "plane": None}
gbg = GrainBoundaryGenerator(Li_bulk)
gb_from_generator = gbg.gb_from_parameters(**gb_gen_params_s3)
gbt_s3 = GrainBoundaryTransformation(**gb_gen_params_s3)
gb_from_trans = gbt_s3.apply_transformation(Li_bulk)
self.assertArrayAlmostEqual(gb_from_generator.lattice.matrix,
gb_from_trans.lattice.matrix)
self.assertArrayAlmostEqual(gb_from_generator.cart_coords,
gb_from_trans.cart_coords)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Li_bulk = Structure.from_spacegroup("Im-3m", Lattice.cubic(2.96771),
["Li"], [[0, 0, 0]])
gb_gen_params_s3 = {"rotation_axis": [1, 1, 1], "rotation_angle": 60.0,
"expand_times": 2, "vacuum_thickness": 0.0, "normal": True,
"ratio": None, "plane": None}
gbg = GrainBoundaryGenerator(Li_bulk)
gb_from_generator = gbg.gb_from_parameters(**gb_gen_params_s3)
gbt_s3 = GrainBoundaryTransformation(**gb_gen_params_s3)
gb_from_trans = gbt_s3.apply_transformation(Li_bulk)
self.assertArrayAlmostEqual(gb_from_generator.lattice.matrix,
gb_from_trans.lattice.matrix)
self.assertArrayAlmostEqual(gb_from_generator.cart_coords,
gb_from_trans.cart_coords)


class DisorderedOrderedTransformationTest(PymatgenTest):

Expand All @@ -608,7 +610,6 @@ def test_apply_transformation(self):
self.assertDictEqual(output.species_and_occu[-1].as_dict(),
{'Ni': 0.5, 'Ba': 0.5})


if __name__ == "__main__":
import logging
# logging.basicConfig(level=logging.INFO)
unittest.main()

0 comments on commit eb014d4

Please sign in to comment.