10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-22 18:57:31 +02:00

INPORTANT

Add interface : output or interface : input in EZFIO.cfg
Update INSTALL.md
Clean ezfio_interface.py
This commit is contained in:
Thomas Applencourt 2015-03-25 15:26:53 +01:00
parent 07f47915e8
commit 7332f5c655
3 changed files with 129 additions and 78 deletions

View File

@ -3,24 +3,27 @@
## Requirements ## Requirements
* curl * curl
* wget
* m4 * m4
* GNU make * GNU make
* Intel Fortran compiler * Fortran compiler (ifort or gfortran)
* Python * Python 2.7 or new
* Bash * Bash
By default, the Ocaml compiler will be installed in `$HOME/ocamlbrew`. ## Installing <<Normaly>>
To install it somewhere else, set the `$OCAMLBREW_BASE` environment
variable to the required destination, for example:
export OCAMLBREW_BASE=/usr/local/ocamlbrew 1) Run `./setup_environment.sh`
It will doawnload and install all the requirement
(Installing OCaml will take somme time 20min)
For more info about the Ocaml installation, check the ocamlbrew 2) `source /home/razoa/quantum_package/quantum_package.rc`
website : https://github.com/hcarty/ocamlbrew It containt all the environement variable neeeded by the quantum package
3) Create the Makefile.config who containt all the flag needed by the compilator.
(`cp ./src/Makefile.config.gfortran ./src/Makefile.config`)
4) make build
It will compile all the fortran
## Installing behind a firewall ## Installing behind a firewall

View File

