nb = 2 ncl = int(np.floor(nc / 2)) ncu = int(np.ceil(nc / 2)) if nc % 2 == 0: #even lstzn1 = rep(zn1, lvecs, na, nb, ncu) lstzn2 = rep(zn2, lvecs, na, nb, ncl - 1) lsto1 = rep(o1 + lvecs[2], lvecs, na, nb, ncl - 1) lsto2 = rep(o2, lvecs, na, nb, ncl) else: # odd lstzn1 = rep(zn1, lvecs, na, nb, ncl) lstzn2 = rep(zn2, lvecs, na, nb, ncl) lsto1 = rep(o1 + lvecs[2], lvecs, na, nb, ncl) lsto2 = rep(o2, lvecs, na, nb, ncl) lsave(lstzn1, 'Zn1') lsave(lstzn2, 'Zn2') lsave(lsto1, 'O1') lsave(lsto2, 'O2') sublats = ['Zn1', 'Zn2', 'O1', 'O2'] a = np.array([lvecs[0], np.zeros(3), np.zeros(3)]) b = np.array([np.zeros(3), lvecs[1], np.zeros(3)]) c = np.array([np.zeros(3), np.zeros(3), lvecs[2]]) scvecs = na * a + nb * b + nc * c genPOSCAR(sublats, scvecs, sys_name='Zinc Oxide', POS_name=str(nc) + 'pPOSCAR.vasp')
ncyl+=1 for i in comb: dist=np.dot(np.array(i),lvecs) + np.array([2*R,2*R,0]) lstmg1.append(mg1+dist) lstmg2.append(mg2+dist) lstmg3.append(mg3+dist) lstmg4.append(mg4+dist) lsto1.append(o1+dist) lsto2.append(o2+dist) lsto3.append(o3+dist) lsto4.append(o4+dist) lsave(lstmg1,'Mg1') #array method possible? lsave(lstmg2,'Mg2') lsave(lstmg3,'Mg3') lsave(lstmg4,'Mg4') lsave(lsto1,'O1') lsave(lsto2,'O2') lsave(lsto3,'O3') lsave(lsto4,'O4') sublats=['Mg1','Mg2','Mg3','Mg4','O1','O2','O3','O4'] scvecs=[[4*R,0,0],[0,4*R,0],[0,0,(2*crange+4)*np.linalg.norm(c)]] genPOSCAR(sublats,scvecs,sys_name='Magnesium Oxide Rod System',POS_name='MgORodPOSCAR.vasp') rel=np.pi*crange*np.linalg.norm(c)/R metr=100*(ncyl/nrect-rel)/rel print(metr)
O_lst.append(dist) elif name == 'N': N_lst.append(dist) else: C_lst.append(dist) H_rot = [] O_rot = [] N_rot = [] C_rot = [] #rotation is not about the center of the molecule but about the origin, need to translate it after the rotation #the molecule will be incorrectly rotated if it is not reported in terms of coordinates relative to its. This may be found alt = 90 * np.pi / 180 azi = 90 * np.pi / 180 disp = np.array([5, 5, 5]) H_lst = orient(H_lst, alt, azi) + disp O_lst = orient(O_lst, alt, azi) + disp N_lst = orient(N_lst, alt, azi) + disp C_lst = orient(C_lst, alt, azi) + disp lsave(H_lst, 'H1') lsave(O_lst, 'O1') lsave(N_lst, 'N1') lsave(C_lst, 'C1') sublats = ['H1', 'O1', 'N1', 'C1'] scvecs = [[10, 0, 0], [0, 10, 0], [0, 0, 10]] genPOSCAR(sublats, scvecs, sys_name='molecule', POS_name='mculPOSCAR.vasp')
zn1, zn2, o1, o2 = bases na = 1 nb = 1 nc = 1 lstzn1 = rep(zn1, lvecs, na, nb, nc) lstzn2 = rep(zn2, lvecs, na, nb, nc) lsto1 = rep(o1 + lvecs[0], lvecs, na, nb, nc) lsto2 = rep(o2, lvecs, na, nb, nc) lsave(lstzn1, 'Zn1') lsave(lstzn2, 'Zn2') lsave(lsto1, 'O1') lsave(lsto2, 'O2') sublats = ['Zn1', 'Zn2', 'O1', 'O2'] a = np.array([lvecs[0], np.zeros(3), np.zeros(3)]) b = np.array([np.zeros(3), lvecs[1], np.zeros(3)]) c = np.array([np.zeros(3), np.zeros(3), lvecs[2]]) rng = np.arange(0.85, 1.15, 0.0125) c = 0 for i in rng: for j in rng: c += 1 scvecs = [lvecs[0] * i, lvecs[1], lvecs[2] * j] genPOSCAR(sublats, scvecs, sys_name='nonpolar zinc oxide', POS_name=str(c) + 'acPOSCAR.vasp')
#note that Zn_Ot is O_Ot alternatingly Zn_Ot = o1 + (nc / 2 - 0.3) * lvecs[2] + shift O_Ot = zn2 + (nc / 2 - 1.1) * lvecs[2] + shift hole_Ot = lvecs[0] + lvecs[1] + (nc / 2 - 0.3) * lvecs[2] + shift bridge_Ot = lvecs[0] / 2 + lvecs[1] / 2 + (nc / 2 - 0.3) * lvecs[2] + shift Zn_Znt = zn2 - 0.3 * lvecs[2] + shift O_Znt = zn1 - 0.3 * lvecs[2] + shift hole_Znt = lvecs[0] + lvecs[1] + 0.3 * lvecs[2] + shift bridge_Znt = lvecs[0] / 2 + lvecs[1] / 2 + 0.3 * lvecs[2] + shift lstO = rep(O_Znt - 0.1 * lvecs[2], lvecs, na, nb, 1) lstH_Znt = rep(O_Znt - 0.325 * lvecs[2], lvecs, na, nb, 1) lstH_Ot = rep(O_Ot - 0.0625 * lvecs[2], lvecs, na, nb, 1) lsave(lstO, 'O3') lsave(lstH_Znt, 'H1') lsave(lstH_Ot, 'H2') lstS = rep(hole_Ot + lvecs[2] * 0.1, lvecs * size, 1, 1, 1) lsave(lstS, 'S1') sublats = ['Zn1', 'Zn2', 'O1', 'O2', 'O3', 'H1', 'H2', 'S1'] scvecs = [na * lvecs[0], nb * lvecs[1], nc * lvecs[2]] genPOSCAR(sublats, scvecs, sys_name='Zinc Oxide', POS_name='sulf' + str(size) + 'pPOSCAR.vasp')
lsave(lstzn1,'Zn1') lsave(lstzn2,'Zn2') lsave(lsto1,'O1') lsave(lsto2,'O2') Zn_Ot=o1+(nc/2-0.3)*lvecs[2] + shift O_Ot=zn2+(nc/2-1.1)*lvecs[2] + shift hole_Ot=lvecs[0]+lvecs[1]+(nc/2-0.3)*lvecs[2] + shift bridge_Ot=lvecs[0]/2+lvecs[1]/2+(nc/2-0.3)*lvecs[2] + shift Zn_Znt=zn2-0.3*lvecs[2] + shift O_Znt=zn1-0.3*lvecs[2] + shift hole_Znt=lvecs[0]+lvecs[1]+0.3*lvecs[2] + shift bridge_Znt=lvecs[0]/2+lvecs[1]/2+0.3*lvecs[2] + shift lstO=rep(O_Znt-0.1*lvecs[2],lvecs,na,nb,1) lstH_Znt=rep(O_Znt-0.325*lvecs[2],lvecs,na,nb,1) if nc % 2 == 0: lstH_Ot=rep(O_Ot-0.0625*lvecs[2],lvecs,na,nb,1) else: lstH_Ot=rep(Zn_Ot,lvecs,na,nb,1) lsave(lstH_Znt,'H1') lsave(lstO,'O3') lsave(lstH_Ot,'H2') sublats=['Zn1','Zn2','O1','O2','O3','H1','H2'] scvecs=[na*lvecs[0],nb*lvecs[1],nc*lvecs[2]] genPOSCAR(sublats,scvecs,sys_name='Zinc Oxide H-terminated',POS_name=str(nc)+'HpPOSCAR.vasp')
lsto3.append(o3 + dist) lsto4.append(o4 + dist) lsave(lstmg1, 'Mg1') #array method possible? lsave(lstmg2, 'Mg2') lsave(lstmg3, 'Mg3') lsave(lstmg4, 'Mg4') lsave(lsto1, 'O1') lsave(lsto2, 'O2') lsave(lsto3, 'O3') lsave(lsto4, 'O4') sublats = ['Mg1', 'Mg2', 'Mg3', 'Mg4', 'O1', 'O2', 'O3', 'O4'] scvecs = [[4 * R, 0, 0], [0, 4 * R, 0], [0, 0, 4 * R]] genPOSCAR(sublats, scvecs, sys_name='Magnesium Oxide Ball System', POS_name='MgOBallPOSCAR.vasp') metr = 100 * (nsph / ncube - np.pi / 6) / (np.pi / 6) print( metr ) #0.523598=pi/6 is the ratio of the volume of a sphere to the volume of a cube in which it is circumbscribed. As the size of the unit cell increases, this should approach 0. #this structure has only dangling bonds, which might be passivated by layering heterostructures. #MD simulations beginning at high temperatures could give the initial positions if one is fairly sloppy about distributing surface ligands or other passivation atoms. #molecular adsorbates can be rotated with the rot function
for na in range(-arange, arange): for nb in range(-brange, brange): for nc in range(-crange, crange): dist = np.linalg.norm(na * a + nb * b + nc * c) i1 += 1 if dist < R: i2 += 1 comb.append([na, nb, nc]) for i in comb: dist = np.dot(np.array(i), lvecs) + np.array([2 * R, 2 * R, 2 * R]) lstzn1.append(zn1 + dist) lstzn2.append(zn2 + dist) lsto1.append(o1 + a + dist) lsto2.append( o2 + dist ) #since don't account for non-centro symmetry, get non-physical terminations. Would need logical similar to that of the slab replication lsave(lstzn1, 'Zn1') lsave(lstzn2, 'Zn2') lsave(lsto1, 'O1') lsave(lsto2, 'O2') sublats = ['Zn1', 'Zn2', 'O1', 'O2'] scvecs = [[4 * R, 0, 0], [0, 4 * R, 0], [0, 0, 4 * R]] genPOSCAR(sublats, scvecs, sys_name='zinc oxide ball', POS_name='ZnOballPOSCAR.vasp')