Пример #1
0
def test_inverse_spinel():
    from numpy import all
    from pylada.crystal import A2BX4
    from pylada.decorations import Transforms
    lattice = A2BX4.b5()
    for atom in lattice:
        if atom.type in ['A', 'B']:
            atom.type = 'A', 'B'
    lattice[0], lattice[-1] = lattice[-1], lattice[0]
    transforms = Transforms(lattice)
    assert len([u for u in transforms.lattice if u.asymmetric]) == 3
    assert all([transforms.lattice[i].asymmetric for i in [0, 1, 4]])
    assert all([not transforms.lattice[i].asymmetric for i in list(range(2, 4)) + list(range(5, 14))])
    assert all([transforms.lattice[i].equivto == 0 for i in [0] + list(range(6, 13))])
    assert all([transforms.lattice[i].equivto == 1 for i in list(range(1, 4)) + [13]])
    assert all([transforms.lattice[i].equivto == 4 for i in [4, 5]])
    assert all([transforms.lattice[i].nbflavors == 1 for i in [0] + list(range(6, 13))])
    assert all([transforms.lattice[i].nbflavors == 2 for i in list(range(1, 4)) + [13]])
    assert all([transforms.lattice[i].nbflavors == 2 for i in [4, 5]])
    index = 0
    for i, atom in enumerate(transforms.lattice):
        if atom.nbflavors == 1:
            assert not hasattr(atom, 'index')
        else:
            assert atom.index == index
            index += 1
Пример #2
0
def test_inverse_spinel():
    from numpy import all
    from pylada.crystal import A2BX4
    from pylada.decorations import Transforms
    lattice = A2BX4.b5()
    for atom in lattice:
        if atom.type in ['A', 'B']:
            atom.type = 'A', 'B'
    lattice[0], lattice[-1] = lattice[-1], lattice[0]
    transforms = Transforms(lattice)
    assert len([u for u in transforms.lattice if u.asymmetric]) == 3
    assert all([transforms.lattice[i].asymmetric for i in [0, 1, 4]])
    assert all([
        not transforms.lattice[i].asymmetric
        for i in list(range(2, 4)) + list(range(5, 14))
    ])
    assert all(
        [transforms.lattice[i].equivto == 0 for i in [0] + list(range(6, 13))])
    assert all(
        [transforms.lattice[i].equivto == 1 for i in list(range(1, 4)) + [13]])
    assert all([transforms.lattice[i].equivto == 4 for i in [4, 5]])
    assert all([
        transforms.lattice[i].nbflavors == 1 for i in [0] + list(range(6, 13))
    ])
    assert all([
        transforms.lattice[i].nbflavors == 2 for i in list(range(1, 4)) + [13]
    ])
    assert all([transforms.lattice[i].nbflavors == 2 for i in [4, 5]])
    index = 0
    for i, atom in enumerate(transforms.lattice):
        if atom.nbflavors == 1:
            assert not hasattr(atom, 'index')
        else:
            assert atom.index == index
            index += 1
Пример #3
0
def test_spinel():
    from numpy import all
    from pylada.crystal import A2BX4
    from pylada.decorations import Transforms
    lattice = A2BX4.b5()
    for atom in lattice:
        if atom.type in ['A', 'B']:
            atom.type = 'A', 'B'
    transforms = Transforms(lattice)
    assert len([u for u in transforms.lattice if u.asymmetric]) == 3
    assert all([transforms.lattice[i].asymmetric for i in [0, 4, 6]])
    assert all([not transforms.lattice[i].asymmetric for i in list(range(1, 4)) + [5] + list(range(7, 14))])
    assert all([transforms.lattice[i].equivto == 0 for i in range(4)])
    assert all([transforms.lattice[i].equivto == 4 for i in range(4, 6)])
    assert all([transforms.lattice[i].equivto == 6 for i in range(6, 14)])
    assert all([transforms.lattice[i].nbflavors == 2 for i in range(4)])
    assert all([transforms.lattice[i].nbflavors == 2 for i in range(4, 6)])
    assert all([transforms.lattice[i].nbflavors == 1 for i in range(6, 14)])
    assert all([transforms.lattice[i].index == i for i in range(6)])
    assert all([not hasattr(transforms.lattice[i], 'index') for i in range(6, 14)])
