-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete3.py
executable file
·354 lines (299 loc) · 11.7 KB
/
delete3.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
import ewt
import fix_uv
import func_ewt
import copy
import sys
from collections import deque
import make_c
import func_mp2
import for_func
import numpy as np
fix_temp = fix_uv
func = func_ewt
f = open("tec.txt", "w")
f_density = open("readfile/test2.50", "r")
f_int = open("Li2/integrals.dat", "r")
f_fock = open("Li2/fock.dat", "r")
f_svdev = open("delete1.txt", "w")
f_overlap = open("delete2.txt", "w")
f_svdev.write("start\n")
#...........input for spin free wicks therem
print "\n Many Body Multireference Perturbation Theory\n"
#Read the input orbital indeces Current assumption : 2 i, 2 u, 3 a
#write a function value to read the file and return the value of the density matrix here
size_vir=24
size_u=2
size_a=3
size_i=2
active = [str(i) for i in range(size_u)]
holes = [str(i) for i in range(size_i)]
particles = [str(i) for i in range(size_vir)]
#make operators without dagger or undegged. -1 for the dagger value meaning not assigned
overall_i, overall_u, overall_a = func.make_operators(holes, active, particles)
#make the single excitation density matrixi
print overall_a
gamma_sin = []
gamma_mv = []
eta_sin = []
coeff = []
gamma_sin, gamma_mv, eta_sin, coeff = func_mp2.read_density_file(f_density, size_u, size_a,size_i)
#print 'gamma\n', gamma_sin
g2, g2mv = for_func.make2(gamma_sin, gamma_mv, coeff, size_u, size_a, size_i)
lambda2 = for_func.lambda2(gamma_sin,g2, coeff, size_u, size_a, size_i)
print 'Lambda\n', np.array(lambda2)
print 'gamma\n', np.array(gamma_sin)
print 'gamma 2\n', np.array(g2)
C = []
#make 1st excitation array of S(u,v)
#Type 1, 2, 3
#Sia=np.array(single_exctd_ovrlp(holes, active, particle, 1))
C.append([])
'''
Siu, Cl=func_mp2.single_excited_overlap(overall_i, overall_u, overall_a, 2, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 2'
Sua, Cl=func_mp2.single_excited_overlap(overall_i, overall_u, overall_a, 3, gamma_sin, eta_sin, lambda2)
print Sua, Cl
C.append(Cl)
print 'done 3'
S2_iajb, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 41, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 4'
S2_iaib, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 42, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 5'
S2_iaia, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 43, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 6'
S2_iuju, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 51, gamma_sin, eta_sin, lambda2)
C.append(Cl)
#print Cl
print 'done 7'
'''
S2_iuiu, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 52, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 8'
'''
S2_aubu, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 61, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print Cl
print 'done 9'
S2_auau, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 62, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 10'
S2_iuuu, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 7, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 11'
S2_uauu, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 8, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 12'
S2_iauu_iuua, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 9, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 13'
S2_iuja, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 101, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 14'
S2_iuia, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 102, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 15'
S2_iaub, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 111, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 16'
S2_iaua, Cl = func_mp2.doubly_excited_overlap(overall_i, overall_u, overall_a, 112, gamma_sin, eta_sin, lambda2)
C.append(Cl)
print 'done 17'
#print C
X_iu, D_iu, Y_iu= np.linalg.svd(Siu, full_matrices=1, compute_uv=1)
X_ua, D_ua, Y_ua= np.linalg.svd(Sua, full_matrices=1, compute_uv=1)
if len(S2_iajb):
X2_iajb, D2_iajb, Y2_iajb = np.linalg.svd(S2_iajb, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iajb, D2_iajb):
print 'sum not matched'
else:
print 'sum matched'
X2_iaib, D2_iaib, Y2_iaib = np.linalg.svd(S2_iaib, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iaib, D2_iaib):
print 'sum not matched'
else:
print 'sum matched'
X2_iaia, D2_iaia, Y2_iaia = np.linalg.svd(S2_iaia, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iaia, D2_iaia):
print 'sum not matched'
else:
print 'sum matched'
if len(S2_iuju):
X2_iuju, D2_iuju, Y2_iuju = np.linalg.svd(S2_iuju, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iuju, D2_iuju):
print 'sum not matched'
else:
print 'sum matched'
X2_iuiu, D2_iuiu, Y2_iuiu = np.linalg.svd(S2_iuiu, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iuiu, D2_iuiu):
print 'sum not matched', '\nX2\n', X2_iuiu, '\nD2\n', D2_iuiu
else:
print 'sum matched'
X2_aubu, D2_aubu, Y2_aubu = np.linalg.svd(S2_aubu, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_aubu, D2_aubu):
print 'sum not matched', '\nX2\n', X2_aubu, '\nD2\n', D2_aubu
else:
print 'sum matched'
X2_auau, D2_auau, Y2_auau = np.linalg.svd(S2_auau, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_auau, D2_auau):
print 'sum not matched', '\nX2\n', X2_auau, '\nD2\n', D2_auau
else:
print 'sum matched'
X2_iuuu, D2_iuuu, Y2_iuuu = np.linalg.svd(S2_iuuu, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iuuu, D2_iuuu):
print 'sum not matched'
else:
print 'sum matched'
X2_uauu, D2_uauu, Y2_uauu = np.linalg.svd(S2_uauu, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_uauu, D2_uauu):
print 'sum not matched'
else:
print 'sum matched'
X2_iauu_iuua, D2_iauu_iuua, Y2_iauu_iuua= np.linalg.svd(S2_iauu_iuua, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iauu_iuua, D2_iauu_iuua):
print 'sum not matched'
else:
print 'sum matched'
if len(S2_iuja):
X2_iuja, D2_iuja, Y2_iuja = np.linalg.svd(S2_iuja, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iuja, D2_iuja):
print 'sum not matched'
else:
print 'sum matched'
X2_iuia, D2_iuia, Y2_iuia = np.linalg.svd(S2_iuia, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iuia, D2_iuia):
print 'sum not matched'
else:
print 'sum matched'
X2_iaub, D2_iaub, Y2_iaub = np.linalg.svd(S2_iaub, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iaub, D2_iaub):
print 'sum not matched'
else:
print 'sum matched'
X2_iaua, D2_iaua, Y2_iaua = np.linalg.svd(S2_iaua, full_matrices=1, compute_uv=1)
if not func_mp2.sum_check(X2_iaua, D2_iaua):
print 'sum not matched'
else:
print 'sum matched'
f_svdev.write('2\n')
f_overlap.write('2\n')
np.savetxt(f_svdev, D_iu, delimiter=' ') # X is an array
np.savetxt(f_overlap, Siu, delimiter=' ') # X is an array
f_svdev.write('3\n')
f_overlap.write('3\n')
np.savetxt(f_svdev, D_ua, delimiter=' ') # X is an array
np.savetxt(f_overlap, Sua, delimiter=' ') # X is an array
if len(S2_iajb):
f_svdev.write('41\n')
f_overlap.write('41\n')
np.savetxt(f_svdev, D2_iajb, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iajb, delimiter=' ') # X is an array
f_svdev.write('42\n')
f_overlap.write('42\n')
np.savetxt(f_svdev, D2_iaib, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iaib, delimiter=' ') # X is an array
f_svdev.write('43\n')
f_overlap.write('43\n')
np.savetxt(f_svdev, D2_iaia, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iaia, delimiter=' ') # X is an array
if len(S2_iuju):
f_svdev.write('51\n')
f_overlap.write('51\n')
np.savetxt(f_svdev, D2_iuju, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iuju, delimiter=' ') # X is an array
f_svdev.write('52\n')
f_overlap.write('52\n')
np.savetxt(f_svdev, D2_iuiu, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iuiu, delimiter=' ') # X is an array
f_svdev.write('61\n')
f_overlap.write('61\n')
np.savetxt(f_svdev, D2_aubu, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_aubu, delimiter=' ') # X is an array
f_svdev.write('62\n')
f_overlap.write('62\n')
np.savetxt(f_svdev, D2_auau, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_auau, delimiter=' ') # X is an array
#f_overlap.write('00')
#f_overlap.close()
#print 'started reading'
#f_overlap = open("overlap.txt", "r")
#temp = func_mp2.readoverlap(f_overlap)
f_svdev.write('7\n')
f_overlap.write('7\n')
np.savetxt(f_svdev, D2_iuuu, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iuuu, delimiter=' ') # X is an array
f_svdev.write('8\n')
f_overlap.write('8\n')
np.savetxt(f_svdev, D2_uauu, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_uauu, delimiter=' ') # X is an array
f_svdev.write('9\n')
f_overlap.write('9\n')
np.savetxt(f_svdev, D2_iauu_iuua, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iauu_iuua, delimiter=' ') # X is an array
if len(S2_iuja):
f_svdev.write('101\n')
f_overlap.write('101\n')
np.savetxt(f_svdev, D2_iuja, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iuja, delimiter=' ') # X is an array
f_svdev.write('102\n')
f_overlap.write('102\n')
np.savetxt(f_svdev, D2_iuia, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iuia, delimiter=' ') # X is an array
f_svdev.write('111\n')
f_overlap.write('111\n')
np.savetxt(f_svdev, D2_iaub, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iaub, delimiter=' ') # X is an array
f_svdev.write('112\n')
f_overlap.write('112\n')
np.savetxt(f_svdev, D2_iaua, delimiter=' ') # X is an array
np.savetxt(f_overlap, S2_iaua, delimiter=' ') # X is an array
f_overlap.write('00')
f_overlap.close()
#print 'started reading'
#f_overlap = open("delete2.txt", "r")
#temp = func_mp2.readoverlap(f_overlap)
#truncate the mastrics
print C[1], C[10]
mat_S2S11 = func_mp2.orthogonalize(C[1], C[10], Siu, gamma_sin, eta_sin, lambda2)
print 'S11\n', S2_iuuu
S2_iuuu = np.subtract(S2_iuuu, mat_S2S11)
print 'new S11\n', S2_iuuu
print C[2], C[11]
mat_S3S12 = func_mp2.orthogonalize(C[1], C[10], Siu, gamma_sin, eta_sin, lambda2)
print 'S12\n', np.array(S2_uauu)
S2_uauu = np.subtract(S2_uauu, mat_S3S12)
print 'new S12\n', S2_uauu
X=[]
X.append([])
X.append(func_mp2.return_truncatedX(Siu, 2))
X.append(func_mp2.return_truncatedX(Sua, 3))
if len(S2_iajb):
X1 = func_mp2.return_truncatedX(S2_iajb, 4)
X1 = func_mp2.return_truncatedX(S2_iaib, 5)
X1 = func_mp2.return_truncatedX(S2_iaia, 6)
if len(S2_iuju):
X1 = func_mp2.return_truncatedX(S2_iuju, 7)
X1 = func_mp2.return_truncatedX(S2_iuiu, 8)
X1 = func_mp2.return_truncatedX(S2_aubu, 9)
X1 = func_mp2.return_truncatedX(S2_auau, 10)
X1 = func_mp2.return_truncatedX(S2_iuuu, 11)
X1 = func_mp2.return_truncatedX(S2_uauu, 12)
X1 = func_mp2.return_truncatedX(S2_iauu_iuua, 13)
if len(S2_iuja):
X1 = func_mp2.return_truncatedX(S2_iuja, 14)
X1 = func_mp2.return_truncatedX(S2_iuia, 15)
X1 = func_mp2.return_truncatedX(S2_iaub, 16)
X1 = func_mp2.return_truncatedX(S2_iaua, 17)
#integrals = func_mp2.readintegrals(f_int, size_vir, size_i, size_u)
fock = func_mp2.readfock(f_fock, size_vir, size_i, size_u)
#Do the energy calculation
print '----------------- energy contribution ', func_mp2.calculate_F(fock, C[1], Siu, X[1], size_i, size_u)
print '----------------- energy contribution ', func_mp2.calculate_F(fock, C[2], Sua, X[2], size_i, size_u)
#print '----------------- energy contribution ', func_mp2.calculate_F(fock, C[3], Siu, X[3], size_i, size_u)
#make array of fock marix needed
#make 2D martix by multiplying each vector to the destined fock 1D matrix
'''
#use overlap atrix to calculate the total energy contribution