@@ -90,7 +90,7 @@ def CreateIndices(S):
90
90
91
91
def Gaussian (r , sigma = 0.5 ):
92
92
twosigma2 = 2. * sigma * sigma
93
- return np .exp (- r * r / twosigma2 ) / np .power (np .sqrt (m .pi * twosigma2 ), 3 );
93
+ return np .exp (- r * r / twosigma2 ) / np .power (np .sqrt (m .pi * twosigma2 ), 3 )
94
94
95
95
96
96
# In[9]:
@@ -137,42 +137,42 @@ def fft3(dat, N, s):
137
137
# In[14]:
138
138
139
139
140
- def cI (input ):
141
- return fft3 (input , S , 1 )
140
+ def cI (inp ):
141
+ return fft3 (inp , S , 1 )
142
142
143
143
144
144
# In[15]:
145
145
146
146
147
- def cJ (input ):
148
- return 1. / np .prod (S ) * fft3 (input , S , - 1 )
147
+ def cJ (inp ):
148
+ return 1. / np .prod (S ) * fft3 (inp , S , - 1 )
149
149
150
150
151
151
# In[16]:
152
152
153
153
154
- def O (input ):
155
- return splalg .det (R ) * input
154
+ def O (inp ):
155
+ return splalg .det (R ) * inp
156
156
157
157
158
158
# In[17]:
159
159
160
160
161
- def L (input ):
162
- return - splalg .det (R ) * G2 * input
161
+ def L (inp ):
162
+ return - splalg .det (R ) * G2 * inp
163
163
164
164
165
165
# In[18]:
166
166
167
167
168
168
def Linv (inp ):
169
169
if inp .ndim == 1 :
170
- input = np .reshape (inp , (inp .size , 1 ))
170
+ vals = np .reshape (inp , (inp .size , 1 ))
171
171
else :
172
- input = inp
172
+ vals = inp
173
173
174
174
old_settings = np .seterr (divide = 'ignore' , invalid = 'ignore' )
175
- result = - 1. / splalg .det (R ) * input / np .reshape (G2 , input .shape )
175
+ result = - 1. / splalg .det (R ) * vals / np .reshape (G2 , vals .shape )
176
176
result [0 ] = 0
177
177
np .seterr (** old_settings )
178
178
return result
@@ -238,7 +238,7 @@ def Plot(dat):
238
238
ax3 = fig .add_subplot (1 , 3 , 3 , projection = '3d' )
239
239
ax3 .plot_surface (xs , ys , toplot3 , cmap = 'viridis' , edgecolor = 'none' )
240
240
241
- plt .tight_layout
241
+ plt .tight_layout ()
242
242
plt .show ()
243
243
244
244
@@ -334,13 +334,13 @@ def Plot(dat):
334
334
335
335
def cI (inp ):
336
336
if inp .ndim == 1 :
337
- input = np .reshape (inp , (inp .size , 1 ))
337
+ vals = np .reshape (inp , (inp .size , 1 ))
338
338
else :
339
- input = inp
339
+ vals = inp
340
340
341
- out = np .zeros (input .shape , dtype = "complex_" )
342
- for col in range (np .size (input , 1 )):
343
- out [:,col ] = fft3 (input [:,col ], S , 1 )
341
+ out = np .zeros (vals .shape , dtype = "complex_" )
342
+ for col in range (np .size (vals , 1 )):
343
+ out [:,col ] = fft3 (vals [:,col ], S , 1 )
344
344
345
345
return out
346
346
@@ -350,15 +350,15 @@ def cI(inp):
350
350
351
351
def cJ (inp ):
352
352
if inp .ndim == 1 :
353
- input = np .reshape (inp , (inp .size , 1 ))
353
+ vals = np .reshape (inp , (inp .size , 1 ))
354
354
else :
355
- input = inp
355
+ vals = inp
356
356
357
357
norm = 1. / np .prod (S )
358
- out = np .zeros (input .shape , dtype = "complex_" )
358
+ out = np .zeros (vals .shape , dtype = "complex_" )
359
359
360
- for col in range (np .size (input , 1 )):
361
- out [:,col ] = norm * fft3 (input [:,col ], S , - 1 )
360
+ for col in range (np .size (vals , 1 )):
361
+ out [:,col ] = norm * fft3 (vals [:,col ], S , - 1 )
362
362
363
363
return out
364
364
@@ -368,26 +368,26 @@ def cJ(inp):
368
368
369
369
def L (inp ):
370
370
if inp .ndim == 1 :
371
- input = np .reshape (inp , (inp .size , 1 ))
371
+ vals = np .reshape (inp , (inp .size , 1 ))
372
372
else :
373
- input = inp
373
+ vals = inp
374
374
375
- return - splalg .det (R ) * (G2 @ np .ones ((1 , np .size (input , 1 )))) * input
375
+ return - splalg .det (R ) * (G2 @ np .ones ((1 , np .size (vals , 1 )))) * vals
376
376
377
377
378
378
# In[37]:
379
379
380
380
381
381
def cIdag (inp ):
382
382
if inp .ndim == 1 :
383
- input = np .reshape (inp , (inp .size , 1 ))
383
+ vals = np .reshape (inp , (inp .size , 1 ))
384
384
else :
385
- input = inp
385
+ vals = inp
386
386
387
- out = np .zeros (input .shape , dtype = "complex_" )
387
+ out = np .zeros (vals .shape , dtype = "complex_" )
388
388
389
- for col in range (np .size (input , 1 )):
390
- out [:,col ] = fft3 (input [:,col ], S , - 1 )
389
+ for col in range (np .size (vals , 1 )):
390
+ out [:,col ] = fft3 (vals [:,col ], S , - 1 )
391
391
392
392
return out
393
393
@@ -397,15 +397,15 @@ def cIdag(inp):
397
397
398
398
def cJdag (inp ):
399
399
if inp .ndim == 1 :
400
- input = np .reshape (inp , (inp .size , 1 ))
400
+ vals = np .reshape (inp , (inp .size , 1 ))
401
401
else :
402
- input = inp
402
+ vals = inp
403
403
404
404
norm = 1. / np .prod (S )
405
- out = np .zeros (input .shape , dtype = "complex_" )
405
+ out = np .zeros (vals .shape , dtype = "complex_" )
406
406
407
- for col in range (np .size (input , 1 )):
408
- out [:,col ] = norm * fft3 (input [:,col ], S , 1 )
407
+ for col in range (np .size (vals , 1 )):
408
+ out [:,col ] = norm * fft3 (vals [:,col ], S , 1 )
409
409
410
410
return out
411
411
@@ -572,7 +572,7 @@ def getPsi(W):
572
572
# In[54]:
573
573
574
574
575
- epsilon
575
+ print ( epsilon )
576
576
577
577
578
578
# In[55]:
@@ -725,7 +725,7 @@ def H(W):
725
725
# In[66]:
726
726
727
727
728
- epsilon
728
+ print ( epsilon )
729
729
730
730
731
731
# In[67]:
@@ -873,8 +873,8 @@ def lm(Win, Nit, fillE = True):
873
873
# In[76]:
874
874
875
875
876
- def K (input ):
877
- return input / (1. + G2 )
876
+ def K (inp ):
877
+ return inp / (1. + G2 )
878
878
879
879
880
880
# The preconditioned line minimization is the same as the line minimization above, but with the direction changed:
@@ -1229,45 +1229,45 @@ def pccg(Win, Nit, cgform, fillE = True, alphat = 0.00003):
1229
1229
1230
1230
def L (inp ):
1231
1231
if inp .ndim == 1 :
1232
- input = np .reshape (inp , (inp .size , 1 ))
1232
+ out = np .reshape (inp , (inp .size , 1 ))
1233
1233
else :
1234
- input = inp
1234
+ out = inp
1235
1235
1236
- if np .size (input , 0 ) == G2c .size :
1237
- return - splalg .det (R ) * (G2c @ np .ones ((1 , np .size (input , 1 )))) * input
1236
+ if np .size (out , 0 ) == G2c .size :
1237
+ return - splalg .det (R ) * (G2c @ np .ones ((1 , np .size (out , 1 )))) * out
1238
1238
1239
- return - splalg .det (R ) * (G2 @ np .ones ((1 , np .size (input , 1 )))) * input
1239
+ return - splalg .det (R ) * (G2 @ np .ones ((1 , np .size (out , 1 )))) * out
1240
1240
1241
1241
1242
1242
# In[92]:
1243
1243
1244
1244
1245
- def K (input ):
1246
- if np .size (input , 0 ) == G2c .size :
1247
- return input / (1. + G2c )
1245
+ def K (inp ):
1246
+ if np .size (inp , 0 ) == G2c .size :
1247
+ return inp / (1. + G2c )
1248
1248
1249
- return input / (1. + G2 )
1249
+ return inp / (1. + G2 )
1250
1250
1251
1251
1252
1252
# In[93]:
1253
1253
1254
1254
1255
1255
def cI (inp ):
1256
1256
if inp .ndim == 1 :
1257
- input = np .reshape (inp , (inp .size , 1 ))
1257
+ vals = np .reshape (inp , (inp .size , 1 ))
1258
1258
else :
1259
- input = inp
1259
+ vals = inp
1260
1260
1261
1261
pS = np .prod (S )
1262
- out = np .zeros ((pS , np .size (input , axis = 1 )), dtype = "complex_" )
1262
+ out = np .zeros ((pS , np .size (vals , axis = 1 )), dtype = "complex_" )
1263
1263
1264
- if np .size (input , 0 ) == pS :
1265
- for col in range (np .size (input , 1 )):
1266
- out [:,col ] = fft3 (input [:,col ], S , 1 )
1264
+ if np .size (vals , 0 ) == pS :
1265
+ for col in range (np .size (vals , 1 )):
1266
+ out [:,col ] = fft3 (out [:,col ], S , 1 )
1267
1267
else :
1268
- for col in range (np .size (input , 1 )):
1268
+ for col in range (np .size (vals , 1 )):
1269
1269
full = np .zeros ((pS , 1 ), dtype = "complex_" )
1270
- full [active ] = input [:,col ]
1270
+ full [active ] = vals [:,col ]
1271
1271
out [:,col ] = fft3 (full [:,col ], S , 1 )
1272
1272
1273
1273
return out
@@ -1278,16 +1278,16 @@ def cI(inp):
1278
1278
1279
1279
def cIdag (inp ):
1280
1280
if inp .ndim == 1 :
1281
- input = np .reshape (inp , (inp .size , 1 ))
1281
+ vals = np .reshape (inp , (inp .size , 1 ))
1282
1282
cols = 1
1283
1283
else :
1284
- input = inp
1285
- cols = np .size (input , 1 )
1284
+ vals = inp
1285
+ cols = np .size (vals , 1 )
1286
1286
1287
1287
out = np .zeros ((active [0 ].size , cols ), dtype = "complex_" )
1288
1288
1289
1289
for col in range (cols ):
1290
- full = fft3 (input [:,col ], S , - 1 )
1290
+ full = fft3 (vals [:,col ], S , - 1 )
1291
1291
out [:,col ] = np .reshape (full ,(full .size , 1 ))[active ]
1292
1292
1293
1293
return out
@@ -1365,7 +1365,7 @@ def H(W):
1365
1365
1366
1366
Veff = Vdual + cJdag (O (PoissonSolve (n ) + cJ (exc ))) + np .reshape (excp , (excp .size , 1 )) * cJdag (O (cJ (n )))
1367
1367
1368
- out = - 0.5 * L (W );
1368
+ out = - 0.5 * L (W )
1369
1369
1370
1370
for col in range (np .size (W , axis = 1 )):
1371
1371
out [:, col ] += np .reshape (cIdag (Veff * cI (W [:,col ])), np .size (out , axis = 0 ))
@@ -1463,7 +1463,7 @@ def PseudoGe(pos):
1463
1463
if pos < 1E-10 :
1464
1464
P = 0
1465
1465
else :
1466
- P = - Z / pos * (1. - m .exp (- lam * pos )) / (1 + m .exp (- lam * (pos - rc )));
1466
+ P = - Z / pos * (1. - m .exp (- lam * pos )) / (1 + m .exp (- lam * (pos - rc )))
1467
1467
1468
1468
return P
1469
1469
@@ -1521,7 +1521,7 @@ def PseudoGe(pos):
1521
1521
ax = fig .add_subplot (1 , 1 , 1 , projection = '3d' )
1522
1522
ax .plot_surface (xs , ys , toplot , cmap = 'viridis' , edgecolor = 'none' )
1523
1523
ax .title .set_text ('Real Space' )
1524
- plt .tight_layout
1524
+ plt .tight_layout ()
1525
1525
plt .show ()
1526
1526
1527
1527
@@ -1538,7 +1538,7 @@ def PseudoGe(pos):
1538
1538
W , Elist = sd (W , 150 , False )
1539
1539
W = orthogonalize (W )
1540
1540
1541
- W , Elist = pccg (W ,100 ,1 , False )
1541
+ W , Elist = pccg (W , 100 , 1 , False )
1542
1542
1543
1543
1544
1544
# In[106]:
@@ -1726,7 +1726,7 @@ def getgrad(W):
1726
1726
Vdual = cJ (Vps * Sf )
1727
1727
1728
1728
1729
- # In[125 ]:
1729
+ # In[117 ]:
1730
1730
1731
1731
1732
1732
np .random .seed (100 )
@@ -1746,7 +1746,7 @@ def getgrad(W):
1746
1746
#W, Elist = pccg(W, 10, 1, True)
1747
1747
1748
1748
1749
- # In[126 ]:
1749
+ # In[118 ]:
1750
1750
1751
1751
1752
1752
Psi , epsilon = getPsi (W )
@@ -1758,5 +1758,4 @@ def getgrad(W):
1758
1758
Etot = E + Ewald
1759
1759
print ('\n Total energy:' , Etot )
1760
1760
print ('Electronic energy:' , E )
1761
- print ('Energy dif beteen s and p orbitals:' , epsilon [1 ] - epsilon [0 ], 'Expected (from NIST data): 0.276641' )
1762
-
1761
+ print ('Energy dif beteen s and p orbitals:' , epsilon [1 ] - epsilon [0 ], 'Expected (from NIST data): 0.276641' )
0 commit comments