forked from vanceeasleaf/aces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.py
77 lines (66 loc) · 1.88 KB
/
Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def getRatio(path):
if(not os.path.exists(path)):return 0.0;
fp=open(path,"r");
fp.next();
natom=int(fp.next().split()[0])
ntype=int(fp.next().split()[0])
if ntype==1:return 0.0;
n=0;
label=""
while(label!="Atoms" and n<20):
label=fp.next().strip();
n+=1
fp.next()
a=[0.0]*ntype
for line in fp:
type=int(line.split()[1])
a[type-1]+=1
return float(a[1])/natom;
def kappa(curPath,result):
# 取出后处理结果,热导率*/
#print curPath
kappaline=shell_exec("cd %s;tail -1 result.txt 2>err;"%curPath);
kappa=kappaline.split('=');
if len(kappa)>1:
kappa=kappa[1]
pwrite(result,"%s"%kappa);
def tEnerty(curPath,result):
# 总能量*/
totalEline=shell_exec("cd %s/minimize;tail -22 log.out| head -1;"%curPath);
totalE=totalEline.split()[1]
pwrite(result,"\t%s"%totalE);
def nAtom(curPath,result):
# 原子数和平均能量*/
Natomline=shell_exec("cd %s/minimize;grep atoms log.out ;"%curPath);
Natom=Natomline.split()[0]
if(Natom.isdigit() and Natom>0):
pwrite(result,"\t%s"%Natom);
#epn=float(totalE)/float(Natom);
#pwrite(result,"\t%f"%epn);
def tDisorder(curPath,result):
# 无序度*/
cd('%s/minimize'%curPath)
mkdir('disorder');cd('disorder')
disorderLine=shell_exec("cp %s"%SRCHOME+"/in.disorder .;"+config.lammps+" <in.disorder 2>err 1>log;tail -1 disorder.txt 2>err;");
k=disorderLine.split()[1:3]
if len(k)==1:
k.append("")
disorder,rd=k
cd(curPath)
pwrite(result,"\t%s\t%s"%(disorder,rd));
def drawStructure(curPath):
cd('%s/minimize'%curPath)
atoms=read('range',format='lammps')
atoms.write('../structure.png')
cd(curPath)
def ineq(ob,curPath,result):
species=ob["species"];
if(not (species in ["CN-small"])):return
cd('%s/minimize'%curPath)
mkdir('nonequ')
cd('nonequ')
ie=inequality()
nonequ5= ie.run()
#nonequ5=shell_exec("cd nonequ;python %s/inequality.py;"%SRCHOME);
cd(curPath)
pwrite(result,"\t%s"%nonequ5);