mirror of
https://gitlab.com/scemama/eplf
synced 2024-10-31 19:23:55 +01:00
Added input wrapper
This commit is contained in:
parent
5444388a05
commit
919c59a86f
@ -1 +0,0 @@
|
||||
EZFIO.1.0.8.tar.gz
|
BIN
EZFIO.tar.gz
Normal file
BIN
EZFIO.tar.gz
Normal file
Binary file not shown.
1
Makefile
1
Makefile
@ -9,6 +9,7 @@ EZFIO/config/eplf.config: EZFIO.tar.gz
|
||||
|
||||
EZFIO/lib/libezfio.so: EZFIO/config/eplf.config
|
||||
make -C EZFIO/
|
||||
cp EZFIO/Python/ezfio.py scripts/
|
||||
|
||||
bin/ezfio.py: EZFIO/lib/libezfio.so
|
||||
if [ -e $@ ] ; then rm $@ ; fi
|
||||
|
313
scripts/input_wrapper.py
Normal file
313
scripts/input_wrapper.py
Normal file
@ -0,0 +1,313 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from ezfio import ezfio
|
||||
import os
|
||||
|
||||
geom_data = """
|
||||
nucl_charge nucl_coord
|
||||
""".split()
|
||||
ro_data = """det_num nucl_num mo_num ao_num
|
||||
""".split()
|
||||
rw_data = """
|
||||
point_num step_size origin opposite
|
||||
compute_ELF compute_EPLF compute_RHO
|
||||
compute_ELF_grad compute_EPLF_grad compute_RHO_grad
|
||||
compute_ELF_lapl compute_EPLF_lapl compute_RHO_lapl
|
||||
""".split()
|
||||
rw_data_full = rw_data + geom_data
|
||||
|
||||
######################################################################
|
||||
DEFAULT_COMPUTE_EPLF = True
|
||||
DEFAULT_COMPUTE_ELF = False
|
||||
DEFAULT_COMPUTE_RHO = False
|
||||
DEFAULT_COMPUTE_EPLF_GRAD = False
|
||||
DEFAULT_COMPUTE_ELF_GRAD = False
|
||||
DEFAULT_COMPUTE_RHO_GRAD = False
|
||||
DEFAULT_COMPUTE_EPLF_LAPL = False
|
||||
DEFAULT_COMPUTE_ELF_LAPL = False
|
||||
DEFAULT_COMPUTE_RHO_LAPL = False
|
||||
DEFAULT_POINT_NUM = [80,80,80]
|
||||
|
||||
######################################################################
|
||||
|
||||
class InputFileExn(Exception):
|
||||
"""Errors in input file raise this exception"""
|
||||
|
||||
def __init__(self,msg):
|
||||
self.msg = msg
|
||||
|
||||
def __str__(self):
|
||||
result = "\n\n=========================================\n"
|
||||
result += self.msg
|
||||
result += "\n=========================================\n"
|
||||
return result
|
||||
|
||||
|
||||
######################################################################
|
||||
class InputFile(object):
|
||||
|
||||
def __init__(self,name):
|
||||
assert isinstance(name,str)
|
||||
wd = os.getcwd()
|
||||
try:
|
||||
os.chdir(name)
|
||||
except OSError:
|
||||
raise InputFileExn("File not found")
|
||||
try:
|
||||
file = open(".version","r")
|
||||
file.close()
|
||||
except IOError:
|
||||
raise InputFileExn("This directory is not a EZFIO file.")
|
||||
os.chdir(wd)
|
||||
ezfio.set_filename(name)
|
||||
self.name = name
|
||||
|
||||
# Read-only values
|
||||
def get_det_num(self):
|
||||
if ezfio.has_determinants_det_num():
|
||||
return ezfio.get_determinants_det_num()
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_nucl_num(self):
|
||||
if ezfio.has_nuclei_nucl_num():
|
||||
return ezfio.get_nuclei_nucl_num()
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_ao_num(self):
|
||||
if ezfio.has_ao_basis_ao_num():
|
||||
return ezfio.get_ao_basis_ao_num()
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_mo_num(self):
|
||||
if ezfio.has_mo_basis_mo_tot_num():
|
||||
return ezfio.get_mo_basis_mo_tot_num()
|
||||
else:
|
||||
return None
|
||||
|
||||
# Read/write values
|
||||
|
||||
def get_nucl_coord(self):
|
||||
if ezfio.has_nuclei_nucl_coord():
|
||||
return ezfio.get_nuclei_nucl_coord()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_nucl_coord(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
try:
|
||||
float(i)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_nuclei_nucl_coord(value)
|
||||
|
||||
def get_nucl_charge(self):
|
||||
if ezfio.has_nuclei_nucl_charge():
|
||||
return ezfio.get_nuclei_nucl_charge()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_nucl_charge(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
try:
|
||||
float(i)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_nuclei_nucl_charge(value)
|
||||
|
||||
def get_point_num(self):
|
||||
if ezfio.has_grid_point_num():
|
||||
return ezfio.get_grid_point_num()
|
||||
else:
|
||||
return DEFAULT_POINT_NUM
|
||||
|
||||
def set_point_num(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
if len(value) != 3:
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
try:
|
||||
int(i)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_grid_point_num(value)
|
||||
|
||||
def get_step_size(self):
|
||||
if ezfio.has_grid_step_size():
|
||||
return ezfio.get_grid_step_size()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_step_size(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
try:
|
||||
float(i)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_grid_step_size(value)
|
||||
|
||||
|
||||
def get_origin(self):
|
||||
if ezfio.has_grid_origin():
|
||||
return ezfio.get_grid_origin()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_origin(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
if len(value) != 3:
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
if not isinstance(i,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
for j in i:
|
||||
try:
|
||||
float(j)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_grid_origin(value)
|
||||
|
||||
|
||||
def get_opposite(self):
|
||||
if ezfio.has_grid_opposite():
|
||||
return ezfio.get_grid_opposite()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_opposite(self,value):
|
||||
if not isinstance(value,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
if len(value) != 3:
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
if not isinstance(i,list):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
for j in i:
|
||||
try:
|
||||
float(j)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_grid_opposite(value)
|
||||
|
||||
def get_compute_ELF(self):
|
||||
if ezfio.has_compute_elf():
|
||||
return ezfio.get_compute_elf()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_ELF
|
||||
|
||||
def set_compute_ELF(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_elf(value)
|
||||
|
||||
def get_compute_EPLF(self):
|
||||
if ezfio.has_compute_eplf():
|
||||
return ezfio.get_compute_eplf()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_EPLF
|
||||
|
||||
def set_compute_EPLF(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_eplf(value)
|
||||
|
||||
def get_compute_RHO(self):
|
||||
if ezfio.has_compute_rho():
|
||||
return ezfio.get_compute_rho()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_RHO
|
||||
|
||||
def set_compute_RHO(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_rho(value)
|
||||
|
||||
|
||||
def get_compute_ELF_grad(self):
|
||||
if ezfio.has_compute_elf_grad():
|
||||
return ezfio.get_compute_elf_grad()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_ELF_GRAD
|
||||
|
||||
def set_compute_ELF_grad(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_elf_grad(value)
|
||||
|
||||
def get_compute_EPLF_grad(self):
|
||||
if ezfio.has_compute_eplf_grad():
|
||||
return ezfio.get_compute_eplf_grad()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_EPLF_GRAD
|
||||
|
||||
def set_compute_EPLF_grad(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_eplf_grad(value)
|
||||
|
||||
def get_compute_RHO_grad(self):
|
||||
if ezfio.has_compute_rho_grad():
|
||||
return ezfio.get_compute_rho_grad()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_RHO_GRAD
|
||||
|
||||
def set_compute_RHO_grad(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_rho_grad(value)
|
||||
|
||||
|
||||
def get_compute_ELF_lapl(self):
|
||||
if ezfio.has_compute_elf_lapl():
|
||||
return ezfio.get_compute_elf_lapl()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_ELF_LAPL
|
||||
|
||||
def set_compute_ELF_lapl(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_elf_lapl(value)
|
||||
|
||||
def get_compute_EPLF_lapl(self):
|
||||
if ezfio.has_compute_eplf_lapl():
|
||||
return ezfio.get_compute_eplf_lapl()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_EPLF_LAPL
|
||||
|
||||
def set_compute_EPLF_lapl(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_eplf_lapl(value)
|
||||
|
||||
def get_compute_RHO_lapl(self):
|
||||
if ezfio.has_compute_rho_lapl():
|
||||
return ezfio.get_compute_rho_lapl()
|
||||
else:
|
||||
return DEFAULT_COMPUTE_RHO_LAPL
|
||||
|
||||
def set_compute_RHO_lapl(self,value):
|
||||
if not isinstance(value,bool):
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_rho_lapl(value)
|
||||
|
||||
# Build the corresponding properties
|
||||
for i in ro_data:
|
||||
exec "%s = property(fget=get_%s,fset=None)"%(i,i)
|
||||
|
||||
for i in rw_data_full:
|
||||
exec "%s = property(fget=get_%s,fset=set_%s)"%(i,i,i)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user