Beispiel #1
0
def structure2aSys(structure,idoffset=1):
    """
    Converts Structure object of pymatgen to NAPSystem object in nap.

    Args:
        structure (Structure): pymatgen Structure object to be converted
        to NAPSystem object..

    Returns:
        aSys (NAPSystem): 
    """
    lattice= structure.lattice
    alc= 1.0
    a1= np.array(lattice.matrix[0])
    a2= np.array(lattice.matrix[1])
    a3= np.array(lattice.matrix[2])
    #... rescale a? vectors
    a1= a1/alc
    a2= a2/alc
    a3= a3/alc
    aSys= NAPSystem()
    aSys.set_lattice(alc,a1,a2,a3)
    for ia in range(structure.num_sites):
        ai= Atom()
        si= structure[ia]
        crd= si.frac_coords
        ai.set_pos(crd[0],crd[1],crd[2])
        sid= structure.symbol_set.index(si.species_string)+idoffset
        ai.set_sid(sid)
        ai.set_id(ia+1)
        aSys.add_atom(ai)
    return aSys
Beispiel #2
0
def structure2aSys(structure, idoffset=1):
    """
    Converts Structure object of pymatgen to NAPSystem object in nap.

    Args:
        structure (Structure): pymatgen Structure object to be converted
        to NAPSystem object..

    Returns:
        aSys (NAPSystem): 
    """
    lattice = structure.lattice
    alc = 1.0
    a1 = np.array(lattice.matrix[0])
    a2 = np.array(lattice.matrix[1])
    a3 = np.array(lattice.matrix[2])
    #... rescale a? vectors
    a1 = a1 / alc
    a2 = a2 / alc
    a3 = a3 / alc
    aSys = NAPSystem()
    aSys.set_lattice(alc, a1, a2, a3)
    for ia in range(structure.num_sites):
        ai = Atom()
        si = structure[ia]
        crd = si.frac_coords
        ai.set_pos(crd[0], crd[1], crd[2])
        sid = structure.symbol_set.index(si.species_string) + idoffset
        ai.set_sid(sid)
        ai.set_id(ia + 1)
        aSys.add_atom(ai)
    return aSys
Beispiel #3
0
def make_sc(latconst=1.0):
    """
    Make a cell of simple cubic structure.
    """
    s= NAPSystem(specorder=_default_specorder)
    #...lattice
    a1= np.array([ 1.0, 0.0, 0.0 ])
    a2= np.array([ 0.0, 1.0, 0.0 ])
    a3= np.array([ 0.0, 0.0, 1.0 ])
    s.set_lattice(latconst,a1,a2,a3)
    p=[0.00, 0.00, 0.00]
    atom= Atom()
    atom.set_pos(p[0],p[1],p[2])
    atom.set_symbol(_default_specorder[0])
    s.add_atom(atom)
    return s
Beispiel #4
0
def make_bcc(latconst=1.0):
    """
    Make a cell of bcc structure.
    """
    s= NAPSystem(specorder=_default_specorder)
    #...lattice
    a1= np.array([ 1.0, 0.0, 0.0 ])
    a2= np.array([ 0.0, 1.0, 0.0 ])
    a3= np.array([ 0.0, 0.0, 1.0 ])
    s.set_lattice(latconst,a1,a2,a3)
    positions=[(0.00, 0.00, 0.00),
               (0.50, 0.50, 0.50)]
    for p in positions:
        atom= Atom()
        atom.set_pos(p[0],p[1],p[2])
        atom.set_symbol(_default_specorder[0])
        s.add_atom(atom)
    return s
Beispiel #5
0
def doc_to_pos(doc,conf):
    """
    Make a pos file, which has pmd format, from a document in MongoDB.
    """
    psys= NAPSystem()
    matrix=doc['calculations'][-1]['output']['crystal']['lattice']['matrix']
    a1= matrix[0]
    a2= matrix[1]
    a3= matrix[2]
    psys.set_lattice(1.0,a1,a2,a3)

    species_ids=conf['species_ids']

    sites= doc['calculations'][-1]['output']['crystal']['sites']
    for site in sites:
        ra= site['abc']
        ai= Atom()
        ai.set_pos(ra[0],ra[1],ra[2])
        ai.set_sid(species_ids[site['species'][0]['element']])
        psys.add_atom(ai)
    return psys
Beispiel #6
0
def doc_to_pos(doc, conf):
    """
    Make a pos file, which has pmd format, from a document in MongoDB.
    """
    psys = NAPSystem()
    matrix = doc['calculations'][-1]['output']['crystal']['lattice']['matrix']
    a1 = matrix[0]
    a2 = matrix[1]
    a3 = matrix[2]
    psys.set_lattice(1.0, a1, a2, a3)

    species_ids = conf['species_ids']

    sites = doc['calculations'][-1]['output']['crystal']['sites']
    for site in sites:
        ra = site['abc']
        ai = Atom()
        ai.set_pos(ra[0], ra[1], ra[2])
        ai.set_sid(species_ids[site['species'][0]['element']])
        psys.add_atom(ai)
    return psys
Beispiel #7
0
pmdexec = options.pmdexec

