Exemplo n.º 1
0
def aluminum():
    from quantities import bohr_radius
    from pylada.crystal.bravais import fcc
    result = fcc()
    result.scale = 7.5 * bohr_radius
    result[0].type = 'Al'
    return result
Exemplo n.º 2
0
def aluminum_structure():
    from quantities import bohr_radius
    from pylada.crystal.bravais import fcc
    result = fcc()
    result.scale = 7.5 * bohr_radius
    result[0].type = 'Al'
    return result
Exemplo n.º 3
0
def test_supercells():
    from pylada.crystal.bravais import fcc
    from pylada.enum import supercells

    # First, a lattice without symmetry
    lattice = fcc()
    lattice.cell = [[1.0, 0.2, 0], [0, 0.9, -0.1], [0, 0, 0.8]]
    scs = supercells(lattice, range(17))
    results = [1, 7, 13, 35, 31, 91, 57, 155, 130, 217, 133, 455, 183, 399, 403, 651]
    for r, s in zip(results, scs.itervalues()):
        assert r == len(s)
    # Then, an fcc lattice.
    lattice = fcc()
    scs = supercells(lattice, range(11))
    results = [1, 2, 3, 7, 5, 10, 7, 20, 14, 18]
    for r, s in zip(results, scs.itervalues()):
        assert r, len(s)
Exemplo n.º 4
0
def diamond_structure():
    from quantities import bohr_radius
    from pylada.crystal.bravais import fcc
    result = fcc()
    result.scale = 10.2 * bohr_radius
    result[0].type = 'Si'
    result.add_atom(0.25, 0.25, 0.25, 'Si')
    return result
Exemplo n.º 5
0
def test_fcc_supercells():
    from pylada.crystal.bravais import fcc
    from pylada.decorations import supercells

    lattice = fcc()
    scs = supercells(lattice, list(range(11)))
    results = [1, 2, 3, 7, 5, 10, 7, 20, 14, 18]
    for r, s in zip(results, scs.values()):
        assert r, len(s)
Exemplo n.º 6
0
def test_fcc_supercells():
    from pylada.crystal.bravais import fcc
    from pylada.decorations import supercells

    lattice = fcc()
    scs = supercells(lattice, list(range(11)))
    results = [1, 2, 3, 7, 5, 10, 7, 20, 14, 18]
    for r, s in zip(results, scs.values()):
        assert r, len(s)
Exemplo n.º 7
0
def test_3b():
  """ Tests triplet generation. """
  from pylada.ce._single_site_factory import factory
  from pylada.crystal import bravais

  lattice = bravais.fcc()
  lattice[0].type = ['A', 'B']
  results = factory(lattice, B3=1)
  assert len(results) == 4
  results = factory(lattice, B3=2)
  assert len(results) == 9
Exemplo n.º 8
0
def test_defects():
    from pylada.crystal.bravais import fcc
    from pylada.decorations.defects import defects
    lattice = fcc()
    lattice[0].type = 'Zr', 'Ti'
    lattice.add_atom(0.25, 0.25, 0.25, 'O', 'A')
    lattice.add_atom(0.75, 0.75, 0.75, 'O', 'A')

    i = 0
    for i, (x, hft, hermite) in enumerate(defects(lattice, 32, {'A': 2, 'Ti': 2})):
        print(x)
    print(i)
Exemplo n.º 9
0
def test_hfgroups():
    from pylada.crystal.bravais import fcc
    from pylada.decorations import hf_groups

    # First, a lattice without symmetry
    lattice = fcc()
    lattice.cell = [[1.0, 0.2, 0], [0, 0.9, -0.1], [0, 0, 0.8]]
    a = [1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 4]
    b = [1, 7, 13, 35, 31, 91, 57, 155, 130, 217, 133, 455, 183, 399, 403, 651]
    results = [u for u in zip(a, b)]
    for r, s in zip(results, hf_groups(lattice, list(range(17)))):
        assert len(s) == r[0]
        assert sum(len(u) for u in s) == r[1]
Exemplo n.º 10
0
def test_hfgroups():
    from pylada.crystal.bravais import fcc
    from pylada.enum import hf_groups

    # First, a lattice without symmetry
    lattice = fcc()
    lattice.cell = [[1.0, 0.2, 0], [0, 0.9, -0.1], [0, 0, 0.8]]
    a = [1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 4]
    b = [1, 7, 13, 35, 31, 91, 57, 155, 130, 217, 133, 455, 183, 399, 403, 651]
    results = [u for u in zip(a, b)]
    for r, s in zip(results, hf_groups(lattice, range(17))):
        assert len(s) == r[0]
        assert sum(len(u) for u in s) == r[1]
Exemplo n.º 11
0
def test_ternary():
  from pylada.crystal import bravais
  from pylada.enum import generate_bitstrings
  from ternarysets import ternarysets

  lattice = bravais.fcc()
  lattice[0].type = ['Si', 'Ge', 'C']
  for n in xrange(1, 9):
    result = []
    for x, hft, hermite in generate_bitstrings(lattice, [n]):
      result.append( ''.join(str(i) for i in hermite.flatten()[[0, 3, 4, 6, 7, 8]]) 
                     + ' ' + ''.join(str(i-1) for i in x) )
    assert len(result) == len(ternarysets[n])
    assert set(result) == ternarysets[n]
