Beispiel #1
0
def test_breaksym():
  from pylada.dftcrystal import Crystal, Functional, Shell, DisplaceAtoms, read

  functional = Functional()
  functional.basis['Si'] = [
      Shell('s', a0=[16120.0, 0.001959],
                 a1=[2426.0, 0.01493], 
                 a2=[553.9, 0.07285],
                 a3=[156.3, 0.2461], 
                 a4=[50.07, 0.4859],
                 a5=[17.02, 0.325]),
      Shell('sp', a0=[292.7, -0.002781, 0.004438],
                  a1=[69.87, -0.03571, 0.03267],
                  a2=[22.34, -0.115, 0.1347],
                  a3=[8.15, 0.09356, 0.3287],
                  a4=[3.135, 0.603, 0.4496]), 
      Shell('sp', 4.0, a0=[1.22, 1.0, 1.0]),
      Shell('sp', 0.0, a0=[0.55, 1.0, 1.0]),
      Shell('sp', 0.0, a0=[0.27, 1.0, 1.0]) ]

  functional.dft.pbe0 = True
  functional.fmixing = 30
  functional.shrink = 8, 16
  functional.levshift = 5, True
  functional.maxcycle = 600
  functional.optgeom.keepsymm = True
  functional.optgeom.enabled = True

  crystal = Crystal(227, 5.43).add_atom(0.125, 0.125, 0.125, 'Si')
  crystal.append('breaksym')
  crystal.append(DisplaceAtoms().add_atom(0.01, 0, 0, 1))
  string = functional.print_input(structure=crystal)
  assert string.splitlines()[10] == 'KEEPSYMM'
  cry, func = read(string)
  assert cry.is_breaksym
  assert func.optgeom.enabled 
  assert func.optgeom.keepsymm 

  functional.optgeom.keepsymm = False
  string = functional.print_input(structure=crystal)
  assert string.splitlines()[10] == 'OPTGEOM'
  cry, func = read(string)
  assert cry.is_breaksym
  assert func.optgeom.enabled 
  assert func.optgeom.breaksym 

  crystal[0] = 'keepsymm'
  string = functional.print_input(structure=crystal)
  assert string.splitlines()[11] == 'BREAKSYM'
  cry, func = read(string)
  assert not cry.is_breaksym
  assert func.optgeom.enabled 
  assert func.optgeom.breaksym 

  functional.optgeom.keepsymm = True
  string = functional.print_input(structure=crystal)
  assert string.splitlines()[11] == 'OPTGEOM'
  cry, func = read(string)
  assert not cry.is_breaksym
  assert func.optgeom.enabled 
  assert func.optgeom.keepsymm 

  string = crystal.print_input()
  crystal.append('keepsymm')
  crystal.append('keepsymm')
  assert crystal.print_input() == string
  crystal.append('breaksym')
  assert crystal.print_input() != string
  assert len(crystal.print_input().splitlines()) == len(string.splitlines()) + 1