asys = NAPSystem()
# system size is bigger than 2*rcut
a1 = np.array([2.0, 0.0, 0.0])
a2 = np.array([0.0, 1.0, 0.0])
a3 = np.array([0.0, 0.0, 1.0])
alc = rcut
asys.set_lattice(alc, a1, a2, a3)

atom1 = Atom()
atom2 = Atom()
atom1.set_pos(0.0, 0.0, 0.0)
atom1.set_id(1)
atom1.set_sid(sid1)
asys.add_atom(atom1)
atom2.set_pos(0.5, 0.0, 0.0)
atom2.set_id(2)
atom2.set_sid(sid2)
asys.add_atom(atom2)

hmin = rmin / (2 * rcut)
hd = (0.5 - hmin) / nsmpl

os.system('cp pmdini pmdorig')

fout = open('out.2body', 'w')
for ip in range(nsmpl + 1):
    print '.',
    d = hmin + hd * ip
    asys.atoms[1].pos[0] = d
Beispiel #8
0
hext[1] = sysext.a2 * sysext.alc
hext[2] = sysext.a3 * sysext.alc

#...make extended system corresponding to the phonopy definition
for ia in range(natm0):
    ai0 = sys0.atoms[ia]
    for i3 in range(r3):
        for i2 in range(r2):
            for i1 in range(r1):
                ai = Atom()
                ai.set_sid(ai0.sid)
                p1 = (ai0.pos[0] + i1) / r1
                p2 = (ai0.pos[1] + i2) / r2
                p3 = (ai0.pos[2] + i3) / r3
                ai.set_pos(p1, p2, p3)
                sysext.add_atom(ai)
sysext.reset_ids()
natme = sysext.num_atoms()
print ' sysext.num_atoms()=', natme

# for ai in sysext.atoms:
#     print ai.pos

os.system('cp pmdini pmdorig')

#...loop for all atoms in the extended system
fcmat = np.zeros((natme, natme, 3, 3))
for ia in range(natme):
    print '.',
    sys.stdout.flush()
    ppos = np.array(sysext.atoms[ia].pos)
Beispiel #9
0
print(' amax          = ',amax)
distance= options.distance
print(' distance      = ',distance,' Ang.')
pmdexec= options.pmdexec

asys= NAPSystem()
a1= np.array([2.0, 0.0, 0.0])
a2= np.array([0.0, 2.0, 0.0])
a3= np.array([0.0, 0.0, 1.0])
alc= rcut
asys.set_lattice(alc,a1,a2,a3)

atom1= Atom()
atom1.set_pos(0.0,0.0,0.0)
atom1.set_id(1)
asys.add_atom(atom1)

hd= distance/(alc*2)
atom2= Atom()
atom2.set_pos(hd,0.0,0.0)
atom2.set_id(2)
asys.add_atom(atom2)

atom3= Atom()
atom3.set_pos(0.0,0.0,0.0)
atom3.set_id(3)
asys.add_atom(atom3)

da  = (amax-amin)/nsmpl

fout= open('out.3body','w')
Beispiel #10
0
hext[1]= sysext.a2 *sysext.alc
hext[2]= sysext.a3 *sysext.alc

#...make extended system corresponding to the phonopy definition
for ia in range(natm0):
    ai0= sys0.atoms[ia]
    for i3 in range(r3):
        for i2 in range(r2):
            for i1 in range(r1):
                ai= Atom()
                ai.set_sid(ai0.sid)
                p1= (ai0.pos[0]+i1)/r1
                p2= (ai0.pos[1]+i2)/r2
                p3= (ai0.pos[2]+i3)/r3
                ai.set_pos(p1,p2,p3)
                sysext.add_atom(ai)
sysext.reset_ids()
natme= sysext.num_atoms()
print ' sysext.num_atoms()=',natme

# for ai in sysext.atoms:
#     print ai.pos

os.system('cp pmd0000 pmd0000.orig')

#...loop for all atoms in the extended system
fcmat= np.zeros((natme,natme,3,3))
for ia in range(natme):
    print '.',
    sys.stdout.flush()
    ppos= np.array(sysext.atoms[ia].pos)
Beispiel #11
0
    hmat= psnew.get_hmat()
    hi = np.linalg.inv(hmat)
    for ia,posi in enumerate(expos):
        sposi = np.dot(hi,posi)
        if 0.0 <= sposi[0] < 1.0 and \
           0.0 <= sposi[1] < 1.0 and \
           0.0 <= sposi[2] < 1.0:
            atom = Atom()
            symbol = exsymbols[ia]
            print('{0:5d} {1:s}'.format(ia,symbol)
                  +' {0:12.5f} {1:12.5f} {2:12.5f}'.format(sposi[0],
                                                           sposi[1],
                                                           sposi[2]))
            
            atom.set_symbol(symbol)
            atom.set_pos(sposi[0],sposi[1],sposi[2])
            psnew.add_atom(atom)
            
    tmp = None
    #tmp = raw_input('Input periodic shift vector if you want: ')
    tmp = ' 0.5, 0.0, 0.5'
    if tmp:
        shift = [ float(x) for x in tmp.split(',')]
        for a in psnew.atoms:
            a.pos[0] += shift[0]
            a.pos[1] += shift[1]
            a.pos[2] += shift[2]
        psnew.assign_pbc()
    psnew.write_POSCAR(infile+'.new')
    print('Check '+infile+'.new')