Пример #1
0
def test_spinlock():
  from collections import namedtuple
  from pickle import loads, dumps
  from pylada.dftcrystal.electronic import SpinLock, Electronic

  Crystal = namedtuple('Crystal', ['dft'])
  Dft = namedtuple('Dft', ['spin'])
  on, off = Crystal(Dft(True)), Crystal(Dft(False))
  a = Electronic()
  b = a._input['spinlock']
  assert a.spinlock.nspin is None
  assert a.spinlock.ncycles is None
  assert b.output_map() is None
  assert eval(repr(b), {'SpinLock': SpinLock}).output_map() is None
  assert eval(repr(b), {'SpinLock': SpinLock}).nspin is None
  assert eval(repr(b), {'SpinLock': SpinLock}).ncycles is None
  assert repr(loads(dumps(b))) == repr(b)

  a.spinlock = 5, 30
  assert a.spinlock[0] == 5
  assert a.spinlock[1] == 30
  assert a.spinlock.nspin == 5
  assert a.spinlock.ncycles == 30
  assert b.output_map(crystal=off) is None
  assert len(b.output_map(crystal=on)) == 1
  assert b.output_map(crystal=on).get('spinlock', 'a a') == '5 30' 
  assert eval(repr(b), {'SpinLock': SpinLock}).output_map(crystal=on)['spinlock'] == '5 30'
  assert eval(repr(b), {'SpinLock': SpinLock}).output_map(crystal=off) is None
  assert eval(repr(b), {'SpinLock': SpinLock}).nspin == 5
  assert eval(repr(b), {'SpinLock': SpinLock}).ncycles == 30
  assert repr(loads(dumps(b))) == repr(b)
Пример #2
0
def test_electronic():
  from pylada.dftcrystal.electronic import Electronic

  a = Electronic()
  assert repr(a) == repr(loads(dumps(a)))
  a.shrink = [8, 8, 9], None
  a.tolinteg = 8, 8, 8, 8, 14
  a.dft.b3lyp = True
  a.dft.exchange = 'lda'
  a.dft.xxlgrid = True
  assert repr(a) == repr(loads(dumps(a)))