@ -32,8 +32,6 @@ from collections import defaultdict
from collections import namedtuple from collections import namedtuple
Type = namedtuple('Type', 'ocaml fortran') Type = namedtuple('Type', 'ocaml fortran')
def bool_convertor(b):
return ( b.lower() in [ "true", ".true." ] )
def get_type_dict(): def get_type_dict():
@ -92,18 +90,39 @@ def get_type_dict():
type_dict = get_type_dict() type_dict = get_type_dict()
def get_dict_config_file(config_file_path,folder): def get_dict_config_file(config_file_path, module_lower):
""" """
Read a ezfio.cfg Input:
Return a dict d[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} 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 # # I n i t #
# ~#~#~#~ # # ~#~#~#~ #
d = defaultdict(dict) d = defaultdict(dict)
list_option_required = ["default", "doc"] l_info_required = ["doc", "interface"]
list_option = ["ezfio_name", "output"] l_info_optional = ["ezfio_name"]
# ~#~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~#~ #
# L o a d _ C o n f i g # # L o a d _ C o n f i g #
@ -116,43 +135,63 @@ def get_dict_config_file(config_file_path,folder):
# F i l l _ d i c t # # F i l l _ d i c t #
# ~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~ #
provider_names = config_file.sections() def error(o, p, c):
for p in provider_names: "o option ; p provider_name ;c config_file_path"
provider_name = p.lower() print "You need a {0} for {1} in {2}".format(o, p, c)
default_d = {"ezfio_name": provider_name, "output": "false" }
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 # Check if type if avalaible
type_ = config_file.get(p, "type") type_ = config_file.get(section, "type")
if type_ not in type_dict: if type_ not in type_dict:
print "{0} not avalaible. Choose in:".format(type_) print "{0} not avalaible. Choose in:".format(type_)
print ", ".join([i for i in type_dict]) print ", ".join([i for i in type_dict])
sys.exit(1) sys.exit(1)
else: else:
d[provider_name]["type"] = type_dict[type_] d[pvd]["type"] = type_dict[type_]
# Fill the dict with allother the information # Fill the dict with REQUIRED information
for k in list_option_required: for option in l_info_required:
try: try:
d[provider_name][k] = config_file.get(p, k) d[pvd][option] = config_file.get(section, option)
except ConfigParser.NoOptionError: except ConfigParser.NoOptionError:
print "You need a {0} for {1} in {2}".format(k, error(option, pvd, config_file_path)
provider_name, sys.exit(1)
config_file_path)
d[provider_name]["ezfio_dir"] = folder
for k in list_option:
try:
d[provider_name][k] = config_file.get(p, k).lower()
except ConfigParser.NoOptionError:
d[provider_name][k] = default_d[k]
# Convert string to bool # Fill the dict with OPTIONAL information
d[provider_name]["output"] = bool_convertor(d[provider_name]["output"]) 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"] == "output":
try:
d[pvd]["default"] = config_file.get(section, "default")
except ConfigParser.NoOptionError:
error("default", pvd, config_file_path)
sys.exit(1)
return dict(d) return dict(d)
def create_ezfio_provider(dict_ezfio_cfg): def create_ezfio_provider(dict_ezfio_cfg):
""" """
From dict d[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} 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 create the a list who containt all the code for the provider
return [code, ...] return [code, ...]
""" """
@ -162,7 +201,7 @@ def create_ezfio_provider(dict_ezfio_cfg):
ez_p = EZFIO_Provider() ez_p = EZFIO_Provider()
for provider_name, dict_info in dict_ezfio_cfg.iteritems(): for provider_name, dict_info in dict_ezfio_cfg.iteritems():
if not dict_info["output"]: if "default" in dict_info:
ez_p.set_type(dict_info['type'].fortran) ez_p.set_type(dict_info['type'].fortran)
ez_p.set_name(provider_name) ez_p.set_name(provider_name)
ez_p.set_doc(dict_info['doc']) ez_p.set_doc(dict_info['doc'])
@ -178,8 +217,7 @@ def create_ezfio_provider(dict_ezfio_cfg):
def save_ezfio_provider(path_head, dict_code_provider): def save_ezfio_provider(path_head, dict_code_provider):
""" """
Write in "ezfio_interface.irp.f" the Write in path_head/"ezfio_interface.irp.f" the value of dict_code_provider
value of dict_code_provider
""" """
path = "{0}/ezfio_interface.irp.f".format(path_head) path = "{0}/ezfio_interface.irp.f".format(path_head)
@ -195,74 +233,79 @@ def save_ezfio_provider(path_head, dict_code_provider):
f.write(code + "\n") f.write(code + "\n")
def create_ezfio_config(dict_ezfio_cfg, opt, folder): def create_ezfio_config(dict_ezfio_cfg, opt, module_lower):
""" """
From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc}
Return the string ezfio_interface_config Return the string ezfio_interface_config
""" """
result = [ folder ] result = [module_lower]
lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2
l = sorted(dict_ezfio_cfg.keys()) l = sorted(dict_ezfio_cfg.keys())
for provider_name in l: for provider_name in l:
provider_info = dict_ezfio_cfg[provider_name] provider_info = dict_ezfio_cfg[provider_name]
s = " {0} {1}".format( provider_name.lower().ljust(lenmax), provider_info["type"].fortran ) s = " {0} {1}".format(
provider_name.lower().ljust(lenmax),
provider_info["type"].fortran)
result.append(s) result.append(s)
return "\n".join(result) return "\n".join(result)
def save_ezfio_config(folder, str_ezfio_config):
def save_ezfio_config(module_lower, str_ezfio_config):
""" """
Write the str_ezfio_config in Write the str_ezfio_config in
$QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(folder) $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower)
""" """
ezfio_dir = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) ezfio_dir = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT'])
path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir, path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir,
folder) module_lower)
print "Path = {}".format(path) print "Path = {}".format(path)
with open(path, "w") as f: with open(path, "w") as f:
f.write(str_ezfio_config) f.write(str_ezfio_config)
def main(): def main():
"""Take in argument a EZFIO.cfg""" """
Two condition:
-Take the EZFIO.cfg path in arg
or
-Look if EZFIO.cfg is present in the pwd
"""
try: try:
path = sys.argv[1] config_file_path = sys.argv[1]
except: except:
path = "EZFIO.cfg" config_file_path = "EZFIO.cfg"
if "EZFIO.cfg" not in os.listdir(os.getcwd()): if "EZFIO.cfg" not in os.listdir(os.getcwd()):
sys.exit(0) sys.exit(0)
path = os.path.expanduser(path) config_file_path = os.path.expanduser(config_file_path)
path = os.path.expandvars(path) config_file_path = os.path.expandvars(config_file_path)
path = os.path.abspath(path) config_file_path = os.path.abspath(config_file_path)
print path print config_file_path
path_dirname = os.path.dirname(path) path_dirname = os.path.dirname(config_file_path)
folder = [i for i in path_dirname.split("/") if i][-1] module = [i for i in path_dirname.split("/") if i][-1]
folder = folder.lower() module_lower = module.lower()
print "Find a EZFIO.cfg in {}".format(path) print "Read {0}".format(config_file_path)
dict_info_provider = get_dict_config_file(path,folder) 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) d_config = create_ezfio_provider(dict_info_provider)
# for provider, code in d_config.iteritems():
# print code
print "Saving the ezfio_interface.irp.f" print "Saving the ezfio_interface.irp.f"
save_ezfio_provider(path_dirname, d_config) 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", folder) config_ezfio = create_ezfio_config(dict_info_provider, "config", module_lower)
# print config_ezfio
print "Saving ezfio_config" print "Saving ezfio_config"
save_ezfio_config(folder, config_ezfio) save_ezfio_config(module_lower, config_ezfio)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,37 +1,42 @@
[N_det_max_fci] [N_det_max_fci]
doc: Max number of determinants in the wave function
type: Det_number_max type: Det_number_max
doc: Max number of determinants in the wave function
interface: output
default: 10000 default: 10000
[N_det_max_fci_property] [N_det_max_fci_property]
doc: Max number of determinants in the wave function when you select for a given property
type: Det_number_max type: Det_number_max
doc: Max number of determinants in the wave function when you select for a given property
interface: output
default: 10000 default: 10000
[do_pt2_end] [do_pt2_end]
type: logical type: logical
doc: If true, compute the PT2 at the end of the selection doc: If true, compute the PT2 at the end of the selection
interface: output
default: true default: true
[PT2_max] [PT2_max]
type: PT2_energy type: PT2_energy
doc: The selection process stops when the largest PT2 (for all the state is lower 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 default: 0.0001
[var_pt2_ratio] [var_pt2_ratio]
type: Normalized_float type: Normalized_float
doc: The selection process stops when the energy ratio variational/(variational+PT2) doc: The selection process stops when the energy ratio variational/(variational+PT2)
is equal to var_pt2_ratio is equal to var_pt2_ratio
interface: output
default: 0.75 default: 0.75
[energy] [energy]
type: double precision type: double precision
doc: "Calculated Full CI energy" doc: "Calculated Full CI energy"
output: true interface: input
[energy_pt2] [energy_pt2]
type: double precision type: double precision
doc: "Calculated Full CI energy" doc: "Calculated Full CI energy"
output: true interface: input