2010-06-22 12:35:25 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from ezfio import ezfio
|
|
|
|
import os
|
|
|
|
|
|
|
|
geom_data = """
|
|
|
|
nucl_charge nucl_coord
|
|
|
|
""".split()
|
2010-06-22 15:59:15 +02:00
|
|
|
ro_data = """det_num nucl_num mo_num ao_num has_mpi
|
2010-06-22 12:35:25 +02:00
|
|
|
""".split()
|
|
|
|
rw_data = """
|
2010-06-22 15:59:15 +02:00
|
|
|
point_num step_size origin opposite nproc
|
2010-06-22 12:53:29 +02:00
|
|
|
compute_elf compute_eplf compute_density
|
|
|
|
compute_elf_grad compute_eplf_grad compute_density_grad
|
|
|
|
compute_elf_lapl compute_eplf_lapl compute_density_lapl
|
2010-06-24 10:40:51 +02:00
|
|
|
compute_elf_partition compute_eplf_partition compute_density_partition
|
2010-06-22 12:35:25 +02:00
|
|
|
""".split()
|
|
|
|
rw_data_full = rw_data + geom_data
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
DEFAULT_COMPUTE_EPLF = True
|
|
|
|
DEFAULT_COMPUTE_ELF = False
|
2010-06-22 12:53:29 +02:00
|
|
|
DEFAULT_COMPUTE_DENSITY = False
|
2010-06-22 12:35:25 +02:00
|
|
|
DEFAULT_COMPUTE_EPLF_GRAD = False
|
|
|
|
DEFAULT_COMPUTE_ELF_GRAD = False
|
2010-06-22 12:53:29 +02:00
|
|
|
DEFAULT_COMPUTE_DENSITY_GRAD = False
|
2010-06-22 12:35:25 +02:00
|
|
|
DEFAULT_COMPUTE_EPLF_LAPL = False
|
|
|
|
DEFAULT_COMPUTE_ELF_LAPL = False
|
2010-06-22 12:53:29 +02:00
|
|
|
DEFAULT_COMPUTE_DENSITY_LAPL = False
|
2010-06-23 18:29:18 +02:00
|
|
|
DEFAULT_COMPUTE_EPLF_PART = False
|
|
|
|
DEFAULT_COMPUTE_ELF_PART = False
|
|
|
|
DEFAULT_COMPUTE_DENSITY_PART = False
|
2010-06-22 12:35:25 +02:00
|
|
|
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)
|
2010-06-22 15:59:15 +02:00
|
|
|
l = len(name)
|
|
|
|
while name[l-1] == '/':
|
|
|
|
l -= 1
|
|
|
|
self.name = name[:l]
|
2010-06-22 12:35:25 +02:00
|
|
|
|
|
|
|
# Read-only values
|
2010-06-22 15:59:15 +02:00
|
|
|
def get_has_mpi(self):
|
|
|
|
if os.getenv("EPLF_HAS_MPI","1") == "1":
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2010-06-22 12:35:25 +02:00
|
|
|
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:
|
2010-06-22 15:59:15 +02:00
|
|
|
if not isinstance(i,float):
|
2010-06-22 12:35:25 +02:00
|
|
|
raise InputFileExn("Wrong type")
|
2010-06-22 15:59:15 +02:00
|
|
|
for j in value:
|
2010-06-22 12:35:25 +02:00
|
|
|
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:
|
2010-06-22 15:59:15 +02:00
|
|
|
if not isinstance(i,float):
|
2010-06-22 12:35:25 +02:00
|
|
|
raise InputFileExn("Wrong type")
|
2010-06-22 15:59:15 +02:00
|
|
|
for j in value:
|
2010-06-22 12:35:25 +02:00
|
|
|
try:
|
|
|
|
float(j)
|
|
|
|
except:
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_grid_opposite(value)
|
|
|
|
|
2010-06-22 15:59:15 +02:00
|
|
|
def get_nproc(self):
|
|
|
|
if ezfio.has_compute_nproc():
|
|
|
|
return ezfio.get_compute_nproc()
|
|
|
|
else:
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def set_nproc(self,value):
|
|
|
|
if not isinstance(value,int):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
if value < 1:
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_nproc(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_elf(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_elf():
|
|
|
|
return ezfio.get_compute_elf()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_ELF
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_elf(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_elf(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_eplf(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_eplf():
|
|
|
|
return ezfio.get_compute_eplf()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_EPLF
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_eplf(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_eplf(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_density(self):
|
|
|
|
if ezfio.has_compute_density():
|
|
|
|
return ezfio.get_compute_density()
|
2010-06-22 12:35:25 +02:00
|
|
|
else:
|
2010-06-22 12:53:29 +02:00
|
|
|
return DEFAULT_COMPUTE_DENSITY
|
2010-06-22 12:35:25 +02:00
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_density(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
2010-06-22 12:53:29 +02:00
|
|
|
ezfio.set_compute_density(value)
|
2010-06-22 12:35:25 +02:00
|
|
|
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_elf_grad(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_elf_grad():
|
|
|
|
return ezfio.get_compute_elf_grad()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_ELF_GRAD
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_elf_grad(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_elf_grad(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_eplf_grad(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_eplf_grad():
|
|
|
|
return ezfio.get_compute_eplf_grad()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_EPLF_GRAD
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_eplf_grad(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_eplf_grad(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_density_grad(self):
|
|
|
|
if ezfio.has_compute_density_grad():
|
|
|
|
return ezfio.get_compute_density_grad()
|
2010-06-22 12:35:25 +02:00
|
|
|
else:
|
2010-06-22 12:53:29 +02:00
|
|
|
return DEFAULT_COMPUTE_DENSITY_GRAD
|
2010-06-22 12:35:25 +02:00
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_density_grad(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
2010-06-22 12:53:29 +02:00
|
|
|
ezfio.set_compute_density_grad(value)
|
2010-06-22 12:35:25 +02:00
|
|
|
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_elf_lapl(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_elf_lapl():
|
|
|
|
return ezfio.get_compute_elf_lapl()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_ELF_LAPL
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_elf_lapl(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_elf_lapl(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_eplf_lapl(self):
|
2010-06-22 12:35:25 +02:00
|
|
|
if ezfio.has_compute_eplf_lapl():
|
|
|
|
return ezfio.get_compute_eplf_lapl()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_EPLF_LAPL
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_eplf_lapl(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_eplf_lapl(value)
|
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def get_compute_density_lapl(self):
|
|
|
|
if ezfio.has_compute_density_lapl():
|
|
|
|
return ezfio.get_compute_density_lapl()
|
2010-06-22 12:35:25 +02:00
|
|
|
else:
|
2010-06-22 12:53:29 +02:00
|
|
|
return DEFAULT_COMPUTE_DENSITY_LAPL
|
2010-06-22 12:35:25 +02:00
|
|
|
|
2010-06-22 12:53:29 +02:00
|
|
|
def set_compute_density_lapl(self,value):
|
2010-06-22 12:35:25 +02:00
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
2010-06-22 12:53:29 +02:00
|
|
|
ezfio.set_compute_density_lapl(value)
|
2010-06-22 12:35:25 +02:00
|
|
|
|
2010-06-23 18:29:18 +02:00
|
|
|
def get_compute_elf_partition(self):
|
|
|
|
if ezfio.has_compute_elf_partition():
|
|
|
|
return ezfio.get_compute_elf_partition()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_ELF_PART
|
|
|
|
|
|
|
|
def set_compute_elf_partition(self,value):
|
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_elf_partition(value)
|
|
|
|
|
2010-06-24 10:40:51 +02:00
|
|
|
def get_compute_eplf_partition(self):
|
|
|
|
if ezfio.has_compute_eplf_partition():
|
|
|
|
return ezfio.get_compute_eplf_partition()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_ELF_PART
|
|
|
|
|
|
|
|
def set_compute_eplf_partition(self,value):
|
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_eplf_partition(value)
|
|
|
|
|
|
|
|
def get_compute_density_partition(self):
|
|
|
|
if ezfio.has_compute_density_partition():
|
|
|
|
return ezfio.get_compute_density_partition()
|
|
|
|
else:
|
|
|
|
return DEFAULT_COMPUTE_DENSITY_PART
|
|
|
|
|
|
|
|
def set_compute_density_partition(self,value):
|
|
|
|
if not isinstance(value,bool):
|
|
|
|
raise InputFileExn("Wrong type")
|
|
|
|
ezfio.set_compute_density_partition(value)
|
|
|
|
|
2010-06-22 12:35:25 +02:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
|
|
|
|