Exemplo n.º 12
0
def test_defects():
    from pylada.crystal.bravais import fcc
    from pylada.decorations.defects import defects
    lattice = fcc()
    lattice[0].type = 'Zr', 'Ti'
    lattice.add_atom(0.25, 0.25, 0.25, 'O', 'A')
    lattice.add_atom(0.75, 0.75, 0.75, 'O', 'A')

    i = 0
    for i, (x, hft,
            hermite) in enumerate(defects(lattice, 32, {
                'A': 2,
                'Ti': 2
            })):
        print(x)
    print(i)
Exemplo n.º 13
0
def test_pairs():
  """ Tests pair generation. """
  from numpy import all, sum
  from pylada.ce._single_site_factory import factory
  from pylada.crystal import bravais
  from pylada.error import ValueError

  lattice = bravais.fcc()
  try: results = factory(lattice, B2=1)
  except ValueError: pass
  else: raise Exception()

  lattice[0].type = ['A', 'B']
  results = factory(lattice, B2=1)
  assert len(results) == 1
  assert all(results[0].spins['position'][0] == [0,0,0])
  assert abs(sum(results[0].spins['position'][1]**2) - 2*0.5*0.5) < 1e-8
  assert len(results[0]._symmetrized) == 12

  results = factory(lattice, B2=2)
  assert len(results) == 2
  assert all(results[0].spins['position'][0] == [0,0,0])
  assert sum(results[0].spins['position'][1]**2) == 2*0.5*0.5
  assert len(results[0]._symmetrized) == 12
  assert all(results[1].spins['position'][0] == [0,0,0])
  assert abs(sum(results[1].spins['position'][1]**2) - 1e0) < 1e-8
  assert len(results[1]._symmetrized) == 6

  results = factory(lattice, B2=3)
  assert len(results) == 3
  assert all(results[0].spins['position'][0] == [0,0,0])
  assert sum(results[0].spins['position'][1]**2) == 2*0.5*0.5
  assert len(results[0]._symmetrized) == 12
  assert all(results[1].spins['position'][0] == [0,0,0])
  assert abs(sum(results[1].spins['position'][1]**2) - 1e0) < 1e-8
  assert len(results[1]._symmetrized) == 6
  assert all(results[2].spins['position'][0] == [0,0,0])
  assert abs(sum(results[2].spins['position'][1]**2) - 1-2*0.25) < 1e-8
  assert len(results[2]._symmetrized) == 24
Exemplo n.º 14
0
def main():
  from pylada import ce
  import boost.mpi as mpi
  from numpy import array
  from pylada.crystal.bravais import fcc

  functional = ce.Cubic()
  functional.set_mpi(mpi.world)
  functional.load( "input.xml" )
  lattice = fcc(); lattice.sites[0].type = "Au", "Pd"
  structure = lattice.to_structure( array([[0,1.0,1.5],[1,0,1.5],[1.0,1.0,0]]))
# print structure.lattice.space_group

  mlclasses = ce.MLClusterClasses("input.xml", False)
# mlclasses[0]
# print mlclasses
  classes = convert(mlclasses)
# print classes
# print
# print functional.clusters

# mlclusters = convert_clusters_to_mlclusters
  tests = [ ("000011100000", -74.377010),
            ("111000000101", -83.064845), 
            ("101000000011", -80.889828), 
            ("000111111000", -84.277151), 
            ("000111111001", -71.156430), 
            ("110000000111", -83.064845), 
            ("110000000101", -80.889828), 
            ("111000000111", -84.277151), 
            ("000111101000", -83.064845), 
            ("000110111000", -83.064845), 
            ("101000000111", -83.064845), 
            ("000110011000", -80.889828), 
            ("000011101000", -80.889828), 
            ("000111011000", -83.064845), 
            ("000011111000", -83.064845), 
            ("110000000011", -80.889828), 
            ("111000100111", -71.156430), 
            ("001000000000", -27.375282), 
            ("011000000111", -83.064845), 
            ("000010000000", -27.375282), 
            ("000000100000", -27.375282), 
            ("000000000001", -27.375282), 
            ("000100001000", -55.269849), 
            ("111010000111", -71.156430), 
            ("000000000100", -27.375282), 
            ("010000000000", -27.375282), 
            ("000111111100", -71.156430), 
            ("000001100000", -55.269849), 
            ("000011110000", -80.889828), 
            ("111001100111", -58.030174), 
            ("100000000010", -55.269849), 
            ("010000000100", -55.269849), 
            ("000001110000", -74.377010), 
            ("010000000001", -55.269849) ] 

  for test in tests:
    for i, atom in enumerate(structure.atoms):
      if test[0][i] == "0": atom.type = "Au"
      else:                 atom.type = "Pd"
    e = mlclasses(structure) 
    c = functional.chemical(structure) 
    if not e == 0e0:
      print "check %f, test %f, diff %f " \
            % ( c, e, c-e )