Skip to content

Commit

Permalink
终端同步
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel-Jia committed Jul 9, 2017
1 parent 7acab6a commit 7722ceb
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 11 deletions.
9 changes: 7 additions & 2 deletions VASP.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def read_poscar(file_name):


def write_poscar(file_name, lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, coordinates, selective):
with open(file_name) as output_file:
with open(file_name, 'w') as output_file:
description = ""
for atom in elements:
description += "%s " % atom
Expand All @@ -113,8 +113,13 @@ def write_poscar(file_name, lattice, basis, elements, num_atoms, selectiveflag,
if re.search(r'^[Dd]', coordinate_type):
coordinates = kardir(basis, coordinates)

# keeping dimension the same
if len(coordinates) - len(selective) > 0:
for i in xrange(len(selective), len(coordinates)):
selective.append(['', '', ''])

for i in xrange(0, len(coordinates)):
output_file.write("%16.10f %16.10f %16.10f %s %s %s" % (coordinates[i][0], coordinates[i][1], coordinates[i][2],
output_file.write("%16.10f %16.10f %16.10f %s %s %s\n" % (coordinates[i][0], coordinates[i][1], coordinates[i][2],
selective[i][0], selective[i][1], selective[i][2]))


Expand Down
100 changes: 100 additions & 0 deletions cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/env python

import sys
from VASP import read_poscar
from VASP import write_poscar

pos=[ [5.8542326628848222, 8.6627288616639202, 5.8614577958952649],
[19.1457883626720999, 8.6618038283281429, 5.8617364474046472],
[12.4996292966500064, 15.5432216444165245, 5.8505835915867426],
[12.4996643651611539, 20.1731884887187114, 5.8689022630647800],
[ 9.8642435232315151, 10.9792336123257641, 5.8473985708617429],
[15.1357647669649271, 10.9791445570918995, 5.8472893749556079],
[ 8.5184517876025279, 17.9094319106692339, 5.8404122824553175],
[16.4803808630984250, 17.9094750385708004, 5.8387698865076327],
[ 5.8239686065138274, 13.2430151734748378, 5.8366213458278002],
[19.1756365833384415, 13.2430391136603038, 5.8350835858967098],
[ 9.8067481495349647, 6.3495826586473152, 5.8328105220657820],
[15.1937500782213348, 6.3490794563218671, 5.8330243464332350],
[ 7.1904979234005300, 15.5651383106483276, 5.8259475258861704],
[17.8087338711519259, 15.5652572833824330, 5.8245572976908671],
[12.5000405878065539, 6.3729308348105809, 5.8218156883507675],
[ 9.8820227202533282, 20.1615823696097038, 5.7844099681486449],
[15.1170850426095829, 20.1616169957727216, 5.7828276269297225],
[ 9.8122233556618639, 15.6062771111702467, 5.7978947497764279],
[15.1870343137687520, 15.6062640823243584, 5.7973780728100950],
[ 8.4652256331715456, 13.2749294624138567, 5.7971824780871497],
[16.5343455597751188, 13.2747877636130056, 5.7962617201112181],
[11.1535516011113938, 8.6216877683269875, 5.7938944716497121],
[13.8466676349981466, 8.6214440419079121, 5.7943806235593751],
[11.1490651429739547, 17.9761055906219411, 5.7801712196507227],
[13.8496966421608665, 17.9760454193992452, 5.7804718311372252],
[ 7.0806236588204898, 10.9316354119090882, 5.7771740040302655],
[17.9196297301407306, 10.9312779304740122, 5.7762362324898824],
[11.1466749444189528, 13.2819533837950718, 5.7838345774454654],
[13.8529870474015446, 13.2820766532686125, 5.7835474481279379],
[ 8.4321768825083225, 8.5939250693677529, 5.7740131122559575],
[16.5679980292057039, 8.5938416892026712, 5.7741364855875670],
[12.5001416610547142, 10.9397393077747278, 5.7828449293659103],
[ 4.5545882618995801, 10.9372558294256201, 5.7785902068256227],
[20.4451384058851815, 10.9363239532347656, 5.7776259828189218],
[ 7.1740910330408996, 6.4035538749654872, 5.7743942607092302],
[17.8255437064344839, 6.4026847899577053, 5.7752304099191845],
[ 5.8568607540469744, 11.7651243950267137, 3.6608883120443871],
[19.1436939971528197, 11.7667770355312129, 3.6604706101656226],
[ 8.5426819733447310, 7.1162155758867005, 3.6587428673277396],
[16.4586851339770135, 7.1174272612378884, 3.6584426541561030],
[ 9.8136168292230721, 18.6222830403632145, 3.6663636877511325],
[12.4995145412520650, 18.6312555181673005, 3.6548235558601054],
[15.1831458084883888, 18.6231885937048105, 3.6654539879666501],
[ 7.1905459875948967, 9.4375562195163099, 3.6484179628325952],
[17.8089055071839013, 9.4369088439504623, 3.6479812702380898],
[ 8.5106357931706622, 16.3341139136295936, 3.6206149773764928],
[16.4878788265676661, 16.3351489370489098, 3.6202856639716825],
[ 7.1851154172870926, 14.0394083936080634, 3.6189915219198379],
[17.8144949861972179, 14.0402357499072128, 3.6176999795794704],
[11.1752410014319725, 7.1318705445070725, 3.6144877158625528],
[13.8259816450236723, 7.1317412695549667, 3.6160137060298552],
[12.4996158325251283, 14.0602012265637786, 3.6075313553575503],
[11.1505765206244050, 11.7223267224017249, 3.6068877754449300],
[13.8502987706658622, 11.7232173727088629, 3.6066155977606549],
[11.1498571077593756, 16.4113638209514292, 3.5760358823059648],
[13.8485674418494789, 16.4107606851385235, 3.5759996716579900],
[ 9.7891812762153094, 9.3780459876955025, 3.5711816461132022],
[15.2101276867227853, 9.3789002597240856, 3.5716568501771477],
[ 8.4393762279991158, 11.7162332293038247, 3.5731022570868047],
[16.5617228908786025, 11.7167625758915364, 3.5727113095524476],
[ 9.7777043270454023, 14.0726331225701404, 3.5575765222356122],
[15.2221258811660487, 14.0731293508385509, 3.5569787180677124],
[12.5002525096445680, 9.3601828303336774, 3.5542392678181502],
[ 8.5320020693175405, 14.7910868434451501, 1.5187845488341576],
[16.4668862744892053, 14.7933338472709952, 1.5180927858648652],
[ 9.8887961265038822, 17.1463588545972883, 1.5146754477426800],
[15.1081461908212749, 17.1487848478586997, 1.5146578136720801],
[12.5020410432031692, 7.9226726991187002, 1.5145458408523949],
[ 7.1705177122920194, 12.4396711855405453, 1.5118473503168626],
[17.8294570832127093, 12.4413426726000420, 1.5111017865561325],
[ 9.7860910857492662, 7.9205963993608606, 1.5076994932664651],
[15.2171821019143749, 7.9212608271536356, 1.5081308582786375],
[12.5003167921428595, 12.5030053504844716, 1.4977462763204274],
[12.4991949683432502, 17.0771780327954161, 1.4738220963398374],
[11.1387551669516434, 14.8215426119312426, 1.4782594263777826],
[13.8601305439163998, 14.8216561851532873, 1.4781982275442249],
[ 9.8121148532213063, 12.5195525373460228, 1.4769349629129875],
[15.1895751883270265, 12.5200970496508468, 1.4764890499645225],
[11.1714269060458786, 10.1654087289077619, 1.4752615333521850],
[13.8288820354799782, 10.1668810853471037, 1.4752820024869751],
[ 8.5369568562395006, 10.2155217644163354, 1.4700324542918575],
[16.4634057452755975, 10.2154701580726197, 1.4701338323750650]
]


lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, coordinates, selective = read_poscar(sys.argv[1])

temp = coordinates[:119]
temp.extend(pos)
temp.extend(coordinates[119:])
num_atoms[0] += 82

write_poscar('POSCAR.vasp', lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, temp, selective)

12 changes: 5 additions & 7 deletions flagck.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import re

file_name = 'POSCAR'

with open(file_name) as input_file:
content = input_file.readlines()

Expand All @@ -15,14 +14,13 @@
print "------------------------------------------"
for i in xrange(9, len(content)):
temp = pattern.split(content[i].strip())
length = len(temp)

if length == 1:
if len(temp) == 1:
exit(0)

if length != 6:
if len(temp) != 6:
print "-----------"
print "%4d: %s" % (i - 8, content[i].strip())
print "%4d: %s" % (i - 8, content[i].rstrip())
print "-----------"
continue

Expand All @@ -36,8 +34,8 @@
continue
else:
pre_flag = flag
print "%4d: %s" % (i - 9, content[i - 1].strip())
print "%4d: %s" % (i - 8, content[i].strip())
print "%4d: %s" % (i - 9, content[i - 1].rstrip())
print "%4d: %s" % (i - 8, content[i].rstrip())
print "-----------"

print ""
157 changes: 157 additions & 0 deletions hlcluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/bin/env python

import sys
import VASP
import re
pos1 = [[ 8.52663112, 14.79337948, 14.52301881],
[ 16.47997580, 14.79343097, 14.51908835],
[ 11.14789630, 14.85687226, 14.51622011],
[ 13.85760488, 14.85722967, 14.51548506],
[ 9.78287211, 12.49254211, 14.51553649],
[ 15.22261961, 12.49238169, 14.51371286],
[ 11.13563815, 10.14933498, 14.51532174],
[ 13.86597088, 10.14847010, 14.51428049],
[ 12.50012880, 7.90943392, 14.51976956],
[ 12.50372460, 12.50075283, 14.72163059],
[ 9.78440676, 17.09766453, 14.48773211],
[ 15.22295554, 17.09739644, 14.48602752],
[ 7.15981020, 12.55477124, 14.48660210],
[ 17.84482988, 12.55353408, 14.48367771],
[ 12.50374400, 17.08727980, 14.47394451],
[ 9.87605186, 7.84598863, 14.48403817],
[ 15.12400216, 7.84505696, 14.48361730],
[ 8.52637045, 10.20520181, 14.47173998],
[ 16.47553419, 10.20431563, 14.47057725],
[ 12.50162082, 15.62744811, 12.44805426],
[ 9.78981284, 10.93427811, 12.44606936],
[ 15.21142132, 10.93350182, 12.44513778],
[ 9.80328010, 15.61779801, 12.45193423],
[ 15.19879468, 15.61737840, 12.45016375],
[ 8.44957785, 13.27629042, 12.45064043],
[ 16.55283128, 13.27448455, 12.44803144],
[ 11.14706080, 8.60486927, 12.44908613],
[ 13.85249392, 8.60483110, 12.44875320],
[ 11.14080909, 13.28417801, 12.37402178],
[ 13.86129087, 13.28384618, 12.37357051],
[ 12.50040244, 10.93013268, 12.37344562],
[ 11.16790993, 17.86382119, 12.37953773],
[ 13.83623659, 17.86393157, 12.37839810],
[ 7.18532081, 10.97162350, 12.37640674],
[ 17.81618039, 10.96917629, 12.37482430],
[ 8.52043182, 8.66069151, 12.37565154],
[ 16.47890651, 8.65897510, 12.37489045],
[ 7.19477108, 15.56239596, 12.31904726],
[ 17.80774841, 15.56122995, 12.31656077],
[ 12.49966163, 6.37471536, 12.31590153],
[ 8.55158958, 17.88809068, 12.32062468],
[ 16.45265851, 17.88723731, 12.31870385],
[ 5.85767123, 13.22339656, 12.31734762],
[ 19.14459556, 13.22189528, 12.31494919],
[ 9.80713808, 6.38527824, 12.31505608],
[ 15.19009880, 6.38373013, 12.31477027],
[ 7.17419958, 18.59601593, 10.22637496],
[ 17.82830097, 18.59530226, 10.22321914],
[ 4.55461164, 14.05906469, 10.22249110],
[ 20.44650799, 14.05754717, 10.21944311],
[ 8.42136455, 16.41006373, 10.18936218],
[ 16.58069447, 16.40942145, 10.18738731],
[ 12.50057691, 14.05937074, 10.21535316],
[ 9.87962931, 4.83952796, 10.21780715],
[ 15.11771081, 4.83864890, 10.21828204],
[ 11.14849921, 11.71880557, 10.21433043],
[ 13.85197245, 11.71839398, 10.21388722],
[ 7.07163033, 14.07557769, 10.18966559],
[ 17.92981245, 14.07451466, 10.18715058],
[ 11.15032078, 7.01258145, 10.18585555],
[ 13.84805427, 7.01260553, 10.18468742],
[ 11.15374139, 16.38258017, 10.19406419],
[ 13.84797712, 16.38262181, 10.19305577],
[ 8.46142283, 11.72200026, 10.19193337],
[ 16.53912952, 11.72137050, 10.19082751],
[ 9.80868275, 9.39175408, 10.19042848],
[ 15.19121513, 9.39139801, 10.19000713],
[ 12.50135228, 18.62698462, 10.16962569],
[ 7.19030646, 9.43427206, 10.16393883],
[ 17.80928245, 9.43264096, 10.16320550],
[ 9.81079791, 18.65246946, 10.15161108],
[ 15.19173033, 18.65258132, 10.15047131],
[ 5.82378702, 11.74973673, 10.14719363],
[ 19.17687861, 11.74901365, 10.14552497],
[ 8.51399694, 7.09243078, 10.14437820],
[ 16.48462386, 7.09196221, 10.14483167],
[ 9.86853781, 14.01808792, 10.15838631],
[ 15.13244188, 14.01737556, 10.15760583],
[ 12.49981106, 9.46102591, 10.15664749],
[ 5.85053309, 16.33653652, 10.14074533],
[ 19.15069695, 16.33600992, 10.13783351],
[ 12.49931777, 4.82427576, 10.13718242],
[ 7.18523207, 17.13677427, 8.01539152],
[ 17.81493362, 17.13612020, 8.01291170],
[ 5.82590638, 14.78219838, 8.01390731],
[ 19.17465308, 14.78132898, 8.01158728],
[ 11.14006478, 5.58027740, 8.01015883],
[ 13.85860959, 5.58043958, 8.00916219],
[ 8.53147710, 19.37002966, 8.00455541],
[ 16.46920527, 19.36960314, 8.00259121],
[ 8.46738535, 14.82637476, 8.00658441],
[ 16.53288730, 14.82600301, 8.00537653],
[ 11.13861128, 14.84751514, 8.00240172],
[ 13.86148623, 14.84720046, 8.00199886],
[ 12.49994745, 12.50006125, 8.00063110],
[ 9.78416859, 17.21308386, 7.99515119],
[ 15.21588849, 17.21290637, 7.99420108],
[ 4.56377466, 12.49940921, 7.99904840],
[ 20.43610028, 12.49779898, 7.99698832],
[ 12.49920704, 7.84559494, 8.00242003],
[ 7.05812000, 12.49413290, 7.99278396],
[ 17.94178450, 12.49358184, 7.99141504],
[ 9.78582520, 12.50421909, 8.00089516],
[ 15.21413615, 12.50369827, 8.00052122],
[ 12.50007180, 17.15587369, 7.99900446],
[ 11.14649591, 10.14802062, 7.99941063],
[ 13.85314391, 10.14774254, 7.99948145],
[ 9.77481016, 7.79245421, 7.98959054],
[ 15.22469429, 7.79201704, 7.98943559],
[ 8.46632515, 10.17202968, 7.99540983],
[ 8.53256540, 5.62907836, 7.99458204],
[ 16.46612157, 5.62801086, 7.99582303],
[ 16.53337285, 10.17092209, 7.99467923],
[ 11.13544681, 19.42130452, 7.97773530],
[ 13.86508896, 19.42136867, 7.97785955],
[ 5.82074273, 10.21941636, 7.97126648],
[ 19.17882835, 10.21844766, 7.97010409],
[ 7.18631774, 7.85639597, 7.96997322],
[ 17.81284174, 7.85499234, 7.97028496]]

# hlcluster.py inputfile.gjf -n +n n-n

lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, coordinates, selective = VASP.read_poscar('POSCAR')
with open(sys.argv[1]) as IN:
input_file = IN.readlines()
space = re.compile(r'\s+')
a = int(sys.argv[2]) - 1
b = int(sys.argv[3]) - 1
temp = sys.argv[4].split('-')
c = int(temp[0]) - 1
d = int(temp[1])

gjfcoord = []
for i in xrange(5, len(input_file)):
if input_file[i].strip() == '':
break
line = space.split(input_file[i].strip())
gjfcoord.append([float(line[1]), float(line[2]), float(line[3])])

coor = []
num_atoms[2] = 0
for i in xrange(c, d):
v1 = gjfcoord[i][0] - gjfcoord[a][0] + pos1[b][0]
v2 = gjfcoord[i][1] - gjfcoord[a][1] + pos1[b][1]
v3 = gjfcoord[i][2] - gjfcoord[a][2] + pos1[b][2]
pos1.append([v1, v2, v3])
num_atoms[2] += 1
num_atoms[2] -= 2

VASP.write_poscar('POSCAR.vasp', lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, pos1, selective)


4 changes: 2 additions & 2 deletions imagefreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re
from VASP import read_total_atoms
from VASP import grep_OUTCAR
from VASP import grep_outcar

print ""
print " --------------------Processing--------------------"
Expand All @@ -12,7 +12,7 @@
atom_num += 2

string = "grep \"f/i\" OUTCAR -A %d" % atom_num
content = grep_OUTCAR(string)
content = grep_outcar(string)

pattern = re.compile("([0-9]+)\s+f/i")
content_length = len(content)
Expand Down

0 comments on commit 7722ceb

Please sign in to comment.