Ejemplo n.º 1
0
def export_for_atomeye(configuration, f):
    "AtomEye Extended CFG format"
    pbc = configuration.pbc
    atoms = configuration.atoms
    aux = [
        # uncomment to add temperature (works if there are atom velocities
        # in the input file)

        #("temperature [K]", lambda a: a.get_temperature()),

        # add aux value that can be used to color code atomic positions
        # in unit cell, in selected direction. The coloring works with hsv
        # color scale in AtomEye, or any other scale that is cyclic, i.e.
        # the same color corresponds to values 0 and 1.

        #("xcolor [0-1]", in_cell_pos_fun(0, pbc[0][0]/2,
        #                                   pos0=_find_pos0(atoms))),
    ]

    # atoms from VASP POSCAR with Selective dynamics have allow_change attr
    if hasattr(atoms[0], "allow_change"):
        aux += [("change x", lambda a: float(a.allow_change[0])),
                ("change y", lambda a: float(a.allow_change[1])),
                ("change z", lambda a: float(a.allow_change[2]))]

    if pbc is None or len(pbc) == 0:
        raise ValueError("no PBC")
    if not isinstance(pbc, numpy.ndarray):
        pbc = numpy.array(pbc)
    print >> f, "Number of particles = %i" % len(atoms)
    for i in get_comment_list(configuration):
        print >> f, "# " + i
    print >> f, "A = 1.0 Angstrom (basic length-scale)"
    for i in range(3):
        for j in range(3):
            print >> f, "H0(%i,%i) = %f A" % (i + 1, j + 1,
                                              configuration.pbc[i][j])
    print >> f, ".NO_VELOCITY."
    print >> f, "entry_count = %i" % (3 + len(aux))
    for n, a in enumerate(aux):
        print >> f, "auxiliary[%i] = %s" % (n, a[0])
    H_1 = linalg.inv(pbc)
    previous_name = None
    for i in atoms:
        if previous_name != i.name:
            print >> f, pse.get_atom_mass(i.name)
            print >> f, i.name
            previous_name = i.name
        s = numpy.dot(i.pos, H_1) % 1.0
        entries = [s[0], s[1], s[2]]
        for aname, afunc in aux:
            entries.append(afunc(i))
        print >> f, " ".join("%f" % i for i in entries)
Ejemplo n.º 2
0
def export_for_atomeye(configuration, f):
    "AtomEye Extended CFG format"
    pbc = configuration.pbc
    atoms = configuration.atoms
    aux = [
            # uncomment to add temperature (works if there are atom velocities
            # in the input file)

           #("temperature [K]", lambda a: a.get_temperature()),

            # add aux value that can be used to color code atomic positions
            # in unit cell, in selected direction. The coloring works with hsv
            # color scale in AtomEye, or any other scale that is cyclic, i.e.
            # the same color corresponds to values 0 and 1.

           #("xcolor [0-1]", in_cell_pos_fun(0, pbc[0][0]/2,
           #                                   pos0=_find_pos0(atoms))),
          ]

    # atoms from VASP POSCAR with Selective dynamics have allow_change attr
    if hasattr(atoms[0], "allow_change"):
        aux += [ ("change x", lambda a: float(a.allow_change[0])),
                 ("change y", lambda a: float(a.allow_change[1])),
                 ("change z", lambda a: float(a.allow_change[2])) ]

    if pbc is None or len(pbc) == 0:
        raise ValueError("no PBC")
    if not isinstance(pbc, numpy.ndarray):
        pbc = numpy.array(pbc)
    print >>f, "Number of particles = %i" % len(atoms)
    for i in get_comment_list(configuration):
        print >>f, "# " + i
    print >>f, "A = 1.0 Angstrom (basic length-scale)"
    for i in range(3):
        for j in range(3):
            print >>f, "H0(%i,%i) = %f A" % (i+1, j+1, configuration.pbc[i][j])
    print >>f, ".NO_VELOCITY."
    print >>f, "entry_count = %i" % (3 + len(aux))
    for n, a in enumerate(aux):
        print >>f, "auxiliary[%i] = %s" % (n, a[0])
    H_1 = linalg.inv(pbc)
    previous_name = None
    for i in atoms:
        if previous_name != i.name:
            print >>f, pse.get_atom_mass(i.name)
            print >>f, i.name
            previous_name = i.name
        s = numpy.dot(i.pos, H_1) % 1.0
        entries = [s[0], s[1], s[2]]
        for aname, afunc in aux:
            entries.append(afunc(i))
        print >>f, " ".join("%f" % i for i in entries)
Ejemplo n.º 3
0
 def get_mass(self):
     return pse.get_atom_mass(self.name)