Exemple #1
0
  def __call__(self, functional, structure, comm):
    """ Computes parameters of FFT mesh. """
    from operator import itemgetter
    from numpy import pi, sqrt
    from numpy.linalg import norm
    from pylada.physics import a0
    from quantities import angstrom

    para = structure.scale*2.0*sqrt(functional.cutoff)/pi/a0.rescale(angstrom).magnitude

    # first determines parameters of mesh.
    mesh = [int(norm(structure.cell[:,0]) * para + 5e-1), \
            int(norm(structure.cell[:,1]) * para + 5e-1), \
            int(norm(structure.cell[:,2]) * para + 5e-1)]

    multiple = comm.size if mesh[0] <= 500 else 3 * comm.size 
    if mesh[0] * mesh[1] % multiple != 0:
      a = 0 if mesh[0] % multiple  == 0 else multiple - mesh[0] % multiple
      b = 0 if mesh[1] % multiple  == 0 else multiple - mesh[1] % multiple
      all_prods = [(i, j, i*j) for i in xrange(mesh[0], mesh[0]+a+1)\
                               for j in xrange(mesh[1], mesh[1]+b+1)\
                               if (i*j) % multiple == 0]
      mesh[0], mesh[1], dummy = min(all_prods, key = itemgetter(2))

    # then determines parameters of smaller mesh.
    smesh = mesh if mesh[0] <= 500 else (mesh[0] // 3, mesh[1] // 3, mesh[2])
    if mesh[0] % smesh[0] != 0: smesh[0] += smesh[0] - mesh[0] % smesh[0]
    if mesh[1] % smesh[1] != 0: smesh[1] += smesh[1] - mesh[1] % smesh[1]

    # finally determines overlap mesh.
    omesh = (smesh[0]//2 if smesh[0] != mesh[0] else 0),\
            (smesh[1]//2 if smesh[1] != mesh[1] else 0),\
            (smesh[2]//2 if smesh[2] != mesh[2] else 0)

    return mesh, smesh, omesh
Exemple #2
0
  def __call__(self, functional, structure, comm):
    """ Computes parameters of FFT mesh. """
    from operator import itemgetter
    from numpy import pi, sqrt
    from numpy.linalg import norm
    from pylada.physics import a0
    from quantities import angstrom

    para = structure.scale*2.0*sqrt(functional.cutoff)/pi/a0.rescale(angstrom).magnitude
    result = [int(norm(structure.cell[:,0]) * para + 5e-1), \
              int(norm(structure.cell[:,1]) * para + 5e-1), \
              int(norm(structure.cell[:,2]) * para + 5e-1)]

    assert result[0] * result[1] >= comm.size,\
           ValueError("Too many comms for a system this size.")

    if result[0] * result[1] % comm.size != 0:
      a = 0 if result[0] % comm.size  == 0 else comm.size - result[0] % comm.size
      b = 0 if result[1] % comm.size  == 0 else comm.size - result[1] % comm.size
      all_prods = [(i, j, i*j) for i in xrange(result[0], result[0]+a+1)\
                               for j in xrange(result[1], result[1]+b+1)\
                               if (i*j) % comm.size == 0]
      result[0], result[1], dummy = min(all_prods, key = itemgetter(2))

    return result, result, (0,0,0)
Exemple #3
0
from quantities import angstrom, eV, hartree

clj  = Clj()
""" Point charge + r^12 + r^6 model. """
clj.ewald_cutoff = 80 * Ry

clj.charges["A"] = -1.0
clj.charges["B"] =  1.0

structure = Structure()
structure.set_cell = (1,0,0),\
                     (0,1,0),\
                     (0,0,1)
structure.scale = 50
structure.add_atom = (0,0,0), "A"
structure.add_atom = (a0.rescale(angstrom)/structure.scale,0,0), "B"

print clj.ewald(structure).energy, hartree.rescale(eV)


from pylada.crystal.A2BX4 import b5
from pylada.crystal import fill_structure
from numpy import array
clj.ewald_cutoff = 20 * Ry
lattice = b5()
lattice.sites[4].type='A'
structure = fill_structure(lattice.cell, lattice)
structure.scale = 8.0

clj.charges["A"] =  3.0
clj.charges["B"] =  2.0
Exemple #4
0
###############################

# davezac@hopper08:~/SiGe/old/jwluo/SiGe_SL_001/Si6Ge4_on_Ge/vff
from numpy import array
from quantities import angstrom
from pylada.escan import read_input, bandgap
from pylada.crystal import sort_layers
from pylada.crystal.binary import zinc_blende
from pylada.physics import a0

input = read_input("input.py")
cell = [[2.5,0,0],[0.5,0.5,0.5],[0,-0.5,0.5]]
subs = {'A':'Si', 'B':'Ge'}

structure = zinc_blende().to_structure(cell, subs)
structure.scale = float(5.33847592 / 0.5 * a0.rescale(angstrom))
structure = sort_layers(structure, array([2.5,0,0]))
for i, atom in enumerate(structure.atoms):
  atom.type = 'Si' if i % 10 < 6 else 'Ge'

result = bandgap( input.escan, structure, eref=None, 
                  outdir="results/dipoles", references = (-0.2, 0.2),
                  nbstates=4, direction = array([1., 0,0]),
                  fft_mesh = (50,14,14) )

tot = array([0e0] * 3)  / a0 / a0
for e0, e1, u in result.dipole(degeneracy = 5e1 * input.escan.tolerance, attenuate=False):
  tot += (u * u.conjugate()).real
check = array([1.13753549e-03,   5.87932303e-05,   5.87932303e-05]) * 1/a0**2
for a, b in zip(abs(check - tot), abs(check)*1e-2): assert a < max(b, 1e-6), (a, b)