Пример #4
0
def test_spinel():
    from numpy import all
    from pylada.crystal import A2BX4
    from pylada.decorations import Transforms
    lattice = A2BX4.b5()
    for atom in lattice:
        if atom.type in ['A', 'B']:
            atom.type = 'A', 'B'
    transforms = Transforms(lattice)
    assert len([u for u in transforms.lattice if u.asymmetric]) == 3
    assert all([transforms.lattice[i].asymmetric for i in [0, 4, 6]])
    assert all([
        not transforms.lattice[i].asymmetric
        for i in list(range(1, 4)) + [5] + list(range(7, 14))
    ])
    assert all([transforms.lattice[i].equivto == 0 for i in range(4)])
    assert all([transforms.lattice[i].equivto == 4 for i in range(4, 6)])
    assert all([transforms.lattice[i].equivto == 6 for i in range(6, 14)])
    assert all([transforms.lattice[i].nbflavors == 2 for i in range(4)])
    assert all([transforms.lattice[i].nbflavors == 2 for i in range(4, 6)])
    assert all([transforms.lattice[i].nbflavors == 1 for i in range(6, 14)])
    assert all([transforms.lattice[i].index == i for i in range(6)])
    assert all(
        [not hasattr(transforms.lattice[i], 'index') for i in range(6, 14)])
Пример #5
0
            j = which_site(op(site.pos), lattice)
            if j != i and j in result:
                result.remove(j)
    return result


from numpy.linalg import norm
from pylada.crystal import A2BX4
from pylada.ce import create_clusters
from math import exp

# input
shell = 35

# create spinel lattice.
lattice = A2BX4.b5()
# occupations.
for site in lattice.sites:
    if "X" in site.type:
        continue
    site.type = ["A", "B"]
# recomputes space group for safety.
lattice.find_space_group()
lattice.set_as_crystal_lattice()

# creates random structure.
structure = A2BX4.b5I().to_structure()
normal = A2BX4.b5().to_structure()
# for atom in structure.atoms:
#   atom.type = choice(lattice.sites[atom.site].type)
Пример #6
0
  nfu = float(len(structure)/7)*0.5 # 0.5 because 2 f.u. in spinel unit-cell.
  vol = det(structure.cell)
  return (nfu * spvol / vol)**(1e0/3e0)

#problem with Rh2TiO4 for some reason

""" Materials to compute. """
materials = [ "Al2MgO4"]

""" Number of random anti-ferro trials. """
nbantiferro = 8
nbrandom    = 3
do_ferro    = False
do_antiferro = False

lattices = [A2BX4.b5(), A2BX4.b21()]

mlen = len( materials)
llen = len( lattices)
matLatPairs = (mlen * llen) * [None]
print "  test/hi/inputFixed: mlen: ", mlen
print "  test/hi/inputFixed: llen: ", llen
print "  test/hi/inputFixed: pairs len: ", len(matLatPairs)
kk = 0
for mat in materials:
  print "  test/hi/inputFixed: mat: ", mat
  for lat in lattices:
    print "    test/hi/inputFixed: lat: ", lat
    matLatPairs[kk] = (mat, lat,)
    kk += 1