Beispiel #2
0
def test_supercell(path):
  from os.path import join
  from numpy import all, abs, array, set_printoptions
  from pylada.dftcrystal import read, Supercell, Crystal, Slabcut, BreakSym,    \
                              KeepSymm, DisplaceAtoms, InsertAtoms
  set_printoptions(precision=12)
  crystal, functional = read(join(path, 'supercell.d12'))

  assert isinstance(crystal, Crystal)
  assert all(abs(array(crystal.params)  - [4.63909875, 2.97938395]) < 1e-6)
  assert crystal.symmgroup == 136
  assert len(crystal) == 8

  assert isinstance(crystal[0], Slabcut)
  assert crystal[0].isup == 2
  assert crystal[0].nl == 15
  assert all(crystal[0].hkl == [1, 1, 0])

  assert isinstance(crystal[1], BreakSym)

  assert isinstance(crystal[2], DisplaceAtoms)
  assert all(array([u.type for u in crystal[2].atoms]) == range(1, 31))
  disp = array([[ 0.         ,  0.         ,  0.00496008 ],
                [ 0.         ,  0.         , -0.152840221],
                [ 0.         ,  0.         ,  0.216529621],
                [ 0.         , -0.052728927,  0.185587552],
                [ 0.         ,  0.052728927,  0.185587552],
                [ 0.         ,  0.         , -0.004768893],
                [ 0.         ,  0.         ,  0.034440171],
                [ 0.         ,  0.         ,  0.136085018],
                [ 0.         ,  0.         , -0.069420272],
                [ 0.         ,  0.035782986,  0.022806847],
                [ 0.         , -0.035782986,  0.022806847],
                [ 0.         ,  0.         ,  0.018900892],
                [ 0.         ,  0.         ,  0.002450591],
                [ 0.         ,  0.         ,  0.         ],
                [ 0.         ,  0.         ,  0.         ],
                [ 0.         , -0.027503191,  0.         ],
                [ 0.         ,  0.027503191,  0.         ],
                [ 0.         ,  0.         , -0.002450591],
                [ 0.         ,  0.         , -0.018900892],
                [ 0.         ,  0.         , -0.136085018],
                [ 0.         ,  0.         ,  0.069420272],
                [ 0.         ,  0.035782986, -0.022806847],
                [ 0.         , -0.035782986, -0.022806847],
                [ 0.         ,  0.         , -0.034440171],
                [ 0.         ,  0.         ,  0.004768893],
                [ 0.         ,  0.         ,  0.152840221],
                [ 0.         ,  0.         , -0.216529621],
                [ 0.         , -0.052728927, -0.185587552],
                [ 0.         ,  0.052728927, -0.185587552],
                [ 0.         ,  0.         , -0.00496008 ]])
  assert all(abs( array([u.pos for u in crystal[2].atoms]) - disp) < 1e-8)

  assert isinstance(crystal[3], BreakSym)

  assert isinstance(crystal[4], DisplaceAtoms)
  assert all(array([u.type for u in crystal[4].atoms]) == range(1, 31))
  disp = array([[ 0.         ,  0.         , -0.005827511],
                [ 0.         ,  0.         , -0.00382378 ],
                [ 0.         ,  0.         , -0.000865488],
                [ 0.         ,  0.001041455, -0.002644481],
                [ 0.         , -0.001041455, -0.002644481],
                [ 0.         ,  0.         , -0.004243966],
                [ 0.         ,  0.         ,  0.001098565],
                [ 0.         ,  0.         ,  0.00118787 ],
                [ 0.         ,  0.         , -0.002160436],
                [ 0.         ,  0.000613051, -0.000776595],
                [ 0.         , -0.000613051, -0.000776595],
                [ 0.         ,  0.         ,  0.00162428 ],
                [ 0.         ,  0.         , -0.000458678],
                [ 0.         ,  0.         ,  0.         ],
                [ 0.         ,  0.         ,  0.         ],
                [ 0.         , -0.000733281,  0.         ],
                [ 0.         ,  0.000733281,  0.         ],
                [ 0.         ,  0.         ,  0.000458678],
                [ 0.         ,  0.         , -0.00162428 ],
                [ 0.         ,  0.         , -0.00118787 ],
                [ 0.         ,  0.         ,  0.002160436],
                [ 0.         ,  0.000613051,  0.000776595],
                [ 0.         , -0.000613051,  0.000776595],
                [ 0.         ,  0.         , -0.001098565],
                [ 0.         ,  0.         ,  0.004243966],
                [ 0.         ,  0.         ,  0.00382378 ],
                [ 0.         ,  0.         ,  0.000865488],
                [ 0.         ,  0.001041455,  0.002644481],
                [ 0.         , -0.001041455,  0.002644481],
                [ 0.         ,  0.         ,  0.005827511]])
  assert all(abs( array([u.pos for u in crystal[4].atoms]) - disp) < 1e-8)

  assert crystal[5].keyword.lower() == 'supercel'
  assert isinstance(crystal[5], Supercell)
  assert all(abs(crystal[5].matrix - [[2, 0], [0, 1]]) < 1e-8)

  assert isinstance(crystal[6], KeepSymm)

  assert isinstance(crystal[7], InsertAtoms)
  assert len(crystal[7].atoms) == 2
  assert crystal[7].atoms[0].type == 'H'
  assert crystal[7].atoms[1].type == 'H'
  assert all(abs(crystal[7].atoms[0].pos -  [0.0, 3.28033818472, 8.731578688]) < 1e-8)
  assert all(abs(crystal[7].atoms[1].pos -  [2.97938395, 3.28033818472, 8.731578688]) < 1e-8)


  assert all(functional.atomspin.up == [3, 4, 15, 16, 39, 40, 51, 52])
  assert functional.biposize             == 9701800
  assert functional.dft.b3lyp            == True
  assert functional.dft.spin             == True
  assert functional.dft.xxlgrid          == True
  assert functional.exchsize             == 6937578
  assert functional.fmixing              == 60
  assert functional.levshift.lock        == True
  assert functional.levshift.shift       == 5.0
  assert functional.maxcycle             == 300
  assert functional.mpp                  == True
  assert functional.nobipola             == True
  assert functional.nofmwf               == True
  assert functional.optgeom.breaksym     == False
  assert functional.optgeom.enabled      == True
  assert functional.optgeom.maxcycle     == 10
  assert functional.ppan                 == True
  assert functional.scfdir               == True
  assert all(functional.shrink.mp == [4, 8])
  assert functional.shrink.gallat == 8
  assert functional.spinlock.ncycles     == 30
  assert functional.spinlock.nspin       == 4
  assert functional.title                == 'rutile'
  assert functional.toldee               == 7
  assert all(functional.tolinteg         == [7, 7, 7, 7, 14])