mirror of
https://github.com/LCPQ/quantum_package
synced 2024-10-02 06:20:59 +02:00
Indend ezfio_with_default and finalze interface. It working for Full_Ci
This commit is contained in:
parent
25cca3fc9e
commit
7b54afd9b4
2
data/.gitignore
vendored
2
data/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
executables
|
||||
cache/*
|
||||
*.ezfio
|
||||
|
||||
dict_cfg.p
|
@ -104,6 +104,23 @@ def create_ezfio_provider(dict_all):
|
||||
import os
|
||||
|
||||
|
||||
def save_ezfio_config(array):
|
||||
path = os.environ.get('QPACKAGE_ROOT') + "/EZFIO/config/"
|
||||
|
||||
with open(path + "interface.ezfio_config","w") as f:
|
||||
for i in array:
|
||||
f.write(i + "\n")
|
||||
|
||||
|
||||
def save_ezfio_provider(array):
|
||||
path = os.environ.get('QPACKAGE_ROOT') + "/src/Ezfio_files/"
|
||||
|
||||
with open(path + "interface.irp.f","w") as f:
|
||||
f.write("!DO NOT MODIFY BY HAND \n")
|
||||
for i in array:
|
||||
f.write(i + "\n")
|
||||
|
||||
|
||||
def get_dict_cfg(pickle=False):
|
||||
|
||||
if pickle:
|
||||
@ -133,8 +150,8 @@ def get_dict_cfg(pickle=False):
|
||||
def get_ezfio_cmd(dict_cfg):
|
||||
d = defaultdict(dict)
|
||||
for k, v in dict_cfg.items():
|
||||
d[k] = {"set": "set_" + v["ezfio_dir"] + "_" + k,
|
||||
"get": "get_" + v["ezfio_dir"] + "_" + k}
|
||||
d[k] = {"set": "ezfio_set_" + v["ezfio_dir"] + "_" + k,
|
||||
"get": "ezfio_get_" + v["ezfio_dir"] + "_" + k}
|
||||
|
||||
return dict(d)
|
||||
|
||||
@ -152,7 +169,9 @@ if __name__ == "__main__":
|
||||
|
||||
print biloute
|
||||
|
||||
for i in create_ezfio_string(biloute, "config"):
|
||||
config = create_ezfio_string(biloute, "config")
|
||||
save_ezfio_config(config)
|
||||
for i in config:
|
||||
print i
|
||||
|
||||
for i in create_ezfio_string(biloute, "default"):
|
||||
@ -160,3 +179,6 @@ if __name__ == "__main__":
|
||||
|
||||
for i in get_ezfio_cmd(biloute).items():
|
||||
print i
|
||||
|
||||
irp = create_ezfio_provider(biloute)
|
||||
save_ezfio_provider(irp)
|
@ -14,7 +14,7 @@ import os
|
||||
|
||||
class EZFIO_Provider(object):
|
||||
|
||||
data = """BEGIN_PROVIDER [ %(type)s, %(name)s ]
|
||||
data = """BEGIN_PROVIDER [ %(type)s, %(name)s ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! %(doc)s
|
||||
@ -33,112 +33,112 @@ class EZFIO_Provider(object):
|
||||
END_PROVIDER
|
||||
"""
|
||||
|
||||
write_correspondance = {
|
||||
"integer" : "write_int",
|
||||
"logical" : "write_bool",
|
||||
"double precision" : "write_double" }
|
||||
write_correspondance = {
|
||||
"integer": "write_int",
|
||||
"logical": "write_bool",
|
||||
"double precision": "write_double"}
|
||||
|
||||
def __init__(self):
|
||||
self.values = "type doc default name ezfio_dir ezfio_name write output".split()
|
||||
for v in self.values:
|
||||
exec "self.%s = None"%(v) in locals()
|
||||
|
||||
def __repr__(self):
|
||||
return self.get_string()
|
||||
|
||||
def get_string(self):
|
||||
self.get_default()
|
||||
self.set_write()
|
||||
for v in self.values:
|
||||
exec "test = self.%s is None"%(v) in locals()
|
||||
if test:
|
||||
print >>sys.stderr, "Error : %s is not set in ezfio_with_default.py"%(v)
|
||||
def __init__(self):
|
||||
self.values = "type doc default name ezfio_dir ezfio_name write output".split()
|
||||
for v in self.values:
|
||||
exec "x = str(self.%s)"%(v) in locals()
|
||||
print >>sys.stderr, "%s : %s"%(v, x)
|
||||
sys.exit(1)
|
||||
return self.data%self.__dict__
|
||||
exec "self.%s = None" % (v) in locals()
|
||||
|
||||
def set_write(self):
|
||||
self.write = ""
|
||||
if self.type in self.write_correspondance:
|
||||
write = self.write_correspondance[self.type]
|
||||
output = self.output
|
||||
name = self.name
|
||||
self.write = """
|
||||
def __repr__(self):
|
||||
return self.get_string()
|
||||
|
||||
def get_string(self):
|
||||
self.get_default()
|
||||
self.set_write()
|
||||
for v in self.values:
|
||||
exec "test = self.%s is None" % (v) in locals()
|
||||
if test:
|
||||
print >>sys.stderr, "Error : %s is not set in ezfio_with_default.py" % (v)
|
||||
for v in self.values:
|
||||
exec "x = str(self.%s)" % (v) in locals()
|
||||
print >>sys.stderr, "%s : %s" % (v, x)
|
||||
sys.exit(1)
|
||||
return self.data % self.__dict__
|
||||
|
||||
def set_write(self):
|
||||
self.write = ""
|
||||
if self.type in self.write_correspondance:
|
||||
write = self.write_correspondance[self.type]
|
||||
output = self.output
|
||||
name = self.name
|
||||
self.write = """
|
||||
call write_time(%(output)s)
|
||||
call %(write)s(%(output)s, %(name)s, &
|
||||
'%(name)s')
|
||||
"""%locals()
|
||||
""" % locals()
|
||||
|
||||
def set_type(self,t):
|
||||
self.type = t.lower()
|
||||
def set_type(self, t):
|
||||
self.type = t.lower()
|
||||
|
||||
def set_doc(self,t):
|
||||
self.doc = t.replace('\n', '\n! ')
|
||||
def set_doc(self, t):
|
||||
self.doc = t.replace('\n', '\n! ')
|
||||
|
||||
def set_name(self,t):
|
||||
self.name = t
|
||||
def set_name(self, t):
|
||||
self.name = t
|
||||
|
||||
def set_ezfio_dir(self,t):
|
||||
self.ezfio_dir = t.lower()
|
||||
def set_ezfio_dir(self, t):
|
||||
self.ezfio_dir = t.lower()
|
||||
|
||||
def set_ezfio_name(self,t):
|
||||
self.ezfio_name = t.lower()
|
||||
def set_ezfio_name(self, t):
|
||||
self.ezfio_name = t.lower()
|
||||
|
||||
def set_output(self,t):
|
||||
self.output = t
|
||||
def set_output(self, t):
|
||||
self.output = t
|
||||
|
||||
def set_default(self,t):
|
||||
self.default = t
|
||||
def set_default(self, t):
|
||||
self.default = t
|
||||
|
||||
def get_default(self):
|
||||
filename = '/'.join( [os.environ['QPACKAGE_ROOT'], 'data', 'ezfio_defaults'] )
|
||||
file = open(filename,'r')
|
||||
lines = file.readlines()
|
||||
file.close()
|
||||
# Search directory
|
||||
for k,line in enumerate(lines):
|
||||
if line[0] != ' ':
|
||||
if line.strip().lower() == self.ezfio_dir:
|
||||
break
|
||||
if k+1 == len(lines):
|
||||
return
|
||||
# Search name
|
||||
while k < len(lines):
|
||||
k+=1
|
||||
buffer = lines[k].split()
|
||||
if len(buffer) == 0:
|
||||
return
|
||||
if buffer[0].lower() == self.ezfio_name:
|
||||
break
|
||||
v = buffer[1]
|
||||
name = self.name
|
||||
try:
|
||||
v_eval = eval(v)
|
||||
if type(v_eval) == bool:
|
||||
v = '.%s.'%(v)
|
||||
elif type(v_eval) == float:
|
||||
v = v.replace('e','d')
|
||||
v = v.replace('E','D')
|
||||
v = "%(name)s = %(v)s"%locals()
|
||||
except:
|
||||
v = "call ezfio_get_%(v)s(%(name)s)"%locals()
|
||||
self.default = v
|
||||
def get_default(self):
|
||||
filename = '/'.join([os.environ['QPACKAGE_ROOT'],
|
||||
'data',
|
||||
'ezfio_defaults'])
|
||||
file = open(filename, 'r')
|
||||
lines = file.readlines()
|
||||
file.close()
|
||||
# Search directory
|
||||
for k, line in enumerate(lines):
|
||||
if line[0] != ' ':
|
||||
if line.strip().lower() == self.ezfio_dir:
|
||||
break
|
||||
if k + 1 == len(lines):
|
||||
return
|
||||
# Search name
|
||||
while k < len(lines):
|
||||
k += 1
|
||||
buffer = lines[k].split()
|
||||
if len(buffer) == 0:
|
||||
return
|
||||
if buffer[0].lower() == self.ezfio_name:
|
||||
break
|
||||
v = buffer[1]
|
||||
name = self.name
|
||||
try:
|
||||
v_eval = eval(v)
|
||||
if isinstance(v_eval, bool):
|
||||
v = '.%s.' % (v)
|
||||
elif isinstance(v_eval, float):
|
||||
v = v.replace('e', 'd')
|
||||
v = v.replace('E', 'D')
|
||||
v = "%(name)s = %(v)s" % locals()
|
||||
except:
|
||||
v = "call ezfio_get_%(v)s(%(name)s)" % locals()
|
||||
self.default = v
|
||||
|
||||
|
||||
def test_module():
|
||||
T = EZFIO_Provider()
|
||||
T.set_type ( "double precision" )
|
||||
T.set_name ( "thresh_SCF" )
|
||||
T.set_doc ( "Threshold on the convergence of the Hartree Fock energy" )
|
||||
T.set_ezfio_dir ( "Hartree_Fock" )
|
||||
T.set_ezfio_name( "thresh_SCF" )
|
||||
T.set_output ( "output_Hartree_Fock" )
|
||||
print T
|
||||
T = EZFIO_Provider()
|
||||
T.set_type("double precision")
|
||||
T.set_name("thresh_SCF")
|
||||
T.set_doc("Threshold on the convergence of the Hartree Fock energy")
|
||||
T.set_ezfio_dir("Hartree_Fock")
|
||||
T.set_ezfio_name("thresh_SCF")
|
||||
T.set_output("output_Hartree_Fock")
|
||||
print T
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_module()
|
||||
|
||||
|
||||
test_module()
|
||||
|
@ -1,4 +0,0 @@
|
||||
full_ci
|
||||
n_det_max_fci integer
|
||||
pt2_max double precision
|
||||
do_pt2_end logical
|
@ -1,65 +0,0 @@
|
||||
BEGIN_PROVIDER [ integer, n_det_max_fci ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Max number of determinants in the wave function
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
call ezfio_has_full_ci_n_det_max_fci(has)
|
||||
if (has) then
|
||||
call ezfio_get_full_ci_n_det_max_fci(n_det_max_fci)
|
||||
else
|
||||
n_det_max_fci = 10000
|
||||
endif
|
||||
|
||||
call write_time(output_full_ci)
|
||||
call write_int(output_full_ci, n_det_max_fci, &
|
||||
'n_det_max_fci')
|
||||
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ double precision, pt2_max ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! The selection process stops when the largest PT2 (for all the states) is lower than pt2_max in absolute value
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
call ezfio_has_full_ci_pt2_max(has)
|
||||
if (has) then
|
||||
call ezfio_get_full_ci_pt2_max(pt2_max)
|
||||
else
|
||||
pt2_max = 1.d-4
|
||||
endif
|
||||
|
||||
call write_time(output_full_ci)
|
||||
call write_double(output_full_ci, pt2_max, &
|
||||
'pt2_max')
|
||||
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ logical, do_pt2_end ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! If true, compute the PT2 at the end of the selection
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
call ezfio_has_full_ci_do_pt2_end(has)
|
||||
if (has) then
|
||||
call ezfio_get_full_ci_do_pt2_end(do_pt2_end)
|
||||
else
|
||||
do_pt2_end = .True.
|
||||
endif
|
||||
|
||||
call write_time(output_full_ci)
|
||||
call write_bool(output_full_ci, do_pt2_end, &
|
||||
'do_pt2_end')
|
||||
|
||||
|
||||
END_PROVIDER
|
@ -114,7 +114,7 @@ endif
|
||||
|
||||
# Define the EZFIO rules
|
||||
|
||||
$(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg) $(wildcard $(QPACKAGE_ROOT)/src/*/options.irp.f) options.irp.f
|
||||
$(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg) interface.irp.f
|
||||
@echo Building EZFIO library
|
||||
@cp $(wildcard $(QPACKAGE_ROOT)/src/*.ezfio_config) $(wildcard $(QPACKAGE_ROOT)/src/*/*.ezfio_config) $(EZFIO_DIR)/config
|
||||
@cd $(EZFIO_DIR) ; export FC="$(FC)" ; export FCFLAGS="$(FCFLAGS)" ; export IRPF90="$(IRPF90)" ; $(MAKE) ; $(MAKE) Python
|
||||
@ -122,9 +122,9 @@ $(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg) $(wildcard $(QPACKAGE_ROO
|
||||
ezfio: $(EZFIO)
|
||||
|
||||
|
||||
options.irp.f: EZFIO.cfg
|
||||
interface.irp.f: EZFIO.cfg
|
||||
$(QPACKAGE_ROOT)/scripts/ezfio_interface.py
|
||||
touch options.irp.f
|
||||
touch interface.irp.f
|
||||
|
||||
# Create symbolic links of other modules
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user