Пример #7
0
def test_lattice():
  """ Tests lattice enhancements. """
  from numpy import all
  from pylada.crystal import binary, A2BX4
  from pylada.enum import Transforms

  lattice = binary.zinc_blende()
  lattice[0].type = ['Si', 'Ge']
  lattice[1].type = ['Si', 'Ge']
  transforms = Transforms(lattice)
  assert len([u for u in transforms.lattice if u.asymmetric]) == 1
  assert transforms.lattice[0].asymmetric
  assert transforms.lattice[0].equivto == 0
  assert transforms.lattice[0].nbflavors == 2
  assert transforms.lattice[0].index == 0
  assert not transforms.lattice[1].asymmetric
  assert transforms.lattice[1].equivto == 0
  assert transforms.lattice[1].nbflavors == 2
  assert transforms.lattice[1].index == 1
  assert all(all(a == b) for a, b in zip(transforms.flavors, (range(1), range(1))))
  assert all(not hasattr(atom, 'nbflavors') for atom in lattice)

  lattice = binary.zinc_blende()
  lattice[0].type = ['Si', 'Ge']
  lattice[1].type = ['Si', 'Ge', 'C']
  transforms = Transforms(lattice)
  assert len([u for u in transforms.lattice if u.asymmetric]) == 2
  assert transforms.lattice[0].asymmetric
  assert transforms.lattice[0].equivto == 0
  assert transforms.lattice[0].nbflavors == 2
  assert transforms.lattice[0].index == 0
  assert transforms.lattice[0].asymmetric
  assert transforms.lattice[1].equivto == 1
  assert transforms.lattice[1].nbflavors == 3
  assert transforms.lattice[1].index == 1
  assert all(all(a == b) for a, b in zip(transforms.flavors, (range(1), range(2))))

  lattice = A2BX4.b5() 
  for atom in lattice: 
    if atom.type in ['A', 'B']: atom.type = 'A', 'B'
  transforms = Transforms(lattice)
  assert len([u for u in transforms.lattice if u.asymmetric]) == 3
  assert all([transforms.lattice[i].asymmetric for i in [0, 4, 6]])
  assert all([not transforms.lattice[i].asymmetric for i in range(1, 4) + [5] + range(7, 14)])
  assert all([transforms.lattice[i].equivto == 0 for i in range(4)])
  assert all([transforms.lattice[i].equivto == 4 for i in range(4, 6)])
  assert all([transforms.lattice[i].equivto == 6 for i in range(6, 14)])
  assert all([transforms.lattice[i].nbflavors == 2 for i in range(4)])
  assert all([transforms.lattice[i].nbflavors == 2 for i in range(4, 6)])
  assert all([transforms.lattice[i].nbflavors == 1 for i in range(6, 14)])
  assert all([transforms.lattice[i].index == i for i in range(6)])
  assert all([not hasattr(transforms.lattice[i], 'index') for i in range(6, 14)])

  lattice[0], lattice[-1] = lattice[-1], lattice[0]
  transforms = Transforms(lattice)
  assert len([u for u in transforms.lattice if u.asymmetric]) == 3
  assert all([transforms.lattice[i].asymmetric for i in [0, 1, 4]])
  assert all([not transforms.lattice[i].asymmetric for i in range(2, 4) + range(5, 14)])
  assert all([transforms.lattice[i].equivto == 0 for i in [0] + range(6, 13)])
  assert all([transforms.lattice[i].equivto == 1 for i in range(1, 4) + [13]])
  assert all([transforms.lattice[i].equivto == 4 for i in [4, 5]])
  assert all([transforms.lattice[i].nbflavors == 1 for i in [0] + range(6, 13)])
  assert all([transforms.lattice[i].nbflavors == 2 for i in range(1, 4) + [13]])
  assert all([transforms.lattice[i].nbflavors == 2 for i in [4, 5]])
  index = 0
  for i, atom in enumerate(transforms.lattice):
    if atom.nbflavors == 1: assert not hasattr(atom, 'index')
    else: 
      assert atom.index == index
      index += 1
Пример #8
0
#  PyLaDa is free software: you can redistribute it and/or modify it under the terms of the GNU General
#  Public License as published by the Free Software Foundation, either version 3 of the License, or (at
#  your option) any later version.
# 
#  PyLaDa is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
#  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
#  Public License for more details.
# 
#  You should have received a copy of the GNU General Public License along with PyLaDa.  If not, see
#  <http://www.gnu.org/licenses/>.
###############################

""" Input script for the calculation of Point Defects. """
from pylada.crystal import A2BX4

lattice = A2BX4.b5()
""" Back-bone lattice. """
# changes species in lattice.
for site in lattice.sites:
  site.type = {"A": "Rh", "B": "Zn", "X": "O"}[site.type[0]]
lattice.scale = 8.506

supercell = array([[-1,  1,  1],\
                   [ 1, -1,  1],\
                   [ 1,  1, -1]], dtype="float64" )
""" Supercell of defect structures. """

vasp = Vasp()
""" VASP functional """
vasp.kpoints    = "Automatic generation\n0\nMonkhorst\n2 2 2\n0 0 0"
vasp.precision  = "accurate"