From a7da480d6628290d6c25379f16ebe950c8083931 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 09:08:58 +0100 Subject: [PATCH 01/60] Cleanning ezfio_interface.py and SIZE keyword support --- scripts/ezfio_interface.py | 44 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 6bcb518e..7617d735 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -47,12 +47,6 @@ def get_type_dict(): # I n i t # # ~#~#~#~ # - # Dict to change ocaml LowLevel type into FortranLowLevel type - ocaml_to_fortran = {"int": "integer", - "float": "double precision", - "logical": "logical", - "string": "character*60"} - fancy_type = defaultdict(dict) # ~#~#~#~#~#~#~#~ # @@ -68,21 +62,32 @@ def get_type_dict(): fancy_type['logical'] = Type("bool", "logical") fancy_type['bool'] = Type("bool", "logical") + fancy_type['character*32'] = Type("string", "character*32") + fancy_type['character*60'] = Type("string", "character*60") + fancy_type['character*256'] = Type("string", "character*256") + # ~#~#~#~#~#~#~#~ # # q p _ t y p e s # # ~#~#~#~#~#~#~#~ # - src = os.environ['QPACKAGE_ROOT'] + "/ocaml/qptypes_generator.ml" + # Dict to change ocaml LowLevel type into FortranLowLevel type + ocaml_to_fortran = {"int": "integer", + "float": "double precision", + "logical": "logical", + "string": "character*32"} + # Read and parse qptype + src = os.environ['QPACKAGE_ROOT'] + "/ocaml/qptypes_generator.ml" with open(src, "r") as f: l = [i for i in f.read().splitlines() if i.strip().startswith("*")] + # Read the fancy_type, the ocaml. and convert the ocam to the fortran for i in l: - ocaml_fancy_type = i.split()[1].strip() - ocaml_type = i.split()[3] - fortran_type = ocaml_to_fortran[ocaml_type] + str_fancy_type = i.split()[1].strip() + str_ocaml_type = i.split()[3] + str_fortran_type = ocaml_to_fortran[str_ocaml_type] - fancy_type[ocaml_fancy_type] = Type(ocaml_type, fortran_type) + fancy_type[str_fancy_type] = Type(str_ocaml_type, str_fortran_type) return dict(fancy_type) @@ -102,6 +107,7 @@ def get_dict_config_file(config_file_path, module_lower): doc, ezfio_name, ezfio_dir, + size, interface, default} @@ -122,7 +128,7 @@ def get_dict_config_file(config_file_path, module_lower): d = defaultdict(dict) l_info_required = ["doc", "interface"] - l_info_optional = ["ezfio_name"] + l_info_optional = ["ezfio_name", "size"] # ~#~#~#~#~#~#~#~#~#~#~ # # L o a d _ C o n f i g # @@ -144,7 +150,7 @@ def get_dict_config_file(config_file_path, module_lower): pvd = section.lower() # Create the dictionary who containt the value per default - d_default = {"ezfio_name": pvd} + d_default = {"ezfio_name": pvd, "size": 1} # Set the ezfio_dir d[pvd]["ezfio_dir"] = module_lower @@ -241,12 +247,12 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): result = [module_lower] lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 - l = sorted(dict_ezfio_cfg.keys()) - for provider_name in l: - provider_info = dict_ezfio_cfg[provider_name] - s = " {0} {1}".format( - provider_name.lower().ljust(lenmax), - provider_info["type"].fortran) + +# l = sorted(dict_ezfio_cfg.keys()) + for provider_name, provider_info in sorted(dict_ezfio_cfg.iteritems()): + + s = " {0} {1}".format(provider_name.lower().ljust(lenmax), + provider_info["type"].fortran) result.append(s) return "\n".join(result) From d3d2430c7422cb1a5eefc5c33faf2641ee7b2ba0 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 09:24:58 +0100 Subject: [PATCH 02/60] Create SIZE in ezfio_interface --- scripts/ezfio_interface.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 7617d735..085629d4 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -228,7 +228,7 @@ def save_ezfio_provider(path_head, dict_code_provider): path = "{0}/ezfio_interface.irp.f".format(path_head) - print "Path = {}".format(path) + print "Path = {0}".format(path) with open(path, "w") as f: f.write("!DO NOT MODIFY BY HAND \n") @@ -244,15 +244,21 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config """ - result = [module_lower] lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 -# l = sorted(dict_ezfio_cfg.keys()) for provider_name, provider_info in sorted(dict_ezfio_cfg.iteritems()): - s = " {0} {1}".format(provider_name.lower().ljust(lenmax), - provider_info["type"].fortran) + name = provider_name.lower() + fortran_type = provider_info["type"].fortran + size_raw = str(provider_info["size"]) + + if size_raw.startswith('='): + size = size_raw + else: + size = "({0})".format(size_raw) + + s = " {0} {1} {2}".format(name.ljust(lenmax), fortran_type, size) result.append(s) return "\n".join(result) @@ -267,7 +273,7 @@ def save_ezfio_config(module_lower, str_ezfio_config): path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir, module_lower) - print "Path = {}".format(path) + print "Path = {0}".format(path) with open(path, "w") as f: f.write(str_ezfio_config) From cd518019ab266446646098db82ca7699af5d43b8 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 10:01:02 +0100 Subject: [PATCH 03/60] Amazing fancy ezfio_interface_config --- scripts/ezfio_interface.py | 57 ++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 085629d4..0756ad91 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -244,22 +244,61 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config """ + + def size_format_to_ezfio(size_raw): + """If = is a formula do nothing + Else but the parenthsesis because is the ezfio_ format + """ + size_raw = str(size_raw) + if size_raw.startswith('='): + size_convert = size_raw + else: + size_convert = "({0})".format(size_raw) + return size_convert + + def create_format_string(size): + """ + Take a size and return the string format for bewing right align + Example size = 10 + Return '{:<10}'.format + """ + + return "{{:<{0}}}".format(size).format + + # ~#~#~#~#~#~#~#~#~#~#~# # + # F o r m a t _ i n f o # + # ~#~#~#~#~#~#~#~#~#~#~# # + + lenmax_name = max([len(i) for i in dict_ezfio_cfg]) + lenmax_type = max([len(i["type"].fortran) for i in dict_ezfio_cfg.values()]) + + str_name_format = create_format_string(lenmax_name + 2) + str_type_format = create_format_string(lenmax_type + 2) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t h e _ s t r i n g # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + result = [module_lower] - lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 for provider_name, provider_info in sorted(dict_ezfio_cfg.iteritems()): - name = provider_name.lower() - fortran_type = provider_info["type"].fortran - size_raw = str(provider_info["size"]) + # Get the value from dict + name_raw = provider_name.lower() + fortran_type_raw = provider_info["type"].fortran + size_raw = size_format_to_ezfio(provider_info["size"]) - if size_raw.startswith('='): - size = size_raw - else: - size = "({0})".format(size_raw) + # Get the string in to good format (left align and co) + str_name = str_name_format(name_raw) + str_fortran_type = str_type_format(fortran_type_raw) + str_size = size_raw - s = " {0} {1} {2}".format(name.ljust(lenmax), fortran_type, size) + # Return the string + s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size) + + # Append result.append(s) + return "\n".join(result) From 01a7a9c345cf37301a926fe10228b532c70d5a20 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 12:02:58 +0100 Subject: [PATCH 04/60] Cleaning, Need to add EZFIO creation support --- scripts/ezfio_interface.py | 56 +++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index dab258fd..ba735fbf 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -7,17 +7,33 @@ EZFIO.cfg are in MODULE directories. create : ezfio_interface.irp.f folder_ezfio_inteface_config +Format specification : + [provider_name] : the name of the provider in irp.f90 + - doc : Is the doc + - Type : Is a fancy_type support by the ocaml + - ezfio_name : Will be the name of the file for the ezfio + (optional by default is the name of the provider) + - interface : The provider is a imput or a output + - default : The default value if interface == output: + - size : Is the string read in ezfio.cgf who containt the size information + (like 1 or =sum(ao_num) or (ao_num,3) ) + Example EZFIO.cfg: ``` [thresh_SCF] doc: Threshold on the convergence of the Hartree Fock energy type: Threshold default: 1.e-10 +interface: output +default: 10000 +size : ao_num, 3 [do_pt2_end] type: logical doc: If true, compute the PT2 at the end of the selection default: true +interface: input +size : 1 ``` """ @@ -111,16 +127,16 @@ def get_dict_config_file(config_file_path, module_lower): interface, default} - Type : Is a fancy_type named typle who containt fortran and ocaml type - doc : Is the doc - ezfio_name : Will be the name of the file - ezfio_dir : Will be the folder who containt the ezfio_name + - Type : Is a fancy_type named typle who containt fortran and ocaml type + - doc : Is the doc + - ezfio_name : Will be the name of the file + - ezfio_dir : Will be the folder who containt the ezfio_name * /ezfio_dir/ezfio_name * equal to MODULE_lower name for the moment. - interface : The provider is a imput or a output - if is a output: - default : The default value - + - interface : The provider is a imput or a output + - default : The default value if interface == output: + - size : Is the string read in ezfio.cgf who containt the size information + (like 1 or =sum(ao_num)) """ # ~#~#~#~ # # I n i t # @@ -150,7 +166,7 @@ def get_dict_config_file(config_file_path, module_lower): pvd = section.lower() # Create the dictionary who containt the value per default - d_default = {"ezfio_name": pvd, "size": 1} + d_default = {"ezfio_name": pvd} # Set the ezfio_dir d[pvd]["ezfio_dir"] = module_lower @@ -177,7 +193,8 @@ def get_dict_config_file(config_file_path, module_lower): try: d[pvd][option] = config_file.get(section, option).lower() except ConfigParser.NoOptionError: - d[pvd][option] = d_default[option] + if option in d_default: + d[pvd][option] = d_default[option] # If interface is output we need a default value information if d[pvd]["interface"] == "output": @@ -197,7 +214,8 @@ def create_ezfio_provider(dict_ezfio_cfg): ezfio_name, ezfio_dir, interface, - default} + default + size} create the a list who containt all the code for the provider return [code, ...] """ @@ -259,11 +277,13 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): """ def size_format_to_ezfio(size_raw): - """If = is a formula do nothing - Else but the parenthsesis because is the ezfio_ format + """If = is a formula so do nothing + If the value are between parenthsesis donothing + Else put the parenthsesis """ size_raw = str(size_raw) - if size_raw.startswith('='): + if any([size_raw.startswith('='), + size_raw.startswith("(") and size_raw.endswith(")")]): size_convert = size_raw else: size_convert = "({0})".format(size_raw) @@ -300,12 +320,16 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): # Get the value from dict name_raw = provider_name.lower() fortran_type_raw = provider_info["type"].fortran - size_raw = size_format_to_ezfio(provider_info["size"]) + + if "size" in provider_info and not provider_info["size"] == "1": + size_raw = provider_info["size"] + else: + size_raw = None # Get the string in to good format (left align and co) str_name = str_name_format(name_raw) str_fortran_type = str_type_format(fortran_type_raw) - str_size = size_raw + str_size = size_format_to_ezfio(size_raw) if size_raw else "" # Return the string s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size) From 246cc669368ee2554aac1deeeda5feaebc0e3779 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 12:27:53 +0100 Subject: [PATCH 05/60] Typo and remove print --- scripts/ezfio_interface.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index ba735fbf..a6ab92fb 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -246,7 +246,7 @@ def save_ezfio_provider(path_head, dict_code_provider): path = "{0}/ezfio_interface.irp.f".format(path_head) - print "Path = {0}".format(path) + # print "Path = {0}".format(path) try: f = open(path, "r") @@ -369,6 +369,9 @@ def main(): -Take the EZFIO.cfg path in arg or -Look if EZFIO.cfg is present in the pwd + + Return : - ezfio_interface.irp.f + - folder_ezfio_inteface_config """ try: @@ -381,28 +384,28 @@ def main(): config_file_path = os.path.expanduser(config_file_path) config_file_path = os.path.expandvars(config_file_path) config_file_path = os.path.abspath(config_file_path) -# print config_file_path + # print config_file_path path_dirname = os.path.dirname(config_file_path) module = [i for i in path_dirname.split("/") if i][-1] module_lower = module.lower() -# print "Read {0}".format(config_file_path) + # print "Read {0}".format(config_file_path) dict_info_provider = get_dict_config_file(config_file_path, module_lower) -# print "Generating the ezfio_interface.irp.f: \n" + # print "Generating the ezfio_interface.irp.f: \n" d_config = create_ezfio_provider(dict_info_provider) -# print "Saving the ezfio_interface.irp.f" + # print "Saving the ezfio_interface.irp.f" save_ezfio_provider(path_dirname, d_config) -# print "Generating the ezfio_config" + # print "Generating the ezfio_config" config_ezfio = create_ezfio_config( dict_info_provider, "config", module_lower) -# print "Saving ezfio_config" + # print "Saving ezfio_config" save_ezfio_config(module_lower, config_ezfio) From 22bae157946a7e7b693ce60c862acbcbbb48cf6a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 12:52:07 +0100 Subject: [PATCH 06/60] PEP 8 in ezfio_with_default and typo --- scripts/ezfio_with_default.py | 184 +++++++++++++++++----------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/scripts/ezfio_with_default.py b/scripts/ezfio_with_default.py index 1208f4b7..5db1e707 100755 --- a/scripts/ezfio_with_default.py +++ b/scripts/ezfio_with_default.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -__author__ = "Anthony Scemama" -__date__ = "Tue Jul 29 12:20:00 CEST 2014" +__author__ = "Anthony Scemama and Applencourt for the amazing PEP8" +__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)" """ Creates the provider of a variable that has to be @@ -14,9 +14,9 @@ import os class EZFIO_Provider(object): - data = """BEGIN_PROVIDER [ %(type)s, %(name)s ] + data = """BEGIN_PROVIDER [ %(type)s, %(name)s ] implicit none - BEGIN_DOC + BEGIN_DOC ! %(doc)s END_DOC @@ -33,109 +33,109 @@ 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): - 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): + self.get_default() + self.set_write() + for v in self.values: + exec "test = self.%s is None" % (v) in locals() + if test: + msg = "Error : %s is not set in ezfio_with_default.py" % (v) + print >>sys.stderr, msg + 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() + '%(name)s')""" % 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']) + + with open(filename, 'r') as f: + lines = f.readlines() + + # 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() From 8ffdd3bc4f1de910ec131e768e19c2679b63d244 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 14:28:32 +0100 Subject: [PATCH 07/60] provider.irp.f90 only read value in ezfio. Is value is not set, just exit --- scripts/ezfio_interface.py | 27 ++++++++++++++++++++++++--- scripts/ezfio_with_default.py | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index a6ab92fb..2eb47320 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -50,6 +50,15 @@ from collections import namedtuple Type = namedtuple('Type', 'ocaml fortran') +def is_bool(str_): + if str_.lower() in ['true', '.true.']: + return Type("true", ".True.") + elif str_.lower() in ['false', '.False.']: + return Type("false", ".False") + else: + raise TypeError + + def get_type_dict(): """ This function makes the correspondance between the type of value read in @@ -199,11 +208,16 @@ def get_dict_config_file(config_file_path, module_lower): # If interface is output we need a default value information if d[pvd]["interface"] == "output": try: - d[pvd]["default"] = config_file.get(section, "default") + default_raw = config_file.get(section, "default") except ConfigParser.NoOptionError: error("default", pvd, config_file_path) sys.exit(1) + try: + d[pvd]["default"] = is_bool(default_raw) + except: + d[pvd]["default"] = Type(default_raw, default_raw) + return dict(d) @@ -231,7 +245,11 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_doc(dict_info['doc']) ez_p.set_ezfio_dir(dict_info['ezfio_dir']) ez_p.set_ezfio_name(dict_info['ezfio_name']) - ez_p.set_default(dict_info['default']) + + # default = "{0} = {1}".format(provider_name, + # dict_info['default'].fortran) + # ez_p.set_default(default) + ez_p.set_default("stop 1") ez_p.set_output("output_%s" % dict_info['ezfio_dir']) dict_code_provider[provider_name] = str(ez_p) @@ -281,6 +299,7 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): If the value are between parenthsesis donothing Else put the parenthsesis """ + size_raw = str(size_raw) if any([size_raw.startswith('='), size_raw.startswith("(") and size_raw.endswith(")")]): @@ -326,10 +345,12 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): else: size_raw = None + # It is the last so we don't need to right align it + str_size = size_format_to_ezfio(size_raw) if size_raw else "" + # Get the string in to good format (left align and co) str_name = str_name_format(name_raw) str_fortran_type = str_type_format(fortran_type_raw) - str_size = size_format_to_ezfio(size_raw) if size_raw else "" # Return the string s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size) diff --git a/scripts/ezfio_with_default.py b/scripts/ezfio_with_default.py index 5db1e707..5b2b07e5 100755 --- a/scripts/ezfio_with_default.py +++ b/scripts/ezfio_with_default.py @@ -43,7 +43,8 @@ END_PROVIDER exec "self.%s = None" % (v) in locals() def __repr__(self): - self.get_default() + if not self.default: + self.get_default() self.set_write() for v in self.values: exec "test = self.%s is None" % (v) in locals() From 69490976fda91d4b2dcc77fe48cd30794d4a73db Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 14:35:09 +0100 Subject: [PATCH 08/60] Doc and typo --- scripts/ezfio_interface.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 2eb47320..d4ecf58a 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -136,14 +136,16 @@ def get_dict_config_file(config_file_path, module_lower): interface, default} - - Type : Is a fancy_type named typle who containt fortran and ocaml type + - Type : Is a Type named tuple who containt + fortran and ocaml type - doc : Is the doc - ezfio_name : Will be the name of the file - ezfio_dir : Will be the folder who containt the ezfio_name * /ezfio_dir/ezfio_name * equal to MODULE_lower name for the moment. - interface : The provider is a imput or a output - - default : The default value if interface == output: + - default : The default value /!\ stored in a Type named type! + if interface == output - size : Is the string read in ezfio.cgf who containt the size information (like 1 or =sum(ao_num)) """ @@ -295,9 +297,10 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): """ def size_format_to_ezfio(size_raw): - """If = is a formula so do nothing - If the value are between parenthsesis donothing - Else put the parenthsesis + """ + If size_raw == "=" is a formula -> do nothing; return + If the value are between parenthses -> do nothing; return + Else put it in parenthsesis """ size_raw = str(size_raw) @@ -310,9 +313,8 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): def create_format_string(size): """ - Take a size and return the string format for bewing right align - Example size = 10 - Return '{:<10}'.format + Take a size number and + return the string format for being right align with this ofset """ return "{{:<{0}}}".format(size).format From 91ac5cc2a8cb53776812312cf9615022113146fa Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 14:50:19 +0100 Subject: [PATCH 09/60] Add pickle to ezfio_interface.py --- scripts/ezfio_interface.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index d4ecf58a..6f6ec9b4 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -51,6 +51,10 @@ Type = namedtuple('Type', 'ocaml fortran') def is_bool(str_): + """ + Take a string, if is a bool return the convert into + fortran and ocaml one. + """ if str_.lower() in ['true', '.true.']: return Type("true", ".True.") elif str_.lower() in ['false', '.False.']: @@ -67,6 +71,21 @@ def get_type_dict(): For example fancy_type['Ndet'].fortran = interger .ocaml = int """ + # ~#~#~#~#~ # + # P i c l e # + # ~#~#~#~#~ # + + import cPickle as pickle + + from os import listdir + + qpackage_root = os.environ['QPACKAGE_ROOT'] + + fancy_type_pickle = qpackage_root + "/scripts/fancy_type.p" + + if fancy_type_pickle in listdir(os.getcwd()): + fancy_type = pickle.load(open(fancy_type_pickle, "rb")) + return fancy_type # ~#~#~#~ # # I n i t # @@ -102,7 +121,7 @@ def get_type_dict(): "string": "character*32"} # Read and parse qptype - src = os.environ['QPACKAGE_ROOT'] + "/ocaml/qptypes_generator.ml" + src = qpackage_root + "/ocaml/qptypes_generator.ml" with open(src, "r") as f: l = [i for i in f.read().splitlines() if i.strip().startswith("*")] @@ -114,6 +133,12 @@ def get_type_dict(): fancy_type[str_fancy_type] = Type(str_ocaml_type, str_fortran_type) + # ~#~#~#~#~#~#~#~ # + # F i n a l i z e # + # ~#~#~#~#~#~#~#~ # + + pickle.dump(dict(fancy_type), open(fancy_type_pickle, "wb")) + return dict(fancy_type) @@ -217,7 +242,7 @@ def get_dict_config_file(config_file_path, module_lower): try: d[pvd]["default"] = is_bool(default_raw) - except: + except TypeError: d[pvd]["default"] = Type(default_raw, default_raw) return dict(d) From 1a2a61edbcb246c036817ebef15bf8724f7661f4 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 17:04:57 +0100 Subject: [PATCH 10/60] Spaces --- scripts/ezfio_interface.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 6f6ec9b4..8ff6ddd5 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -273,10 +273,13 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_ezfio_dir(dict_info['ezfio_dir']) ez_p.set_ezfio_name(dict_info['ezfio_name']) - # default = "{0} = {1}".format(provider_name, - # dict_info['default'].fortran) - # ez_p.set_default(default) - ez_p.set_default("stop 1") + str_ = "\n".join([" print *, '{0}/{1} not found in EZFIO file'", + " stop 1" ]) + + str_ = str_.format(dict_info['ezfio_dir'], + dict_info['ezfio_name']) + + ez_p.set_default(str_) ez_p.set_output("output_%s" % dict_info['ezfio_dir']) dict_code_provider[provider_name] = str(ez_p) From 94e06e2a5b593d9ecbbe30a3966daa14adf802dc Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 18:24:40 +0100 Subject: [PATCH 11/60] Ocaml default on multiple files --- data/ezfio_defaults | 60 -------------------------------------- data/ezfio_defaults/.empty | 0 ocaml/Input_full_ci.ml | 2 +- ocaml/Input_mo_basis.ml | 26 +++++++---------- ocaml/Qpackage.ml | 30 ++++++++++++++++--- 5 files changed, 37 insertions(+), 81 deletions(-) delete mode 100644 data/ezfio_defaults create mode 100644 data/ezfio_defaults/.empty diff --git a/data/ezfio_defaults b/data/ezfio_defaults deleted file mode 100644 index 5da4d813..00000000 --- a/data/ezfio_defaults +++ /dev/null @@ -1,60 +0,0 @@ -bielec_integrals - read_ao_integrals False - read_mo_integrals False - write_ao_integrals False - write_mo_integrals False - threshold_ao 1.e-15 - threshold_mo 1.e-15 - direct False - -cis_dressed - n_state_cis 10 - n_core_cis 0 - n_act_cis mo_basis_mo_tot_num - mp2_dressing False - standard_doubles True - en_2_2 False - -determinants - n_states 1 - n_states_diag determinants_n_states - n_det_max_jacobi 1000 - threshold_generators 0.99 - threshold_selectors 0.999 - read_wf False - s2_eig False - only_single_double_dm False - -full_ci - n_det_max_fci 10000 - n_det_max_fci_property 50000 - pt2_max 1.e-4 - do_pt2_end True - var_pt2_ratio 0.75 - -all_singles - n_det_max_fci 50000 - pt2_max 1.e-8 - do_pt2_end False - -cassd - n_det_max_cassd 10000 - pt2_max 1.e-4 - do_pt2_end True - -hartree_fock - n_it_scf_max 200 - thresh_scf 1.e-10 - guess "Huckel" - -cisd_selected - n_det_max_cisd 10000 - pt2_max 1.e-4 - -cisd_sc2_selected - n_det_max_cisd_sc2 10000 - pt2_max 1.e-4 - do_pt2_end True - -properties - z_one_point 3.9 diff --git a/data/ezfio_defaults/.empty b/data/ezfio_defaults/.empty new file mode 100644 index 00000000..e69de29b diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml index 01548e88..f963ee7e 100644 --- a/ocaml/Input_full_ci.ml +++ b/ocaml/Input_full_ci.ml @@ -3,7 +3,7 @@ open Qputils;; open Core.Std;; module Full_ci : sig - type t = + type t = { n_det_max_fci : Det_number_max.t; pt2_max : PT2_energy.t; do_pt2_end : bool; diff --git a/ocaml/Input_mo_basis.ml b/ocaml/Input_mo_basis.ml index f02dbfa9..ab75b869 100644 --- a/ocaml/Input_mo_basis.ml +++ b/ocaml/Input_mo_basis.ml @@ -2,27 +2,21 @@ open Qptypes;; open Qputils;; open Core.Std;; +type t_mo = + { mo_tot_num : MO_number.t ; + mo_label : MO_label.t; + mo_occ : MO_occ.t array; + mo_coef : (MO_coef.t array) array; + ao_md5 : MD5.t; + } with sexp + module Mo_basis : sig - type t = - { mo_tot_num : MO_number.t ; - mo_label : MO_label.t; - mo_occ : MO_occ.t array; - mo_coef : (MO_coef.t array) array; - ao_md5 : MD5.t; - } with sexp - ;; + type t = t_mo val read : unit -> t option val to_string : t -> string val to_rst : t -> Rst_string.t end = struct - type t = - { mo_tot_num : MO_number.t ; - mo_label : MO_label.t; - mo_occ : MO_occ.t array; - mo_coef : (MO_coef.t array) array; - ao_md5 : MD5.t; - } with sexp - ;; + type t = t_mo let get_default = Qpackage.get_ezfio_default "mo_basis";; diff --git a/ocaml/Qpackage.ml b/ocaml/Qpackage.ml index 143cff28..4d08192a 100644 --- a/ocaml/Qpackage.ml +++ b/ocaml/Qpackage.ml @@ -71,8 +71,8 @@ let executables = lazy ( ) -let get_ezfio_default directory data = - let filename = root^"/data/ezfio_defaults" in + +let get_ezfio_default_in_file ~directory ~data ~filename = let lines = In_channel.with_file filename ~f:(fun in_channel -> In_channel.input_lines in_channel) in let rec find_dir = function @@ -93,8 +93,10 @@ let get_ezfio_default directory data = begin match (String.lsplit2 ~on:' ' (String.strip line)) with | Some (l,r) -> - if (l = data) then (String.lowercase (String.strip r)) - else find_data rest + if (l = data) then + String.lowercase (String.strip r) + else + find_data rest | None -> raise Not_found end | [] -> raise Not_found @@ -102,3 +104,23 @@ let get_ezfio_default directory data = find_dir lines |> find_data ; ;; + +let get_ezfio_default directory data = + let dirname = root^"/data/ezfio_defaults/" in + + let rec aux = function + | [] -> raise Not_found + | filename :: tail -> + let filename = + dirname^filename + in + try + get_ezfio_default_in_file ~directory ~data ~filename + with + | Not_found -> aux tail + in + Sys.readdir dirname + |> Array.to_list + |> aux +;; + From b72f6a813c2a3549ea7a20cb1821dfb6db1835a9 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 19:04:19 +0100 Subject: [PATCH 12/60] Add python 2.6 in travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6b29a49e..1a1b3701 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ sudo: true +language: python +python: + - "2.6" + before_script: - sudo apt-get update - sudo apt-get install gfortran liblapack-dev zip From 7e1c45bedd60ff6375a0ceb4ae4ca90601acc318 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 19:26:48 +0100 Subject: [PATCH 13/60] Now ezfio_interface.py work in Python 2.6 --- scripts/ezfio_interface.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 8ff6ddd5..f875d326 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -342,10 +342,9 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): def create_format_string(size): """ Take a size number and - return the string format for being right align with this ofset + return the string format for being right align with this offset """ - - return "{{:<{0}}}".format(size).format + return "{{0:<{0}}}".format(size).format # ~#~#~#~#~#~#~#~#~#~#~# # # F o r m a t _ i n f o # From 3c368023e95ce907400dbcaecd0b737f0e892350 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 20:04:05 +0100 Subject: [PATCH 14/60] Modif ezfio_default for reflection the new change in default. Add ezfio_generate_provider who is the new version of the program --- scripts/ezfio_generate_provider.py | 142 +++++++++++++++++++++ scripts/ezfio_interface.py | 10 +- scripts/ezfio_with_default.py | 190 +++++++++++++++-------------- 3 files changed, 246 insertions(+), 96 deletions(-) create mode 100755 scripts/ezfio_generate_provider.py diff --git a/scripts/ezfio_generate_provider.py b/scripts/ezfio_generate_provider.py new file mode 100755 index 00000000..5b2b07e5 --- /dev/null +++ b/scripts/ezfio_generate_provider.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python + +__author__ = "Anthony Scemama and Applencourt for the amazing PEP8" +__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)" + +""" +Creates the provider of a variable that has to be +fetched from the EZFIO file. +""" + +import sys +import os + + +class EZFIO_Provider(object): + + data = """BEGIN_PROVIDER [ %(type)s, %(name)s ] + implicit none + BEGIN_DOC +! %(doc)s + END_DOC + + logical :: has + PROVIDE ezfio_filename + call ezfio_has_%(ezfio_dir)s_%(ezfio_name)s(has) + if (has) then + call ezfio_get_%(ezfio_dir)s_%(ezfio_name)s(%(name)s) + else + %(default)s + endif + %(write)s + +END_PROVIDER +""" + + 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): + if not self.default: + self.get_default() + self.set_write() + for v in self.values: + exec "test = self.%s is None" % (v) in locals() + if test: + msg = "Error : %s is not set in ezfio_with_default.py" % (v) + print >>sys.stderr, msg + 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() + + def set_type(self, t): + self.type = t.lower() + + def set_doc(self, t): + self.doc = t.replace('\n', '\n! ') + + def set_name(self, t): + self.name = t + + def set_ezfio_dir(self, t): + self.ezfio_dir = t.lower() + + def set_ezfio_name(self, t): + self.ezfio_name = t.lower() + + def set_output(self, t): + self.output = t + + def set_default(self, t): + self.default = t + + def get_default(self): + filename = '/'.join([os.environ['QPACKAGE_ROOT'], + 'data', + 'ezfio_defaults']) + + with open(filename, 'r') as f: + lines = f.readlines() + + # 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 + + +if __name__ == '__main__': + test_module() diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index f875d326..6f6d654f 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -260,7 +260,7 @@ def create_ezfio_provider(dict_ezfio_cfg): create the a list who containt all the code for the provider return [code, ...] """ - from ezfio_with_default import EZFIO_Provider + from ezfio_generate_provider import EZFIO_Provider dict_code_provider = dict() @@ -274,11 +274,11 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_ezfio_name(dict_info['ezfio_name']) str_ = "\n".join([" print *, '{0}/{1} not found in EZFIO file'", - " stop 1" ]) - + " stop 1"]) + str_ = str_.format(dict_info['ezfio_dir'], - dict_info['ezfio_name']) - + dict_info['ezfio_name']) + ez_p.set_default(str_) ez_p.set_output("output_%s" % dict_info['ezfio_dir']) diff --git a/scripts/ezfio_with_default.py b/scripts/ezfio_with_default.py index 5b2b07e5..46981132 100755 --- a/scripts/ezfio_with_default.py +++ b/scripts/ezfio_with_default.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -__author__ = "Anthony Scemama and Applencourt for the amazing PEP8" -__date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)" +__author__ = "Anthony Scemama" +__date__ = "Tue Jul 29 12:20:00 CEST 2014" """ Creates the provider of a variable that has to be @@ -14,9 +14,9 @@ import os class EZFIO_Provider(object): - data = """BEGIN_PROVIDER [ %(type)s, %(name)s ] + data = """BEGIN_PROVIDER [ %(type)s, %(name)s ] implicit none - BEGIN_DOC + BEGIN_DOC ! %(doc)s END_DOC @@ -33,110 +33,118 @@ 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() + 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): + 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 "self.%s = None" % (v) in locals() + exec "x = str(self.%s)"%(v) in locals() + print >>sys.stderr, "%s : %s"%(v, x) + sys.exit(1) + return self.data%self.__dict__ - def __repr__(self): - if not self.default: - self.get_default() - self.set_write() - for v in self.values: - exec "test = self.%s is None" % (v) in locals() - if test: - msg = "Error : %s is not set in ezfio_with_default.py" % (v) - print >>sys.stderr, msg - 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 = """ + 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() + '%(name)s') + """%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']) + def get_default(self): - with open(filename, 'r') as f: - lines = f.readlines() + from os import listdir + from os.path import isfile, join - # 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 + mypath = '/'.join( [os.environ['QPACKAGE_ROOT'], 'data', 'ezfio_defaults','/']) + onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ] + + lines= [] + for filename in onlyfiles: + file = open(mypath+filename,'r') + lines.extend(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 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() + + From 9d27774df1935322bd52ca1995dd0785d6d4749c Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 20:26:20 +0100 Subject: [PATCH 15/60] Cleaning of ezfio_generate_provider.py --- scripts/ezfio_generate_provider.py | 80 +++++++----------------------- scripts/ezfio_interface.py | 10 +--- src/Full_CI/EZFIO.cfg | 2 +- 3 files changed, 19 insertions(+), 73 deletions(-) diff --git a/scripts/ezfio_generate_provider.py b/scripts/ezfio_generate_provider.py index 5b2b07e5..d18710d7 100755 --- a/scripts/ezfio_generate_provider.py +++ b/scripts/ezfio_generate_provider.py @@ -8,16 +8,14 @@ Creates the provider of a variable that has to be fetched from the EZFIO file. """ -import sys -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 +! %(doc)s END_DOC logical :: has @@ -26,34 +24,30 @@ class EZFIO_Provider(object): if (has) then call ezfio_get_%(ezfio_dir)s_%(ezfio_name)s(%(name)s) else - %(default)s + print *, '%(ezfio_dir)s/%(ezfio_name)s not found in EZFIO file' + stop 1 endif - %(write)s + +%(write)s END_PROVIDER -""" +""".strip() 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() + self.values = "type doc name ezfio_dir ezfio_name write output".split() for v in self.values: - exec "self.%s = None" % (v) in locals() + exec "self.{0} = None".format(v) def __repr__(self): - if not self.default: - self.get_default() self.set_write() for v in self.values: - exec "test = self.%s is None" % (v) in locals() - if test: + if not v: msg = "Error : %s is not set in ezfio_with_default.py" % (v) print >>sys.stderr, msg - 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__ @@ -63,16 +57,17 @@ END_PROVIDER 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() + + l_write = [" call write_time(%(output)s)", + " call %(write)s(%(output)s, %(name)s, &", + " '%(name)s')"] + self.write = "\n".join(l_write) % locals() def set_type(self, t): self.type = t.lower() def set_doc(self, t): - self.doc = t.replace('\n', '\n! ') + self.doc = t.strip().replace('\n', '\n! ') def set_name(self, t): self.name = t @@ -86,46 +81,6 @@ END_PROVIDER def set_output(self, t): self.output = t - def set_default(self, t): - self.default = t - - def get_default(self): - filename = '/'.join([os.environ['QPACKAGE_ROOT'], - 'data', - 'ezfio_defaults']) - - with open(filename, 'r') as f: - lines = f.readlines() - - # 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() @@ -137,6 +92,5 @@ def test_module(): T.set_output("output_Hartree_Fock") print T - if __name__ == '__main__': test_module() diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 6f6d654f..b826598f 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -272,16 +272,8 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_doc(dict_info['doc']) ez_p.set_ezfio_dir(dict_info['ezfio_dir']) ez_p.set_ezfio_name(dict_info['ezfio_name']) - - str_ = "\n".join([" print *, '{0}/{1} not found in EZFIO file'", - " stop 1"]) - - str_ = str_.format(dict_info['ezfio_dir'], - dict_info['ezfio_name']) - - ez_p.set_default(str_) - ez_p.set_output("output_%s" % dict_info['ezfio_dir']) + dict_code_provider[provider_name] = str(ez_p) return dict_code_provider diff --git a/src/Full_CI/EZFIO.cfg b/src/Full_CI/EZFIO.cfg index febd0530..8146ff81 100644 --- a/src/Full_CI/EZFIO.cfg +++ b/src/Full_CI/EZFIO.cfg @@ -19,7 +19,7 @@ default: true [PT2_max] type: PT2_energy doc: The selection process stops when the largest PT2 (for all the state is lower - than pt2_max in absolute value + than pt2_max in absolute value) interface: output default: 0.0001 From f55e5cf88f0ddd003166636641154bdf488476ad Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 20:32:59 +0100 Subject: [PATCH 16/60] with the default_file is beter --- .../ezfio_defaults/bi_integrals.ezfio_default | 9 +++ data/ezfio_defaults/cisd.ezfio_default | 4 ++ data/ezfio_defaults/cisd_sc2.ezfio_default | 5 ++ .../ezfio_defaults/determinants.ezfio_default | 9 +++ data/ezfio_defaults/full_ci.ezfio_default | 6 ++ .../ezfio_defaults/hartree_fock.ezfio_default | 4 ++ data/ezfio_defaults/properties.ezfio_default | 2 + data/ezfio_defaults/q_package.ezfio_default | 60 +++++++++++++++++++ 8 files changed, 99 insertions(+) create mode 100644 data/ezfio_defaults/bi_integrals.ezfio_default create mode 100644 data/ezfio_defaults/cisd.ezfio_default create mode 100644 data/ezfio_defaults/cisd_sc2.ezfio_default create mode 100644 data/ezfio_defaults/determinants.ezfio_default create mode 100644 data/ezfio_defaults/full_ci.ezfio_default create mode 100644 data/ezfio_defaults/hartree_fock.ezfio_default create mode 100644 data/ezfio_defaults/properties.ezfio_default create mode 100644 data/ezfio_defaults/q_package.ezfio_default diff --git a/data/ezfio_defaults/bi_integrals.ezfio_default b/data/ezfio_defaults/bi_integrals.ezfio_default new file mode 100644 index 00000000..7cdf7a9b --- /dev/null +++ b/data/ezfio_defaults/bi_integrals.ezfio_default @@ -0,0 +1,9 @@ +bielec_integrals + read_ao_integrals False + read_mo_integrals False + write_ao_integrals False + write_mo_integrals False + threshold_ao 1.e-15 + threshold_mo 1.e-15 + direct False + diff --git a/data/ezfio_defaults/cisd.ezfio_default b/data/ezfio_defaults/cisd.ezfio_default new file mode 100644 index 00000000..95991f8f --- /dev/null +++ b/data/ezfio_defaults/cisd.ezfio_default @@ -0,0 +1,4 @@ +cisd_selected + n_det_max_cisd 10000 + pt2_max 1.e-4 + diff --git a/data/ezfio_defaults/cisd_sc2.ezfio_default b/data/ezfio_defaults/cisd_sc2.ezfio_default new file mode 100644 index 00000000..624ac35d --- /dev/null +++ b/data/ezfio_defaults/cisd_sc2.ezfio_default @@ -0,0 +1,5 @@ +cisd_sc2_selected + n_det_max_cisd_sc2 10000 + pt2_max 1.e-4 + do_pt2_end True + diff --git a/data/ezfio_defaults/determinants.ezfio_default b/data/ezfio_defaults/determinants.ezfio_default new file mode 100644 index 00000000..42f6b384 --- /dev/null +++ b/data/ezfio_defaults/determinants.ezfio_default @@ -0,0 +1,9 @@ +determinants + n_states 1 + n_states_diag determinants_n_states + n_det_max_jacobi 1000 + threshold_generators 0.99 + threshold_selectors 0.999 + read_wf False + s2_eig False + only_single_double_dm False diff --git a/data/ezfio_defaults/full_ci.ezfio_default b/data/ezfio_defaults/full_ci.ezfio_default new file mode 100644 index 00000000..359cc4d2 --- /dev/null +++ b/data/ezfio_defaults/full_ci.ezfio_default @@ -0,0 +1,6 @@ +full_ci + n_det_max_fci 10000 + n_det_max_fci_property 50000 + pt2_max 1.e-4 + do_pt2_end True + var_pt2_ratio 0.75 diff --git a/data/ezfio_defaults/hartree_fock.ezfio_default b/data/ezfio_defaults/hartree_fock.ezfio_default new file mode 100644 index 00000000..048a3c77 --- /dev/null +++ b/data/ezfio_defaults/hartree_fock.ezfio_default @@ -0,0 +1,4 @@ +hartree_fock + n_it_scf_max 200 + thresh_scf 1.e-10 + guess "Huckel" diff --git a/data/ezfio_defaults/properties.ezfio_default b/data/ezfio_defaults/properties.ezfio_default new file mode 100644 index 00000000..ce06d413 --- /dev/null +++ b/data/ezfio_defaults/properties.ezfio_default @@ -0,0 +1,2 @@ +properties + z_one_point 3.9 diff --git a/data/ezfio_defaults/q_package.ezfio_default b/data/ezfio_defaults/q_package.ezfio_default new file mode 100644 index 00000000..5da4d813 --- /dev/null +++ b/data/ezfio_defaults/q_package.ezfio_default @@ -0,0 +1,60 @@ +bielec_integrals + read_ao_integrals False + read_mo_integrals False + write_ao_integrals False + write_mo_integrals False + threshold_ao 1.e-15 + threshold_mo 1.e-15 + direct False + +cis_dressed + n_state_cis 10 + n_core_cis 0 + n_act_cis mo_basis_mo_tot_num + mp2_dressing False + standard_doubles True + en_2_2 False + +determinants + n_states 1 + n_states_diag determinants_n_states + n_det_max_jacobi 1000 + threshold_generators 0.99 + threshold_selectors 0.999 + read_wf False + s2_eig False + only_single_double_dm False + +full_ci + n_det_max_fci 10000 + n_det_max_fci_property 50000 + pt2_max 1.e-4 + do_pt2_end True + var_pt2_ratio 0.75 + +all_singles + n_det_max_fci 50000 + pt2_max 1.e-8 + do_pt2_end False + +cassd + n_det_max_cassd 10000 + pt2_max 1.e-4 + do_pt2_end True + +hartree_fock + n_it_scf_max 200 + thresh_scf 1.e-10 + guess "Huckel" + +cisd_selected + n_det_max_cisd 10000 + pt2_max 1.e-4 + +cisd_sc2_selected + n_det_max_cisd_sc2 10000 + pt2_max 1.e-4 + do_pt2_end True + +properties + z_one_point 3.9 From e620921ba0caf8129bccdd43cdb785670d15ac24 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 20:34:02 +0100 Subject: [PATCH 17/60] Add *.mod and *.p in gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index cdcdc6d8..2a924323 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ bin/ quantum_package_static.tar.gz resultsFile opam_installer.sh +*.mod +*.p \ No newline at end of file From b2f3e32e3cd98b2090756d4bd398e42a405b2e0e Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 20:45:25 +0100 Subject: [PATCH 18/60] Behing AGILE : Remove a non using opt --- scripts/ezfio_interface.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index b826598f..9233a6c5 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -310,7 +310,7 @@ def save_ezfio_provider(path_head, dict_code_provider): f.write(output) -def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): +def create_ezfio_config(dict_ezfio_cfg, module_lower): """ From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config @@ -405,6 +405,10 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.write(str_ezfio_config) +def create_ocaml_check(dict_code_provider): + pass + + def main(): """ Two condition: @@ -442,10 +446,8 @@ def main(): save_ezfio_provider(path_dirname, d_config) # print "Generating the ezfio_config" - config_ezfio = create_ezfio_config( - dict_info_provider, - "config", - module_lower) + config_ezfio = create_ezfio_config(dict_info_provider, + module_lower) # print "Saving ezfio_config" save_ezfio_config(module_lower, config_ezfio) From 55580d8eb6d1e983cf8e243eeb2c5b9e30a7470f Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 21:08:55 +0100 Subject: [PATCH 19/60] Doc in ezfio_interace.py --- scripts/ezfio_interface.py | 63 ++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 9233a6c5..94e7ae47 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -6,6 +6,8 @@ Check if EZFIO.cfg exists. EZFIO.cfg are in MODULE directories. create : ezfio_interface.irp.f folder_ezfio_inteface_config +Ezfio_dir : is equal to MODULE.lower! + Format specification : [provider_name] : the name of the provider in irp.f90 @@ -310,7 +312,7 @@ def save_ezfio_provider(path_head, dict_code_provider): f.write(output) -def create_ezfio_config(dict_ezfio_cfg, module_lower): +def create_ezfio_config(dict_ezfio_cfg): """ From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config @@ -353,7 +355,14 @@ def create_ezfio_config(dict_ezfio_cfg, module_lower): # C r e a t e _ t h e _ s t r i n g # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - result = [module_lower] + # Checking is many ezfio_dir provided + l_ezfio_dir = [d['ezfio_dir'] for d in dict_ezfio_cfg.values()] + + if not l_ezfio_dir.count(l_ezfio_dir[0]) == len(l_ezfio_dir): + print >> sys.stderr, "You have many ezfio_dir. Not supported yet" + raise TypeError + else: + result = [l_ezfio_dir[0]] for provider_name, provider_info in sorted(dict_ezfio_cfg.iteritems()): @@ -388,8 +397,8 @@ def save_ezfio_config(module_lower, str_ezfio_config): $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) """ - ezfio_dir = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) - path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir, + root_ezfio = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) + path = "{0}/config/{1}.ezfio_interface_config".format(root_ezfio, module_lower) try: @@ -407,6 +416,19 @@ def save_ezfio_config(module_lower, str_ezfio_config): def create_ocaml_check(dict_code_provider): pass +# def create_creade(): +# +#""" +# let read_{ezfio_name} () = +# if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then +# get_default "{ezfio_name}" +# |> Float.of_string +# |> Ezfio.set_{ezfio_dir}_{ezfio_name} +# ; +# Ezfio.get_{ezfio_dir}_{ezfio_name} () +# |> Normalized_float.of_float +# ;; +#""" def main(): @@ -420,6 +442,10 @@ def main(): - folder_ezfio_inteface_config """ + # ~#~#~#~# # + # I n i t # + # ~#~#~#~# # + try: config_file_path = sys.argv[1] except: @@ -430,27 +456,32 @@ def main(): config_file_path = os.path.expanduser(config_file_path) config_file_path = os.path.expandvars(config_file_path) config_file_path = os.path.abspath(config_file_path) - # print config_file_path + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # G e t _ m o d u l e _ d i r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # path_dirname = os.path.dirname(config_file_path) module = [i for i in path_dirname.split("/") if i][-1] module_lower = module.lower() - # print "Read {0}".format(config_file_path) - dict_info_provider = get_dict_config_file(config_file_path, module_lower) + # Because we only authorise this right now! + ezfio_dir = module_lower + dict_info_provider = get_dict_config_file(config_file_path, ezfio_dir) - # print "Generating the ezfio_interface.irp.f: \n" - d_config = create_ezfio_provider(dict_info_provider) + # ~#~#~#~#~#~#~#~# # + # I R P . f 9 0 # + # ~#~#~#~#~#~#~#~# # - # print "Saving the ezfio_interface.irp.f" - save_ezfio_provider(path_dirname, d_config) + l_str_code = create_ezfio_provider(dict_info_provider) + save_ezfio_provider(path_dirname, l_str_code) - # print "Generating the ezfio_config" - config_ezfio = create_ezfio_config(dict_info_provider, - module_lower) + # ~#~#~#~#~#~#~#~#~#~#~#~# # + # e z f i o _ c o n f i g # + # ~#~#~#~#~#~#~#~#~#~#~#~# # - # print "Saving ezfio_config" - save_ezfio_config(module_lower, config_ezfio) + str_ezfio_config = create_ezfio_config(dict_info_provider) + save_ezfio_config(module_lower, str_ezfio_config) if __name__ == "__main__": From 04514b5b4f5313c2535e43e202fb33b255ebb220 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Mar 2015 22:07:44 +0100 Subject: [PATCH 20/60] First try for read snipet --- scripts/ezfio_interface.py | 109 +++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index 94e7ae47..11e5a7cd 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -49,7 +49,7 @@ import ConfigParser from collections import defaultdict from collections import namedtuple -Type = namedtuple('Type', 'ocaml fortran') +Type = namedtuple('Type', 'fancy ocaml fortran') def is_bool(str_): @@ -58,9 +58,9 @@ def is_bool(str_): fortran and ocaml one. """ if str_.lower() in ['true', '.true.']: - return Type("true", ".True.") + return Type(None, "true", ".True.") elif str_.lower() in ['false', '.False.']: - return Type("false", ".False") + return Type(None, "false", ".False") else: raise TypeError @@ -99,18 +99,18 @@ def get_type_dict(): # R a w _ t y p e # # ~#~#~#~#~#~#~#~ # - fancy_type['integer'] = Type("int", "integer") - fancy_type['int'] = Type("int", "integer") + fancy_type['integer'] = Type(None, "int", "integer") + fancy_type['int'] = Type(None, "int", "integer") - fancy_type['float'] = Type("float", "double precision") - fancy_type['double precision'] = Type("float", "double precision") + fancy_type['float'] = Type(None, "float", "double precision") + fancy_type['double precision'] = Type(None, "float", "double precision") - fancy_type['logical'] = Type("bool", "logical") - fancy_type['bool'] = Type("bool", "logical") + fancy_type['logical'] = Type(None, "bool", "logical") + fancy_type['bool'] = Type(None, "bool", "logical") - fancy_type['character*32'] = Type("string", "character*32") - fancy_type['character*60'] = Type("string", "character*60") - fancy_type['character*256'] = Type("string", "character*256") + fancy_type['character*32'] = Type(None, "string", "character*32") + fancy_type['character*60'] = Type(None, "string", "character*60") + fancy_type['character*256'] = Type(None, "string", "character*256") # ~#~#~#~#~#~#~#~ # # q p _ t y p e s # @@ -133,7 +133,9 @@ def get_type_dict(): str_ocaml_type = i.split()[3] str_fortran_type = ocaml_to_fortran[str_ocaml_type] - fancy_type[str_fancy_type] = Type(str_ocaml_type, str_fortran_type) + fancy_type[str_fancy_type] = Type(str_fancy_type, + str_ocaml_type, + str_fortran_type) # ~#~#~#~#~#~#~#~ # # F i n a l i z e # @@ -245,7 +247,7 @@ def get_dict_config_file(config_file_path, module_lower): try: d[pvd]["default"] = is_bool(default_raw) except TypeError: - d[pvd]["default"] = Type(default_raw, default_raw) + d[pvd]["default"] = Type(None, default_raw, default_raw) return dict(d) @@ -288,8 +290,6 @@ def save_ezfio_provider(path_head, dict_code_provider): path = "{0}/ezfio_interface.irp.f".format(path_head) - # print "Path = {0}".format(path) - try: f = open(path, "r") except IOError: @@ -414,21 +414,52 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.write(str_ezfio_config) -def create_ocaml_check(dict_code_provider): - pass -# def create_creade(): -# -#""" -# let read_{ezfio_name} () = -# if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then -# get_default "{ezfio_name}" -# |> Float.of_string -# |> Ezfio.set_{ezfio_dir}_{ezfio_name} -# ; -# Ezfio.get_{ezfio_dir}_{ezfio_name} () -# |> Normalized_float.of_float -# ;; -#""" +def create_ocaml_check(dict_ezfio_cfg): + + # ~#~#~#~#~#~#~#~# # + # F u n c t i o n # + # ~#~#~#~#~#~#~#~# # + + def create_read(d_format): + + template = """ + (* Read snippet for {ezfio_name} *) + let read_{ezfio_name} () = + if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then + get_default "{ezfio_name}" + |> {Ocaml_type}.of_string + |> Ezfio.set_{ezfio_dir}_{ezfio_name} + ; + Ezfio.get_{ezfio_dir}_{ezfio_name} () +""" + fancy_type = d_format["type"] + if d_format["type"].fancy: + template += " |> {0}.of_{1}".format(fancy_type.fancy, + fancy_type.ocaml) + + template += """ + ;; + """ + return template.strip().format(**d_format) + + # ~#~#~#~#~#~#~#~# # + # C r e a t i o n # + # ~#~#~#~#~#~#~#~# # + + for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()): + + ocaml_type = d_val["type"].ocaml.capitalize() + ezfio_dir = d_val["ezfio_dir"] + ezfio_name = d_val["ezfio_name"] + + d = {"ezfio_dir": ezfio_dir, + "ezfio_name": ezfio_name, + "type": d_val["type"], + "Ocaml_type": ocaml_type} + + template = create_read(d) + + print template def main(): @@ -467,20 +498,26 @@ def main(): # Because we only authorise this right now! ezfio_dir = module_lower - dict_info_provider = get_dict_config_file(config_file_path, ezfio_dir) + dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir) - # ~#~#~#~#~#~#~#~# # + # ~#~#~#~#~#~# + # O c a m l # + # ~#~#~#~#~#~# + + _ = create_ocaml_check(dict_ezfio_cfg) + + # ~#~#~#~#~#~#~#~# # I R P . f 9 0 # - # ~#~#~#~#~#~#~#~# # + # ~#~#~#~#~#~#~#~# - l_str_code = create_ezfio_provider(dict_info_provider) + l_str_code = create_ezfio_provider(dict_ezfio_cfg) save_ezfio_provider(path_dirname, l_str_code) # ~#~#~#~#~#~#~#~#~#~#~#~# # # e z f i o _ c o n f i g # # ~#~#~#~#~#~#~#~#~#~#~#~# # - str_ezfio_config = create_ezfio_config(dict_info_provider) + str_ezfio_config = create_ezfio_config(dict_ezfio_cfg) save_ezfio_config(module_lower, str_ezfio_config) From 7db2751cdb2272de34d24c84abe6417795fb2828 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 10:44:39 +0100 Subject: [PATCH 21/60] Add directory for ezfio_interface, first apparition of ezfio_generate_ocaml --- .../ei_handler.py} | 37 +++--------- .../ezfio_interface/ezfio_generate_ocaml.py | 59 +++++++++++++++++++ .../ezfio_generate_provider.py | 2 +- scripts/prepare_ezfio.sh | 2 +- scripts/run_Makefile_common.sh | 3 +- setup_environment.sh | 4 +- 6 files changed, 71 insertions(+), 36 deletions(-) rename scripts/{ezfio_interface.py => ezfio_interface/ei_handler.py} (94%) create mode 100755 scripts/ezfio_interface/ezfio_generate_ocaml.py rename scripts/{ => ezfio_interface}/ezfio_generate_provider.py (97%) diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface/ei_handler.py similarity index 94% rename from scripts/ezfio_interface.py rename to scripts/ezfio_interface/ei_handler.py index 11e5a7cd..0852eb79 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -83,7 +83,7 @@ def get_type_dict(): qpackage_root = os.environ['QPACKAGE_ROOT'] - fancy_type_pickle = qpackage_root + "/scripts/fancy_type.p" + fancy_type_pickle = qpackage_root + "/scripts/ezfio_interface/fancy_type.p" if fancy_type_pickle in listdir(os.getcwd()): fancy_type = pickle.load(open(fancy_type_pickle, "rb")) @@ -416,36 +416,14 @@ def save_ezfio_config(module_lower, str_ezfio_config): def create_ocaml_check(dict_ezfio_cfg): - # ~#~#~#~#~#~#~#~# # - # F u n c t i o n # - # ~#~#~#~#~#~#~#~# # - - def create_read(d_format): - - template = """ - (* Read snippet for {ezfio_name} *) - let read_{ezfio_name} () = - if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then - get_default "{ezfio_name}" - |> {Ocaml_type}.of_string - |> Ezfio.set_{ezfio_dir}_{ezfio_name} - ; - Ezfio.get_{ezfio_dir}_{ezfio_name} () -""" - fancy_type = d_format["type"] - if d_format["type"].fancy: - template += " |> {0}.of_{1}".format(fancy_type.fancy, - fancy_type.ocaml) - - template += """ - ;; - """ - return template.strip().format(**d_format) - # ~#~#~#~#~#~#~#~# # # C r e a t i o n # # ~#~#~#~#~#~#~#~# # + from ezfio_generate_ocaml import EZFIO_ocaml + + e = EZFIO_ocaml() + for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()): ocaml_type = d_val["type"].ocaml.capitalize() @@ -454,10 +432,9 @@ def create_ocaml_check(dict_ezfio_cfg): d = {"ezfio_dir": ezfio_dir, "ezfio_name": ezfio_name, - "type": d_val["type"], - "Ocaml_type": ocaml_type} + "type": d_val["type"]} - template = create_read(d) + template = e.create_read(**d) print template diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py new file mode 100755 index 00000000..07eaee6e --- /dev/null +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +import sys + + +class EZFIO_ocaml(object): + + def __init__(self): + pass + + def create_read(self, **param): + ''' + Take an imput a list of keyword argument + ezfio_dir = str + ezfio_name = str + type = Named_tuple(fancy_type, ocaml_type, fortrant_type) + + Return the read template + ''' + + l_name_need = "ezfio_dir ezfio_name type".split() + + for key in l_name_need: + if key not in param: + print "You need to provide {0} at keyword argument".format(key) + sys.exit(1) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = ['(* Read snippet for {ezfio_name} *)', + 'let read_{ezfio_name} () =', + ' if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then', + ' get_default "{ezfio_name}"', + ' |> {Ocaml_type}.of_string', + ' |> Ezfio.set_{ezfio_dir}_{ezfio_name}', + ' ;', + ' Ezfio.get_{ezfio_dir}_{ezfio_name} ()'] + + if param["type"].fancy: + l_template += [" |> {fancy_type}.of_{Ocaml_type}"] + + l_template += [";;;"] + + template = "\n ".join(l_template) + + # ~#~#~#~#~#~ # + # R e n d e r # + # ~#~#~#~#~#~ # + + param["Ocaml_type"] = param["type"].ocaml.capitalize() + param["fancy_type"] = param["type"].fancy + template_rendered = template.format(**param) + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return template_rendered diff --git a/scripts/ezfio_generate_provider.py b/scripts/ezfio_interface/ezfio_generate_provider.py similarity index 97% rename from scripts/ezfio_generate_provider.py rename to scripts/ezfio_interface/ezfio_generate_provider.py index d18710d7..21dc8450 100755 --- a/scripts/ezfio_generate_provider.py +++ b/scripts/ezfio_interface/ezfio_generate_provider.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -__author__ = "Anthony Scemama and Applencourt for the amazing PEP8" +__author__ = "Applencourt PEP8" __date__ = "jeudi 26 mars 2015, 12:49:35 (UTC+0100)" """ diff --git a/scripts/prepare_ezfio.sh b/scripts/prepare_ezfio.sh index c01bacd3..96ba3cdc 100755 --- a/scripts/prepare_ezfio.sh +++ b/scripts/prepare_ezfio.sh @@ -9,7 +9,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-" for dir in ${QPACKAGE_ROOT}/src/*/ do cd $dir || exit -1 - ${QPACKAGE_ROOT}/scripts/ezfio_interface.py + ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py done # For old-style directories. Will be removed some day... diff --git a/scripts/run_Makefile_common.sh b/scripts/run_Makefile_common.sh index 0a579a94..82e898ac 100755 --- a/scripts/run_Makefile_common.sh +++ b/scripts/run_Makefile_common.sh @@ -65,5 +65,4 @@ fi ${QPACKAGE_ROOT}/scripts/create_Makefile_depend.sh # Update EZFIO interface -${QPACKAGE_ROOT}/scripts/ezfio_interface.py - + ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py diff --git a/setup_environment.sh b/setup_environment.sh index ca853fdf..8db6a11c 100755 --- a/setup_environment.sh +++ b/setup_environment.sh @@ -34,8 +34,8 @@ export QPACKAGE_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P ) export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH} export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH} export C_INCLUDE_PATH="\${QPACKAGE_ROOT}"/include:\${C_INCLUDE_PATH} -export PYTHONPATH=\${PYTHONPATH}:"\${QPACKAGE_ROOT}"/scripts -export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/scripts +export PYTHONPATH=\${PYTHONPATH}:"\${QPACKAGE_ROOT}"/scripts:"\${QPACKAGE_ROOT}"/scripts/ezfio_interface +export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/scripts:"\${QPACKAGE_ROOT}"/scripts/ezfio_interface export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/bin export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ocaml source "\${QPACKAGE_ROOT}"/bin/irpman &> /dev/null From 5845768b31ee952bc6c382dd6e0981851bf20692 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 11:15:55 +0100 Subject: [PATCH 22/60] Cleaning ezfio_generate_ocaml --- scripts/ezfio_interface/ei_handler.py | 7 +-- .../ezfio_interface/ezfio_generate_ocaml.py | 56 ++++++++++++------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 0852eb79..7b631721 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -422,11 +422,8 @@ def create_ocaml_check(dict_ezfio_cfg): from ezfio_generate_ocaml import EZFIO_ocaml - e = EZFIO_ocaml() - for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()): - ocaml_type = d_val["type"].ocaml.capitalize() ezfio_dir = d_val["ezfio_dir"] ezfio_name = d_val["ezfio_name"] @@ -434,7 +431,9 @@ def create_ocaml_check(dict_ezfio_cfg): "ezfio_name": ezfio_name, "type": d_val["type"]} - template = e.create_read(**d) + e = EZFIO_ocaml(**d) + + template = e.create_read() print template diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index 07eaee6e..bbed9685 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -5,10 +5,23 @@ import sys class EZFIO_ocaml(object): - def __init__(self): - pass + def __init__(self, **kwargs): - def create_read(self, **param): + for k, v in kwargs.iteritems(): + if k == "type": + self.type = kwargs["type"] + else: + exec "self.{0} = '{1}'".format(k, v) + + @property + def Ocaml_type(self): + return self.type.ocaml.capitalize() + + @property + def fancy_type(self): + return self.type.fancy + + def create_read(self): ''' Take an imput a list of keyword argument ezfio_dir = str @@ -18,28 +31,28 @@ class EZFIO_ocaml(object): Return the read template ''' - l_name_need = "ezfio_dir ezfio_name type".split() - - for key in l_name_need: - if key not in param: - print "You need to provide {0} at keyword argument".format(key) - sys.exit(1) + for i in ["ezfio_dir", "ezfio_name", "type"]: + try: + "exec self.{0}".format(i) + except NameError: + msg = "You need to provide a '{0}' for creating read function" + raise KeyError(msg.format(i)) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # # C r e a t e _ t e m pl a t e # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - l_template = ['(* Read snippet for {ezfio_name} *)', - 'let read_{ezfio_name} () =', - ' if not (Ezfio.has_{ezfio_dir}_{ezfio_name} ()) then', - ' get_default "{ezfio_name}"', - ' |> {Ocaml_type}.of_string', - ' |> Ezfio.set_{ezfio_dir}_{ezfio_name}', + l_template = ['(* Read snippet for {self.ezfio_name} *)', + 'let read_{self.ezfio_name} () =', + ' if not (Ezfio.has_{self.ezfio_dir}_{self.ezfio_name} ()) then', + ' get_default "{self.ezfio_name}"', + ' |> {self.Ocaml_type}.of_string', + ' |> Ezfio.set_{self.ezfio_dir}_{self.ezfio_name}', ' ;', - ' Ezfio.get_{ezfio_dir}_{ezfio_name} ()'] + ' Ezfio.get_{self.ezfio_dir}_{self.ezfio_name} ()'] - if param["type"].fancy: - l_template += [" |> {fancy_type}.of_{Ocaml_type}"] + if self.fancy_type: + l_template += [" |> {self.fancy_type}.of_{self.Ocaml_type}"] l_template += [";;;"] @@ -49,11 +62,12 @@ class EZFIO_ocaml(object): # R e n d e r # # ~#~#~#~#~#~ # - param["Ocaml_type"] = param["type"].ocaml.capitalize() - param["fancy_type"] = param["type"].fancy - template_rendered = template.format(**param) + template_rendered = template.format(**locals()) # ~#~#~#~#~#~ # # R e t u r n # # ~#~#~#~#~#~ # return template_rendered + + def create_write(self): + pass From fe93782666ab6595563ff507aec3e1855f695962 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 16:12:47 +0100 Subject: [PATCH 23/60] ei_handler write Input_full_ci.ml --- ocaml/Input_full_ci.ml | 153 --------------- scripts/ezfio_interface/ei_handler.py | 85 +++++++- .../ezfio_interface/ezfio_generate_ocaml.py | 183 ++++++++++++++++-- src/Full_CI/EZFIO.cfg | 4 +- 4 files changed, 254 insertions(+), 171 deletions(-) delete mode 100644 ocaml/Input_full_ci.ml diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml deleted file mode 100644 index f963ee7e..00000000 --- a/ocaml/Input_full_ci.ml +++ /dev/null @@ -1,153 +0,0 @@ -open Qptypes;; -open Qputils;; -open Core.Std;; - -module Full_ci : sig - type t = - { n_det_max_fci : Det_number_max.t; - pt2_max : PT2_energy.t; - do_pt2_end : bool; - var_pt2_ratio : Normalized_float.t; - } with sexp - ;; - val read : unit -> t option - val write : t-> unit - val to_string : t -> string - val to_rst : t -> Rst_string.t - val of_rst : Rst_string.t -> t option -end = struct - type t = - { n_det_max_fci : Det_number_max.t; - pt2_max : PT2_energy.t; - do_pt2_end : bool; - var_pt2_ratio : Normalized_float.t; - } with sexp - ;; - - let get_default = Qpackage.get_ezfio_default "full_ci";; - - let read_n_det_max_fci () = - if not (Ezfio.has_full_ci_n_det_max_fci ()) then - get_default "n_det_max_fci" - |> Int.of_string - |> Ezfio.set_full_ci_n_det_max_fci - ; - Ezfio.get_full_ci_n_det_max_fci () - |> Det_number_max.of_int - ;; - - let write_n_det_max_fci ndet = - Det_number_max.to_int ndet - |> Ezfio.set_full_ci_n_det_max_fci - ;; - - let read_var_pt2_ratio () = - if not (Ezfio.has_full_ci_var_pt2_ratio ()) then - get_default "var_pt2_ratio" - |> Float.of_string - |> Ezfio.set_full_ci_var_pt2_ratio - ; - Ezfio.get_full_ci_var_pt2_ratio () - |> Normalized_float.of_float - ;; - - let write_var_pt2_ratio ratio = - Normalized_float.to_float ratio - |> Ezfio.set_full_ci_var_pt2_ratio - ;; - - let read_pt2_max () = - if not (Ezfio.has_full_ci_pt2_max ()) then - get_default "pt2_max" - |> Float.of_string - |> Ezfio.set_full_ci_pt2_max - ; - Ezfio.get_full_ci_pt2_max () - |> PT2_energy.of_float - ;; - - let write_pt2_max pt2_max = - PT2_energy.to_float pt2_max - |> Ezfio.set_full_ci_pt2_max - ;; - - let read_do_pt2_end () = - if not (Ezfio.has_full_ci_do_pt2_end ()) then - get_default "do_pt2_end" - |> Bool.of_string - |> Ezfio.set_full_ci_do_pt2_end - ; - Ezfio.get_full_ci_do_pt2_end () - ;; - - let write_do_pt2_end = - Ezfio.set_full_ci_do_pt2_end - ;; - - - let read () = - Some - { n_det_max_fci = read_n_det_max_fci (); - pt2_max = read_pt2_max (); - do_pt2_end = read_do_pt2_end (); - var_pt2_ratio = read_var_pt2_ratio (); - } - ;; - - - let write { n_det_max_fci ; - pt2_max ; - do_pt2_end ; - var_pt2_ratio ; - } = - write_n_det_max_fci n_det_max_fci; - write_pt2_max pt2_max; - write_do_pt2_end do_pt2_end; - write_var_pt2_ratio var_pt2_ratio; - ;; - - let to_string b = - Printf.sprintf " -n_det_max_fci = %s -pt2_max = %s -do_pt2_end = %s -var_pt2_ratio = %s -" - (Det_number_max.to_string b.n_det_max_fci) - (PT2_energy.to_string b.pt2_max) - (Bool.to_string b.do_pt2_end) - (Normalized_float.to_string b.var_pt2_ratio) - ;; - - let to_rst b = - Printf.sprintf " -Stop when the `n_det` > `n_det_max_fci` :: - - n_det_max_fci = %s - -Stop when -E(PT2) < `pt2_max` :: - - pt2_max = %s - -Compute E(PT2) at the end :: - - do_pt2_end = %s - -Target energy ratio variational/(variational+PT2) :: - - var_pt2_ratio = %s -" - (Det_number_max.to_string b.n_det_max_fci) - (PT2_energy.to_string b.pt2_max) - (Bool.to_string b.do_pt2_end) - (Normalized_float.to_string b.var_pt2_ratio) - |> Rst_string.of_string - ;; - - include Generic_input_of_rst;; - let of_rst = of_rst t_of_sexp;; - - -end - - diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 7b631721..3396e6db 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -414,7 +414,11 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.write(str_ezfio_config) -def create_ocaml_check(dict_ezfio_cfg): +def create_ocaml_input(dict_ezfio_cfg): + + l_provider = [k for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] + l_type = [v["type"] for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] + l_doc = [v["doc"] for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] # ~#~#~#~#~#~#~#~# # # C r e a t i o n # @@ -422,8 +426,42 @@ def create_ocaml_check(dict_ezfio_cfg): from ezfio_generate_ocaml import EZFIO_ocaml + template = ['(* =~=~ *)', + '(* Init *)', + '(* =~=~ *)', + ""] + + template += ["open Qptypes;;", + "open Qputils;;", + "open Core.Std;;", + "", + "module Full_ci : sig"] + + template += [EZFIO_ocaml.create_type(l_provider, l_type)] + + template += [" val read : unit -> t option", + " val write : t-> unit", + " val to_string : t -> string", + " val to_rst : t -> Rst_string.t", + " val of_rst : Rst_string.t -> t option", + "end = struct"] + + template += [EZFIO_ocaml.create_type(l_provider, l_type)] + + template += ['', + ' let get_default = Qpackage.get_ezfio_default "full_ci";;', + ''] + + template += ['(* =~=~=~=~=~=~==~=~=~=~=~=~ *)', + '(* Generate Special Function *)', + '(* =~=~=~==~=~~=~=~=~=~=~=~=~ *)', + ""] + for provider_name, d_val in sorted(dict_ezfio_cfg.iteritems()): + if 'default' not in d_val: + continue + ezfio_dir = d_val["ezfio_dir"] ezfio_name = d_val["ezfio_name"] @@ -433,10 +471,48 @@ def create_ocaml_check(dict_ezfio_cfg): e = EZFIO_ocaml(**d) - template = e.create_read() + template += [e.create_read(), + e.create_write(), + ""] - print template + template += ['(* =~=~=~=~=~=~=~=~=~=~=~=~ *)', + '(* Generate Global Function *)', + '(* =~=~=~=~=~=~=~=~=~=~=~=~ *)', + ""] + template += [EZFIO_ocaml.create_read_global(l_provider), + EZFIO_ocaml.create_write_global(l_provider), + EZFIO_ocaml.create_to_string(l_provider, l_type), + EZFIO_ocaml.create_to_rst(l_provider, l_type, l_doc)] + + template += [" include Generic_input_of_rst;;", + " let of_rst = of_rst t_of_sexp;;", + "", + "end"] + + return "\n".join(template) + + +def save_ocaml_input(module_lower, str_ocaml_input): + """ + Write the str_ocaml_input in + $QPACKAGE_ROOT/ocaml/Input_{0}.ml".format(module_lower) + """ + + path = "{0}/ocaml/Input_{1}.ml".format(os.environ['QPACKAGE_ROOT'], + module_lower) + + try: + f = open(path, "r") + except IOError: + old_output = "" + else: + old_output = f.read() + f.close() + + if str_ocaml_input != old_output: + with open(path, "w") as f: + f.write(str_ocaml_input) def main(): """ @@ -480,7 +556,8 @@ def main(): # O c a m l # # ~#~#~#~#~#~# - _ = create_ocaml_check(dict_ezfio_cfg) + str_ocaml_input = create_ocaml_input(dict_ezfio_cfg) + save_ocaml_input(module_lower, str_ocaml_input) # ~#~#~#~#~#~#~#~# # I R P . f 9 0 # diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index bbed9685..fc71ddbe 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -17,13 +17,17 @@ class EZFIO_ocaml(object): def Ocaml_type(self): return self.type.ocaml.capitalize() + @property + def ocaml_type(self): + return self.type.ocaml + @property def fancy_type(self): return self.type.fancy def create_read(self): ''' - Take an imput a list of keyword argument + You need to instantiate the EZFIO_ocaml with this keyword argument ezfio_dir = str ezfio_name = str type = Named_tuple(fancy_type, ocaml_type, fortrant_type) @@ -42,19 +46,20 @@ class EZFIO_ocaml(object): # C r e a t e _ t e m pl a t e # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - l_template = ['(* Read snippet for {self.ezfio_name} *)', - 'let read_{self.ezfio_name} () =', - ' if not (Ezfio.has_{self.ezfio_dir}_{self.ezfio_name} ()) then', - ' get_default "{self.ezfio_name}"', - ' |> {self.Ocaml_type}.of_string', - ' |> Ezfio.set_{self.ezfio_dir}_{self.ezfio_name}', - ' ;', - ' Ezfio.get_{self.ezfio_dir}_{self.ezfio_name} ()'] + l_template = [ + '(* Read snippet for {self.ezfio_name} *)', + 'let read_{self.ezfio_name} () =', + ' if not (Ezfio.has_{self.ezfio_dir}_{self.ezfio_name} ()) then', + ' get_default "{self.ezfio_name}"', + ' |> {self.Ocaml_type}.of_string', + ' |> Ezfio.set_{self.ezfio_dir}_{self.ezfio_name}', + ' ;', + ' Ezfio.get_{self.ezfio_dir}_{self.ezfio_name} ()'] if self.fancy_type: - l_template += [" |> {self.fancy_type}.of_{self.Ocaml_type}"] + l_template += [" |> {self.fancy_type}.of_{self.ocaml_type}"] - l_template += [";;;"] + l_template += [";;"] template = "\n ".join(l_template) @@ -70,4 +75,158 @@ class EZFIO_ocaml(object): return template_rendered def create_write(self): - pass + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + ezfio_dir = str + ezfio_name = str + type = Named_tuple(fancy_type, ocaml_type, fortrant_type) + + Return the read template + ''' + + for i in ["ezfio_dir", "ezfio_name", "type"]: + try: + "exec self.{0}".format(i) + except NameError: + msg = "You need to provide a '{0}' for creating read function" + raise KeyError(msg.format(i)) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = ['(* Write snippet for {self.ezfio_name} *)'] + + if self.fancy_type: + l_template += ['let write_{self.ezfio_name} var = ', + ' {self.fancy_type}.to_{self.ocaml_type} var', + ' |> Ezfio.set_{self.ezfio_dir}_{self.ezfio_name}'] + else: + l_template += ['let write_{self.ezfio_name} =', + ' Ezfio.set_{self.ezfio_dir}_{self.ezfio_name}'] + + l_template += [';;'] + + template = "\n ".join(l_template) + + # ~#~#~#~#~#~ # + # R e n d e r # + # ~#~#~#~#~#~ # + + template_rendered = template.format(**locals()) + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return template_rendered + + @staticmethod + def create_type(l_provider, l_type): + + l_template = ["(* Generate type *)", + "type t = ", + " {"] + + for p, t in zip(l_provider, l_type): + + if t.fancy: + l_template += [" {0:<30} : {1}.t;".format(p, t.fancy)] + else: + l_template += [" {0:<30} : {1};".format(p, t.ocaml)] + l_template += [" } with sexp", + ";;"] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return "\n ".join(l_template) + + @staticmethod + def create_read_global(l_provider): + + l_template = ["(* Read all *)", + "let read() = ", + " Some", + " {"] + l_template += [" {0:<30} = read_{0} ();".format(p) for p in l_provider] + + l_template += [" }", + ";;"] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return "\n ".join(l_template) + + @staticmethod + def create_write_global(l_provider): + + l_template = ["(* Write all *)", + "let write{ "] + l_template += [" {0};".format(p) for p in l_provider] + l_template += [" } ="] + l_template += [" write_{0:<30} {0};".format(p) for p in l_provider] + l_template += [";;"] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return "\n ".join(l_template) + + @staticmethod + def create_to_string(l_provider, l_type): + + l_template = ['(* to_string*)', + 'let to_string b =', + ' Printf.sprintf "'] + + l_template += ["{0} = %s".format(p) for p in l_provider] + l_template += ['"'] + + for p, t in zip(l_provider, l_type): + + if t.fancy: + str_ = t.fancy + else: + str_ = t.ocaml.capitalize() + + l_template += [" ({0}.to_string b.{1})".format(str_, p)] + + l_template += [";;"] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return "\n ".join(l_template) + + @staticmethod + def create_to_rst(l_provider, l_type, l_doc): + + l_template = ['(* to_rst*)', + 'let to_rst b =', + ' Printf.sprintf "'] + + for p, d in zip(l_provider, l_doc): + + l_template += ["{0} ::".format(d), + "", + " {0} = %s".format(p), + ""] + l_template += ['"'] + + for p, t in zip(l_provider, l_type): + + if t.fancy: + str_ = t.fancy + else: + str_ = t.ocaml.capitalize() + + l_template += [" ({0}.to_string b.{1})".format(str_, p)] + + l_template += ["|> Rst_string.of_string", + ";;"] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + return "\n ".join(l_template) diff --git a/src/Full_CI/EZFIO.cfg b/src/Full_CI/EZFIO.cfg index 8146ff81..1f701ad8 100644 --- a/src/Full_CI/EZFIO.cfg +++ b/src/Full_CI/EZFIO.cfg @@ -18,8 +18,8 @@ default: true [PT2_max] type: PT2_energy -doc: The selection process stops when the largest PT2 (for all the state is lower - than pt2_max in absolute value) +doc: The selection process stops when the largest PT2 (for all the state) is lower + than pt2_max in absolute value interface: output default: 0.0001 From 5f84af566c4962eec07318a20d5d2f9a8b7ffe2d Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 16:16:28 +0100 Subject: [PATCH 24/60] Fix veryclean in QPROOT --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a59dac50..bced5d0f 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,6 @@ ocaml/Qptypes.ml: QPACKAGE_ROOT=$$PWD ./scripts/install_ocaml.sh | tee install_ocaml.log veryclean: - rm -f EZFIO + rm -rf EZFIO $(MAKE) EZFIO $(MAKE) -C src veryclean From b281ab1248753fb1bcb0aec7b667c921e6c2fbec Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 16:56:35 +0100 Subject: [PATCH 25/60] Input need a default, not output ! --- scripts/ezfio_interface/ei_handler.py | 21 ++++++++++++------- .../ezfio_interface/ezfio_generate_ocaml.py | 9 ++++---- src/Full_CI/EZFIO.cfg | 14 ++++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 3396e6db..72ee2b93 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -16,7 +16,7 @@ Format specification : - ezfio_name : Will be the name of the file for the ezfio (optional by default is the name of the provider) - interface : The provider is a imput or a output - - default : The default value if interface == output: + - default : The default value if interface == input: - size : Is the string read in ezfio.cgf who containt the size information (like 1 or =sum(ao_num) or (ao_num,3) ) @@ -26,7 +26,7 @@ Example EZFIO.cfg: doc: Threshold on the convergence of the Hartree Fock energy type: Threshold default: 1.e-10 -interface: output +interface: input default: 10000 size : ao_num, 3 @@ -34,7 +34,7 @@ size : ao_num, 3 type: logical doc: If true, compute the PT2 at the end of the selection default: true -interface: input +interface: output size : 1 ``` @@ -237,7 +237,7 @@ def get_dict_config_file(config_file_path, module_lower): d[pvd][option] = d_default[option] # If interface is output we need a default value information - if d[pvd]["interface"] == "output": + if d[pvd]["interface"] == "input": try: default_raw = config_file.get(section, "default") except ConfigParser.NoOptionError: @@ -416,9 +416,15 @@ def save_ezfio_config(module_lower, str_ezfio_config): def create_ocaml_input(dict_ezfio_cfg): - l_provider = [k for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] - l_type = [v["type"] for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] - l_doc = [v["doc"] for k, v in dict_ezfio_cfg.iteritems() if 'default' in v] + l_provider = [] + l_type = [] + l_doc = [] + + for k, v in dict_ezfio_cfg.iteritems(): + if v['interface'] == "output": + l_provider.append(k) + l_type.append(v["type"]) + l_doc.append(v["doc"]) # ~#~#~#~#~#~#~#~# # # C r e a t i o n # @@ -514,6 +520,7 @@ def save_ocaml_input(module_lower, str_ocaml_input): with open(path, "w") as f: f.write(str_ocaml_input) + def main(): """ Two condition: diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index fc71ddbe..f3eb3d27 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -148,7 +148,8 @@ class EZFIO_ocaml(object): "let read() = ", " Some", " {"] - l_template += [" {0:<30} = read_{0} ();".format(p) for p in l_provider] + l_template += [" {0:<30} = read_{0} ();".format(p) + for p in l_provider] l_template += [" }", ";;"] @@ -161,8 +162,8 @@ class EZFIO_ocaml(object): @staticmethod def create_write_global(l_provider): - l_template = ["(* Write all *)", - "let write{ "] + l_template = ["(* Write all *)", + "let write{ "] l_template += [" {0};".format(p) for p in l_provider] l_template += [" } ="] l_template += [" write_{0:<30} {0};".format(p) for p in l_provider] @@ -180,7 +181,7 @@ class EZFIO_ocaml(object): 'let to_string b =', ' Printf.sprintf "'] - l_template += ["{0} = %s".format(p) for p in l_provider] + l_template += ["{0} = %s".format(p) for p in l_provider] l_template += ['"'] for p, t in zip(l_provider, l_type): diff --git a/src/Full_CI/EZFIO.cfg b/src/Full_CI/EZFIO.cfg index 1f701ad8..30528fd8 100644 --- a/src/Full_CI/EZFIO.cfg +++ b/src/Full_CI/EZFIO.cfg @@ -1,42 +1,42 @@ [N_det_max_fci] type: Det_number_max doc: Max number of determinants in the wave function -interface: output +interface: input default: 10000 [N_det_max_fci_property] type: Det_number_max doc: Max number of determinants in the wave function when you select for a given property -interface: output +interface: input default: 10000 [do_pt2_end] type: logical doc: If true, compute the PT2 at the end of the selection -interface: output +interface: input default: true [PT2_max] type: PT2_energy doc: The selection process stops when the largest PT2 (for all the state) is lower than pt2_max in absolute value -interface: output +interface: input default: 0.0001 [var_pt2_ratio] type: Normalized_float doc: The selection process stops when the energy ratio variational/(variational+PT2) is equal to var_pt2_ratio -interface: output +interface: input default: 0.75 [energy] type: double precision doc: "Calculated Full CI energy" -interface: input +interface: output [energy_pt2] type: double precision doc: "Calculated Full CI energy" -interface: input +interface: output From ba190353e839a7f296b819dacfd4e384abc4a339 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 17:25:57 +0100 Subject: [PATCH 26/60] ei_handler now handle ezfio_default --- data/ezfio_defaults/full_ci.ezfio_default | 6 --- scripts/ezfio_interface/ei_handler.py | 63 ++++++++++++++++++++--- 2 files changed, 56 insertions(+), 13 deletions(-) delete mode 100644 data/ezfio_defaults/full_ci.ezfio_default diff --git a/data/ezfio_defaults/full_ci.ezfio_default b/data/ezfio_defaults/full_ci.ezfio_default deleted file mode 100644 index 359cc4d2..00000000 --- a/data/ezfio_defaults/full_ci.ezfio_default +++ /dev/null @@ -1,6 +0,0 @@ -full_ci - n_det_max_fci 10000 - n_det_max_fci_property 50000 - pt2_max 1.e-4 - do_pt2_end True - var_pt2_ratio 0.75 diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 72ee2b93..02d6d667 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -58,9 +58,9 @@ def is_bool(str_): fortran and ocaml one. """ if str_.lower() in ['true', '.true.']: - return Type(None, "true", ".True.") + return Type(None, "True", ".True.") elif str_.lower() in ['false', '.False.']: - return Type(None, "false", ".False") + return Type(None, "False", ".False") else: raise TypeError @@ -236,7 +236,7 @@ def get_dict_config_file(config_file_path, module_lower): if option in d_default: d[pvd][option] = d_default[option] - # If interface is output we need a default value information + # If interface is input we need a default value information if d[pvd]["interface"] == "input": try: default_raw = config_file.get(section, "default") @@ -312,7 +312,7 @@ def save_ezfio_provider(path_head, dict_code_provider): f.write(output) -def create_ezfio_config(dict_ezfio_cfg): +def create_ezfio_stuff(dict_ezfio_cfg, config_or_default="config"): """ From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config @@ -383,18 +383,32 @@ def create_ezfio_config(dict_ezfio_cfg): str_fortran_type = str_type_format(fortran_type_raw) # Return the string - s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size) - + if config_or_default == "config": + s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size) + elif config_or_default == "default": + try: + str_value = provider_info["default"].ocaml + except KeyError: + continue + else: + s = " {0} {1}".format(str_name, str_value) + else: + raise KeyError # Append result.append(s) return "\n".join(result) +def create_ezfio_config(dict_ezfio_cfg): + return create_ezfio_stuff(dict_ezfio_cfg, + config_or_default="config") + + def save_ezfio_config(module_lower, str_ezfio_config): """ Write the str_ezfio_config in - $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) + "$QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) """ root_ezfio = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) @@ -414,6 +428,34 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.write(str_ezfio_config) +def create_ezfio_default(dict_ezfio_cfg): + return create_ezfio_stuff(dict_ezfio_cfg, + config_or_default="default") + + +def save_ezfio_default(module_lower, str_ezfio_default): + """ + Write the str_ezfio_config in + "$QPACKAGE_ROOT/data/ezfio_defaults/{0}.ezfio_interface_default".format(module_lower) + """ + + root_ezfio_default = "{0}/data/ezfio_defaults/".format(os.environ['QPACKAGE_ROOT']) + path = "{0}/{1}.ezfio_interface_default".format(root_ezfio_default, + module_lower) + + try: + f = open(path, "r") + except IOError: + old_output = "" + else: + old_output = f.read() + f.close() + + if str_ezfio_default != old_output: + with open(path, "w") as f: + f.write(str_ezfio_default) + + def create_ocaml_input(dict_ezfio_cfg): l_provider = [] @@ -580,6 +622,13 @@ def main(): str_ezfio_config = create_ezfio_config(dict_ezfio_cfg) save_ezfio_config(module_lower, str_ezfio_config) + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + # e z f i o _ d e f a u l t # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + + str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) + save_ezfio_default(module_lower, str_ezfio_default) + if __name__ == "__main__": main() From d76f3683e1095da06f71d1196fe6e88e5237166b Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 18:15:23 +0100 Subject: [PATCH 27/60] Fixed ocaml generator --- scripts/ezfio_interface/ei_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 02d6d667..0b8cca3f 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -463,7 +463,7 @@ def create_ocaml_input(dict_ezfio_cfg): l_doc = [] for k, v in dict_ezfio_cfg.iteritems(): - if v['interface'] == "output": + if v['interface'] == "input": l_provider.append(k) l_type.append(v["type"]) l_doc.append(v["doc"]) From d9e6c9f708dc626e14e6775aca5b090a8084c304 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 27 Mar 2015 19:03:15 +0100 Subject: [PATCH 28/60] First try of unit test --- .travis.yml | 2 +- tests/unit_test/unit_test.py | 86 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100755 tests/unit_test/unit_test.py diff --git a/.travis.yml b/.travis.yml index 1a1b3701..0ca4d142 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ script: - source ./quantum_package.rc - cp ./src/Makefile.config.gfortran ./src/Makefile.config - make build - + - ./tests/unit_test/unit_test.py diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py new file mode 100755 index 00000000..f13abba6 --- /dev/null +++ b/tests/unit_test/unit_test.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import unittest +import subprocess +import os + +qpackage_root = os.environ['QPACKAGE_ROOT'] + +import sys +EZFIO = "{0}/EZFIO".format(qpackage_root) + +sys.path = [EZFIO + "/Python"] + sys.path + +from ezfio import ezfio + +precision = 1.e-8 + +from collections import defaultdict + + +def init_folder(name, basis): + + cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, name) + subprocess.check_call([cmd], shell=True) + + cmd = "qp_create_ezfio_from_xyz -b {0} {1}.xyz".format(basis, name) + subprocess.check_call([cmd], shell=True) + + +def run_hf(name, basis): + + ref_energy = defaultdict(dict) + + ref_energy["sto-3g"]["methane"] = -39.7267433402 + + init_folder(name, basis) + + cmd = "qp_run SCF {0}.ezfio/".format(name) + subprocess.check_call([cmd], shell=True) + + ezfio.set_file("{0}.ezfio".format(name)) + cur_e = ezfio.get_hartree_fock_energy() + + return abs(cur_e - ref_energy[basis][name]) <= precision + + +def run_full_ci_10k_pt2_end(name, basis): + + ref_energy_var = defaultdict(dict) + ref_energy_pt2 = defaultdict(dict) + + ref_energy_var["sto-3g"]["methane"] = -0.398058753535695E+02 + ref_energy_pt2["sto-3g"]["methane"] = -0.398059182483741E+02 + + ezfio.set_file("{0}.ezfio".format(name)) + + ezfio.full_ci_do_pt2_end = True + ezfio.full_ci_n_det_max_fci = 10000 + ezfio.full_ci_pt2_max = 1.e-8 + + cmd = "qp_run full_ci {0}.ezfio/".format(name) + subprocess.check_call([cmd], shell=True) + + cur_var = ezfio.get_full_ci_energy() + cur_pt2 = ezfio.get_full_ci_energy_pt2() + + t = [abs(cur_var - ref_energy_var[basis][name]) <= precision, + abs(cur_pt2 - ref_energy_pt2[basis][name]) <= precision] + + return all(t) + + +def run_big_test(name, basis): + if run_hf(name, basis): + return run_full_ci_10k_pt2_end(name, basis) + else: + raise ValueError("Fail un run_hf") + + +class SimplisticTest(unittest.TestCase): + + def test_full_ci_10k_pt2_end(self): + self.assertTrue(run_big_test("methane", "sto-3g")) + +if __name__ == '__main__': + unittest.main() From be8818538a305cb2d2502b1bdb12dab8a30cecef Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 28 Mar 2015 00:15:09 +0100 Subject: [PATCH 29/60] Completed SVD ezfio for QMC=Chem --- src/Dets/save_for_qmcchem.irp.f | 2 + src/Dets/spindeterminants.ezfio_config | 4 ++ src/Dets/spindeterminants.irp.f | 51 +++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/Dets/save_for_qmcchem.irp.f b/src/Dets/save_for_qmcchem.irp.f index 363e0ba2..7dea70c6 100644 --- a/src/Dets/save_for_qmcchem.irp.f +++ b/src/Dets/save_for_qmcchem.irp.f @@ -42,8 +42,10 @@ subroutine save_dets_qmcchem enddo close(31) call system('gzip -f '//trim(ezfio_filename)//'/mo_basis/mo_classif') + end program save_for_qmc call save_dets_qmcchem + call write_spindeterminants end diff --git a/src/Dets/spindeterminants.ezfio_config b/src/Dets/spindeterminants.ezfio_config index e6a0ed9a..1c7d81e3 100644 --- a/src/Dets/spindeterminants.ezfio_config +++ b/src/Dets/spindeterminants.ezfio_config @@ -7,4 +7,8 @@ spindeterminants psi_det_alpha integer*8 (spindeterminants_n_int*spindeterminants_bit_kind/8,spindeterminants_n_det_alpha) psi_det_beta integer*8 (spindeterminants_n_int*spindeterminants_bit_kind/8,spindeterminants_n_det_beta) psi_coef_matrix double precision (spindeterminants_n_det_alpha,spindeterminants_n_det_beta,spindeterminants_n_states) + n_svd_coefs integer + psi_svd_alpha double precision (spindeterminants_n_det_alpha,spindeterminants_n_svd_coefs,spindeterminants_n_states) + psi_svd_beta double precision (spindeterminants_n_det_beta,spindeterminants_n_svd_coefs,spindeterminants_n_states) + psi_svd_coefs double precision (spindeterminants_n_svd_coefs,spindeterminants_n_states) diff --git a/src/Dets/spindeterminants.irp.f b/src/Dets/spindeterminants.irp.f index 236dc1fc..4b426faa 100644 --- a/src/Dets/spindeterminants.irp.f +++ b/src/Dets/spindeterminants.irp.f @@ -26,7 +26,7 @@ subroutine write_spindeterminants enddo call ezfio_set_spindeterminants_psi_det_alpha(psi_det_alpha_unique) deallocate(tmpdet) - + allocate(tmpdet(N_int2,N_det_beta_unique)) do i=1,N_det_beta_unique do k=1,N_int @@ -38,7 +38,54 @@ subroutine write_spindeterminants enddo call ezfio_set_spindeterminants_psi_det_beta(psi_det_beta_unique) deallocate(tmpdet) - + call ezfio_set_spindeterminants_psi_coef_matrix(psi_svd_matrix) + + integer :: n_svd_coefs + double precision :: norm, f + f = 1.d0/dble(N_states) + norm = 1.d0 + do n_svd_coefs=1,N_det_alpha_unique + do k=1,N_states + norm -= psi_svd_coefs(n_svd_coefs,k)*psi_svd_coefs(n_svd_coefs,k) + enddo + if (norm < 1.d-6) then + exit + endif + enddo + n_svd_coefs -= 1 + call ezfio_set_spindeterminants_n_svd_coefs(n_svd_coefs) + + double precision, allocatable :: dtmp(:,:,:) + allocate(dtmp(N_det_alpha_unique,n_svd_coefs,N_states)) + do k=1,N_states + do j=1,n_svd_coefs + do i=1,N_det_alpha_unique + dtmp(i,j,k) = psi_svd_alpha(i,j,k) + enddo + enddo + enddo + call ezfio_set_spindeterminants_psi_svd_alpha(dtmp) + deallocate(dtmp) + + allocate(dtmp(N_det_beta_unique,n_svd_coefs,N_states)) + do k=1,N_states + do j=1,n_svd_coefs + do i=1,N_det_beta_unique + dtmp(i,j,k) = psi_svd_beta(i,j,k) + enddo + enddo + enddo + call ezfio_set_spindeterminants_psi_svd_beta(dtmp) + deallocate(dtmp) + + allocate(dtmp(n_svd_coefs,N_states,1)) + do k=1,N_states + do j=1,n_svd_coefs + dtmp(j,k,1) = psi_svd_coefs(j,k) + enddo + enddo + call ezfio_set_spindeterminants_psi_svd_coefs(dtmp) + deallocate(dtmp) end From 6bdbe6a78c5c9ab00e4793e95698e46c2dc0355d Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 09:42:12 +0200 Subject: [PATCH 30/60] Cleaning ei_handler.py --- scripts/ezfio_interface/ei_handler.py | 35 ++-- .../ezfio_interface/ezfio_generate_ocaml.py | 158 ++++++++++++++---- 2 files changed, 146 insertions(+), 47 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 0b8cca3f..7ad415b2 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -439,7 +439,8 @@ def save_ezfio_default(module_lower, str_ezfio_default): "$QPACKAGE_ROOT/data/ezfio_defaults/{0}.ezfio_interface_default".format(module_lower) """ - root_ezfio_default = "{0}/data/ezfio_defaults/".format(os.environ['QPACKAGE_ROOT']) + root_ezfio_default = "{0}/data/ezfio_defaults/".format( + os.environ['QPACKAGE_ROOT']) path = "{0}/{1}.ezfio_interface_default".format(root_ezfio_default, module_lower) @@ -458,6 +459,12 @@ def save_ezfio_default(module_lower, str_ezfio_default): def create_ocaml_input(dict_ezfio_cfg): + # ~#~#~#~# # + # I n i t # + # ~#~#~#~# # + + from ezfio_generate_ocaml import EZFIO_ocaml + l_provider = [] l_type = [] l_doc = [] @@ -468,12 +475,14 @@ def create_ocaml_input(dict_ezfio_cfg): l_type.append(v["type"]) l_doc.append(v["doc"]) + e_glob = EZFIO_ocaml(l_provider=l_provider, + l_type=l_type, + l_doc=l_doc) + # ~#~#~#~#~#~#~#~# # # C r e a t i o n # # ~#~#~#~#~#~#~#~# # - from ezfio_generate_ocaml import EZFIO_ocaml - template = ['(* =~=~ *)', '(* Init *)', '(* =~=~ *)', @@ -485,7 +494,7 @@ def create_ocaml_input(dict_ezfio_cfg): "", "module Full_ci : sig"] - template += [EZFIO_ocaml.create_type(l_provider, l_type)] + template += [e_glob.create_type()] template += [" val read : unit -> t option", " val write : t-> unit", @@ -494,7 +503,7 @@ def create_ocaml_input(dict_ezfio_cfg): " val of_rst : Rst_string.t -> t option", "end = struct"] - template += [EZFIO_ocaml.create_type(l_provider, l_type)] + template += [e_glob.create_type()] template += ['', ' let get_default = Qpackage.get_ezfio_default "full_ci";;', @@ -513,11 +522,9 @@ def create_ocaml_input(dict_ezfio_cfg): ezfio_dir = d_val["ezfio_dir"] ezfio_name = d_val["ezfio_name"] - d = {"ezfio_dir": ezfio_dir, - "ezfio_name": ezfio_name, - "type": d_val["type"]} - - e = EZFIO_ocaml(**d) + e = EZFIO_ocaml(ezfio_dir=ezfio_dir, + ezfio_name=ezfio_name, + type=d_val["type"]) template += [e.create_read(), e.create_write(), @@ -528,10 +535,10 @@ def create_ocaml_input(dict_ezfio_cfg): '(* =~=~=~=~=~=~=~=~=~=~=~=~ *)', ""] - template += [EZFIO_ocaml.create_read_global(l_provider), - EZFIO_ocaml.create_write_global(l_provider), - EZFIO_ocaml.create_to_string(l_provider, l_type), - EZFIO_ocaml.create_to_rst(l_provider, l_type, l_doc)] + template += [e_glob.create_read_global(), + e_glob.create_write_global(), + e_glob.create_to_string(), + e_glob.create_to_rst()] template += [" include Generic_input_of_rst;;", " let of_rst = of_rst t_of_sexp;;", diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index f3eb3d27..9dd4c640 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -2,15 +2,19 @@ import sys +# If type in **kwargs +from ei_handler import Type + class EZFIO_ocaml(object): def __init__(self, **kwargs): for k, v in kwargs.iteritems(): - if k == "type": - self.type = kwargs["type"] - else: + + try: + exec "self.{0} = {1}".format(k, v) + except NameError: exec "self.{0} = '{1}'".format(k, v) @property @@ -25,6 +29,14 @@ class EZFIO_ocaml(object): def fancy_type(self): return self.type.fancy + def check_if_init(self, l_arg, name): + for i in l_arg: + try: + exec "self.{0}".format(i) + except AttributeError: + msg = "You need to provide a '{0}' for creating {1}" + raise KeyError(msg.format(i, name)) + def create_read(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument @@ -35,12 +47,12 @@ class EZFIO_ocaml(object): Return the read template ''' - for i in ["ezfio_dir", "ezfio_name", "type"]: - try: - "exec self.{0}".format(i) - except NameError: - msg = "You need to provide a '{0}' for creating read function" - raise KeyError(msg.format(i)) + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["ezfio_dir", "ezfio_name", "type"], + sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # # C r e a t e _ t e m pl a t e # @@ -84,12 +96,12 @@ class EZFIO_ocaml(object): Return the read template ''' - for i in ["ezfio_dir", "ezfio_name", "type"]: - try: - "exec self.{0}".format(i) - except NameError: - msg = "You need to provide a '{0}' for creating read function" - raise KeyError(msg.format(i)) + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["ezfio_dir", "ezfio_name", "type"], + sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # # C r e a t e _ t e m pl a t e # @@ -120,14 +132,31 @@ class EZFIO_ocaml(object): # ~#~#~#~#~#~ # return template_rendered - @staticmethod - def create_type(l_provider, l_type): + def create_type(self): + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + l_provider = [provider_name, ...] + l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] + + Return the type template + ''' + + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_provider", "l_type"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # l_template = ["(* Generate type *)", "type t = ", " {"] - for p, t in zip(l_provider, l_type): + for p, t in zip(self.l_provider, self.l_type): if t.fancy: l_template += [" {0:<30} : {1}.t;".format(p, t.fancy)] @@ -141,15 +170,31 @@ class EZFIO_ocaml(object): # ~#~#~#~#~#~ # return "\n ".join(l_template) - @staticmethod - def create_read_global(l_provider): + def create_read_global(self): + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + l_provider = [provider_name, ...] + + Return the read_global template + ''' + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_provider"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # l_template = ["(* Read all *)", "let read() = ", " Some", " {"] + l_template += [" {0:<30} = read_{0} ();".format(p) - for p in l_provider] + for p in self.l_provider] l_template += [" }", ";;"] @@ -159,14 +204,29 @@ class EZFIO_ocaml(object): # ~#~#~#~#~#~ # return "\n ".join(l_template) - @staticmethod - def create_write_global(l_provider): + def create_write_global(self): + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + l_provider = [provider_name, ...] + + Return the type template + ''' + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_provider"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # l_template = ["(* Write all *)", "let write{ "] - l_template += [" {0};".format(p) for p in l_provider] + l_template += [" {0};".format(p) for p in self.l_provider] l_template += [" } ="] - l_template += [" write_{0:<30} {0};".format(p) for p in l_provider] + l_template += [" write_{0:<30} {0};".format(p) for p in self.l_provider] l_template += [";;"] # ~#~#~#~#~#~ # @@ -174,17 +234,33 @@ class EZFIO_ocaml(object): # ~#~#~#~#~#~ # return "\n ".join(l_template) - @staticmethod - def create_to_string(l_provider, l_type): + def create_to_string(self): + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + l_provider = [provider_name, ...] + l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] + + Return the type template + ''' + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_provider", "l_type"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # l_template = ['(* to_string*)', 'let to_string b =', ' Printf.sprintf "'] - l_template += ["{0} = %s".format(p) for p in l_provider] + l_template += ["{0} = %s".format(p) for p in self.l_provider] l_template += ['"'] - for p, t in zip(l_provider, l_type): + for p, t in zip(self.l_provider, self.l_type): if t.fancy: str_ = t.fancy @@ -200,14 +276,30 @@ class EZFIO_ocaml(object): # ~#~#~#~#~#~ # return "\n ".join(l_template) - @staticmethod - def create_to_rst(l_provider, l_type, l_doc): + def create_to_rst(self): + ''' + You need to instantiate the EZFIO_ocaml with this keyword argument + l_provider = [provider_name, ...] + l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] + + Return the type template + ''' + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_provider", "l_type", "l_doc"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # l_template = ['(* to_rst*)', 'let to_rst b =', ' Printf.sprintf "'] - for p, d in zip(l_provider, l_doc): + for p, d in zip(self.l_provider, self.l_doc): l_template += ["{0} ::".format(d), "", @@ -215,7 +307,7 @@ class EZFIO_ocaml(object): ""] l_template += ['"'] - for p, t in zip(l_provider, l_type): + for p, t in zip(self.l_provider, self.l_type): if t.fancy: str_ = t.fancy From aa7bfdc46d55260e499379288ea25725654a58fc Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 10:15:35 +0200 Subject: [PATCH 31/60] Beter unit test --- tests/unit_test/unit_test.py | 84 ++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index f13abba6..d08a8baa 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -3,48 +3,81 @@ import unittest import subprocess import os +import sys qpackage_root = os.environ['QPACKAGE_ROOT'] -import sys EZFIO = "{0}/EZFIO".format(qpackage_root) - sys.path = [EZFIO + "/Python"] + sys.path from ezfio import ezfio +from collections import defaultdict + +# ~#~#~ # +# O p t # +# ~#~#~ # precision = 1.e-8 -from collections import defaultdict +# A test get a geo file and a basis file. +# A global dict containt the result for this test +# A test return True or Raise a error ! +# More ezfio condition you set, beter it is -def init_folder(name, basis): +def init_folder(geo, basis, mult=1): + ''' + Take a geo in arg (aka a existing geo.xyz in test/) + And create the geo.ezfio with the adeguate basis and multipliciti + DO NOT CHECK IS THE EZFIO FOLDER ALREADY EXIST + ''' - cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, name) + cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, geo) subprocess.check_call([cmd], shell=True) - cmd = "qp_create_ezfio_from_xyz -b {0} {1}.xyz".format(basis, name) + cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz".format(basis, + mult, + geo) subprocess.check_call([cmd], shell=True) -def run_hf(name, basis): +def get_error_message(l_exepected, l_cur): + l_msg = ["Need {0} get {1}".format(i,j) for i,j in zip(l_exepected,l_cur)] + return "\n".join(l_msg) + + +def run_hf(geo, basis): + """ + Run a simle by default hf + EZFIO path = geo.ezfio + + """ ref_energy = defaultdict(dict) ref_energy["sto-3g"]["methane"] = -39.7267433402 - init_folder(name, basis) + init_folder(geo, basis) - cmd = "qp_run SCF {0}.ezfio/".format(name) + cmd = "qp_run SCF {0}.ezfio/".format(geo) subprocess.check_call([cmd], shell=True) - ezfio.set_file("{0}.ezfio".format(name)) + ezfio.set_file("{0}.ezfio".format(geo)) + cur_e = ezfio.get_hartree_fock_energy() + ref_e = ref_energy[basis][geo] - return abs(cur_e - ref_energy[basis][name]) <= precision + if abs(cur_e - ref_e) <= precision: + return True + else: + raise ValueError(get_error_message([ref_e], [cur_e])) -def run_full_ci_10k_pt2_end(name, basis): +def run_full_ci_10k_pt2_end(geo, basis): + """ + Run a Full_ci with 10k with the TruePT2 + EZFIO path = geo.ezfio + """ ref_energy_var = defaultdict(dict) ref_energy_pt2 = defaultdict(dict) @@ -52,29 +85,36 @@ def run_full_ci_10k_pt2_end(name, basis): ref_energy_var["sto-3g"]["methane"] = -0.398058753535695E+02 ref_energy_pt2["sto-3g"]["methane"] = -0.398059182483741E+02 - ezfio.set_file("{0}.ezfio".format(name)) + ezfio.set_file("{0}.ezfio".format(geo)) ezfio.full_ci_do_pt2_end = True ezfio.full_ci_n_det_max_fci = 10000 ezfio.full_ci_pt2_max = 1.e-8 - cmd = "qp_run full_ci {0}.ezfio/".format(name) + cmd = "qp_run full_ci {0}.ezfio/".format(geo) subprocess.check_call([cmd], shell=True) cur_var = ezfio.get_full_ci_energy() cur_pt2 = ezfio.get_full_ci_energy_pt2() - t = [abs(cur_var - ref_energy_var[basis][name]) <= precision, - abs(cur_pt2 - ref_energy_pt2[basis][name]) <= precision] + ref_var = ref_energy_var[basis][geo] + ref_pt2 = ref_energy_pt2[basis][geo] - return all(t) + t = [abs(cur_var - ref_var) <= precision, + abs(cur_pt2 - ref_pt2) <= precision] - -def run_big_test(name, basis): - if run_hf(name, basis): - return run_full_ci_10k_pt2_end(name, basis) + if all(t): + return True else: - raise ValueError("Fail un run_hf") + raise ValueError(get_error_message([ref_var, ref_pt2], + [cur_var, cur_pt2])) + + +def run_big_test(geo, basis): + + run_hf(geo, basis) + run_full_ci_10k_pt2_end(geo, basis) + return True class SimplisticTest(unittest.TestCase): From 125e7d4c8f093ef617ea157552c620d5a66735c9 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 10:37:11 +0200 Subject: [PATCH 32/60] Add doc and global varialbe in unit_test --- tests/unit_test/unit_test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index d08a8baa..f4934c63 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -25,6 +25,12 @@ precision = 1.e-8 # More ezfio condition you set, beter it is +# You cannot order the test flow. +# So if you dont whant to remarque on test (for example the HF), set +# a global variable and check for it +global has_hf_alredy +has_hf_alredy = False + def init_folder(geo, basis, mult=1): ''' Take a geo in arg (aka a existing geo.xyz in test/) @@ -50,8 +56,9 @@ def run_hf(geo, basis): """ Run a simle by default hf EZFIO path = geo.ezfio - """ + global has_hf_alredy + has_hf_alredy = True ref_energy = defaultdict(dict) @@ -111,8 +118,9 @@ def run_full_ci_10k_pt2_end(geo, basis): def run_big_test(geo, basis): + if not has_hf_alredy: + run_hf(geo, basis) - run_hf(geo, basis) run_full_ci_10k_pt2_end(geo, basis) return True From 94b0209b0113ed1881d74a17fd9a1809c28f2437 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 10:38:13 +0200 Subject: [PATCH 33/60] I guess with Input_full_ci is beter... --- ocaml/Input_full_ci.ml | 201 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 ocaml/Input_full_ci.ml diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml new file mode 100644 index 00000000..0b9dbda0 --- /dev/null +++ b/ocaml/Input_full_ci.ml @@ -0,0 +1,201 @@ +(* =~=~ *) +(* Init *) +(* =~=~ *) + +open Qptypes;; +open Qputils;; +open Core.Std;; + +module Full_ci : sig +(* Generate type *) + type t = + { + do_pt2_end : bool; + var_pt2_ratio : Normalized_float.t; + n_det_max_fci_property : Det_number_max.t; + n_det_max_fci : Det_number_max.t; + pt2_max : PT2_energy.t; + } with sexp + ;; + val read : unit -> t option + val write : t-> unit + val to_string : t -> string + val to_rst : t -> Rst_string.t + val of_rst : Rst_string.t -> t option +end = struct +(* Generate type *) + type t = + { + do_pt2_end : bool; + var_pt2_ratio : Normalized_float.t; + n_det_max_fci_property : Det_number_max.t; + n_det_max_fci : Det_number_max.t; + pt2_max : PT2_energy.t; + } with sexp + ;; + + let get_default = Qpackage.get_ezfio_default "full_ci";; + +(* =~=~=~=~=~=~==~=~=~=~=~=~ *) +(* Generate Special Function *) +(* =~=~=~==~=~~=~=~=~=~=~=~=~ *) + +(* Read snippet for do_pt2_end *) + let read_do_pt2_end () = + if not (Ezfio.has_full_ci_do_pt2_end ()) then + get_default "do_pt2_end" + |> Bool.of_string + |> Ezfio.set_full_ci_do_pt2_end + ; + Ezfio.get_full_ci_do_pt2_end () + ;; +(* Write snippet for do_pt2_end *) + let write_do_pt2_end = + Ezfio.set_full_ci_do_pt2_end + ;; + +(* Read snippet for n_det_max_fci *) + let read_n_det_max_fci () = + if not (Ezfio.has_full_ci_n_det_max_fci ()) then + get_default "n_det_max_fci" + |> Int.of_string + |> Ezfio.set_full_ci_n_det_max_fci + ; + Ezfio.get_full_ci_n_det_max_fci () + |> Det_number_max.of_int + ;; +(* Write snippet for n_det_max_fci *) + let write_n_det_max_fci var = + Det_number_max.to_int var + |> Ezfio.set_full_ci_n_det_max_fci + ;; + +(* Read snippet for n_det_max_fci_property *) + let read_n_det_max_fci_property () = + if not (Ezfio.has_full_ci_n_det_max_fci_property ()) then + get_default "n_det_max_fci_property" + |> Int.of_string + |> Ezfio.set_full_ci_n_det_max_fci_property + ; + Ezfio.get_full_ci_n_det_max_fci_property () + |> Det_number_max.of_int + ;; +(* Write snippet for n_det_max_fci_property *) + let write_n_det_max_fci_property var = + Det_number_max.to_int var + |> Ezfio.set_full_ci_n_det_max_fci_property + ;; + +(* Read snippet for pt2_max *) + let read_pt2_max () = + if not (Ezfio.has_full_ci_pt2_max ()) then + get_default "pt2_max" + |> Float.of_string + |> Ezfio.set_full_ci_pt2_max + ; + Ezfio.get_full_ci_pt2_max () + |> PT2_energy.of_float + ;; +(* Write snippet for pt2_max *) + let write_pt2_max var = + PT2_energy.to_float var + |> Ezfio.set_full_ci_pt2_max + ;; + +(* Read snippet for var_pt2_ratio *) + let read_var_pt2_ratio () = + if not (Ezfio.has_full_ci_var_pt2_ratio ()) then + get_default "var_pt2_ratio" + |> Float.of_string + |> Ezfio.set_full_ci_var_pt2_ratio + ; + Ezfio.get_full_ci_var_pt2_ratio () + |> Normalized_float.of_float + ;; +(* Write snippet for var_pt2_ratio *) + let write_var_pt2_ratio var = + Normalized_float.to_float var + |> Ezfio.set_full_ci_var_pt2_ratio + ;; + +(* =~=~=~=~=~=~=~=~=~=~=~=~ *) +(* Generate Global Function *) +(* =~=~=~=~=~=~=~=~=~=~=~=~ *) + +(* Read all *) + let read() = + Some + { + do_pt2_end = read_do_pt2_end (); + var_pt2_ratio = read_var_pt2_ratio (); + n_det_max_fci_property = read_n_det_max_fci_property (); + n_det_max_fci = read_n_det_max_fci (); + pt2_max = read_pt2_max (); + } + ;; +(* Write all *) + let write{ + do_pt2_end; + var_pt2_ratio; + n_det_max_fci_property; + n_det_max_fci; + pt2_max; + } = + write_do_pt2_end do_pt2_end; + write_var_pt2_ratio var_pt2_ratio; + write_n_det_max_fci_property n_det_max_fci_property; + write_n_det_max_fci n_det_max_fci; + write_pt2_max pt2_max; + ;; +(* to_string*) + let to_string b = + Printf.sprintf " + do_pt2_end = %s + var_pt2_ratio = %s + n_det_max_fci_property = %s + n_det_max_fci = %s + pt2_max = %s + " + (Bool.to_string b.do_pt2_end) + (Normalized_float.to_string b.var_pt2_ratio) + (Det_number_max.to_string b.n_det_max_fci_property) + (Det_number_max.to_string b.n_det_max_fci) + (PT2_energy.to_string b.pt2_max) + ;; +(* to_rst*) + let to_rst b = + Printf.sprintf " + If true, compute the PT2 at the end of the selection :: + + do_pt2_end = %s + + The selection process stops when the energy ratio variational/(variational+PT2) +is equal to var_pt2_ratio :: + + var_pt2_ratio = %s + + Max number of determinants in the wave function when you select for a given property :: + + n_det_max_fci_property = %s + + Max number of determinants in the wave function :: + + n_det_max_fci = %s + + The selection process stops when the largest PT2 (for all the state) is lower +than pt2_max in absolute value :: + + pt2_max = %s + + " + (Bool.to_string b.do_pt2_end) + (Normalized_float.to_string b.var_pt2_ratio) + (Det_number_max.to_string b.n_det_max_fci_property) + (Det_number_max.to_string b.n_det_max_fci) + (PT2_energy.to_string b.pt2_max) + |> Rst_string.of_string + ;; + include Generic_input_of_rst;; + let of_rst = of_rst t_of_sexp;; + +end \ No newline at end of file From 1cb8a7bdd9b2c3a40e6dc70b1675908bd5fefdff Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 10:48:52 +0200 Subject: [PATCH 34/60] Remove --- ocaml/Input_full_ci.ml | 201 ----------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 ocaml/Input_full_ci.ml diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml deleted file mode 100644 index 0b9dbda0..00000000 --- a/ocaml/Input_full_ci.ml +++ /dev/null @@ -1,201 +0,0 @@ -(* =~=~ *) -(* Init *) -(* =~=~ *) - -open Qptypes;; -open Qputils;; -open Core.Std;; - -module Full_ci : sig -(* Generate type *) - type t = - { - do_pt2_end : bool; - var_pt2_ratio : Normalized_float.t; - n_det_max_fci_property : Det_number_max.t; - n_det_max_fci : Det_number_max.t; - pt2_max : PT2_energy.t; - } with sexp - ;; - val read : unit -> t option - val write : t-> unit - val to_string : t -> string - val to_rst : t -> Rst_string.t - val of_rst : Rst_string.t -> t option -end = struct -(* Generate type *) - type t = - { - do_pt2_end : bool; - var_pt2_ratio : Normalized_float.t; - n_det_max_fci_property : Det_number_max.t; - n_det_max_fci : Det_number_max.t; - pt2_max : PT2_energy.t; - } with sexp - ;; - - let get_default = Qpackage.get_ezfio_default "full_ci";; - -(* =~=~=~=~=~=~==~=~=~=~=~=~ *) -(* Generate Special Function *) -(* =~=~=~==~=~~=~=~=~=~=~=~=~ *) - -(* Read snippet for do_pt2_end *) - let read_do_pt2_end () = - if not (Ezfio.has_full_ci_do_pt2_end ()) then - get_default "do_pt2_end" - |> Bool.of_string - |> Ezfio.set_full_ci_do_pt2_end - ; - Ezfio.get_full_ci_do_pt2_end () - ;; -(* Write snippet for do_pt2_end *) - let write_do_pt2_end = - Ezfio.set_full_ci_do_pt2_end - ;; - -(* Read snippet for n_det_max_fci *) - let read_n_det_max_fci () = - if not (Ezfio.has_full_ci_n_det_max_fci ()) then - get_default "n_det_max_fci" - |> Int.of_string - |> Ezfio.set_full_ci_n_det_max_fci - ; - Ezfio.get_full_ci_n_det_max_fci () - |> Det_number_max.of_int - ;; -(* Write snippet for n_det_max_fci *) - let write_n_det_max_fci var = - Det_number_max.to_int var - |> Ezfio.set_full_ci_n_det_max_fci - ;; - -(* Read snippet for n_det_max_fci_property *) - let read_n_det_max_fci_property () = - if not (Ezfio.has_full_ci_n_det_max_fci_property ()) then - get_default "n_det_max_fci_property" - |> Int.of_string - |> Ezfio.set_full_ci_n_det_max_fci_property - ; - Ezfio.get_full_ci_n_det_max_fci_property () - |> Det_number_max.of_int - ;; -(* Write snippet for n_det_max_fci_property *) - let write_n_det_max_fci_property var = - Det_number_max.to_int var - |> Ezfio.set_full_ci_n_det_max_fci_property - ;; - -(* Read snippet for pt2_max *) - let read_pt2_max () = - if not (Ezfio.has_full_ci_pt2_max ()) then - get_default "pt2_max" - |> Float.of_string - |> Ezfio.set_full_ci_pt2_max - ; - Ezfio.get_full_ci_pt2_max () - |> PT2_energy.of_float - ;; -(* Write snippet for pt2_max *) - let write_pt2_max var = - PT2_energy.to_float var - |> Ezfio.set_full_ci_pt2_max - ;; - -(* Read snippet for var_pt2_ratio *) - let read_var_pt2_ratio () = - if not (Ezfio.has_full_ci_var_pt2_ratio ()) then - get_default "var_pt2_ratio" - |> Float.of_string - |> Ezfio.set_full_ci_var_pt2_ratio - ; - Ezfio.get_full_ci_var_pt2_ratio () - |> Normalized_float.of_float - ;; -(* Write snippet for var_pt2_ratio *) - let write_var_pt2_ratio var = - Normalized_float.to_float var - |> Ezfio.set_full_ci_var_pt2_ratio - ;; - -(* =~=~=~=~=~=~=~=~=~=~=~=~ *) -(* Generate Global Function *) -(* =~=~=~=~=~=~=~=~=~=~=~=~ *) - -(* Read all *) - let read() = - Some - { - do_pt2_end = read_do_pt2_end (); - var_pt2_ratio = read_var_pt2_ratio (); - n_det_max_fci_property = read_n_det_max_fci_property (); - n_det_max_fci = read_n_det_max_fci (); - pt2_max = read_pt2_max (); - } - ;; -(* Write all *) - let write{ - do_pt2_end; - var_pt2_ratio; - n_det_max_fci_property; - n_det_max_fci; - pt2_max; - } = - write_do_pt2_end do_pt2_end; - write_var_pt2_ratio var_pt2_ratio; - write_n_det_max_fci_property n_det_max_fci_property; - write_n_det_max_fci n_det_max_fci; - write_pt2_max pt2_max; - ;; -(* to_string*) - let to_string b = - Printf.sprintf " - do_pt2_end = %s - var_pt2_ratio = %s - n_det_max_fci_property = %s - n_det_max_fci = %s - pt2_max = %s - " - (Bool.to_string b.do_pt2_end) - (Normalized_float.to_string b.var_pt2_ratio) - (Det_number_max.to_string b.n_det_max_fci_property) - (Det_number_max.to_string b.n_det_max_fci) - (PT2_energy.to_string b.pt2_max) - ;; -(* to_rst*) - let to_rst b = - Printf.sprintf " - If true, compute the PT2 at the end of the selection :: - - do_pt2_end = %s - - The selection process stops when the energy ratio variational/(variational+PT2) -is equal to var_pt2_ratio :: - - var_pt2_ratio = %s - - Max number of determinants in the wave function when you select for a given property :: - - n_det_max_fci_property = %s - - Max number of determinants in the wave function :: - - n_det_max_fci = %s - - The selection process stops when the largest PT2 (for all the state) is lower -than pt2_max in absolute value :: - - pt2_max = %s - - " - (Bool.to_string b.do_pt2_end) - (Normalized_float.to_string b.var_pt2_ratio) - (Det_number_max.to_string b.n_det_max_fci_property) - (Det_number_max.to_string b.n_det_max_fci) - (PT2_energy.to_string b.pt2_max) - |> Rst_string.of_string - ;; - include Generic_input_of_rst;; - let of_rst = of_rst t_of_sexp;; - -end \ No newline at end of file From 53f473cfae2dcd58778aa244be47618685a05f10 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 11:16:15 +0200 Subject: [PATCH 35/60] Add EZFIO.cfg to Hartree_fock --- .../ezfio_defaults/hartree_fock.ezfio_default | 4 - ocaml/Input_hartree_fock.ml | 128 ------------------ scripts/ezfio_interface/ei_handler.py | 12 +- src/Hartree_Fock/EZFIO.cfg | 22 +++ src/Hartree_Fock/hartree_fock.ezfio_config | 6 - src/Hartree_Fock/options.irp.f | 35 ----- 6 files changed, 28 insertions(+), 179 deletions(-) delete mode 100644 data/ezfio_defaults/hartree_fock.ezfio_default delete mode 100644 ocaml/Input_hartree_fock.ml create mode 100644 src/Hartree_Fock/EZFIO.cfg delete mode 100644 src/Hartree_Fock/hartree_fock.ezfio_config delete mode 100644 src/Hartree_Fock/options.irp.f diff --git a/data/ezfio_defaults/hartree_fock.ezfio_default b/data/ezfio_defaults/hartree_fock.ezfio_default deleted file mode 100644 index 048a3c77..00000000 --- a/data/ezfio_defaults/hartree_fock.ezfio_default +++ /dev/null @@ -1,4 +0,0 @@ -hartree_fock - n_it_scf_max 200 - thresh_scf 1.e-10 - guess "Huckel" diff --git a/ocaml/Input_hartree_fock.ml b/ocaml/Input_hartree_fock.ml deleted file mode 100644 index 82110647..00000000 --- a/ocaml/Input_hartree_fock.ml +++ /dev/null @@ -1,128 +0,0 @@ -open Qptypes;; -open Qputils;; -open Core.Std;; - -module Hartree_fock : sig - type t = - { n_it_scf_max : Strictly_positive_int.t; - thresh_scf : Threshold.t; - guess : MO_guess.t; - } with sexp - ;; - val read : unit -> t option - val write : t -> unit - val to_string : t -> string - val to_rst : t -> Rst_string.t - val of_rst : Rst_string.t -> t option -end = struct - type t = - { n_it_scf_max : Strictly_positive_int.t; - thresh_scf : Threshold.t; - guess : MO_guess.t; - } with sexp - ;; - - let get_default = Qpackage.get_ezfio_default "hartree_fock";; - - let read_n_it_scf_max () = - if not (Ezfio.has_hartree_fock_n_it_scf_max ()) then - get_default "n_it_scf_max" - |> Int.of_string - |> Ezfio.set_hartree_fock_n_it_scf_max - ; - Ezfio.get_hartree_fock_n_it_scf_max () - |> Strictly_positive_int.of_int - ;; - - let write_n_it_scf_max n_it_scf_max = - Strictly_positive_int.to_int n_it_scf_max - |> Ezfio.set_hartree_fock_n_it_scf_max - ;; - - let read_thresh_scf () = - if not (Ezfio.has_hartree_fock_thresh_scf()) then - get_default "thresh_scf" - |> Float.of_string - |> Ezfio.set_hartree_fock_thresh_scf - ; - Ezfio.get_hartree_fock_thresh_scf () - |> Threshold.of_float - ;; - - let write_thresh_scf thresh_scf = - Threshold.to_float thresh_scf - |> Ezfio.set_hartree_fock_thresh_scf - ;; - - let read_guess () = - if not (Ezfio.has_hartree_fock_guess ()) then - get_default "guess" - |> String.strip ~drop:(fun x -> x = '"') - |> Ezfio.set_hartree_fock_guess - ; - Ezfio.get_hartree_fock_guess () - |> MO_guess.of_string - ;; - - let write_guess guess = - MO_guess.to_string guess - |> Ezfio.set_hartree_fock_guess - ;; - - let read () = - Some - { n_it_scf_max = read_n_it_scf_max (); - thresh_scf = read_thresh_scf (); - guess = read_guess (); - } - ;; - - - let write { n_it_scf_max ; - thresh_scf ; - guess ; - } = - write_n_it_scf_max n_it_scf_max; - write_thresh_scf thresh_scf; - write_guess guess - ;; - - - let to_string b = - Printf.sprintf " -n_it_scf_max = %s -thresh_scf = %s -guess = %s -" - (Strictly_positive_int.to_string b.n_it_scf_max) - (Threshold.to_string b.thresh_scf) - (MO_guess.to_string b.guess) - ;; - - let to_rst b = - Printf.sprintf " -Type of MO guess [ Huckel | HCore ] :: - - guess = %s - -Max number of SCF iterations :: - - n_it_scf_max = %s - -SCF convergence criterion (on energy) :: - - thresh_scf = %s - -" - (MO_guess.to_string b.guess) - (Strictly_positive_int.to_string b.n_it_scf_max) - (Threshold.to_string b.thresh_scf) - |> Rst_string.of_string - ;; - - include Generic_input_of_rst;; - let of_rst = of_rst t_of_sexp;; - -end - - diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 7ad415b2..ca7eee70 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -108,9 +108,9 @@ def get_type_dict(): fancy_type['logical'] = Type(None, "bool", "logical") fancy_type['bool'] = Type(None, "bool", "logical") - fancy_type['character*32'] = Type(None, "string", "character*32") - fancy_type['character*60'] = Type(None, "string", "character*60") - fancy_type['character*256'] = Type(None, "string", "character*256") + fancy_type['character*(32)'] = Type(None, "string", "character*(32)") + fancy_type['character*(60)'] = Type(None, "string", "character*(60)") + fancy_type['character*(256)'] = Type(None, "string", "character*(256)") # ~#~#~#~#~#~#~#~ # # q p _ t y p e s # @@ -457,7 +457,7 @@ def save_ezfio_default(module_lower, str_ezfio_default): f.write(str_ezfio_default) -def create_ocaml_input(dict_ezfio_cfg): +def create_ocaml_input(dict_ezfio_cfg,module_lower): # ~#~#~#~# # # I n i t # @@ -492,7 +492,7 @@ def create_ocaml_input(dict_ezfio_cfg): "open Qputils;;", "open Core.Std;;", "", - "module Full_ci : sig"] + "module {0} : sig".format(module_lower.capitalize())] template += [e_glob.create_type()] @@ -612,7 +612,7 @@ def main(): # O c a m l # # ~#~#~#~#~#~# - str_ocaml_input = create_ocaml_input(dict_ezfio_cfg) + str_ocaml_input = create_ocaml_input(dict_ezfio_cfg, module_lower) save_ocaml_input(module_lower, str_ocaml_input) # ~#~#~#~#~#~#~#~# diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg new file mode 100644 index 00000000..376ef315 --- /dev/null +++ b/src/Hartree_Fock/EZFIO.cfg @@ -0,0 +1,22 @@ +[thresh_SCF] +type: Threshold +doc: Threshold on the convergence of the Hartree Fock energy +interface: input +default: 1.e-10 + +[n_it_scf_max] +type: Strictly_positive_int +doc: Maximum number of SCF iterations +interface: input +default: 200 + +[mo_guess_type] +type: character*(32) +doc: Initial MO guess. Can be [ Huckel | HCore ] +interface: input +default: Huckel + +[energy] +type: double precision +doc: "Calculated HF energy" +interface: output \ No newline at end of file diff --git a/src/Hartree_Fock/hartree_fock.ezfio_config b/src/Hartree_Fock/hartree_fock.ezfio_config deleted file mode 100644 index 3909f652..00000000 --- a/src/Hartree_Fock/hartree_fock.ezfio_config +++ /dev/null @@ -1,6 +0,0 @@ -hartree_fock - thresh_scf double precision - n_it_scf_max integer - energy double precision - guess character*(32) - diff --git a/src/Hartree_Fock/options.irp.f b/src/Hartree_Fock/options.irp.f deleted file mode 100644 index 22f86d6c..00000000 --- a/src/Hartree_Fock/options.irp.f +++ /dev/null @@ -1,35 +0,0 @@ -BEGIN_SHELL [ /usr/bin/python ] -from ezfio_with_default import EZFIO_Provider -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 ( "integer" ) -T.set_name ( "n_it_scf_max" ) -T.set_doc ( "Maximum number of SCF iterations" ) -T.set_ezfio_dir ( "Hartree_Fock" ) -T.set_ezfio_name( "n_it_scf_max" ) -T.set_output ( "output_Hartree_Fock" ) -print T - -T = EZFIO_Provider() -T.set_type ( "character*(32)" ) -T.set_name ( "mo_guess_type" ) -T.set_doc ( "Initial MO guess. Can be [ Huckel | HCore ]" ) -T.set_ezfio_dir ( "Hartree_Fock" ) -T.set_ezfio_name( "guess" ) -T.set_output ( "output_Hartree_Fock" ) -print T - - -END_SHELL - - - - From d458696fcbc1314c661bc00001c243ed5f0c875a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 11:21:34 +0200 Subject: [PATCH 36/60] Add convert_ezfio.sh --- scripts/ezfio_interface/convert_ezfio.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 scripts/ezfio_interface/convert_ezfio.sh diff --git a/scripts/ezfio_interface/convert_ezfio.sh b/scripts/ezfio_interface/convert_ezfio.sh new file mode 100644 index 00000000..a1f8fc88 --- /dev/null +++ b/scripts/ezfio_interface/convert_ezfio.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Convert a old ezfio file (with option.irp.f ezfio_default) +# into a new EZFIO.cfg type +mv $1/Hartree_Fock $1/hartree_fock \ No newline at end of file From 757b785f30979eaa7b6fea5130b4a3493181ec70 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 11:47:56 +0200 Subject: [PATCH 37/60] Fix unit_test --- scripts/ezfio_interface/convert_ezfio.sh | 3 ++- src/Hartree_Fock/EZFIO.cfg | 2 +- tests/unit_test/unit_test.py | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/ezfio_interface/convert_ezfio.sh b/scripts/ezfio_interface/convert_ezfio.sh index a1f8fc88..71b68fcc 100644 --- a/scripts/ezfio_interface/convert_ezfio.sh +++ b/scripts/ezfio_interface/convert_ezfio.sh @@ -1,4 +1,5 @@ #!/bin/bash # Convert a old ezfio file (with option.irp.f ezfio_default) # into a new EZFIO.cfg type -mv $1/Hartree_Fock $1/hartree_fock \ No newline at end of file +mv $1/Hartree_Fock $1/hartree_fock +mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg index 376ef315..53a17c73 100644 --- a/src/Hartree_Fock/EZFIO.cfg +++ b/src/Hartree_Fock/EZFIO.cfg @@ -1,4 +1,4 @@ -[thresh_SCF] +[thresh_scf] type: Threshold doc: Threshold on the convergence of the Hartree Fock energy interface: input diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index f4934c63..7057640b 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -66,11 +66,14 @@ def run_hf(geo, basis): init_folder(geo, basis) + ezfio.set_file("{0}.ezfio".format(geo)) + ezfio.set_hartree_fock_mo_guess_type("Huckel") + ezfio.set_hartree_fock_thresh_scf("1.e-10") + ezfio.set_hartree_fock_n_it_scf_max("100") + cmd = "qp_run SCF {0}.ezfio/".format(geo) subprocess.check_call([cmd], shell=True) - ezfio.set_file("{0}.ezfio".format(geo)) - cur_e = ezfio.get_hartree_fock_energy() ref_e = ref_energy[basis][geo] From c484b9cf9327e5a029dd48fd579dd610f0df8a8c Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 11:57:42 +0200 Subject: [PATCH 38/60] Set parameter in unit_test.py --- tests/unit_test/unit_test.py | 56 ++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 7057640b..8e00d4c3 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -57,23 +57,47 @@ def run_hf(geo, basis): Run a simle by default hf EZFIO path = geo.ezfio """ - global has_hf_alredy - has_hf_alredy = True + # ~#~#~#~#~#~#~#~#~#~ # + # R e f _ e n e r g y # + # ~#~#~#~#~#~#~#~#~#~ # ref_energy = defaultdict(dict) ref_energy["sto-3g"]["methane"] = -39.7267433402 - init_folder(geo, basis) + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + # G l o b a l _ v a r i a b l e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + global has_hf_alredy + has_hf_alredy = True + + # ~#~#~#~ # + # I n i t # + # ~#~#~#~ # + + init_folder(geo, basis) ezfio.set_file("{0}.ezfio".format(geo)) - ezfio.set_hartree_fock_mo_guess_type("Huckel") - ezfio.set_hartree_fock_thresh_scf("1.e-10") - ezfio.set_hartree_fock_n_it_scf_max("100") + + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # S e t _ p a r a m e t e r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + + ezfio.hartree_fock_mo_guess_type = "Huckel" + ezfio.hartree_fock_thresh_scf = 1.e-10 + ezfio.hartree_fock_n_it_scf_max = 100 + + # ~#~#~ # + # R u n # + # ~#~#~ # cmd = "qp_run SCF {0}.ezfio/".format(geo) subprocess.check_call([cmd], shell=True) + # ~#~#~#~#~ # + # C h e c k # + # ~#~#~#~#~ # + cur_e = ezfio.get_hartree_fock_energy() ref_e = ref_energy[basis][geo] @@ -89,21 +113,41 @@ def run_full_ci_10k_pt2_end(geo, basis): EZFIO path = geo.ezfio """ + # ~#~#~#~#~#~#~#~#~#~ # + # R e f _ e n e r g y # + # ~#~#~#~#~#~#~#~#~#~ # + ref_energy_var = defaultdict(dict) ref_energy_pt2 = defaultdict(dict) ref_energy_var["sto-3g"]["methane"] = -0.398058753535695E+02 ref_energy_pt2["sto-3g"]["methane"] = -0.398059182483741E+02 + # ~#~#~#~ # + # I n i t # + # ~#~#~#~ # + ezfio.set_file("{0}.ezfio".format(geo)) + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # S e t _ p a r a m e t e r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + ezfio.full_ci_do_pt2_end = True ezfio.full_ci_n_det_max_fci = 10000 ezfio.full_ci_pt2_max = 1.e-8 + # ~#~#~ # + # R u n # + # ~#~#~ # + cmd = "qp_run full_ci {0}.ezfio/".format(geo) subprocess.check_call([cmd], shell=True) + # ~#~#~#~#~ # + # C h e c k # + # ~#~#~#~#~ # + cur_var = ezfio.get_full_ci_energy() cur_pt2 = ezfio.get_full_ci_energy_pt2() From 96d69921ffce9019e79d3f554bddbe501de8fb96 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 14:53:13 +0200 Subject: [PATCH 39/60] Beter doc for ei_handler --- scripts/ezfio_interface/ei_handler.py | 11 ++++------- src/Hartree_Fock/EZFIO.cfg | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index ca7eee70..4424be6a 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -27,15 +27,12 @@ doc: Threshold on the convergence of the Hartree Fock energy type: Threshold default: 1.e-10 interface: input -default: 10000 -size : ao_num, 3 +size: 1 -[do_pt2_end] -type: logical -doc: If true, compute the PT2 at the end of the selection -default: true +[energy] +type: double precision +doc: Calculated HF energy interface: output -size : 1 ``` """ diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg index 53a17c73..5bb96a7f 100644 --- a/src/Hartree_Fock/EZFIO.cfg +++ b/src/Hartree_Fock/EZFIO.cfg @@ -18,5 +18,5 @@ default: Huckel [energy] type: double precision -doc: "Calculated HF energy" +doc: Calculated HF energy interface: output \ No newline at end of file From 4c3803f383307d2d92c1fb353132668f1ba75b11 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 16:50:27 +0200 Subject: [PATCH 40/60] Add mo_guess into EZFIO.cfg --- scripts/ezfio_interface/ei_handler.py | 4 +++- scripts/ezfio_interface/ezfio_generate_ocaml.py | 2 ++ src/Hartree_Fock/EZFIO.cfg | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 4424be6a..bdb52244 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -105,6 +105,8 @@ def get_type_dict(): fancy_type['logical'] = Type(None, "bool", "logical") fancy_type['bool'] = Type(None, "bool", "logical") + fancy_type['MO_guess'] = Type("MO_guess", "string", "character*(32)") + fancy_type['character*(32)'] = Type(None, "string", "character*(32)") fancy_type['character*(60)'] = Type(None, "string", "character*(60)") fancy_type['character*(256)'] = Type(None, "string", "character*(256)") @@ -212,7 +214,7 @@ def get_dict_config_file(config_file_path, module_lower): type_ = config_file.get(section, "type") if type_ not in type_dict: print "{0} not avalaible. Choose in:".format(type_) - print ", ".join([i for i in type_dict]) + print ", ".join(sorted([i for i in type_dict])) sys.exit(1) else: d[pvd]["type"] = type_dict[type_] diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index 9dd4c640..18863e7d 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -162,6 +162,8 @@ class EZFIO_ocaml(object): l_template += [" {0:<30} : {1}.t;".format(p, t.fancy)] else: l_template += [" {0:<30} : {1};".format(p, t.ocaml)] + + print p, t, l_template l_template += [" } with sexp", ";;"] diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg index 5bb96a7f..87f1a878 100644 --- a/src/Hartree_Fock/EZFIO.cfg +++ b/src/Hartree_Fock/EZFIO.cfg @@ -11,7 +11,7 @@ interface: input default: 200 [mo_guess_type] -type: character*(32) +type: MO_guess doc: Initial MO guess. Can be [ Huckel | HCore ] interface: input default: Huckel From ac7490635a685cf30b8725d29256c1c7cff433a7 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 17:36:39 +0200 Subject: [PATCH 41/60] Add EZFIO.cfg to ezfio_generate_ocaml --- .../ezfio_interface/ezfio_generate_ocaml.py | 1 - src/CISD_SC2_selected/EZFIO.cfg | 29 +++++++++++ src/CISD_SC2_selected/cisd_sc2.ezfio_config | 4 -- src/CISD_SC2_selected/options.irp.f | 51 ------------------- 4 files changed, 29 insertions(+), 56 deletions(-) create mode 100644 src/CISD_SC2_selected/EZFIO.cfg delete mode 100644 src/CISD_SC2_selected/cisd_sc2.ezfio_config delete mode 100644 src/CISD_SC2_selected/options.irp.f diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index 18863e7d..4590f9b9 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -163,7 +163,6 @@ class EZFIO_ocaml(object): else: l_template += [" {0:<30} : {1};".format(p, t.ocaml)] - print p, t, l_template l_template += [" } with sexp", ";;"] diff --git a/src/CISD_SC2_selected/EZFIO.cfg b/src/CISD_SC2_selected/EZFIO.cfg new file mode 100644 index 00000000..84cefe2f --- /dev/null +++ b/src/CISD_SC2_selected/EZFIO.cfg @@ -0,0 +1,29 @@ +[N_det_max_cisd_sc2] +type: Det_number_max +doc: Get n_det_max_cisd_sc2 from EZFIO file +interface: input +default: 10000 + +[do_pt2_end] +type: logical +doc: If true, compute the PT2 at the end of the selection +interface: input +default: true + +[PT2_max] +type: PT2_energy +doc: The selection process stops when the largest PT2 (for all the state) is lower + than pt2_max in absolute value +interface: input +default: 0.0001 + +[energy] +type: double precision +doc: "Calculated Full CI energy" +interface: output + +[energy_pt2] +type: double precision +doc: "Calculated Full CI energy" +interface: output + diff --git a/src/CISD_SC2_selected/cisd_sc2.ezfio_config b/src/CISD_SC2_selected/cisd_sc2.ezfio_config deleted file mode 100644 index 35008968..00000000 --- a/src/CISD_SC2_selected/cisd_sc2.ezfio_config +++ /dev/null @@ -1,4 +0,0 @@ -cisd_sc2_selected - n_det_max_cisd_sc2 integer - pt2_max double precision - do_pt2_end logical diff --git a/src/CISD_SC2_selected/options.irp.f b/src/CISD_SC2_selected/options.irp.f deleted file mode 100644 index 1fe3e158..00000000 --- a/src/CISD_SC2_selected/options.irp.f +++ /dev/null @@ -1,51 +0,0 @@ - BEGIN_PROVIDER [ integer, n_det_max_cisd_sc2 ] - implicit none - BEGIN_DOC - ! Get n_det_max_cisd_sc2 from EZFIO file - END_DOC - logical :: has_n_det_max_cisd_sc2 - PROVIDE ezfio_filename - call ezfio_has_cisd_sc2_selected_n_det_max_cisd_sc2(has_n_det_max_cisd_sc2) - if (has_n_det_max_cisd_sc2) then - call ezfio_get_cisd_sc2_selected_n_det_max_cisd_sc2(n_det_max_cisd_sc2) - else - n_det_max_cisd_sc2 = 1000 - call ezfio_set_cisd_sc2_selected_n_det_max_cisd_sc2(n_det_max_cisd_sc2) - endif - print*,'n_det_max_cisd_sc2 = ',n_det_max_cisd_sc2 - END_PROVIDER - - BEGIN_PROVIDER [ double precision , pt2_max ] - implicit none - BEGIN_DOC - ! Get pt2_max from EZFIO file - END_DOC - logical :: has_pt2_max - PROVIDE ezfio_filename - call ezfio_has_cisd_sc2_selected_pt2_max(has_pt2_max) - if (has_pt2_max) then - call ezfio_get_cisd_sc2_selected_pt2_max(pt2_max) - else - pt2_max = 1.d-3 - call ezfio_set_cisd_sc2_selected_pt2_max(pt2_max) - endif - print*,'pt2_max = ',pt2_max - END_PROVIDER - - BEGIN_PROVIDER [ logical, do_pt2_end ] - implicit none - BEGIN_DOC - ! Get do_pt2_end from EZFIO file - END_DOC - logical :: has_do_pt2_end - PROVIDE ezfio_filename - call ezfio_has_cisd_sc2_selected_do_pt2_end(has_do_pt2_end) - if (has_do_pt2_end) then - call ezfio_get_cisd_sc2_selected_do_pt2_end(do_pt2_end) - else - do_pt2_end = .True. - call ezfio_set_cisd_sc2_selected_do_pt2_end(do_pt2_end) - endif - print*,'do_pt2_end = ',do_pt2_end - END_PROVIDER - From e9665c276ca124ae8574b48248e90ca3a06d5f11 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 30 Mar 2015 17:56:17 +0200 Subject: [PATCH 42/60] Add cisd_sc2_selected to qp_edit --- ocaml/Input.ml | 2 +- ocaml/qp_edit.ml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ocaml/Input.ml b/ocaml/Input.ml index df293cc7..62de42f8 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -7,6 +7,7 @@ include Input_ao_basis;; include Input_bi_integrals;; include Input_bitmasks;; include Input_cisd_sc2;; +include Input_cisd_sc2_selected;; include Input_determinants;; include Input_electrons;; include Input_full_ci;; @@ -14,4 +15,3 @@ include Input_hartree_fock;; include Input_mo_basis;; include Input_nuclei;; - diff --git a/ocaml/qp_edit.ml b/ocaml/qp_edit.ml index 2fc13e8c..c60db6e2 100644 --- a/ocaml/qp_edit.ml +++ b/ocaml/qp_edit.ml @@ -13,6 +13,7 @@ type keyword = | Ao_basis | Bielec_integrals | Cisd_sc2 +| Cisd_sc2_selected | Determinants | Electrons | Full_ci @@ -26,6 +27,7 @@ let keyword_to_string = function | Ao_basis -> "AO basis" | Bielec_integrals -> "Two electron integrals" | Cisd_sc2 -> "CISD (SC)^2" +| Cisd_sc2_selected -> "CISD (SC)^2 selected" | Determinants -> "Determinants" | Electrons -> "Electrons" | Full_ci -> "Selected Full-CI" @@ -80,6 +82,8 @@ let get s = f Electrons.(read, to_rst) | Cisd_sc2 -> f Cisd_sc2.(read, to_rst) + | Cisd_sc2_selected -> + f Cisd_sc2_selected.(read, to_rst) | Nuclei -> f Nuclei.(read, to_rst) | Ao_basis -> @@ -129,6 +133,7 @@ let set str s = | Full_ci -> write Full_ci.(of_rst, write) s | Electrons -> write Electrons.(of_rst, write) s | Cisd_sc2 -> write Cisd_sc2.(of_rst, write) s + | Cisd_sc2_selected -> write Cisd_sc2_selected.(of_rst, write) s | Bielec_integrals -> write Bielec_integrals.(of_rst, write) s | Determinants -> write Determinants.(of_rst, write) s | Nuclei -> write Nuclei.(of_rst, write) s @@ -179,6 +184,7 @@ let run check_only ezfio_filename = Bielec_integrals ; Hartree_fock ; Cisd_sc2 ; + Cisd_sc2_selected ; Full_ci ; Mo_basis; Determinants ; From 951a4e35e03671199c6ba1bac23d2bddef4f0132 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 09:31:59 +0200 Subject: [PATCH 43/60] CISD (SC)^2 into CISD (SC)^2 SELECTED cause is the name of the module --- ocaml/Input.ml | 1 - ocaml/Input_cisd_sc2.ml | 127 ------------------ ocaml/qp_edit.ml | 24 ++-- ocaml/test_input.ml | 8 +- .../cisd_sc2_selection.irp.f | 1 + 5 files changed, 14 insertions(+), 147 deletions(-) delete mode 100644 ocaml/Input_cisd_sc2.ml diff --git a/ocaml/Input.ml b/ocaml/Input.ml index 62de42f8..3c4c74d3 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -6,7 +6,6 @@ open Core.Std;; include Input_ao_basis;; include Input_bi_integrals;; include Input_bitmasks;; -include Input_cisd_sc2;; include Input_cisd_sc2_selected;; include Input_determinants;; include Input_electrons;; diff --git a/ocaml/Input_cisd_sc2.ml b/ocaml/Input_cisd_sc2.ml deleted file mode 100644 index ed046d79..00000000 --- a/ocaml/Input_cisd_sc2.ml +++ /dev/null @@ -1,127 +0,0 @@ -open Qptypes;; -open Qputils;; -open Core.Std;; - -module Cisd_sc2 : sig - type t = - { n_det_max_cisd_sc2 : Det_number_max.t; - pt2_max : PT2_energy.t; - do_pt2_end : bool; - } with sexp - ;; - val read : unit -> t option - val write : t -> unit - val to_string : t -> string - val to_rst : t -> Rst_string.t - val of_rst : Rst_string.t -> t option -end = struct - type t = - { n_det_max_cisd_sc2 : Det_number_max.t; - pt2_max : PT2_energy.t; - do_pt2_end : bool; - } with sexp - ;; - - let get_default = Qpackage.get_ezfio_default "cisd_sc2_selected";; - - let read_n_det_max_cisd_sc2 () = - if not (Ezfio.has_cisd_sc2_selected_n_det_max_cisd_sc2 ()) then - get_default "n_det_max_cisd_sc2" - |> Int.of_string - |> Ezfio.set_cisd_sc2_selected_n_det_max_cisd_sc2 - ; - Ezfio.get_cisd_sc2_selected_n_det_max_cisd_sc2 () - |> Det_number_max.of_int - ;; - - let write_n_det_max_cisd_sc2 n = - Det_number_max.to_int n - |> Ezfio.set_cisd_sc2_selected_n_det_max_cisd_sc2 - ;; - - - let read_pt2_max () = - if not (Ezfio.has_cisd_sc2_selected_pt2_max ()) then - get_default "pt2_max" - |> Float.of_string - |> Ezfio.set_cisd_sc2_selected_pt2_max - ; - Ezfio.get_cisd_sc2_selected_pt2_max () - |> PT2_energy.of_float - ;; - - let write_pt2_max p = - PT2_energy.to_float p - |> Ezfio.set_cisd_sc2_selected_pt2_max - ;; - - - let read_do_pt2_end () = - if not (Ezfio.has_cisd_sc2_selected_do_pt2_end ()) then - get_default "do_pt2_end" - |> Bool.of_string - |> Ezfio.set_cisd_sc2_selected_do_pt2_end - ; - Ezfio.get_cisd_sc2_selected_do_pt2_end () - ;; - - let write_do_pt2_end = - Ezfio.set_cisd_sc2_selected_do_pt2_end - ;; - - - let read () = - Some - { n_det_max_cisd_sc2 = read_n_det_max_cisd_sc2 (); - pt2_max = read_pt2_max (); - do_pt2_end = read_do_pt2_end (); - } - ;; - - let write { n_det_max_cisd_sc2 ; - pt2_max ; - do_pt2_end ; - } = - write_n_det_max_cisd_sc2 n_det_max_cisd_sc2; - write_pt2_max pt2_max; - write_do_pt2_end do_pt2_end; - ;; - - let to_string b = - Printf.sprintf " -n_det_max_cisd_sc2 = %s -pt2_max = %s -do_pt2_end = %s -" - (Det_number_max.to_string b.n_det_max_cisd_sc2) - (PT2_energy.to_string b.pt2_max) - (Bool.to_string b.do_pt2_end) - ;; - - let to_rst b = - Printf.sprintf " -Stop when the `n_det` > `n_det_max_cisd_sc2` :: - - n_det_max_cisd_sc2 = %s - -Stop when -E(PT2) < `pt2_max` :: - - pt2_max = %s - -Compute E(PT2) at the end :: - - do_pt2_end = %s - -" - (Det_number_max.to_string b.n_det_max_cisd_sc2) - (PT2_energy.to_string b.pt2_max) - (Bool.to_string b.do_pt2_end) - |> Rst_string.of_string - ;; - - include Generic_input_of_rst;; - let of_rst = of_rst t_of_sexp;; - -end - - diff --git a/ocaml/qp_edit.ml b/ocaml/qp_edit.ml index c60db6e2..df7635e0 100644 --- a/ocaml/qp_edit.ml +++ b/ocaml/qp_edit.ml @@ -12,7 +12,6 @@ open Core.Std;; type keyword = | Ao_basis | Bielec_integrals -| Cisd_sc2 | Cisd_sc2_selected | Determinants | Electrons @@ -24,16 +23,15 @@ type keyword = let keyword_to_string = function -| Ao_basis -> "AO basis" -| Bielec_integrals -> "Two electron integrals" -| Cisd_sc2 -> "CISD (SC)^2" -| Cisd_sc2_selected -> "CISD (SC)^2 selected" -| Determinants -> "Determinants" -| Electrons -> "Electrons" -| Full_ci -> "Selected Full-CI" -| Hartree_fock -> "Hartree-Fock" -| Mo_basis -> "MO basis" -| Nuclei -> "Molecule" +| Ao_basis -> "AO basis" +| Bielec_integrals -> "Two electron integrals" +| Cisd_sc2_selected -> "CISD (SC)^2" +| Determinants -> "Determinants" +| Electrons -> "Electrons" +| Full_ci -> "Selected Full-CI" +| Hartree_fock -> "Hartree-Fock" +| Mo_basis -> "MO basis" +| Nuclei -> "Molecule" ;; @@ -80,8 +78,6 @@ let get s = f Mo_basis.(read, to_rst) | Electrons -> f Electrons.(read, to_rst) - | Cisd_sc2 -> - f Cisd_sc2.(read, to_rst) | Cisd_sc2_selected -> f Cisd_sc2_selected.(read, to_rst) | Nuclei -> @@ -132,7 +128,6 @@ let set str s = | Hartree_fock -> write Hartree_fock.(of_rst, write) s | Full_ci -> write Full_ci.(of_rst, write) s | Electrons -> write Electrons.(of_rst, write) s - | Cisd_sc2 -> write Cisd_sc2.(of_rst, write) s | Cisd_sc2_selected -> write Cisd_sc2_selected.(of_rst, write) s | Bielec_integrals -> write Bielec_integrals.(of_rst, write) s | Determinants -> write Determinants.(of_rst, write) s @@ -183,7 +178,6 @@ let run check_only ezfio_filename = Electrons ; Bielec_integrals ; Hartree_fock ; - Cisd_sc2 ; Cisd_sc2_selected ; Full_ci ; Mo_basis; diff --git a/ocaml/test_input.ml b/ocaml/test_input.ml index d7e0c9d3..956fd745 100644 --- a/ocaml/test_input.ml +++ b/ocaml/test_input.ml @@ -61,13 +61,13 @@ let test_dets () = let test_cisd_sc2 () = Ezfio.set_file "F2.ezfio" ; - let b = match Input.Cisd_sc2.read () with + let b = match Input.Cisd_sc2_selected.read () with | Some x -> x | None -> assert false in - print_endline (Input.Cisd_sc2.to_string b); - let rst = Input.Cisd_sc2.to_rst b in - let b2 = match Input.Cisd_sc2.of_rst rst with + print_endline (Input.Cisd_sc2_selected.to_string b); + let rst = Input.Cisd_sc2_selected.to_rst b in + let b2 = match Input.Cisd_sc2_selected.of_rst rst with | Some x -> x | None -> assert false in diff --git a/src/CISD_SC2_selected/cisd_sc2_selection.irp.f b/src/CISD_SC2_selected/cisd_sc2_selection.irp.f index fb7de4cf..1c4b2ed0 100644 --- a/src/CISD_SC2_selected/cisd_sc2_selection.irp.f +++ b/src/CISD_SC2_selected/cisd_sc2_selection.irp.f @@ -68,6 +68,7 @@ program cisd_sc2_selected touch N_det psi_det psi_coef davidson_threshold davidson_criterion call diagonalize_CI_SC2 pt2 = 0.d0 + if(do_pt2_end)then threshold_selectors = 1.d0 call H_apply_PT2(pt2, norm_pert, H_pert_diag, N_st) From 0a8d393dbc177d9ada01c323e588c772ec1ecd26 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 09:58:25 +0200 Subject: [PATCH 44/60] BiInt => Bielec_integrals --- .../ezfio_defaults/bi_integrals.ezfio_default | 9 ---- data/ezfio_defaults/cisd_sc2.ezfio_default | 5 -- scripts/ezfio_interface/convert_ezfio.sh | 8 ++++ scripts/ezfio_interface/ei_handler.py | 5 +- .../ezfio_generate_provider.py | 1 - src/BiInts/bi_integrals.ezfio_config | 9 ---- src/BiInts/options.irp.f | 46 ------------------- .../ASSUMPTIONS.rst | 0 src/Bielec_integrals/EZFIO.cfg | 44 ++++++++++++++++++ src/{BiInts => Bielec_integrals}/Makefile | 0 .../NEEDED_MODULES | 0 src/{BiInts => Bielec_integrals}/README.rst | 0 .../ao_bi_integrals.irp.f | 22 ++++----- .../gauss_legendre.irp.f | 0 .../map_integrals.irp.f | 4 +- .../mo_bi_integrals.irp.f | 22 ++++----- src/CAS_SD_selected/NEEDED_MODULES | 2 +- src/CID/NEEDED_MODULES | 2 +- src/CID_SC2_selected/NEEDED_MODULES | 2 +- src/CID_selected/NEEDED_MODULES | 2 +- src/CIS/NEEDED_MODULES | 2 +- src/CISD/NEEDED_MODULES | 2 +- src/CISD_SC2_selected/NEEDED_MODULES | 2 +- src/CISD_selected/NEEDED_MODULES | 2 +- src/DDCI_selected/NEEDED_MODULES | 2 +- src/Dets/NEEDED_MODULES | 2 +- src/FCIdump/NEEDED_MODULES | 2 +- src/Full_CI/NEEDED_MODULES | 2 +- src/Generators_CAS/NEEDED_MODULES | 2 +- src/Generators_full/NEEDED_MODULES | 2 +- src/Generators_restart/NEEDED_MODULES | 2 +- src/Hartree_Fock/NEEDED_MODULES | 2 +- src/MP2/NEEDED_MODULES | 2 +- src/NEEDED_MODULES | 2 +- src/Perturbation/NEEDED_MODULES | 2 +- src/Properties/NEEDED_MODULES | 2 +- src/Selectors_full/NEEDED_MODULES | 2 +- src/Selectors_no_sorted/NEEDED_MODULES | 2 +- tests/unit_test/unit_test.py | 8 ++++ 39 files changed, 109 insertions(+), 118 deletions(-) delete mode 100644 data/ezfio_defaults/bi_integrals.ezfio_default delete mode 100644 data/ezfio_defaults/cisd_sc2.ezfio_default delete mode 100644 src/BiInts/bi_integrals.ezfio_config delete mode 100644 src/BiInts/options.irp.f rename src/{BiInts => Bielec_integrals}/ASSUMPTIONS.rst (100%) create mode 100644 src/Bielec_integrals/EZFIO.cfg rename src/{BiInts => Bielec_integrals}/Makefile (100%) rename src/{BiInts => Bielec_integrals}/NEEDED_MODULES (100%) rename src/{BiInts => Bielec_integrals}/README.rst (100%) rename src/{BiInts => Bielec_integrals}/ao_bi_integrals.irp.f (97%) rename src/{BiInts => Bielec_integrals}/gauss_legendre.irp.f (100%) rename src/{BiInts => Bielec_integrals}/map_integrals.irp.f (99%) rename src/{BiInts => Bielec_integrals}/mo_bi_integrals.irp.f (94%) diff --git a/data/ezfio_defaults/bi_integrals.ezfio_default b/data/ezfio_defaults/bi_integrals.ezfio_default deleted file mode 100644 index 7cdf7a9b..00000000 --- a/data/ezfio_defaults/bi_integrals.ezfio_default +++ /dev/null @@ -1,9 +0,0 @@ -bielec_integrals - read_ao_integrals False - read_mo_integrals False - write_ao_integrals False - write_mo_integrals False - threshold_ao 1.e-15 - threshold_mo 1.e-15 - direct False - diff --git a/data/ezfio_defaults/cisd_sc2.ezfio_default b/data/ezfio_defaults/cisd_sc2.ezfio_default deleted file mode 100644 index 624ac35d..00000000 --- a/data/ezfio_defaults/cisd_sc2.ezfio_default +++ /dev/null @@ -1,5 +0,0 @@ -cisd_sc2_selected - n_det_max_cisd_sc2 10000 - pt2_max 1.e-4 - do_pt2_end True - diff --git a/scripts/ezfio_interface/convert_ezfio.sh b/scripts/ezfio_interface/convert_ezfio.sh index 71b68fcc..a7752f54 100644 --- a/scripts/ezfio_interface/convert_ezfio.sh +++ b/scripts/ezfio_interface/convert_ezfio.sh @@ -1,5 +1,13 @@ #!/bin/bash # Convert a old ezfio file (with option.irp.f ezfio_default) # into a new EZFIO.cfg type + +# Hartree Fock +# Changin the case, don't know if is needed or not mv $1/Hartree_Fock $1/hartree_fock mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf + +mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf + +# BiInts +mv $1/bi_integrals $1/bielect_integrals \ No newline at end of file diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index bdb52244..38d69ff7 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -304,7 +304,7 @@ def save_ezfio_provider(path_head, dict_code_provider): l_output += [code for code in dict_code_provider.values()] - output = "\n".join(l_output) + output = "\n\n".join(l_output) if output != old_output: with open(path, "w") as f: @@ -366,7 +366,8 @@ def create_ezfio_stuff(dict_ezfio_cfg, config_or_default="config"): for provider_name, provider_info in sorted(dict_ezfio_cfg.iteritems()): # Get the value from dict - name_raw = provider_name.lower() + name_raw = provider_info["ezfio_name"].lower() + fortran_type_raw = provider_info["type"].fortran if "size" in provider_info and not provider_info["size"] == "1": diff --git a/scripts/ezfio_interface/ezfio_generate_provider.py b/scripts/ezfio_interface/ezfio_generate_provider.py index 21dc8450..a99c0089 100755 --- a/scripts/ezfio_interface/ezfio_generate_provider.py +++ b/scripts/ezfio_interface/ezfio_generate_provider.py @@ -29,7 +29,6 @@ BEGIN_PROVIDER [ %(type)s, %(name)s ] endif %(write)s - END_PROVIDER """.strip() diff --git a/src/BiInts/bi_integrals.ezfio_config b/src/BiInts/bi_integrals.ezfio_config deleted file mode 100644 index e780dce8..00000000 --- a/src/BiInts/bi_integrals.ezfio_config +++ /dev/null @@ -1,9 +0,0 @@ -bielec_integrals - read_ao_integrals logical - read_mo_integrals logical - write_ao_integrals logical - write_mo_integrals logical - threshold_ao double precision - threshold_mo double precision - direct logical - diff --git a/src/BiInts/options.irp.f b/src/BiInts/options.irp.f deleted file mode 100644 index 3a54fd19..00000000 --- a/src/BiInts/options.irp.f +++ /dev/null @@ -1,46 +0,0 @@ -BEGIN_SHELL [ /usr/bin/python ] -from ezfio_with_default import EZFIO_Provider -T = EZFIO_Provider() -T.set_type ( "logical" ) -T.set_name ( "do_direct_integrals" ) -T.set_doc ( "If true, compute integrals on the fly" ) -T.set_ezfio_dir ( "bielec_integrals" ) -T.set_ezfio_name( "direct" ) -T.set_output ( "output_biints" ) -print T - -T.set_type ( "logical" ) -T.set_name ( "write_mo_integrals" ) -T.set_doc ( "If true, write MO integrals in EZFIO" ) -T.set_ezfio_name( "write_mo_integrals" ) -print T - -T.set_name ( "write_ao_integrals" ) -T.set_doc ( "If true, write AO integrals in EZFIO" ) -T.set_ezfio_name( "write_ao_integrals" ) -print T - -T.set_name ( "read_mo_integrals" ) -T.set_doc ( "If true, read MO integrals in EZFIO" ) -T.set_ezfio_name( "read_mo_integrals" ) -print T - -T.set_name ( "read_ao_integrals" ) -T.set_doc ( "If true, read AO integrals in EZFIO" ) -T.set_ezfio_name( "read_ao_integrals" ) -print T - -T.set_type ( "double precision" ) -T.set_name ( "ao_integrals_threshold" ) -T.set_doc ( "If < ao_integrals_threshold, = 0" ) -T.set_ezfio_name( "threshold_ao" ) -print T - -T.set_name ( "mo_integrals_threshold" ) -T.set_doc ( "If < mo_integrals_threshold, = 0" ) -T.set_ezfio_name( "threshold_mo" ) -print T - -END_SHELL - - diff --git a/src/BiInts/ASSUMPTIONS.rst b/src/Bielec_integrals/ASSUMPTIONS.rst similarity index 100% rename from src/BiInts/ASSUMPTIONS.rst rename to src/Bielec_integrals/ASSUMPTIONS.rst diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg new file mode 100644 index 00000000..61c58c51 --- /dev/null +++ b/src/Bielec_integrals/EZFIO.cfg @@ -0,0 +1,44 @@ +[do_direct_integrals] +type: logical +doc: If true, compute integrals on the fly +interface: input +default: False +ezfio_name: direct + +[write_ao_integrals] +type: logical +doc: If true, write AO integrals in EZFIO +interface: input +default: False + +[write_mo_integrals] +type: logical +doc: If true, write MO integrals in EZFIO +interface: input +default: False + +[read_ao_integrals] +type: logical +doc: If true, read AO integrals in EZFIO +interface: input +default: False + +[read_mo_integrals] +type: logical +doc: If true, read MO integrals in EZFIO +interface: input +default: False + +[ao_integrals_threshold] +type: Threshold +doc: If < ao_integrals_threshold => = 0 +interface: input +default: 1.e-15 +ezfio_name: threshold_ao + +[mo_integrals_threshold] +type: Threshold +doc: If < ao_integrals_threshold => = 0 +interface: input +default: 1.e-15 +ezfio_name: threshold_mo \ No newline at end of file diff --git a/src/BiInts/Makefile b/src/Bielec_integrals/Makefile similarity index 100% rename from src/BiInts/Makefile rename to src/Bielec_integrals/Makefile diff --git a/src/BiInts/NEEDED_MODULES b/src/Bielec_integrals/NEEDED_MODULES similarity index 100% rename from src/BiInts/NEEDED_MODULES rename to src/Bielec_integrals/NEEDED_MODULES diff --git a/src/BiInts/README.rst b/src/Bielec_integrals/README.rst similarity index 100% rename from src/BiInts/README.rst rename to src/Bielec_integrals/README.rst diff --git a/src/BiInts/ao_bi_integrals.irp.f b/src/Bielec_integrals/ao_bi_integrals.irp.f similarity index 97% rename from src/BiInts/ao_bi_integrals.irp.f rename to src/Bielec_integrals/ao_bi_integrals.irp.f index 67fc0a1b..f2645c6d 100644 --- a/src/BiInts/ao_bi_integrals.irp.f +++ b/src/Bielec_integrals/ao_bi_integrals.irp.f @@ -356,7 +356,7 @@ BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ] integer :: load_ao_integrals print*,'Reading the AO integrals' if (load_ao_integrals(trim(ezfio_filename)//'/work/ao_integrals.bin') == 0) then - write(output_BiInts,*) 'AO integrals provided' + write(output_bielec_integrals,*) 'AO integrals provided' ao_bielec_integrals_in_map = .True. return endif @@ -374,7 +374,7 @@ BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ] PROVIDE progress_bar call omp_init_lock(lock) lmax = ao_num*(ao_num+1)/2 - write(output_BiInts,*) 'Providing the AO integrals' + write(output_bielec_integrals,*) 'Providing the AO integrals' call wall_time(wall_0) call wall_time(wall_1) call cpu_time(cpu_1) @@ -385,7 +385,7 @@ BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ] !$OMP DEFAULT(NONE) & !$OMP SHARED (ao_num, jl_pairs, ao_integrals_map,thresh, & !$OMP cpu_1,wall_1,lock, lmax,n_centers,ao_nucl, & - !$OMP ao_overlap_abs,ao_overlap,output_BiInts,abort_here, & + !$OMP ao_overlap_abs,ao_overlap,output_bielec_integrals,abort_here, & !$OMP wall_0,progress_bar,progress_value) allocate(buffer_i(size_buffer)) @@ -452,7 +452,7 @@ IRP_ENDIF if (thread_num == 0) then if (wall_2 - wall_0 > 1.d0) then wall_0 = wall_2 - write(output_BiInts,*) 100.*float(kk)/float(lmax), '% in ', & + write(output_bielec_integrals,*) 100.*float(kk)/float(lmax), '% in ', & wall_2-wall_1, 's', map_mb(ao_integrals_map) ,'MB' progress_value = dble(map_mb(ao_integrals_map)) endif @@ -469,21 +469,21 @@ IRP_ENDIF stop 'Aborting in AO integrals calculation' endif IRP_IF COARRAY - write(output_BiInts,*) 'Communicating the map' + write(output_bielec_integrals,*) 'Communicating the map' call communicate_ao_integrals() IRP_ENDIF COARRAY - write(output_BiInts,*) 'Sorting the map' + write(output_bielec_integrals,*) 'Sorting the map' call map_sort(ao_integrals_map) call cpu_time(cpu_2) call wall_time(wall_2) integer(map_size_kind) :: get_ao_map_size, ao_map_size ao_map_size = get_ao_map_size() - write(output_BiInts,*) 'AO integrals provided:' - write(output_BiInts,*) ' Size of AO map : ', map_mb(ao_integrals_map) ,'MB' - write(output_BiInts,*) ' Number of AO integrals :', ao_map_size - write(output_BiInts,*) ' cpu time :',cpu_2 - cpu_1, 's' - write(output_BiInts,*) ' wall time :',wall_2 - wall_1, 's ( x ', (cpu_2-cpu_1)/(wall_2-wall_1+tiny(1.d0)), ' )' + write(output_bielec_integrals,*) 'AO integrals provided:' + write(output_bielec_integrals,*) ' Size of AO map : ', map_mb(ao_integrals_map) ,'MB' + write(output_bielec_integrals,*) ' Number of AO integrals :', ao_map_size + write(output_bielec_integrals,*) ' cpu time :',cpu_2 - cpu_1, 's' + write(output_bielec_integrals,*) ' wall time :',wall_2 - wall_1, 's ( x ', (cpu_2-cpu_1)/(wall_2-wall_1+tiny(1.d0)), ' )' ao_bielec_integrals_in_map = .True. if (write_ao_integrals) then diff --git a/src/BiInts/gauss_legendre.irp.f b/src/Bielec_integrals/gauss_legendre.irp.f similarity index 100% rename from src/BiInts/gauss_legendre.irp.f rename to src/Bielec_integrals/gauss_legendre.irp.f diff --git a/src/BiInts/map_integrals.irp.f b/src/Bielec_integrals/map_integrals.irp.f similarity index 99% rename from src/BiInts/map_integrals.irp.f rename to src/Bielec_integrals/map_integrals.irp.f index ae50207e..1426288a 100644 --- a/src/BiInts/map_integrals.irp.f +++ b/src/Bielec_integrals/map_integrals.irp.f @@ -13,7 +13,7 @@ BEGIN_PROVIDER [ type(map_type), ao_integrals_map ] call bielec_integrals_index(ao_num,ao_num,ao_num,ao_num,key_max) sze = key_max call map_init(ao_integrals_map,sze) - write(output_BiInts,*) 'AO map initialized' + write(output_bielec_integrals,*) 'AO map initialized' END_PROVIDER subroutine bielec_integrals_index(i,j,k,l,i1) @@ -244,7 +244,7 @@ BEGIN_PROVIDER [ type(map_type), mo_integrals_map ] call bielec_integrals_index(mo_tot_num,mo_tot_num,mo_tot_num,mo_tot_num,key_max) sze = key_max call map_init(mo_integrals_map,sze) - write(output_BiInts,*) 'MO map initialized' + write(output_bielec_integrals,*) 'MO map initialized' END_PROVIDER subroutine insert_into_ao_integrals_map(n_integrals, & diff --git a/src/BiInts/mo_bi_integrals.irp.f b/src/Bielec_integrals/mo_bi_integrals.irp.f similarity index 94% rename from src/BiInts/mo_bi_integrals.irp.f rename to src/Bielec_integrals/mo_bi_integrals.irp.f index 54d274c7..5adc980b 100644 --- a/src/BiInts/mo_bi_integrals.irp.f +++ b/src/Bielec_integrals/mo_bi_integrals.irp.f @@ -31,7 +31,7 @@ BEGIN_PROVIDER [ logical, mo_bielec_integrals_in_map ] integer :: load_mo_integrals print*,'Reading the MO integrals' if (load_mo_integrals(trim(ezfio_filename)//'/work/mo_integrals.bin') == 0) then - write(output_BiInts,*) 'MO integrals provided' + write(output_bielec_integrals,*) 'MO integrals provided' return endif endif @@ -84,8 +84,8 @@ subroutine add_integrals_to_map(mask_ijkl) call bitstring_to_list( mask_ijkl(1,4), list_ijkl(1,4), n_l, N_int ) size_buffer = min(ao_num*ao_num*ao_num,16000000) - write(output_BiInts,*) 'Providing the molecular integrals ' - write(output_BiInts,*) 'Buffers : ', 8.*(mo_tot_num_align*(n_j)*(n_k+1) + mo_tot_num_align +& + write(output_bielec_integrals,*) 'Providing the molecular integrals ' + write(output_bielec_integrals,*) 'Buffers : ', 8.*(mo_tot_num_align*(n_j)*(n_k+1) + mo_tot_num_align +& ao_num+ao_num*ao_num+ size_buffer*3)/(1024*1024), 'MB / core' call wall_time(wall_1) @@ -99,7 +99,7 @@ subroutine add_integrals_to_map(mask_ijkl) !$OMP wall_0,thread_num) & !$OMP DEFAULT(NONE) & !$OMP SHARED(size_buffer,ao_num,mo_tot_num,n_i,n_j,n_k,n_l,mo_tot_num_align,& - !$OMP mo_coef_transp,output_BiInts, & + !$OMP mo_coef_transp,output_bielec_integrals, & !$OMP mo_coef_transp_is_built, list_ijkl, & !$OMP mo_coef_is_built, wall_1, abort_here, & !$OMP mo_coef,mo_integrals_threshold,ao_integrals_map,mo_integrals_map,progress_bar,progress_value) @@ -272,7 +272,7 @@ IRP_ENDIF if (thread_num == 0) then if (wall_2 - wall_0 > 1.d0) then wall_0 = wall_2 - write(output_BiInts,*) 100.*float(l1)/float(ao_num), '% in ', & + write(output_bielec_integrals,*) 100.*float(l1)/float(ao_num), '% in ', & wall_2-wall_1, 's', map_mb(mo_integrals_map) ,'MB' progress_value = dble(map_mb(mo_integrals_map)) @@ -291,7 +291,7 @@ IRP_ENDIF stop 'Aborting in MO integrals calculation' endif IRP_IF COARRAY - write(output_BiInts,*) 'Communicating the map' + write(output_bielec_integrals,*) 'Communicating the map' call communicate_mo_integrals() IRP_ENDIF call map_unique(mo_integrals_map) @@ -304,11 +304,11 @@ IRP_ENDIF deallocate(list_ijkl) - write(output_BiInts,*)'Molecular integrals provided:' - write(output_BiInts,*)' Size of MO map ', map_mb(mo_integrals_map) ,'MB' - write(output_BiInts,*)' Number of MO integrals: ', mo_map_size - write(output_BiInts,*)' cpu time :',cpu_2 - cpu_1, 's' - write(output_BiInts,*)' wall time :',wall_2 - wall_1, 's ( x ', (cpu_2-cpu_1)/(wall_2-wall_1), ')' + write(output_bielec_integrals,*)'Molecular integrals provided:' + write(output_bielec_integrals,*)' Size of MO map ', map_mb(mo_integrals_map) ,'MB' + write(output_bielec_integrals,*)' Number of MO integrals: ', mo_map_size + write(output_bielec_integrals,*)' cpu time :',cpu_2 - cpu_1, 's' + write(output_bielec_integrals,*)' wall time :',wall_2 - wall_1, 's ( x ', (cpu_2-cpu_1)/(wall_2-wall_1), ')' if (write_mo_integrals) then call dump_mo_integrals(trim(ezfio_filename)//'/work/mo_integrals.bin') diff --git a/src/CAS_SD_selected/NEEDED_MODULES b/src/CAS_SD_selected/NEEDED_MODULES index 7d7c112f..cbf44be7 100644 --- a/src/CAS_SD_selected/NEEDED_MODULES +++ b/src/CAS_SD_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Generators_CAS Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Generators_CAS Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils diff --git a/src/CID/NEEDED_MODULES b/src/CID/NEEDED_MODULES index 3832d4c1..ac8e21ab 100644 --- a/src/CID/NEEDED_MODULES +++ b/src/CID/NEEDED_MODULES @@ -1,3 +1,3 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils diff --git a/src/CID_SC2_selected/NEEDED_MODULES b/src/CID_SC2_selected/NEEDED_MODULES index d7bca283..42d83610 100644 --- a/src/CID_SC2_selected/NEEDED_MODULES +++ b/src/CID_SC2_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask CISD CISD_selected Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask CISD CISD_selected Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils diff --git a/src/CID_selected/NEEDED_MODULES b/src/CID_selected/NEEDED_MODULES index 56946f0e..b27ab85e 100644 --- a/src/CID_selected/NEEDED_MODULES +++ b/src/CID_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask CISD Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask CISD Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils diff --git a/src/CIS/NEEDED_MODULES b/src/CIS/NEEDED_MODULES index 847ba574..010e60f5 100644 --- a/src/CIS/NEEDED_MODULES +++ b/src/CIS/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils diff --git a/src/CISD/NEEDED_MODULES b/src/CISD/NEEDED_MODULES index 847ba574..010e60f5 100644 --- a/src/CISD/NEEDED_MODULES +++ b/src/CISD/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Selectors_full SingleRefMethod Utils diff --git a/src/CISD_SC2_selected/NEEDED_MODULES b/src/CISD_SC2_selected/NEEDED_MODULES index d7bca283..42d83610 100644 --- a/src/CISD_SC2_selected/NEEDED_MODULES +++ b/src/CISD_SC2_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask CISD CISD_selected Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask CISD CISD_selected Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils diff --git a/src/CISD_selected/NEEDED_MODULES b/src/CISD_selected/NEEDED_MODULES index 56946f0e..b27ab85e 100644 --- a/src/CISD_selected/NEEDED_MODULES +++ b/src/CISD_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask CISD Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask CISD Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils diff --git a/src/DDCI_selected/NEEDED_MODULES b/src/DDCI_selected/NEEDED_MODULES index 7d7c112f..cbf44be7 100644 --- a/src/DDCI_selected/NEEDED_MODULES +++ b/src/DDCI_selected/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Generators_CAS Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Generators_CAS Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils diff --git a/src/Dets/NEEDED_MODULES b/src/Dets/NEEDED_MODULES index 163bdf10..824c75ed 100644 --- a/src/Dets/NEEDED_MODULES +++ b/src/Dets/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/FCIdump/NEEDED_MODULES b/src/FCIdump/NEEDED_MODULES index 26097b8b..7f2f0ca8 100644 --- a/src/FCIdump/NEEDED_MODULES +++ b/src/FCIdump/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/Full_CI/NEEDED_MODULES b/src/Full_CI/NEEDED_MODULES index f2bb9ba7..5e074d3c 100644 --- a/src/Full_CI/NEEDED_MODULES +++ b/src/Full_CI/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Generators_full Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Generators_full Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils diff --git a/src/Generators_CAS/NEEDED_MODULES b/src/Generators_CAS/NEEDED_MODULES index 26097b8b..7f2f0ca8 100644 --- a/src/Generators_CAS/NEEDED_MODULES +++ b/src/Generators_CAS/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/Generators_full/NEEDED_MODULES b/src/Generators_full/NEEDED_MODULES index 3f5f6001..7d973bce 100644 --- a/src/Generators_full/NEEDED_MODULES +++ b/src/Generators_full/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Utils diff --git a/src/Generators_restart/NEEDED_MODULES b/src/Generators_restart/NEEDED_MODULES index 26097b8b..7f2f0ca8 100644 --- a/src/Generators_restart/NEEDED_MODULES +++ b/src/Generators_restart/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/Hartree_Fock/NEEDED_MODULES b/src/Hartree_Fock/NEEDED_MODULES index 4ebba314..8f7f21c6 100644 --- a/src/Hartree_Fock/NEEDED_MODULES +++ b/src/Hartree_Fock/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Electrons Ezfio_files MonoInts MOGuess MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Electrons Ezfio_files MonoInts MOGuess MOs Nuclei Output Utils diff --git a/src/MP2/NEEDED_MODULES b/src/MP2/NEEDED_MODULES index 98fbcc58..076746d1 100644 --- a/src/MP2/NEEDED_MODULES +++ b/src/MP2/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full SingleRefMethod Utils diff --git a/src/NEEDED_MODULES b/src/NEEDED_MODULES index 3df2ab88..f71f28fd 100644 --- a/src/NEEDED_MODULES +++ b/src/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask CID CID_SC2_selected CID_selected CIS CISD CISD_selected CISD_SC2_selected Dets Electrons Ezfio_files Full_CI Generators_full Hartree_Fock MOGuess MonoInts MOs MP2 Nuclei Output Selectors_full Utils Molden FCIdump Generators_CAS CAS_SD_selected DDCI_selected +AOs Bielec_integrals Bitmask CID CID_SC2_selected CID_selected CIS CISD CISD_selected CISD_SC2_selected Dets Electrons Ezfio_files Full_CI Generators_full Hartree_Fock MOGuess MonoInts MOs MP2 Nuclei Output Selectors_full Utils Molden FCIdump Generators_CAS CAS_SD_selected DDCI_selected diff --git a/src/Perturbation/NEEDED_MODULES b/src/Perturbation/NEEDED_MODULES index 4f7ab529..4fa6ff4b 100644 --- a/src/Perturbation/NEEDED_MODULES +++ b/src/Perturbation/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Properties Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Properties Utils diff --git a/src/Properties/NEEDED_MODULES b/src/Properties/NEEDED_MODULES index 8cf33c90..9095dbdf 100644 --- a/src/Properties/NEEDED_MODULES +++ b/src/Properties/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/src/Selectors_full/NEEDED_MODULES b/src/Selectors_full/NEEDED_MODULES index 3f5f6001..7d973bce 100644 --- a/src/Selectors_full/NEEDED_MODULES +++ b/src/Selectors_full/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files Hartree_Fock MOGuess MonoInts MOs Nuclei Output Utils diff --git a/src/Selectors_no_sorted/NEEDED_MODULES b/src/Selectors_no_sorted/NEEDED_MODULES index 26097b8b..7f2f0ca8 100644 --- a/src/Selectors_no_sorted/NEEDED_MODULES +++ b/src/Selectors_no_sorted/NEEDED_MODULES @@ -1 +1 @@ -AOs BiInts Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils +AOs Bielec_integrals Bitmask Dets Electrons Ezfio_files MonoInts MOs Nuclei Output Utils diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 8e00d4c3..8a753754 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -82,6 +82,14 @@ def run_hf(geo, basis): # ~#~#~#~#~#~#~#~#~#~#~#~#~ # # S e t _ p a r a m e t e r # # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + ezfio.bielec_integrals_direct = False + ezfio.bielec_integrals_threshold_ao = 1.e-15 + ezfio.bielec_integrals_write_ao_integrals = False + ezfio.bielec_integrals_read_ao_integrals = False + + ezfio.bielec_integrals_threshold_mo = 1.e-15 + ezfio.bielec_integrals_write_mo_integrals = False + ezfio.bielec_integrals_read_mo_integrals = False ezfio.hartree_fock_mo_guess_type = "Huckel" ezfio.hartree_fock_thresh_scf = 1.e-10 From 2c0480fcd8d6da480e884460d0828e22a211505a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 11:14:45 +0200 Subject: [PATCH 45/60] Ocaml generator need l_ezfio_name and not l_provider --- ocaml/Input.ml | 2 +- scripts/ezfio_interface/ei_handler.py | 6 ++-- .../ezfio_interface/ezfio_generate_ocaml.py | 36 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ocaml/Input.ml b/ocaml/Input.ml index 3c4c74d3..49ac3152 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -4,7 +4,7 @@ open Core.Std;; include Input_ao_basis;; -include Input_bi_integrals;; +include Input_bielec_integrals;; include Input_bitmasks;; include Input_cisd_sc2_selected;; include Input_determinants;; diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 38d69ff7..8bff5e69 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -465,17 +465,17 @@ def create_ocaml_input(dict_ezfio_cfg,module_lower): from ezfio_generate_ocaml import EZFIO_ocaml - l_provider = [] + l_ezfio_name = [] l_type = [] l_doc = [] for k, v in dict_ezfio_cfg.iteritems(): if v['interface'] == "input": - l_provider.append(k) + l_ezfio_name.append(v['ezfio_name']) l_type.append(v["type"]) l_doc.append(v["doc"]) - e_glob = EZFIO_ocaml(l_provider=l_provider, + e_glob = EZFIO_ocaml(l_ezfio_name=l_ezfio_name, l_type=l_type, l_doc=l_doc) diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index 4590f9b9..21da15b7 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -135,7 +135,7 @@ class EZFIO_ocaml(object): def create_type(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument - l_provider = [provider_name, ...] + l_ezfio_name = [provider_name, ...] l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] Return the type template @@ -145,7 +145,7 @@ class EZFIO_ocaml(object): # C h e c k i n g # # ~#~#~#~#~#~#~#~ # - self.check_if_init(["l_provider", "l_type"], + self.check_if_init(["l_ezfio_name", "l_type"], sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # @@ -156,7 +156,7 @@ class EZFIO_ocaml(object): "type t = ", " {"] - for p, t in zip(self.l_provider, self.l_type): + for p, t in zip(self.l_ezfio_name, self.l_type): if t.fancy: l_template += [" {0:<30} : {1}.t;".format(p, t.fancy)] @@ -174,7 +174,7 @@ class EZFIO_ocaml(object): def create_read_global(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument - l_provider = [provider_name, ...] + l_ezfio_name = [ezfio_name, ...] Return the read_global template ''' @@ -182,7 +182,7 @@ class EZFIO_ocaml(object): # C h e c k i n g # # ~#~#~#~#~#~#~#~ # - self.check_if_init(["l_provider"], + self.check_if_init(["l_ezfio_name"], sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # @@ -195,7 +195,7 @@ class EZFIO_ocaml(object): " {"] l_template += [" {0:<30} = read_{0} ();".format(p) - for p in self.l_provider] + for p in self.l_ezfio_name] l_template += [" }", ";;"] @@ -208,7 +208,7 @@ class EZFIO_ocaml(object): def create_write_global(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument - l_provider = [provider_name, ...] + l_ezfio_name = [provider_name, ...] Return the type template ''' @@ -216,7 +216,7 @@ class EZFIO_ocaml(object): # C h e c k i n g # # ~#~#~#~#~#~#~#~ # - self.check_if_init(["l_provider"], + self.check_if_init(["l_ezfio_name"], sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # @@ -225,9 +225,9 @@ class EZFIO_ocaml(object): l_template = ["(* Write all *)", "let write{ "] - l_template += [" {0};".format(p) for p in self.l_provider] + l_template += [" {0};".format(p) for p in self.l_ezfio_name] l_template += [" } ="] - l_template += [" write_{0:<30} {0};".format(p) for p in self.l_provider] + l_template += [" write_{0:<30} {0};".format(p) for p in self.l_ezfio_name] l_template += [";;"] # ~#~#~#~#~#~ # @@ -238,7 +238,7 @@ class EZFIO_ocaml(object): def create_to_string(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument - l_provider = [provider_name, ...] + l_ezfio_name = [provider_name, ...] l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] Return the type template @@ -247,7 +247,7 @@ class EZFIO_ocaml(object): # C h e c k i n g # # ~#~#~#~#~#~#~#~ # - self.check_if_init(["l_provider", "l_type"], + self.check_if_init(["l_ezfio_name", "l_type"], sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # @@ -258,10 +258,10 @@ class EZFIO_ocaml(object): 'let to_string b =', ' Printf.sprintf "'] - l_template += ["{0} = %s".format(p) for p in self.l_provider] + l_template += ["{0} = %s".format(p) for p in self.l_ezfio_name] l_template += ['"'] - for p, t in zip(self.l_provider, self.l_type): + for p, t in zip(self.l_ezfio_name, self.l_type): if t.fancy: str_ = t.fancy @@ -280,7 +280,7 @@ class EZFIO_ocaml(object): def create_to_rst(self): ''' You need to instantiate the EZFIO_ocaml with this keyword argument - l_provider = [provider_name, ...] + l_ezfio_name = [provider_name, ...] l_type = [Named_tuple(fancy_type, ocaml_type, fortrant_type), ...] Return the type template @@ -289,7 +289,7 @@ class EZFIO_ocaml(object): # C h e c k i n g # # ~#~#~#~#~#~#~#~ # - self.check_if_init(["l_provider", "l_type", "l_doc"], + self.check_if_init(["l_ezfio_name", "l_type", "l_doc"], sys._getframe().f_code.co_name) # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # @@ -300,7 +300,7 @@ class EZFIO_ocaml(object): 'let to_rst b =', ' Printf.sprintf "'] - for p, d in zip(self.l_provider, self.l_doc): + for p, d in zip(self.l_ezfio_name, self.l_doc): l_template += ["{0} ::".format(d), "", @@ -308,7 +308,7 @@ class EZFIO_ocaml(object): ""] l_template += ['"'] - for p, t in zip(self.l_provider, self.l_type): + for p, t in zip(self.l_ezfio_name, self.l_type): if t.fancy: str_ = t.fancy From ba805c3d8e60bceacc19d85d5eccdb9c87c32fc4 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 11:41:07 +0200 Subject: [PATCH 46/60] '=' is not alowed in EZFIO.cfg. Ocaml bug --- scripts/ezfio_interface/ei_handler.py | 2 +- src/Bielec_integrals/EZFIO.cfg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 8bff5e69..fd08a152 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -506,7 +506,7 @@ def create_ocaml_input(dict_ezfio_cfg,module_lower): template += [e_glob.create_type()] template += ['', - ' let get_default = Qpackage.get_ezfio_default "full_ci";;', + ' let get_default = Qpackage.get_ezfio_default "{0}";;'.format(module_lower), ''] template += ['(* =~=~=~=~=~=~==~=~=~=~=~=~ *)', diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg index 61c58c51..e6156754 100644 --- a/src/Bielec_integrals/EZFIO.cfg +++ b/src/Bielec_integrals/EZFIO.cfg @@ -31,14 +31,14 @@ default: False [ao_integrals_threshold] type: Threshold -doc: If < ao_integrals_threshold => = 0 +doc: If < ao_integrals_threshold then is null interface: input default: 1.e-15 ezfio_name: threshold_ao [mo_integrals_threshold] type: Threshold -doc: If < ao_integrals_threshold => = 0 +doc: If < ao_integrals_threshold then is null interface: input default: 1.e-15 ezfio_name: threshold_mo \ No newline at end of file From 855e839c35cc87365c32b58c79d3b8796432d5a8 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 11:45:18 +0200 Subject: [PATCH 47/60] '=' is not alowed in EZFIO.cfg. Ocaml bug --- src/Bielec_integrals/EZFIO.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg index e6156754..3d685193 100644 --- a/src/Bielec_integrals/EZFIO.cfg +++ b/src/Bielec_integrals/EZFIO.cfg @@ -1,31 +1,31 @@ [do_direct_integrals] type: logical -doc: If true, compute integrals on the fly +doc: Compute integrals on the fly interface: input default: False ezfio_name: direct [write_ao_integrals] type: logical -doc: If true, write AO integrals in EZFIO +doc: Write AO integrals from disk (EZFIO folder) interface: input default: False [write_mo_integrals] type: logical -doc: If true, write MO integrals in EZFIO +doc: Write MO integrals from disk (EZFIO folder) interface: input default: False [read_ao_integrals] type: logical -doc: If true, read AO integrals in EZFIO +doc: Read AO integrals from disk (EZFIO folder) interface: input default: False [read_mo_integrals] type: logical -doc: If true, read MO integrals in EZFIO +doc: Read MO integrals from disk (EZFIO folder) interface: input default: False From 274f2752d06b581d7070acdf9364d26a85ad1d9a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 11:58:30 +0200 Subject: [PATCH 48/60] Add gitignore to ezfio_default for filter generated file --- data/ezfio_defaults/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 data/ezfio_defaults/.gitignore diff --git a/data/ezfio_defaults/.gitignore b/data/ezfio_defaults/.gitignore new file mode 100644 index 00000000..f88730c3 --- /dev/null +++ b/data/ezfio_defaults/.gitignore @@ -0,0 +1 @@ +*ezfio_interface_default \ No newline at end of file From 00be8bc06afcedbd15de85bfdfaae66a036e07d5 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 31 Mar 2015 13:31:43 +0200 Subject: [PATCH 49/60] precision for unit test set to 5.e-8 --- tests/unit_test/unit_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 8a753754..47155776 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -17,7 +17,7 @@ from collections import defaultdict # O p t # # ~#~#~ # -precision = 1.e-8 +precision = 5.e-8 # A test get a geo file and a basis file. # A global dict containt the result for this test @@ -31,6 +31,7 @@ precision = 1.e-8 global has_hf_alredy has_hf_alredy = False + def init_folder(geo, basis, mult=1): ''' Take a geo in arg (aka a existing geo.xyz in test/) @@ -48,7 +49,8 @@ def init_folder(geo, basis, mult=1): def get_error_message(l_exepected, l_cur): - l_msg = ["Need {0} get {1}".format(i,j) for i,j in zip(l_exepected,l_cur)] + l_msg = ["Need {0} get {1} error is {2}".format(i, j, abs(i - j)) + for i, j in zip(l_exepected, l_cur)] return "\n".join(l_msg) From 88db8c9ae69d3d38bd285b02fea5435d00c0681b Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 1 Apr 2015 12:02:02 +0200 Subject: [PATCH 50/60] Add new type Disk_access (Read Write None) --- ocaml/qptypes_generator.ml | 28 +++++++++++++ scripts/ezfio_interface/convert_ezfio.sh | 22 ++++++++-- scripts/ezfio_interface/ei_handler.py | 40 ++++++++++++------ .../ezfio_generate_provider.py | 9 ++-- src/Bielec_integrals/EZFIO.cfg | 28 ++++--------- src/Bielec_integrals/ao_bi_integrals.irp.f | 7 ---- src/Bielec_integrals/read_write.irp.f | 41 +++++++++++++++++++ tests/unit_test/unit_test.py | 10 +++-- 8 files changed, 135 insertions(+), 50 deletions(-) mode change 100644 => 100755 scripts/ezfio_interface/convert_ezfio.sh create mode 100644 src/Bielec_integrals/read_write.irp.f diff --git a/ocaml/qptypes_generator.ml b/ocaml/qptypes_generator.ml index f5a62356..633727f8 100644 --- a/ocaml/qptypes_generator.ml +++ b/ocaml/qptypes_generator.ml @@ -161,8 +161,36 @@ end = struct | \"hcore\" -> HCore | _ -> failwith (\"Wrong Guess type : \"^s) +end + +module Disk_access : sig + type t with sexp + val to_string : t -> string + val of_string : string -> t +end = struct + type t = + | Read + | Write + | None + with sexp + + let to_string = function + | Read -> \"Read\" + | Write -> \"Write\" + | None -> \"None\" + let of_string s = + let s = + String.lowercase s + in + match s with + | \"read\" -> Read + | \"write\" -> Write + | \"none\" -> None + | _ -> failwith (\"Wrong IO type : \"^s) + end " + ;; let template = format_of_string " diff --git a/scripts/ezfio_interface/convert_ezfio.sh b/scripts/ezfio_interface/convert_ezfio.sh old mode 100644 new mode 100755 index a7752f54..ec0ab770 --- a/scripts/ezfio_interface/convert_ezfio.sh +++ b/scripts/ezfio_interface/convert_ezfio.sh @@ -4,10 +4,24 @@ # Hartree Fock # Changin the case, don't know if is needed or not -mv $1/Hartree_Fock $1/hartree_fock -mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf +mv $1/Hartree_Fock $1/hartree_fock 2> /dev/null -mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf +mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf 2> /dev/null # BiInts -mv $1/bi_integrals $1/bielect_integrals \ No newline at end of file +mv $1/bi_integrals $1/bielect_integrals 2> /dev/null + +if [ -f $1/bielect_integrals/read_ao_integrals ]; then + if [ `cat $1/bielect_integrals/read_ao_integrals` -eq "True" ] + then + echo "Read" > $1/bielect_integrals/disk_access_ao_integrals + + elif [ `cat bielect_integrals/write_ao_integrals` -eq "True" ] + then + echo "Write" > $1/bielect_integrals/disk_access_ao_integrals + + else + echo "None" > $1/bielect_integrals/disk_access_ao_integrals + + fi +fi \ No newline at end of file diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index fd08a152..95a3e38c 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -105,8 +105,6 @@ def get_type_dict(): fancy_type['logical'] = Type(None, "bool", "logical") fancy_type['bool'] = Type(None, "bool", "logical") - fancy_type['MO_guess'] = Type("MO_guess", "string", "character*(32)") - fancy_type['character*(32)'] = Type(None, "string", "character*(32)") fancy_type['character*(60)'] = Type(None, "string", "character*(60)") fancy_type['character*(256)'] = Type(None, "string", "character*(256)") @@ -121,16 +119,34 @@ def get_type_dict(): "logical": "logical", "string": "character*32"} - # Read and parse qptype + # Read and parse qptype generate src = qpackage_root + "/ocaml/qptypes_generator.ml" with open(src, "r") as f: - l = [i for i in f.read().splitlines() if i.strip().startswith("*")] + r = f.read() + + # Generate + l_gen = [i for i in r.splitlines() if i.strip().startswith("*")] + + # Untouch + b = r.find('let untouched = "') + e = r.find(';;', b) + + l_un = [i for i in r[b:e].splitlines() if i.strip().startswith("module")] + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + # q p _ t y p e s _ g e n e r a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # # Read the fancy_type, the ocaml. and convert the ocam to the fortran - for i in l: + for i in l_gen + l_un: str_fancy_type = i.split()[1].strip() str_ocaml_type = i.split()[3] - str_fortran_type = ocaml_to_fortran[str_ocaml_type] + + if str_ocaml_type != 'sig': + str_fortran_type = ocaml_to_fortran[str_ocaml_type] + else: + str_fortran_type = 'character*(32)' + str_ocaml_type = 'string' fancy_type[str_fancy_type] = Type(str_fancy_type, str_ocaml_type, @@ -277,7 +293,7 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_ezfio_name(dict_info['ezfio_name']) ez_p.set_output("output_%s" % dict_info['ezfio_dir']) - dict_code_provider[provider_name] = str(ez_p) + dict_code_provider[provider_name] = str(ez_p) + "\n" return dict_code_provider @@ -304,10 +320,10 @@ def save_ezfio_provider(path_head, dict_code_provider): l_output += [code for code in dict_code_provider.values()] - output = "\n\n".join(l_output) + output = "\n".join(l_output) if output != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(output) @@ -424,7 +440,7 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.close() if str_ezfio_config != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ezfio_config) @@ -453,7 +469,7 @@ def save_ezfio_default(module_lower, str_ezfio_default): f.close() if str_ezfio_default != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ezfio_default) @@ -566,7 +582,7 @@ def save_ocaml_input(module_lower, str_ocaml_input): f.close() if str_ocaml_input != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ocaml_input) diff --git a/scripts/ezfio_interface/ezfio_generate_provider.py b/scripts/ezfio_interface/ezfio_generate_provider.py index a99c0089..af4fcd6a 100755 --- a/scripts/ezfio_interface/ezfio_generate_provider.py +++ b/scripts/ezfio_interface/ezfio_generate_provider.py @@ -8,6 +8,7 @@ Creates the provider of a variable that has to be fetched from the EZFIO file. """ +import sys class EZFIO_Provider(object): @@ -27,7 +28,6 @@ BEGIN_PROVIDER [ %(type)s, %(name)s ] print *, '%(ezfio_dir)s/%(ezfio_name)s not found in EZFIO file' stop 1 endif - %(write)s END_PROVIDER """.strip() @@ -57,9 +57,12 @@ END_PROVIDER output = self.output name = self.name - l_write = [" call write_time(%(output)s)", + l_write = ["", + " call write_time(%(output)s)", " call %(write)s(%(output)s, %(name)s, &", - " '%(name)s')"] + " '%(name)s')", + ""] + self.write = "\n".join(l_write) % locals() def set_type(self, t): diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg index 3d685193..bd1d774a 100644 --- a/src/Bielec_integrals/EZFIO.cfg +++ b/src/Bielec_integrals/EZFIO.cfg @@ -5,29 +5,17 @@ interface: input default: False ezfio_name: direct -[write_ao_integrals] -type: logical -doc: Write AO integrals from disk (EZFIO folder) +[disk_access_mo_integrals] +type: Disk_access +doc: Write, Read, None for MO integrals from disk (EZFIO folder) interface: input -default: False +default: None -[write_mo_integrals] -type: logical -doc: Write MO integrals from disk (EZFIO folder) +[disk_access_ao_integrals] +type: Disk_access +doc: Write or Read or None for AO integrals from disk (EZFIO folder) interface: input -default: False - -[read_ao_integrals] -type: logical -doc: Read AO integrals from disk (EZFIO folder) -interface: input -default: False - -[read_mo_integrals] -type: logical -doc: Read MO integrals from disk (EZFIO folder) -interface: input -default: False +default: None [ao_integrals_threshold] type: Threshold diff --git a/src/Bielec_integrals/ao_bi_integrals.irp.f b/src/Bielec_integrals/ao_bi_integrals.irp.f index f2645c6d..0da76021 100644 --- a/src/Bielec_integrals/ao_bi_integrals.irp.f +++ b/src/Bielec_integrals/ao_bi_integrals.irp.f @@ -319,13 +319,6 @@ subroutine compute_ao_bielec_integrals(j,k,l,sze,buffer_value) end - - - - - - - BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ] implicit none use map_module diff --git a/src/Bielec_integrals/read_write.irp.f b/src/Bielec_integrals/read_write.irp.f new file mode 100644 index 00000000..6319641b --- /dev/null +++ b/src/Bielec_integrals/read_write.irp.f @@ -0,0 +1,41 @@ +BEGIN_PROVIDER [ logical, read_ao_integrals ] +&BEGIN_PROVIDER [ logical, read_mo_integrals ] +&BEGIN_PROVIDER [ logical, write_ao_integrals ] +&BEGIN_PROVIDER [ logical, write_mo_integrals ] + + BEGIN_DOC +! One level of abstraction for disk_access_ao_integrals and disk_access_mo_integrals + END_DOC +implicit none + + if (disk_access_ao_integrals.EQ.'Read') then + read_ao_integrals = .True. + write_ao_integrals = .False. + + else if (disk_access_ao_integrals.EQ.'Write') then + read_ao_integrals = .False. + write_ao_integrals = .True. + + else if (disk_access_ao_integrals.EQ.'None') then + read_ao_integrals = .False. + write_ao_integrals = .False. + + else if (disk_access_mo_integrals.EQ.'Read') then + read_mo_integrals = .True. + write_mo_integrals = .False. + + else if (disk_access_mo_integrals.EQ.'Write') then + read_mo_integrals = .False. + write_mo_integrals = .True. + + else if (disk_access_mo_integrals.EQ.'None') then + read_mo_integrals = .False. + write_mo_integrals = .False. + + else + print *, 'bielec_integrals/disk_acces not of a the good type' + stop "1" + + endif + +END_PROVIDER diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 47155776..5a1ed2dd 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -54,6 +54,10 @@ def get_error_message(l_exepected, l_cur): return "\n".join(l_msg) +def check_hf(geo, basis): + ezfio.bielec_integrals_disk_access_ao_integrals = "None" + + def run_hf(geo, basis): """ Run a simle by default hf @@ -86,12 +90,10 @@ def run_hf(geo, basis): # ~#~#~#~#~#~#~#~#~#~#~#~#~ # ezfio.bielec_integrals_direct = False ezfio.bielec_integrals_threshold_ao = 1.e-15 - ezfio.bielec_integrals_write_ao_integrals = False - ezfio.bielec_integrals_read_ao_integrals = False + ezfio.bielec_integrals_disk_access_ao_integrals = "None" ezfio.bielec_integrals_threshold_mo = 1.e-15 - ezfio.bielec_integrals_write_mo_integrals = False - ezfio.bielec_integrals_read_mo_integrals = False + ezfio.bielec_integrals_disk_access_mo_integrals = "None" ezfio.hartree_fock_mo_guess_type = "Huckel" ezfio.hartree_fock_thresh_scf = 1.e-10 From 780b0276ee315fecdc251b0316b989c764ea9ab2 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 1 Apr 2015 14:26:42 +0200 Subject: [PATCH 51/60] Amelioration of unit test --- src/Hartree_Fock/EZFIO.cfg | 2 +- tests/unit_test/unit_test.py | 144 +++++++++++++++++++++++++++++++---- 2 files changed, 131 insertions(+), 15 deletions(-) diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg index 87f1a878..e2b0ea5a 100644 --- a/src/Hartree_Fock/EZFIO.cfg +++ b/src/Hartree_Fock/EZFIO.cfg @@ -19,4 +19,4 @@ default: Huckel [energy] type: double precision doc: Calculated HF energy -interface: output \ No newline at end of file +interface: output diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 5a1ed2dd..eb9b1e79 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -31,8 +31,10 @@ precision = 5.e-8 global has_hf_alredy has_hf_alredy = False +global filename_check -def init_folder(geo, basis, mult=1): + +def init_folder(geo, basis, mult=1, ezfio_name=None): ''' Take a geo in arg (aka a existing geo.xyz in test/) And create the geo.ezfio with the adeguate basis and multipliciti @@ -42,10 +44,12 @@ def init_folder(geo, basis, mult=1): cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, geo) subprocess.check_call([cmd], shell=True) - cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz".format(basis, - mult, - geo) - subprocess.check_call([cmd], shell=True) + if not ezfio_name: + ezfio_name = geo + + cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz -o {3}.ezfio" + subprocess.check_call([cmd.format(basis, mult, geo, ezfio_name)], + shell=True) def get_error_message(l_exepected, l_cur): @@ -54,11 +58,98 @@ def get_error_message(l_exepected, l_cur): return "\n".join(l_msg) -def check_hf(geo, basis): - ezfio.bielec_integrals_disk_access_ao_integrals = "None" +# _ +# / |_ _ _ | o ._ ._ _|_ +# \_ | | (/_ (_ |< | | | |_) |_| |_ +# | + +def check_disk_acess(geo, basis, mult=1): + + import uuid + filename = str(uuid.uuid4()) + + # ~#~#~#~ # + # I n i t # + # ~#~#~#~ # + + init_folder(geo, basis, mult, ezfio_name=filename) + ezfio.set_file("{0}.ezfio".format(filename)) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # S e t _ p a r a m e t e r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + + # Test 1 + ezfio.bielec_integrals_disk_access_ao_integrals = "Write" + cmd = "qp_edit -c {0}.ezfio".format(filename) + subprocess.check_call([cmd], shell=True) + + # Test 2 + ezfio.bielec_integrals_disk_access_ao_integrals = "IculeAcess" + cmd = "qp_edit -c {0}.ezfio".format(filename) + + try: + subprocess.check_call([cmd], shell=True) + return_code = False + except subprocess.CalledProcessError: + return_code = True + + # ~#~#~#~#~#~#~#~ # + # F i n a l i z e # + # ~#~#~#~#~#~#~#~ # + + if return_code: + subprocess.call(["rm -R {0}.ezfio".format(filename)], shell=True) + return return_code -def run_hf(geo, basis): +def check_mo_guess(geo, basis, mult=1): + + import uuid + filename = str(uuid.uuid4()) + + # ~#~#~#~ # + # I n i t # + # ~#~#~#~ # + + init_folder(geo, basis, mult, ezfio_name=filename) + ezfio.set_file("{0}.ezfio".format(filename)) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # S e t _ p a r a m e t e r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + + # Test 1 + ezfio.hartree_fock_mo_guess_type = "Huckel" + cmd = "qp_edit -c {0}.ezfio".format(filename) + subprocess.check_call([cmd], shell=True) + + # Test 2 + ezfio.hartree_fock_mo_guess_type = "IculeGuess" + cmd = "qp_edit -c {0}.ezfio".format(filename) + + try: + subprocess.check_call([cmd], shell=True) + return_code = False + except subprocess.CalledProcessError: + return_code = True + + # ~#~#~#~#~#~#~#~ # + # F i n a l i z e # + # ~#~#~#~#~#~#~#~ # + + if return_code: + subprocess.call(["rm -R {0}.ezfio".format(filename)], shell=True) + return return_code + + +# _ +# / |_ _ _ | _. | _ _ +# \_ | | (/_ (_ |< \/ (_| | |_| (/_ _> +# + + +def run_hf(geo, basis, mult=1): """ Run a simle by default hf EZFIO path = geo.ezfio @@ -82,7 +173,7 @@ def run_hf(geo, basis): # I n i t # # ~#~#~#~ # - init_folder(geo, basis) + init_folder(geo, basis, mult) ezfio.set_file("{0}.ezfio".format(geo)) # ~#~#~#~#~#~#~#~#~#~#~#~#~ # @@ -176,18 +267,43 @@ def run_full_ci_10k_pt2_end(geo, basis): [cur_var, cur_pt2])) -def run_big_test(geo, basis): +def hf_then_10k_test(geo, basis): if not has_hf_alredy: run_hf(geo, basis) - run_full_ci_10k_pt2_end(geo, basis) - return True + try: + run_full_ci_10k_pt2_end(geo, basis) + return_code = True + except: + return_code = False + + # ~#~#~#~#~#~#~#~ # + # F i n a l i z e # + # ~#~#~#~#~#~#~#~ # + + if return_code: + subprocess.call(["rm -R {0}.ezfio".format(geo)], shell=True) + return return_code -class SimplisticTest(unittest.TestCase): +# ___ +# | _ _ _|_ +# | (/_ _> |_ +# +class ValueTest(unittest.TestCase): def test_full_ci_10k_pt2_end(self): - self.assertTrue(run_big_test("methane", "sto-3g")) + self.assertTrue(hf_then_10k_test("methane", "sto-3g")) + + +class InputTest(unittest.TestCase): + + def test_check_disk_acess(self): + self.assertTrue(check_disk_acess("methane", "un-ccemd-ref")) + + def test_check_mo_guess(self): + self.assertTrue(check_mo_guess("methane", "maug-cc-pVDZ")) + if __name__ == '__main__': unittest.main() From 1b6a3d74a13111643fcc1aeaca1a4655b0d69fda Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 1 Apr 2015 15:50:34 +0200 Subject: [PATCH 52/60] Add print into output on cisd_sc2_selection.irp.f --- src/CISD_SC2_selected/EZFIO.cfg | 4 ++-- src/CISD_SC2_selected/cisd_sc2_selection.irp.f | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/CISD_SC2_selected/EZFIO.cfg b/src/CISD_SC2_selected/EZFIO.cfg index 84cefe2f..660f9fd6 100644 --- a/src/CISD_SC2_selected/EZFIO.cfg +++ b/src/CISD_SC2_selected/EZFIO.cfg @@ -19,11 +19,11 @@ default: 0.0001 [energy] type: double precision -doc: "Calculated Full CI energy" +doc: Calculated CISD_SC2 energy of ground_state interface: output [energy_pt2] type: double precision -doc: "Calculated Full CI energy" +doc: Calculated CISD_SC2 energy+pt2 of ground_state interface: output diff --git a/src/CISD_SC2_selected/cisd_sc2_selection.irp.f b/src/CISD_SC2_selected/cisd_sc2_selection.irp.f index 1c4b2ed0..55234fcb 100644 --- a/src/CISD_SC2_selected/cisd_sc2_selection.irp.f +++ b/src/CISD_SC2_selected/cisd_sc2_selection.irp.f @@ -62,6 +62,13 @@ program cisd_sc2_selected if (abort_all) then exit endif + + ! =~=~=~=~=~=~=~=~=~=~=~=~=~! + ! W r i t e _ o n _ d i s k ! + ! =~=~=~=~=~=~=~=~=~=~=~=~=~! + + call ezfio_set_full_ci_energy(CI_SC2_energy(1)) + enddo N_det = min(n_det_max_cisd_sc2,N_det) davidson_threshold = 1.d-10 @@ -98,6 +105,12 @@ program cisd_sc2_selected print*,'Degree of excitation of this determinant : ',degree enddo + + ! =~=~=~=~=~=~=~=~=~=~=~=~=~! + ! W r i t e _ o n _ d i s k ! + ! =~=~=~=~=~=~=~=~=~=~=~=~=~! + + call ezfio_set_full_ci_energy_pt2(CI_SC2_energy(i)+pt2(i)* (1.d0 + norm_pert) - H_pert_diag(i)) endif call save_wavefunction deallocate(pt2,norm_pert,H_pert_diag) From 295579b7d9df58b06e740247cb0abd5f4b0a95c5 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 2 Apr 2015 10:20:56 +0200 Subject: [PATCH 53/60] Add docopt for a beter ei_handler.py cli --- scripts/docopt.py | 590 ++++++++++++++++++++++++++ scripts/ezfio_interface/ei_handler.py | 135 +++--- 2 files changed, 670 insertions(+), 55 deletions(-) create mode 100755 scripts/docopt.py diff --git a/scripts/docopt.py b/scripts/docopt.py new file mode 100755 index 00000000..59830d53 --- /dev/null +++ b/scripts/docopt.py @@ -0,0 +1,590 @@ +"""Pythonic command-line interface parser that will make you smile. + + * http://docopt.org + * Repository and issue-tracker: https://github.com/docopt/docopt + * Licensed under terms of MIT license (see LICENSE-MIT) + * Copyright (c) 2013 Vladimir Keleshev, vladimir@keleshev.com + +""" +import sys +import re + + +__all__ = ['docopt'] +__version__ = '0.6.1' + + +class DocoptLanguageError(Exception): + + """Error in construction of usage-message by developer.""" + + +class DocoptExit(SystemExit): + + """Exit in case user invoked program with incorrect arguments.""" + + usage = '' + + def __init__(self, message=''): + SystemExit.__init__(self, (message + '\n' + self.usage).strip()) + + +class Pattern(object): + + def __eq__(self, other): + return repr(self) == repr(other) + + def __hash__(self): + return hash(repr(self)) + + def fix(self): + self.fix_identities() + self.fix_repeating_arguments() + return self + + def fix_identities(self, uniq=None): + """Make pattern-tree tips point to same object if they are equal.""" + if not hasattr(self, 'children'): + return self + uniq = list(set(self.flat())) if uniq is None else uniq + for i, child in enumerate(self.children): + if not hasattr(child, 'children'): + assert child in uniq + self.children[i] = uniq[uniq.index(child)] + else: + child.fix_identities(uniq) + + def fix_repeating_arguments(self): + """Fix elements that should accumulate/increment values.""" + either = [list(child.children) for child in transform(self).children] + for case in either: + for e in [child for child in case if case.count(child) > 1]: + if isinstance( + e, + Argument) or isinstance( + e, + Option) and e.argcount: + if e.value is None: + e.value = [] + elif not isinstance(e.value, list): + e.value = e.value.split() + if isinstance( + e, + Command) or isinstance( + e, + Option) and e.argcount == 0: + e.value = 0 + return self + + +def transform(pattern): + """Expand pattern into an (almost) equivalent one, but with single Either. + + Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d) + Quirks: [-a] => (-a), (-a...) => (-a -a) + + """ + result = [] + groups = [[pattern]] + while groups: + children = groups.pop(0) + parents = [Required, Optional, OptionsShortcut, Either, OneOrMore] + if any(t in map(type, children) for t in parents): + child = [c for c in children if type(c) in parents][0] + children.remove(child) + if isinstance(child, Either): + for c in child.children: + groups.append([c] + children) + elif isinstance(child, OneOrMore): + groups.append(child.children * 2 + children) + else: + groups.append(child.children + children) + else: + result.append(children) + return Either(*[Required(*e) for e in result]) + + +class LeafPattern(Pattern): + + """Leaf/terminal node of a pattern tree.""" + + def __init__(self, name, value=None): + self.name, self.value = name, value + + def __repr__(self): + return '%s(%r, %r)' % (self.__class__.__name__, self.name, self.value) + + def flat(self, *types): + return [self] if not types or type(self) in types else [] + + def match(self, left, collected=None): + collected = [] if collected is None else collected + pos, match = self.single_match(left) + if match is None: + return False, left, collected + left_ = left[:pos] + left[pos + 1:] + same_name = [a for a in collected if a.name == self.name] + if type(self.value) in (int, list): + if isinstance(self.value, int): + increment = 1 + else: + increment = ([match.value] if isinstance(match.value, str) + else match.value) + if not same_name: + match.value = increment + return True, left_, collected + [match] + same_name[0].value += increment + return True, left_, collected + return True, left_, collected + [match] + + +class BranchPattern(Pattern): + + """Branch/inner node of a pattern tree.""" + + def __init__(self, *children): + self.children = list(children) + + def __repr__(self): + return '%s(%s)' % (self.__class__.__name__, + ', '.join(repr(a) for a in self.children)) + + def flat(self, *types): + if type(self) in types: + return [self] + return sum([child.flat(*types) for child in self.children], []) + + +class Argument(LeafPattern): + + def single_match(self, left): + for n, pattern in enumerate(left): + if isinstance(pattern, Argument): + return n, Argument(self.name, pattern.value) + return None, None + + @classmethod + def parse(class_, source): + name = re.findall('(<\S*?>)', source)[0] + value = re.findall('\[default: (.*)\]', source, flags=re.I) + return class_(name, value[0] if value else None) + + +class Command(Argument): + + def __init__(self, name, value=False): + self.name, self.value = name, value + + def single_match(self, left): + for n, pattern in enumerate(left): + if isinstance(pattern, Argument): + if pattern.value == self.name: + return n, Command(self.name, True) + else: + break + return None, None + + +class Option(LeafPattern): + + def __init__(self, short=None, long=None, argcount=0, value=False): + assert argcount in (0, 1) + self.short, self.long, self.argcount = short, long, argcount + self.value = None if value is False and argcount else value + + @classmethod + def parse(class_, option_description): + short, long, argcount, value = None, None, 0, False + options, _, description = option_description.strip().partition(' ') + options = options.replace(',', ' ').replace('=', ' ') + for s in options.split(): + if s.startswith('--'): + long = s + elif s.startswith('-'): + short = s + else: + argcount = 1 + if argcount: + matched = re.findall('\[default: (.*)\]', description, flags=re.I) + value = matched[0] if matched else None + return class_(short, long, argcount, value) + + def single_match(self, left): + for n, pattern in enumerate(left): + if self.name == pattern.name: + return n, pattern + return None, None + + @property + def name(self): + return self.long or self.short + + def __repr__(self): + return 'Option(%r, %r, %r, %r)' % (self.short, self.long, + self.argcount, self.value) + + +class Required(BranchPattern): + + def match(self, left, collected=None): + collected = [] if collected is None else collected + l = left + c = collected + for pattern in self.children: + matched, l, c = pattern.match(l, c) + if not matched: + return False, left, collected + return True, l, c + + +class Optional(BranchPattern): + + def match(self, left, collected=None): + collected = [] if collected is None else collected + for pattern in self.children: + m, left, collected = pattern.match(left, collected) + return True, left, collected + + +class OptionsShortcut(Optional): + + """Marker/placeholder for [options] shortcut.""" + + +class OneOrMore(BranchPattern): + + def match(self, left, collected=None): + assert len(self.children) == 1 + collected = [] if collected is None else collected + l = left + c = collected + l_ = None + matched = True + times = 0 + while matched: + # could it be that something didn't match but changed l or c? + matched, l, c = self.children[0].match(l, c) + times += 1 if matched else 0 + if l_ == l: + break + l_ = l + if times >= 1: + return True, l, c + return False, left, collected + + +class Either(BranchPattern): + + def match(self, left, collected=None): + collected = [] if collected is None else collected + outcomes = [] + for pattern in self.children: + matched, _, _ = outcome = pattern.match(left, collected) + if matched: + outcomes.append(outcome) + if outcomes: + return min(outcomes, key=lambda outcome: len(outcome[1])) + return False, left, collected + + +class Tokens(list): + + def __init__(self, source, error=DocoptExit): + self += source.split() if hasattr(source, 'split') else source + self.error = error + + @staticmethod + def from_pattern(source): + source = re.sub(r'([\[\]\(\)\|]|\.\.\.)', r' \1 ', source) + source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s] + return Tokens(source, error=DocoptLanguageError) + + def move(self): + return self.pop(0) if len(self) else None + + def current(self): + return self[0] if len(self) else None + + +def parse_long(tokens, options): + """long ::= '--' chars [ ( ' ' | '=' ) chars ] ;""" + long, eq, value = tokens.move().partition('=') + assert long.startswith('--') + value = None if eq == value == '' else value + similar = [o for o in options if o.long == long] + if tokens.error is DocoptExit and similar == []: # if no exact match + similar = [o for o in options if o.long and o.long.startswith(long)] + if len(similar) > 1: # might be simply specified ambiguously 2+ times? + raise tokens.error('%s is not a unique prefix: %s?' % + (long, ', '.join(o.long for o in similar))) + elif len(similar) < 1: + argcount = 1 if eq == '=' else 0 + o = Option(None, long, argcount) + options.append(o) + if tokens.error is DocoptExit: + o = Option(None, long, argcount, value if argcount else True) + else: + o = Option(similar[0].short, similar[0].long, + similar[0].argcount, similar[0].value) + if o.argcount == 0: + if value is not None: + raise tokens.error('%s must not have an argument' % o.long) + else: + if value is None: + if tokens.current() in [None, '--']: + raise tokens.error('%s requires argument' % o.long) + value = tokens.move() + if tokens.error is DocoptExit: + o.value = value if value is not None else True + return [o] + + +def parse_shorts(tokens, options): + """shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;""" + token = tokens.move() + assert token.startswith('-') and not token.startswith('--') + left = token.lstrip('-') + parsed = [] + while left != '': + short, left = '-' + left[0], left[1:] + similar = [o for o in options if o.short == short] + if len(similar) > 1: + raise tokens.error('%s is specified ambiguously %d times' % + (short, len(similar))) + elif len(similar) < 1: + o = Option(short, None, 0) + options.append(o) + if tokens.error is DocoptExit: + o = Option(short, None, 0, True) + else: # why copying is necessary here? + o = Option(short, similar[0].long, + similar[0].argcount, similar[0].value) + value = None + if o.argcount != 0: + if left == '': + if tokens.current() in [None, '--']: + raise tokens.error('%s requires argument' % short) + value = tokens.move() + else: + value = left + left = '' + if tokens.error is DocoptExit: + o.value = value if value is not None else True + parsed.append(o) + return parsed + + +def parse_pattern(source, options): + tokens = Tokens.from_pattern(source) + result = parse_expr(tokens, options) + if tokens.current() is not None: + raise tokens.error('unexpected ending: %r' % ' '.join(tokens)) + return Required(*result) + + +def parse_expr(tokens, options): + """expr ::= seq ( '|' seq )* ;""" + seq = parse_seq(tokens, options) + if tokens.current() != '|': + return seq + result = [Required(*seq)] if len(seq) > 1 else seq + while tokens.current() == '|': + tokens.move() + seq = parse_seq(tokens, options) + result += [Required(*seq)] if len(seq) > 1 else seq + return [Either(*result)] if len(result) > 1 else result + + +def parse_seq(tokens, options): + """seq ::= ( atom [ '...' ] )* ;""" + result = [] + while tokens.current() not in [None, ']', ')', '|']: + atom = parse_atom(tokens, options) + if tokens.current() == '...': + atom = [OneOrMore(*atom)] + tokens.move() + result += atom + return result + + +def parse_atom(tokens, options): + """atom ::= '(' expr ')' | '[' expr ']' | 'options' + | long | shorts | argument | command ; + """ + token = tokens.current() + result = [] + if token in '([': + tokens.move() + matching, pattern = {'(': [')', Required], '[': [']', Optional]}[token] + result = pattern(*parse_expr(tokens, options)) + if tokens.move() != matching: + raise tokens.error("unmatched '%s'" % token) + return [result] + elif token == 'options': + tokens.move() + return [OptionsShortcut()] + elif token.startswith('--') and token != '--': + return parse_long(tokens, options) + elif token.startswith('-') and token not in ('-', '--'): + return parse_shorts(tokens, options) + elif token.startswith('<') and token.endswith('>') or token.isupper(): + return [Argument(tokens.move())] + else: + return [Command(tokens.move())] + + +def parse_argv(tokens, options, options_first=False): + """Parse command-line argument vector. + + If options_first: + argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ; + else: + argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ; + + """ + parsed = [] + while tokens.current() is not None: + if tokens.current() == '--': + return parsed + [Argument(None, v) for v in tokens] + elif tokens.current().startswith('--'): + parsed += parse_long(tokens, options) + elif tokens.current().startswith('-') and tokens.current() != '-': + parsed += parse_shorts(tokens, options) + elif options_first: + return parsed + [Argument(None, v) for v in tokens] + else: + parsed.append(Argument(None, tokens.move())) + return parsed + + +def parse_defaults(doc): + defaults = [] + for s in parse_section('options:', doc): + # FIXME corner case "bla: options: --foo" + _, _, s = s.partition(':') # get rid of "options:" + split = re.split('\n[ \t]*(-\S+?)', '\n' + s)[1:] + split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] + options = [Option.parse(s) for s in split if s.startswith('-')] + defaults += options + return defaults + + +def parse_section(name, source): + pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', + re.IGNORECASE | re.MULTILINE) + return [s.strip() for s in pattern.findall(source)] + + +def formal_usage(section): + _, _, section = section.partition(':') # drop "usage:" + pu = section.split() + return '( ' + ' '.join(') | (' if s == pu[0] else s for s in pu[1:]) + ' )' + + +def extras(help, version, options, doc): + if help and any((o.name in ('-h', '--help')) and o.value for o in options): + print(doc.strip("\n")) + sys.exit() + if version and any(o.name == '--version' and o.value for o in options): + print(version) + sys.exit() + + +class Dict(dict): + + def __repr__(self): + return '{%s}' % ',\n '.join('%r: %r' % i for i in sorted(self.items())) + + +def docopt(doc, argv=None, help=True, version=None, options_first=False): + """Parse `argv` based on command-line interface described in `doc`. + + `docopt` creates your command-line interface based on its + description that you pass as `doc`. Such description can contain + --options, , commands, which could be + [optional], (required), (mutually | exclusive) or repeated... + + Parameters + ---------- + doc : str + Description of your command-line interface. + argv : list of str, optional + Argument vector to be parsed. sys.argv[1:] is used if not + provided. + help : bool (default: True) + Set to False to disable automatic help on -h or --help + options. + version : any object + If passed, the object will be printed if --version is in + `argv`. + options_first : bool (default: False) + Set to True to require options precede positional arguments, + i.e. to forbid options and positional arguments intermix. + + Returns + ------- + args : dict + A dictionary, where keys are names of command-line elements + such as e.g. "--verbose" and "", and values are the + parsed values of those elements. + + Example + ------- + >>> from docopt import docopt + >>> doc = ''' + ... Usage: + ... my_program tcp [--timeout=] + ... my_program serial [--baud=] [--timeout=] + ... my_program (-h | --help | --version) + ... + ... Options: + ... -h, --help Show this screen and exit. + ... --baud= Baudrate [default: 9600] + ... ''' + >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30'] + >>> docopt(doc, argv) + {'--baud': '9600', + '--help': False, + '--timeout': '30', + '--version': False, + '': '127.0.0.1', + '': '80', + 'serial': False, + 'tcp': True} + + See also + -------- + * For video introduction see http://docopt.org + * Full documentation is available in README.rst as well as online + at https://github.com/docopt/docopt#readme + + """ + argv = sys.argv[1:] if argv is None else argv + + usage_sections = parse_section('usage:', doc) + if len(usage_sections) == 0: + raise DocoptLanguageError('"usage:" (case-insensitive) not found.') + if len(usage_sections) > 1: + raise DocoptLanguageError('More than one "usage:" (case-insensitive).') + DocoptExit.usage = usage_sections[0] + + options = parse_defaults(doc) + pattern = parse_pattern(formal_usage(DocoptExit.usage), options) + # [default] syntax for argument is disabled + # for a in pattern.flat(Argument): + # same_name = [d for d in arguments if d.name == a.name] + # if same_name: + # a.value = same_name[0].value + argv = parse_argv(Tokens(argv), list(options), options_first) + pattern_options = set(pattern.flat(Option)) + for options_shortcut in pattern.flat(OptionsShortcut): + doc_options = parse_defaults(doc) + options_shortcut.children = list(set(doc_options) - pattern_options) + # if any_options: + # options_shortcut.children += [Option(o.short, o.long, o.argcount) + # for o in argv if type(o) is Option] + extras(help, version, argv, doc) + matched, left, collected = pattern.fix().match(argv) + if matched and left == []: # better error message if left? + return Dict((a.name, a.value) for a in (pattern.flat() + collected)) + raise DocoptExit() diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 95a3e38c..44a2be36 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -1,26 +1,40 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Take a path in argv -Check if EZFIO.cfg exists. -EZFIO.cfg are in MODULE directories. -create : ezfio_interface.irp.f - folder_ezfio_inteface_config -Ezfio_dir : is equal to MODULE.lower! +Welcom the ei_handler. +We will create all the ezfio related stuff from a EZFIO.cfg file. +Usage: + ei_handler.py [--path] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] +By default all the option are executed. + +Options: + -h --help + --path The path of the `EZFIO.cfg`, by default will look in the ${pwd} + --irpf90 Create the `ezfio_interface.ipf90` + who containt all the provider needed + (aka all with the `interface: input` parameter) + in `${pwd}` + --ezfio_config Create the `${module_lower}_ezfio_interface_config` in + `${QPACKAGE_ROOT}/EZFIO/config/` + This file is needed by *EZFIO* to create the `libezfio.so` + --ocaml Create the `Input_module.lower.ml` for the *qp_edit* + --ezfio_default Create the `${module_lower}_ezfio_interface_default` in + `${QPACKAGE_ROOT}/data/ezfio_defaults` needed by + the ocaml Format specification : - [provider_name] : the name of the provider in irp.f90 - - doc : Is the doc - - Type : Is a fancy_type support by the ocaml - - ezfio_name : Will be the name of the file for the ezfio - (optional by default is the name of the provider) - - interface : The provider is a imput or a output - - default : The default value if interface == input: - - size : Is the string read in ezfio.cgf who containt the size information - (like 1 or =sum(ao_num) or (ao_num,3) ) + [provider_name] | the name of the provider in irp.f90 + doc:{str} | Is the doc + Type:{str} | Is a fancy_type support by the ocaml + ezfio_name:{str} | Will be the name of the file for the ezfio + (optional by default is the name of the provider) + interface:{str} | The provider is a imput or a output + default:{str} | The default value if interface == input: + size:{str} | the size information + (like 1 or =sum(ao_num) or (ao_num,3) ) -Example EZFIO.cfg: +Example of EZFIO.cfg: ``` [thresh_SCF] doc: Threshold on the convergence of the Hartree Fock energy @@ -34,8 +48,8 @@ type: double precision doc: Calculated HF energy interface: output ``` - """ +from docopt import docopt import sys import os @@ -586,28 +600,22 @@ def save_ocaml_input(module_lower, str_ocaml_input): f.write(str_ocaml_input) -def main(): - """ - Two condition: - -Take the EZFIO.cfg path in arg - or - -Look if EZFIO.cfg is present in the pwd +if __name__ == "__main__": + arguments = docopt(__doc__) - Return : - ezfio_interface.irp.f - - folder_ezfio_inteface_config - """ + # ___ + # | ._ o _|_ + # _|_ | | | |_ + # - # ~#~#~#~# # - # I n i t # - # ~#~#~#~# # - - try: - config_file_path = sys.argv[1] - except: + if not arguments["--path"]: config_file_path = "EZFIO.cfg" if "EZFIO.cfg" not in os.listdir(os.getcwd()): sys.exit(0) + else: + config_file_path = arguments["path"] + # Get the full path config_file_path = os.path.expanduser(config_file_path) config_file_path = os.path.expandvars(config_file_path) config_file_path = os.path.abspath(config_file_path) @@ -624,34 +632,51 @@ def main(): ezfio_dir = module_lower dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir) + # _ + # / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._ + # \_ (_) (_| (/_ (_| (/_ | | (/_ | (_| |_ | (_) | | + # _| + + # ~#~#~#~#~#~#~#~#~#~ # + # W h a t _ t o _ d o # + # ~#~#~#~#~#~#~#~#~#~ # + if any([arguments[i] for i in ["--irpf90", + "--ezfio_config", + "--ocaml", + "--ezfio_default", + ]]): + # User changer somme argument, do what he want + do_all = False + else: + # Do all the stuff + do_all = True + + # ~#~#~#~#~#~#~ # + # I R P . f 9 0 # + # ~#~#~#~#~#~#~ # + + if do_all or arguments["--irpf90"]: + l_str_code = create_ezfio_provider(dict_ezfio_cfg) + save_ezfio_provider(path_dirname, l_str_code) + + # ~#~#~#~#~#~#~#~#~#~#~#~ # + # e z f i o _ c o n f i g # + # ~#~#~#~#~#~#~#~#~#~#~#~ # + + if do_all or arguments["--ezfio_config"]: + str_ezfio_config = create_ezfio_config(dict_ezfio_cfg) + save_ezfio_config(module_lower, str_ezfio_config) + # ~#~#~#~#~#~# - # O c a m l # + # O c a m l # # ~#~#~#~#~#~# str_ocaml_input = create_ocaml_input(dict_ezfio_cfg, module_lower) save_ocaml_input(module_lower, str_ocaml_input) - # ~#~#~#~#~#~#~#~# - # I R P . f 9 0 # - # ~#~#~#~#~#~#~#~# - - l_str_code = create_ezfio_provider(dict_ezfio_cfg) - save_ezfio_provider(path_dirname, l_str_code) - - # ~#~#~#~#~#~#~#~#~#~#~#~# # - # e z f i o _ c o n f i g # - # ~#~#~#~#~#~#~#~#~#~#~#~# # - - str_ezfio_config = create_ezfio_config(dict_ezfio_cfg) - save_ezfio_config(module_lower, str_ezfio_config) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - # e z f i o _ d e f a u l t # - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # e z f i o _ d e f a u l t # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) save_ezfio_default(module_lower, str_ezfio_default) - - -if __name__ == "__main__": - main() From cf31a07818faf1b5e5c212dc8bba2996a756a3ef Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 2 Apr 2015 12:30:34 +0200 Subject: [PATCH 54/60] Added gitattributes --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..99956fdc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.irp.f linguist-language=IRPF90 +*.f linguist-language=Fortran +*.ml linguist-language=Ocaml +*.sh linguist-language=Bash +*.py linguist-language=Python From 11c0013992618b8919c249dd03f27433dcd6b1c6 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 2 Apr 2015 11:30:03 +0200 Subject: [PATCH 55/60] Autobuild qp_edit.ml --- ocaml/Input.ml | 7 +- scripts/ezfio_interface/ei_handler.py | 159 ++++++++++++++---- .../ezfio_interface/ezfio_generate_ocaml.py | 159 +++++++++++++++++- .../ezfio_interface/qp_edit_template | 29 +--- 4 files changed, 293 insertions(+), 61 deletions(-) rename ocaml/qp_edit.ml => scripts/ezfio_interface/qp_edit_template (88%) diff --git a/ocaml/Input.ml b/ocaml/Input.ml index 49ac3152..01bb54a0 100644 --- a/ocaml/Input.ml +++ b/ocaml/Input.ml @@ -2,15 +2,10 @@ open Qputils;; open Qptypes;; open Core.Std;; - include Input_ao_basis;; -include Input_bielec_integrals;; include Input_bitmasks;; -include Input_cisd_sc2_selected;; include Input_determinants;; include Input_electrons;; -include Input_full_ci;; -include Input_hartree_fock;; include Input_mo_basis;; include Input_nuclei;; - +include Input_auto_generated;; \ No newline at end of file diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 44a2be36..8fad8511 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -5,14 +5,14 @@ Welcom the ei_handler. We will create all the ezfio related stuff from a EZFIO.cfg file. Usage: - ei_handler.py [--path] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] + ei_handler.py [--path] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] [--global] By default all the option are executed. Options: -h --help --path The path of the `EZFIO.cfg`, by default will look in the ${pwd} - --irpf90 Create the `ezfio_interface.ipf90` + --irpf90 Create the `ezfio_interface.ipf90` who containt all the provider needed (aka all with the `interface: input` parameter) in `${pwd}` @@ -23,6 +23,8 @@ Options: --ezfio_default Create the `${module_lower}_ezfio_interface_default` in `${QPACKAGE_ROOT}/data/ezfio_defaults` needed by the ocaml + --global Create all the stuff who need all the EZFIO.cfg + Format specification : [provider_name] | the name of the provider in irp.f90 doc:{str} | Is the doc @@ -93,7 +95,6 @@ def get_type_dict(): from os import listdir qpackage_root = os.environ['QPACKAGE_ROOT'] - fancy_type_pickle = qpackage_root + "/scripts/ezfio_interface/fancy_type.p" if fancy_type_pickle in listdir(os.getcwd()): @@ -145,7 +146,9 @@ def get_type_dict(): b = r.find('let untouched = "') e = r.find(';;', b) - l_un = [i for i in r[b:e].splitlines() if i.strip().startswith("module")] + l_un = [ + i for i in r[ + b:e].splitlines() if i.strip().startswith("module")] # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # # q p _ t y p e s _ g e n e r a t e # @@ -294,7 +297,6 @@ def create_ezfio_provider(dict_ezfio_cfg): return [code, ...] """ from ezfio_generate_provider import EZFIO_Provider - dict_code_provider = dict() ez_p = EZFIO_Provider() @@ -487,7 +489,7 @@ def save_ezfio_default(module_lower, str_ezfio_default): f.write(str_ezfio_default) -def create_ocaml_input(dict_ezfio_cfg,module_lower): +def create_ocaml_input(dict_ezfio_cfg, module_lower): # ~#~#~#~# # # I n i t # @@ -600,6 +602,93 @@ def save_ocaml_input(module_lower, str_ocaml_input): f.write(str_ocaml_input) +def create_ocaml_input_global(): + """ + Check for all the EZFIO.cfg get the module lower + then create incule {module_lower}.ml + """ + + # ~#~#~#~# # + # I n i t # + # ~#~#~#~# # + + from os import listdir + from os.path import isdir, join, exists + + mypath = "{0}/src".format(os.environ['QPACKAGE_ROOT']) + + onlyfodler = [f for f in listdir(mypath) if isdir(join(mypath, f))] + + l_module_lower = [f.lower() for f in onlyfodler + if exists("{0}/{1}/EZFIO.cfg".format(mypath, f))] + + # ~#~#~#~#~#~#~#~# # + # C r e a t i o n # + # ~#~#~#~#~#~#~#~# # + + from ezfio_generate_ocaml import EZFIO_ocaml + + qpackage_root = os.environ['QPACKAGE_ROOT'] + path = qpackage_root + "/scripts/ezfio_interface/qp_edit_template" + + with open(path, "r") as f: + template_raw = f.read() + + e = EZFIO_ocaml(l_module_lower=l_module_lower) + + template = template_raw.format(keywords=e.create_qp_keywords(), + keywords_to_string=e.create_qp_keywords_to_string(), + section_to_rst=e.create_qp_section_to_rst(), + write=e.create_qp_write(), + tasks=e.create_qp_tasks()) + + input_auto = e.create_input_auto_generated() + + return (template, input_auto) + + +def save_ocaml_input_auto(str_ocaml_input_global): + """ + Write the str_ocaml_input in + $QPACKAGE_ROOT/ocaml/Input_auto_generated.ml + """ + + path = "{0}/ocaml/Input_auto_generated.ml".format(os.environ['QPACKAGE_ROOT']) + + try: + f = open(path, "r") + except IOError: + old_output = "" + else: + old_output = f.read() + f.close() + + if str_ocaml_input_global != old_output: + with open(path, "w+") as f: + f.write(str_ocaml_input_global) + + +def save_ocaml_qp_edit(str_ocaml_qp_edit): + """ + Write the str_ocaml_qp_edit in + $QPACKAGE_ROOT/ocaml/qp_edit.ml + """ + + path = "{0}/ocaml/qp_edit.ml".format(os.environ['QPACKAGE_ROOT']) + + try: + f = open(path, "r") + except IOError: + old_output = "" + else: + old_output = f.read() + f.close() + + if str_ocaml_qp_edit != old_output: + with open(path, "w+") as f: + f.write(str_ocaml_qp_edit) + + if __name__ == "__main__": arguments = docopt(__doc__) @@ -608,29 +697,30 @@ if __name__ == "__main__": # _|_ | | | |_ # - if not arguments["--path"]: - config_file_path = "EZFIO.cfg" - if "EZFIO.cfg" not in os.listdir(os.getcwd()): - sys.exit(0) - else: - config_file_path = arguments["path"] + if not arguments["--global"]: + if not arguments["--path"]: + config_file_path = "EZFIO.cfg" + if "EZFIO.cfg" not in os.listdir(os.getcwd()): + sys.exit(0) + else: + config_file_path = arguments["path"] - # Get the full path - config_file_path = os.path.expanduser(config_file_path) - config_file_path = os.path.expandvars(config_file_path) - config_file_path = os.path.abspath(config_file_path) + # Get the full path + config_file_path = os.path.expanduser(config_file_path) + config_file_path = os.path.expandvars(config_file_path) + config_file_path = os.path.abspath(config_file_path) - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - # G e t _ m o d u l e _ d i r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # G e t _ m o d u l e _ d i r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - path_dirname = os.path.dirname(config_file_path) - module = [i for i in path_dirname.split("/") if i][-1] - module_lower = module.lower() + path_dirname = os.path.dirname(config_file_path) + module = [i for i in path_dirname.split("/") if i][-1] + module_lower = module.lower() - # Because we only authorise this right now! - ezfio_dir = module_lower - dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir) + # Because we only authorise this right now! + ezfio_dir = module_lower + dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir) # _ # / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._ @@ -644,7 +734,7 @@ if __name__ == "__main__": "--ezfio_config", "--ocaml", "--ezfio_default", - ]]): + "--global"]]): # User changer somme argument, do what he want do_all = False else: @@ -670,13 +760,22 @@ if __name__ == "__main__": # ~#~#~#~#~#~# # O c a m l # # ~#~#~#~#~#~# + if do_all or arguments["--ocaml"]: + str_ocaml_input = create_ocaml_input(dict_ezfio_cfg, module_lower) + save_ocaml_input(module_lower, str_ocaml_input) - str_ocaml_input = create_ocaml_input(dict_ezfio_cfg, module_lower) - save_ocaml_input(module_lower, str_ocaml_input) + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # e z f i o _ d e f a u l t # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + if do_all or arguments["--ezfio_default"]: + str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) + save_ezfio_default(module_lower, str_ezfio_default) # ~#~#~#~#~#~#~#~#~#~#~#~#~ # # e z f i o _ d e f a u l t # # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) - save_ezfio_default(module_lower, str_ezfio_default) + if do_all or arguments["--global"]: + str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global() + save_ocaml_input_auto(str_ocaml_input_auto) + save_ocaml_qp_edit(str_ocaml_qp_edit) diff --git a/scripts/ezfio_interface/ezfio_generate_ocaml.py b/scripts/ezfio_interface/ezfio_generate_ocaml.py index 21da15b7..25b6c55f 100755 --- a/scripts/ezfio_interface/ezfio_generate_ocaml.py +++ b/scripts/ezfio_interface/ezfio_generate_ocaml.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys +import os # If type in **kwargs from ei_handler import Type @@ -227,7 +228,8 @@ class EZFIO_ocaml(object): "let write{ "] l_template += [" {0};".format(p) for p in self.l_ezfio_name] l_template += [" } ="] - l_template += [" write_{0:<30} {0};".format(p) for p in self.l_ezfio_name] + l_template += [" write_{0:<30} {0};".format(p) + for p in self.l_ezfio_name] l_template += [";;"] # ~#~#~#~#~#~ # @@ -324,3 +326,158 @@ class EZFIO_ocaml(object): # R e t u r n # # ~#~#~#~#~#~ # return "\n ".join(l_template) + + def create_input_auto_generated(self): + """ + Generate the include of all the Input_module.lower template + """ + + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = ['open Qputils;;', + 'open Qptypes;;', + 'open Core.Std;;', + ''] + + for m in self.l_module_lower: + l_template += ["include Input_{0}".format(m)] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) + + def create_qp_keywords(self): + """ + Generate keywords template + """ + + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = ["| {0}".format(m.capitalize()) + for m in self.l_module_lower] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) + + def create_qp_keywords_to_string(self): + """ + Generate keywords to string template + """ + + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = ['| {0} -> "{0}"'.format(m.capitalize()) + for m in self.l_module_lower] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) + + def create_qp_section_to_rst(self): + """ + Generate section to rst + """ + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = [] + for m in self.l_module_lower: + m_cap = m.capitalize() + l_template += [" | {0} ->".format(m_cap), + " f {0}.(read, to_rst)".format(m_cap)] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) + + def create_qp_write(self): + """ + Generate write + """ + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + str_ = " | {0} -> write {0}.(of_rst, write) s" + l_template = [str_.format(m.capitalize()) for m in self.l_module_lower] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) + + def create_qp_tasks(self): + """ + Generate taks + """ + # ~#~#~#~#~#~#~#~ # + # C h e c k i n g # + # ~#~#~#~#~#~#~#~ # + + self.check_if_init(["l_module_lower"], + sys._getframe().f_code.co_name) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # C r e a t e _ t e m pl a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + l_template = [" {0} ; ".format(m.capitalize()) + for m in self.l_module_lower] + + # ~#~#~#~#~#~ # + # R e t u r n # + # ~#~#~#~#~#~ # + + return "\n".join(l_template) diff --git a/ocaml/qp_edit.ml b/scripts/ezfio_interface/qp_edit_template similarity index 88% rename from ocaml/qp_edit.ml rename to scripts/ezfio_interface/qp_edit_template index df7635e0..8d52acfd 100644 --- a/ocaml/qp_edit.ml +++ b/scripts/ezfio_interface/qp_edit_template @@ -11,27 +11,21 @@ open Core.Std;; (** Keywords used to define input sections *) type keyword = | Ao_basis -| Bielec_integrals -| Cisd_sc2_selected | Determinants | Electrons -| Full_ci -| Hartree_fock | Mo_basis | Nuclei +{keywords} ;; let keyword_to_string = function | Ao_basis -> "AO basis" -| Bielec_integrals -> "Two electron integrals" -| Cisd_sc2_selected -> "CISD (SC)^2" | Determinants -> "Determinants" | Electrons -> "Electrons" -| Full_ci -> "Selected Full-CI" -| Hartree_fock -> "Hartree-Fock" | Mo_basis -> "MO basis" | Nuclei -> "Molecule" +{keywords_to_string} ;; @@ -70,24 +64,17 @@ let get s = begin let open Input in match s with - | Full_ci -> - f Full_ci.(read, to_rst) - | Hartree_fock -> - f Hartree_fock.(read, to_rst) | Mo_basis -> f Mo_basis.(read, to_rst) | Electrons -> f Electrons.(read, to_rst) - | Cisd_sc2_selected -> - f Cisd_sc2_selected.(read, to_rst) | Nuclei -> f Nuclei.(read, to_rst) | Ao_basis -> f Ao_basis.(read, to_rst) - | Bielec_integrals -> - f Bielec_integrals.(read, to_rst) | Determinants -> f Determinants.(read, to_rst) +{section_to_rst} end with | Sys_error msg -> (Printf.eprintf "Info: %s\n%!" msg ; "") @@ -125,11 +112,8 @@ let set str s = in let open Input in match s with - | Hartree_fock -> write Hartree_fock.(of_rst, write) s - | Full_ci -> write Full_ci.(of_rst, write) s +{write} | Electrons -> write Electrons.(of_rst, write) s - | Cisd_sc2_selected -> write Cisd_sc2_selected.(of_rst, write) s - | Bielec_integrals -> write Bielec_integrals.(of_rst, write) s | Determinants -> write Determinants.(of_rst, write) s | Nuclei -> write Nuclei.(of_rst, write) s | Ao_basis -> () (* TODO *) @@ -176,10 +160,7 @@ let run check_only ezfio_filename = Nuclei ; Ao_basis; Electrons ; - Bielec_integrals ; - Hartree_fock ; - Cisd_sc2_selected ; - Full_ci ; +{tasks} Mo_basis; Determinants ; ] From 26e41d52a5a66f07b01e066b653dc49cdce5cbdd Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 2 Apr 2015 15:04:18 +0200 Subject: [PATCH 56/60] Fix conflicts --- src/MRCC/NEEDED_MODULES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MRCC/NEEDED_MODULES b/src/MRCC/NEEDED_MODULES index 3711786f..8ae0a127 100644 --- a/src/MRCC/NEEDED_MODULES +++ b/src/MRCC/NEEDED_MODULES @@ -1,2 +1,2 @@ -AOs BiInts Bitmask CAS_SD_selected Dets Electrons Ezfio_files Generators_CAS Generators_full Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils +AOs Bielec_integrals Bitmask CAS_SD_selected Dets Electrons Ezfio_files Generators_CAS Generators_full Hartree_Fock MOGuess MonoInts MOs Nuclei Output Perturbation Properties Selectors_full Utils From 9b2324ae51c9d29ccef35c613f97919128108965 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 7 Apr 2015 10:17:38 +0200 Subject: [PATCH 57/60] Solved problem with lowercases --- data/ezfio_defaults/q_package.ezfio_default | 33 --------------------- ocaml/Qpackage.ml | 2 +- ocaml/qp_run.ml | 4 +++ ocaml/qptypes_generator.ml | 18 ++++------- scripts/ezfio_interface/ei_handler.py | 20 ++++++------- src/Bielec_integrals/EZFIO.cfg | 10 +++---- src/CISD/cisd.irp.f | 5 +--- src/CISD_SC2_selected/EZFIO.cfg | 6 ++-- src/Dets/det_svd.irp.f | 23 ++++++++------ src/Full_CI/EZFIO.cfg | 4 +-- 10 files changed, 46 insertions(+), 79 deletions(-) diff --git a/data/ezfio_defaults/q_package.ezfio_default b/data/ezfio_defaults/q_package.ezfio_default index 5da4d813..9d9604d8 100644 --- a/data/ezfio_defaults/q_package.ezfio_default +++ b/data/ezfio_defaults/q_package.ezfio_default @@ -1,12 +1,3 @@ -bielec_integrals - read_ao_integrals False - read_mo_integrals False - write_ao_integrals False - write_mo_integrals False - threshold_ao 1.e-15 - threshold_mo 1.e-15 - direct False - cis_dressed n_state_cis 10 n_core_cis 0 @@ -25,13 +16,6 @@ determinants s2_eig False only_single_double_dm False -full_ci - n_det_max_fci 10000 - n_det_max_fci_property 50000 - pt2_max 1.e-4 - do_pt2_end True - var_pt2_ratio 0.75 - all_singles n_det_max_fci 50000 pt2_max 1.e-8 @@ -41,20 +25,3 @@ cassd n_det_max_cassd 10000 pt2_max 1.e-4 do_pt2_end True - -hartree_fock - n_it_scf_max 200 - thresh_scf 1.e-10 - guess "Huckel" - -cisd_selected - n_det_max_cisd 10000 - pt2_max 1.e-4 - -cisd_sc2_selected - n_det_max_cisd_sc2 10000 - pt2_max 1.e-4 - do_pt2_end True - -properties - z_one_point 3.9 diff --git a/ocaml/Qpackage.ml b/ocaml/Qpackage.ml index 4d08192a..a3862f11 100644 --- a/ocaml/Qpackage.ml +++ b/ocaml/Qpackage.ml @@ -94,7 +94,7 @@ let get_ezfio_default_in_file ~directory ~data ~filename = match (String.lsplit2 ~on:' ' (String.strip line)) with | Some (l,r) -> if (l = data) then - String.lowercase (String.strip r) + String.strip r else find_data rest | None -> raise Not_found diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index 341a4ce6..2abea107 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -20,6 +20,10 @@ let run exe ezfio_file = Printf.printf "===============\nQuantum Package\n===============\n\n"; Printf.printf "Date : %s\n\n%!" (Time.to_string time_start); + match (Sys.command ("qp_edit -c "^ezfio_file)) with + | 0 -> () + | i -> failwith "Error: Input inconsistent\n"; + ; let exe = match (List.find ~f:(fun (x,_) -> x = exe) executables) with | None -> assert false diff --git a/ocaml/qptypes_generator.ml b/ocaml/qptypes_generator.ml index 633727f8..fd1739f1 100644 --- a/ocaml/qptypes_generator.ml +++ b/ocaml/qptypes_generator.ml @@ -150,15 +150,12 @@ end = struct let to_string = function | Huckel -> \"Huckel\" - | HCore -> \"HCore\" + | HCore -> \"Hcore\" let of_string s = - let s = - String.lowercase s - in match s with - | \"huckel\" -> Huckel - | \"hcore\" -> HCore + | \"Huckel\" -> Huckel + | \"Hcore\" -> HCore | _ -> failwith (\"Wrong Guess type : \"^s) end @@ -179,13 +176,10 @@ end = struct | Write -> \"Write\" | None -> \"None\" let of_string s = - let s = - String.lowercase s - in match s with - | \"read\" -> Read - | \"write\" -> Write - | \"none\" -> None + | \"Read\" -> Read + | \"Write\" -> Write + | \"None\" -> None | _ -> failwith (\"Wrong IO type : \"^s) end diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 8fad8511..4adf85b9 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -12,8 +12,8 @@ By default all the option are executed. Options: -h --help --path The path of the `EZFIO.cfg`, by default will look in the ${pwd} - --irpf90 Create the `ezfio_interface.ipf90` - who containt all the provider needed + --irpf90 Create the `ezfio_interface.irpf90` + which contains all the providers needed (aka all with the `interface: input` parameter) in `${pwd}` --ezfio_config Create the `${module_lower}_ezfio_interface_config` in @@ -28,7 +28,7 @@ Options: Format specification : [provider_name] | the name of the provider in irp.f90 doc:{str} | Is the doc - Type:{str} | Is a fancy_type support by the ocaml + Type:{str} | Is a fancy_type supported by the ocaml ezfio_name:{str} | Will be the name of the file for the ezfio (optional by default is the name of the provider) interface:{str} | The provider is a imput or a output @@ -67,13 +67,13 @@ Type = namedtuple('Type', 'fancy ocaml fortran') def is_bool(str_): """ - Take a string, if is a bool return the convert into - fortran and ocaml one. + Take a string, if is a bool return the conversion into + fortran and ocaml. """ if str_.lower() in ['true', '.true.']: - return Type(None, "True", ".True.") - elif str_.lower() in ['false', '.False.']: - return Type(None, "False", ".False") + return Type(None, "true", ".True.") + elif str_.lower() in ['false', '.false.']: + return Type(None, "false", ".False") else: raise TypeError @@ -81,7 +81,7 @@ def is_bool(str_): def get_type_dict(): """ This function makes the correspondance between the type of value read in - ezfio.cfg into the f90 and Ocam Type + ezfio.cfg into the f90 and Ocaml Type return fancy_type[fancy_type] = namedtuple('Type', 'ocaml fortran') For example fancy_type['Ndet'].fortran = interger .ocaml = int @@ -154,7 +154,7 @@ def get_type_dict(): # q p _ t y p e s _ g e n e r a t e # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - # Read the fancy_type, the ocaml. and convert the ocam to the fortran + # Read the fancy_type, the ocaml. and convert the ocaml to the fortran for i in l_gen + l_un: str_fancy_type = i.split()[1].strip() str_ocaml_type = i.split()[3] diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg index bd1d774a..eaada232 100644 --- a/src/Bielec_integrals/EZFIO.cfg +++ b/src/Bielec_integrals/EZFIO.cfg @@ -7,26 +7,26 @@ ezfio_name: direct [disk_access_mo_integrals] type: Disk_access -doc: Write, Read, None for MO integrals from disk (EZFIO folder) +doc: Read/Write MO integrals from/to disk [ Write | Read | None ] interface: input default: None [disk_access_ao_integrals] type: Disk_access -doc: Write or Read or None for AO integrals from disk (EZFIO folder) +doc: Read/Write AO integrals from/to disk [ Write | Read | None ] interface: input default: None [ao_integrals_threshold] type: Threshold -doc: If < ao_integrals_threshold then is null +doc: If || < ao_integrals_threshold then is zero interface: input default: 1.e-15 ezfio_name: threshold_ao [mo_integrals_threshold] type: Threshold -doc: If < ao_integrals_threshold then is null +doc: If || < ao_integrals_threshold then is zero interface: input default: 1.e-15 -ezfio_name: threshold_mo \ No newline at end of file +ezfio_name: threshold_mo diff --git a/src/CISD/cisd.irp.f b/src/CISD/cisd.irp.f index 0b6bc9fd..cfa21005 100644 --- a/src/CISD/cisd.irp.f +++ b/src/CISD/cisd.irp.f @@ -13,8 +13,5 @@ program cisd print *, 'E_corr = ',CI_electronic_energy(i) - ref_bitmask_energy enddo -! call CISD_SC2(psi_det,psi_coef,eigvalues,size(psi_coef,1),N_det,N_states,N_int) -! do i = 1, N_states -! print*,'eigvalues(i) = ',eigvalues(i) -! enddo + call save_wavefunction end diff --git a/src/CISD_SC2_selected/EZFIO.cfg b/src/CISD_SC2_selected/EZFIO.cfg index 660f9fd6..a97e2d76 100644 --- a/src/CISD_SC2_selected/EZFIO.cfg +++ b/src/CISD_SC2_selected/EZFIO.cfg @@ -1,6 +1,6 @@ [N_det_max_cisd_sc2] type: Det_number_max -doc: Get n_det_max_cisd_sc2 from EZFIO file +doc: Max number of determinants interface: input default: 10000 @@ -12,8 +12,8 @@ default: true [PT2_max] type: PT2_energy -doc: The selection process stops when the largest PT2 (for all the state) is lower - than pt2_max in absolute value +doc: The selection process stops when the largest PT2 (for all the states) is lower + than abs(pt2_max) interface: input default: 0.0001 diff --git a/src/Dets/det_svd.irp.f b/src/Dets/det_svd.irp.f index 8365b42c..0a57acf3 100644 --- a/src/Dets/det_svd.irp.f +++ b/src/Dets/det_svd.irp.f @@ -3,7 +3,7 @@ program det_svd BEGIN_DOC ! Computes the SVD of the Alpha x Beta determinant coefficient matrix END_DOC - integer :: i,j + integer :: i,j,k read_wf = .True. TOUCH read_wf @@ -40,17 +40,22 @@ program det_svd print *, 'N_det_alpha = ', N_det_alpha_unique print *, 'N_det_beta = ', N_det_beta_unique print *, '' - -! do i=1,N_det_alpha_unique -! do j=1,N_det_beta_unique -! print *, i,j,psi_svd_matrix(i,j,:) -! enddo -! enddo - print *, '' + call diagonalize_ci print *, 'Energy = ', ci_energy + + do i=1,N_det_alpha_unique + do j=1,N_det_beta_unique + do k=1,N_states + if (dabs(psi_svd_matrix(i,j,k)) < 1.d-15) then + psi_svd_matrix(i,j,k) = 0.d0 + endif + enddo + enddo + enddo + print *, '' print *, psi_svd_coefs(1:20,1) -! call save_wavefunction + call save_wavefunction end diff --git a/src/Full_CI/EZFIO.cfg b/src/Full_CI/EZFIO.cfg index 30528fd8..f59e094f 100644 --- a/src/Full_CI/EZFIO.cfg +++ b/src/Full_CI/EZFIO.cfg @@ -32,11 +32,11 @@ default: 0.75 [energy] type: double precision -doc: "Calculated Full CI energy" +doc: Calculated Selected FCI energy interface: output [energy_pt2] type: double precision -doc: "Calculated Full CI energy" +doc: Calculated FCI energy + PT2 interface: output From dcd9310033b4004dece52ec0d7a7e395568ac210 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 7 Apr 2015 10:25:39 +0200 Subject: [PATCH 58/60] Solved problem with lowercases --- data/ezfio_defaults/determinants.ezfio_default | 6 +++--- data/ezfio_defaults/q_package.ezfio_default | 16 +++------------- scripts/ezfio_with_default.py | 2 ++ src/MRCC/mrcc.irp.f | 15 +++++++-------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/data/ezfio_defaults/determinants.ezfio_default b/data/ezfio_defaults/determinants.ezfio_default index 42f6b384..2cfbe3ea 100644 --- a/data/ezfio_defaults/determinants.ezfio_default +++ b/data/ezfio_defaults/determinants.ezfio_default @@ -4,6 +4,6 @@ determinants n_det_max_jacobi 1000 threshold_generators 0.99 threshold_selectors 0.999 - read_wf False - s2_eig False - only_single_double_dm False + read_wf false + s2_eig false + only_single_double_dm false diff --git a/data/ezfio_defaults/q_package.ezfio_default b/data/ezfio_defaults/q_package.ezfio_default index 9d9604d8..8a527b95 100644 --- a/data/ezfio_defaults/q_package.ezfio_default +++ b/data/ezfio_defaults/q_package.ezfio_default @@ -2,24 +2,14 @@ cis_dressed n_state_cis 10 n_core_cis 0 n_act_cis mo_basis_mo_tot_num - mp2_dressing False + mp2_dressing false standard_doubles True - en_2_2 False - -determinants - n_states 1 - n_states_diag determinants_n_states - n_det_max_jacobi 1000 - threshold_generators 0.99 - threshold_selectors 0.999 - read_wf False - s2_eig False - only_single_double_dm False + en_2_2 false all_singles n_det_max_fci 50000 pt2_max 1.e-8 - do_pt2_end False + do_pt2_end false cassd n_det_max_cassd 10000 diff --git a/scripts/ezfio_with_default.py b/scripts/ezfio_with_default.py index 46981132..0ee41935 100755 --- a/scripts/ezfio_with_default.py +++ b/scripts/ezfio_with_default.py @@ -121,6 +121,8 @@ END_PROVIDER v = buffer[1] name = self.name try: + true = True + false = False v_eval = eval(v) if type(v_eval) == bool: v = '.%s.'%(v) diff --git a/src/MRCC/mrcc.irp.f b/src/MRCC/mrcc.irp.f index 663b9f5a..b5188632 100644 --- a/src/MRCC/mrcc.irp.f +++ b/src/MRCC/mrcc.irp.f @@ -12,7 +12,6 @@ subroutine run print *, N_det_cas print *, N_det_sd -! call update_generators integer :: i print *, 'CAS' print *, '===' @@ -21,13 +20,13 @@ subroutine run call debug_det(psi_cas(1,1,i),N_int) enddo -! print *, 'SD' -! print *, '==' -! do i=1,N_det_sd -! print *, psi_sd_coefs(i,:) -! call debug_det(psi_sd(1,1,i),N_int) -! enddo -! + print *, 'SD' + print *, '==' + do i=1,N_det_sd + print *, psi_sd_coefs(i,:) + call debug_det(psi_sd(1,1,i),N_int) + enddo + print *, 'MRCC' print *, '====' print *, ci_energy(:) From 4ea60695ea90aded67b015161828f7d7ec6cb3bb Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 9 Apr 2015 14:03:24 +0200 Subject: [PATCH 59/60] Add Patch requirement for OPEM --- INSTALL.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 712e3d8f..47319c9c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,8 +6,9 @@ * m4 * GNU make * Fortran compiler (ifort or gfortran are tested) -* Python >= 2.7 +* Python >= 2.6 * Bash +* Patch (for opam) ## Standard installation From 7d7626df53072889d6752174b567e6cb869962bb Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Apr 2015 19:32:35 +0200 Subject: [PATCH 60/60] Cleaning --- .../WILL_BE_DELETED.ezfio_default | 7 +- data/ezfio_defaults/q_package.ezfio_default | 23 -- scripts/create_rst_templates.sh | 2 + scripts/ezfio_interface.py | 333 ------------------ setup_environment.sh | 10 - src/MRCC/README.rst | 87 +---- 6 files changed, 10 insertions(+), 452 deletions(-) delete mode 100644 data/ezfio_defaults/q_package.ezfio_default delete mode 100755 scripts/ezfio_interface.py diff --git a/data/ezfio_defaults/WILL_BE_DELETED.ezfio_default b/data/ezfio_defaults/WILL_BE_DELETED.ezfio_default index 79f0f114..cf54a1dd 100644 --- a/data/ezfio_defaults/WILL_BE_DELETED.ezfio_default +++ b/data/ezfio_defaults/WILL_BE_DELETED.ezfio_default @@ -43,11 +43,6 @@ all_singles pt2_max 1.e-8 do_pt2_end False -cassd - n_det_max_cassd 10000 - pt2_max 1.e-4 - do_pt2_end True - hartree_fock n_it_scf_max 200 thresh_scf 1.e-10 @@ -63,4 +58,4 @@ cisd_sc2_selected do_pt2_end True properties - z_one_point 3.9 \ No newline at end of file + z_one_point 3.9 diff --git a/data/ezfio_defaults/q_package.ezfio_default b/data/ezfio_defaults/q_package.ezfio_default deleted file mode 100644 index 89c948fc..00000000 --- a/data/ezfio_defaults/q_package.ezfio_default +++ /dev/null @@ -1,23 +0,0 @@ -cis_dressed - n_state_cis 10 - n_core_cis 0 - n_act_cis mo_basis_mo_tot_num - mp2_dressing false - standard_doubles True - en_2_2 false - -cas_sd - n_det_max_cas_sd 100000 - pt2_max 1.e-4 - do_pt2_end True - var_pt2_ratio 0.75 - -all_singles - n_det_max_fci 50000 - pt2_max 1.e-8 - do_pt2_end false - -cassd - n_det_max_cassd 10000 - pt2_max 1.e-4 - do_pt2_end True diff --git a/scripts/create_rst_templates.sh b/scripts/create_rst_templates.sh index 931701ee..4d85b827 100755 --- a/scripts/create_rst_templates.sh +++ b/scripts/create_rst_templates.sh @@ -12,6 +12,8 @@ fi source ${QPACKAGE_ROOT}/scripts/qp_include.sh check_current_dir_is_module +MODULE=$(basename $PWD) + README="True" if [[ -f README.rst ]] diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py deleted file mode 100755 index 7c196cf8..00000000 --- a/scripts/ezfio_interface.py +++ /dev/null @@ -1,333 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -Take a path in argv -Check if EZFIO.cfg exists. -EZFIO.cfg are in MODULE directories. -create : ezfio_interface.irp.f - folder_ezfio_inteface_config - -Example EZFIO.cfg: -``` -[thresh_SCF] -doc: Threshold on the convergence of the Hartree Fock energy -type: Threshold -default: 1.e-10 - -[do_pt2_end] -type: logical -doc: If true, compute the PT2 at the end of the selection -default: true -``` - -""" - -import sys -import os -import os.path - -import ConfigParser - -from collections import defaultdict -from collections import namedtuple - -Type = namedtuple('Type', 'ocaml fortran') -def bool_convertor(b): - return ( b.lower() in [ "true", ".true." ] ) - - -def get_type_dict(): - """ - This function makes the correspondance between the type of value read in - ezfio.cfg into the f90 and Ocam Type - return fancy_type[fancy_type] = namedtuple('Type', 'ocaml fortran') - For example fancy_type['Ndet'].fortran = interger - .ocaml = int - """ - - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - # Dict to change ocaml LowLevel type into FortranLowLevel type - ocaml_to_fortran = {"int": "integer", - "float": "double precision", - "logical": "logical", - "string": "character*60"} - - fancy_type = defaultdict(dict) - - # ~#~#~#~#~#~#~#~ # - # R a w _ t y p e # - # ~#~#~#~#~#~#~#~ # - - fancy_type['integer'] = Type("int", "integer") - fancy_type['int'] = Type("int", "integer") - - fancy_type['float'] = Type("float", "double precision") - fancy_type['double precision'] = Type("float", "double precision") - - fancy_type['logical'] = Type("bool", "logical") - fancy_type['bool'] = Type("bool", "logical") - - # ~#~#~#~#~#~#~#~ # - # q p _ t y p e s # - # ~#~#~#~#~#~#~#~ # - - src = os.environ['QPACKAGE_ROOT'] + "/ocaml/qptypes_generator.ml" - - with open(src, "r") as f: - l = [i for i in f.read().splitlines() if i.strip().startswith("*")] - - for i in l: - ocaml_fancy_type = i.split()[1].strip() - ocaml_type = i.split()[3] - fortran_type = ocaml_to_fortran[ocaml_type] - - fancy_type[ocaml_fancy_type] = Type(ocaml_type, fortran_type) - - return dict(fancy_type) - - -type_dict = get_type_dict() - - -def get_dict_config_file(config_file_path, module_lower): - """ - Input: - config_file_path is the config file path - (for example FULL_PATH/EZFIO.cfg) - module_lower is the MODULE name lowered - (Ex fullci) - - Return a dict d[provider_name] = {type, - doc, - ezfio_name, - ezfio_dir, - interface, - default} - - Type : Is a fancy_type named typle who containt fortran and ocaml type - doc : Is the doc - ezfio_name : Will be the name of the file - ezfio_dir : Will be the folder who containt the ezfio_name - * /ezfio_dir/ezfio_name - * equal to MODULE_lower name for the moment. - interface : The provider is a imput or a output - if is a output: - default : The default value - - """ - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - d = defaultdict(dict) - l_info_required = ["doc", "interface"] - l_info_optional = ["ezfio_name"] - - # ~#~#~#~#~#~#~#~#~#~#~ # - # L o a d _ C o n f i g # - # ~#~#~#~#~#~#~#~#~#~#~ # - - config_file = ConfigParser.ConfigParser() - config_file.readfp(open(config_file_path)) - - # ~#~#~#~#~#~#~#~#~ # - # F i l l _ d i c t # - # ~#~#~#~#~#~#~#~#~ # - - def error(o, p, c): - "o option ; p provider_name ;c config_file_path" - print "You need a {0} for {1} in {2}".format(o, p, c) - - for section in config_file.sections(): - # pvd = provider - pvd = section.lower() - - # Create the dictionary who containt the value per default - d_default = {"ezfio_name": pvd} - - # Set the ezfio_dir - d[pvd]["ezfio_dir"] = module_lower - - # Check if type if avalaible - type_ = config_file.get(section, "type") - if type_ not in type_dict: - print "{0} not avalaible. Choose in:".format(type_) - print ", ".join([i for i in type_dict]) - sys.exit(1) - else: - d[pvd]["type"] = type_dict[type_] - - # Fill the dict with REQUIRED information - for option in l_info_required: - try: - d[pvd][option] = config_file.get(section, option) - except ConfigParser.NoOptionError: - error(option, pvd, config_file_path) - sys.exit(1) - - # Fill the dict with OPTIONAL information - for option in l_info_optional: - try: - d[pvd][option] = config_file.get(section, option).lower() - except ConfigParser.NoOptionError: - d[pvd][option] = d_default[option] - - # If interface is output we need a default value information - if d[pvd]["interface"] == "input": - try: - d[pvd]["default"] = config_file.get(section, "default") - except ConfigParser.NoOptionError: - error("default", pvd, config_file_path) - sys.exit(1) - - return dict(d) - - -def create_ezfio_provider(dict_ezfio_cfg): - """ - From dict d[provider_name] = {type, - doc, - ezfio_name, - ezfio_dir, - interface, - default} - create the a list who containt all the code for the provider - return [code, ...] - """ - from ezfio_with_default import EZFIO_Provider - - dict_code_provider = dict() - - ez_p = EZFIO_Provider() - for provider_name, dict_info in dict_ezfio_cfg.iteritems(): - if "default" in dict_info: - ez_p.set_type(dict_info['type'].fortran) - ez_p.set_name(provider_name) - ez_p.set_doc(dict_info['doc']) - ez_p.set_ezfio_dir(dict_info['ezfio_dir']) - ez_p.set_ezfio_name(dict_info['ezfio_name']) - ez_p.set_default(dict_info['default']) - ez_p.set_output("output_%s" % dict_info['ezfio_dir']) - - dict_code_provider[provider_name] = str(ez_p) - - return dict_code_provider - - -def save_ezfio_provider(path_head, dict_code_provider): - """ - Write in path_head/"ezfio_interface.irp.f" the value of dict_code_provider - """ - - path = "{0}/ezfio_interface.irp.f".format(path_head) - -# print "Path = {}".format(path) - - try: - f = open(path, "r") - except IOError: - old_output = "" - else: - old_output = f.read() - f.close() - - output = "! DO NOT MODIFY BY HAND\n" + \ - "! Created by $QPACKAGE_ROOT/scripts/ezfio_interface.py\n" + \ - "! from file {0}/EZFIO.cfg\n".format(path_head) + \ - "\n" - for provider_name, code in dict_code_provider.iteritems(): - output += str(code) + "\n" - - if output != old_output: - with open(path, "w") as f: - f.write(output) - - -def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): - """ - From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} - Return the string ezfio_interface_config - """ - - result = [module_lower] - lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 - l = sorted(dict_ezfio_cfg.keys()) - for provider_name in l: - provider_info = dict_ezfio_cfg[provider_name] - s = " {0} {1}".format( - provider_name.lower().ljust(lenmax), - provider_info["type"].fortran) - result.append(s) - return "\n".join(result) - - -def save_ezfio_config(module_lower, str_ezfio_config): - """ - Write the str_ezfio_config in - $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) - """ - - ezfio_dir = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) - path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir, - module_lower) - -# print "Path = {}".format(path) - - try: - f = open(path, "r") - except IOError: - old_output = "" - else: - old_output = f.read() - f.close() - - if str_ezfio_config != old_output: - with open(path, "w") as f: - f.write(str_ezfio_config) - - -def main(): - """ - Two condition: - -Take the EZFIO.cfg path in arg - or - -Look if EZFIO.cfg is present in the pwd - """ - - try: - config_file_path = sys.argv[1] - except: - config_file_path = "EZFIO.cfg" - if "EZFIO.cfg" not in os.listdir(os.getcwd()): - sys.exit(0) - - config_file_path = os.path.expanduser(config_file_path) - config_file_path = os.path.expandvars(config_file_path) - config_file_path = os.path.abspath(config_file_path) -# print config_file_path - - path_dirname = os.path.dirname(config_file_path) - module = [i for i in path_dirname.split("/") if i][-1] - module_lower = module.lower() - -# print "Read {0}".format(config_file_path) - dict_info_provider = get_dict_config_file(config_file_path, module_lower) - -# print "Generating the ezfio_interface.irp.f: \n" - d_config = create_ezfio_provider(dict_info_provider) - -# print "Saving the ezfio_interface.irp.f" - save_ezfio_provider(path_dirname, d_config) - -# print "Generating the ezfio_config" - config_ezfio = create_ezfio_config(dict_info_provider, "config", module_lower) - -# print "Saving ezfio_config" - save_ezfio_config(module_lower, config_ezfio) - - -if __name__ == "__main__": - main() diff --git a/setup_environment.sh b/setup_environment.sh index c3dc4194..be4bae64 100755 --- a/setup_environment.sh +++ b/setup_environment.sh @@ -48,16 +48,6 @@ then fi -echo "${BLUE}===== Installing EZFIO ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install_ezfio.sh | tee install_ezfio.log - -if [[ ! -d ${QPACKAGE_ROOT}/EZFIO ]] -then - echo $RED "Error in EZFIO installation" $BLACK - exit 1 -fi - - echo "${BLUE}===== Installing Zlib ===== ${BLACK}" ${QPACKAGE_ROOT}/scripts/install_zlib.sh | tee install_zlib.log diff --git a/src/MRCC/README.rst b/src/MRCC/README.rst index 3720884a..73518f88 100644 --- a/src/MRCC/README.rst +++ b/src/MRCC/README.rst @@ -1,82 +1,9 @@ -E(CAS+SD) = -3.93510180989509 - - -0.726935163332 - ++++---- - ++++---- - - 0.685482292841 - +++-+--- - +++-+--- - - 0.0409791961003 - ++-+-+-- - ++-+-+-- - -c2*c3/c1 = -0.038642391672 - - - -0.996413146877 - ++++---- - ++++---- - - -0.0598366139154 - ++-+-+-- - +++-+--- - - -0.0598366139154 - +++-+--- - ++-+-+-- - - -======= - - 0.706616635698 - +++-+--- - +++-+--- - - -0.692594178414 - ++++---- - ++++---- - - -0.0915716740265 - ++-+-+-- - +++-+--- - - -0.0915716740265 - +++-+--- - ++-+-+-- - - 0.0461418323107 - ++-+-+-- - ++-+-+-- - - -0.0458957789452 - ++--++-- - ++--++-- - - ----- - - 0.713102867186 - ++++---- - ++++---- - - -0.688067688244 - +++-+--- - +++-+--- - - 0.089262694488 - +++-+--- - ++-+-+-- - - 0.089262694488 - ++-+-+-- - +++-+--- - - -0.0459510603899 - ++-+-+-- - ++-+-+-- - - +=========== +MRCC Module +=========== +Needed Modules +============== +Documentation +=============