mirror of
https://gitlab.com/scemama/eplf
synced 2024-09-06 19:54:44 +02:00
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
![]() |
#!/usr/bin/env python
|
||
|
|
||
|
import common
|
||
|
import sys,os,time
|
||
|
from ezfio import ezfio
|
||
|
from math import *
|
||
|
|
||
|
# Check command line
|
||
|
|
||
|
firstArg = sys.argv[1]
|
||
|
|
||
|
if len(sys.argv) == 2:
|
||
|
det_thr=0.001
|
||
|
elif len(sys.argv) == 3:
|
||
|
det_thr=float(sys.argv[2])
|
||
|
else:
|
||
|
print "usage: "+sys.argv[0]+" file.out det_threshold"
|
||
|
sys.exit(2)
|
||
|
|
||
|
def reduce_dets():
|
||
|
ezfio.set_file(firstArg)
|
||
|
os.system ("cp -r %s/determinants %s/determinants.bak"%(firstArg,firstArg))
|
||
|
print "Initial number of determinants: ",ezfio.determinants_det_num
|
||
|
coef = ezfio.determinants_det_coef
|
||
|
norm = sum( map(lambda x: x*x,coef) )
|
||
|
print "Norm of the initial wave function: ", sqrt(norm)
|
||
|
dets_a, dets_b = ezfio.determinants_det_occ
|
||
|
|
||
|
to_remove = []
|
||
|
for i, c in enumerate(coef):
|
||
|
if abs(c) < det_thr:
|
||
|
to_remove.append(i)
|
||
|
|
||
|
to_remove.sort()
|
||
|
to_remove.reverse()
|
||
|
for i in to_remove:
|
||
|
coef.pop(i)
|
||
|
dets_a.pop(i)
|
||
|
dets_b.pop(i)
|
||
|
print "New number of determinants: ", len(coef)
|
||
|
norm = sum( map(lambda x: x*x,coef) )
|
||
|
print "Norm of the new wave function: ", sqrt(norm)
|
||
|
ezfio.determinants_det_num = len(coef)
|
||
|
ezfio.determinants_det_coef = coef
|
||
|
ezfio.determinants_det_occ = dets_a+dets_b
|
||
|
|
||
|
def main():
|
||
|
reduce_dets()
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|
||
|
|