1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-07 14:43:41 +01:00

Allow no basis set

This commit is contained in:
Anthony Scemama 2023-05-10 14:44:30 +02:00
parent 192f4c6913
commit 6f04cc0eb0
2 changed files with 99 additions and 78 deletions

View File

@ -1,8 +1,22 @@
program import_integrals_ao program import_integrals_ao
call run use trexio
implicit none
integer(trexio_t) :: f ! TREXIO file handle
integer(trexio_exit_code) :: rc
f = trexio_open(trexio_filename, 'r', TREXIO_AUTO, rc)
if (f == 0_8) then
print *, 'Unable to open TREXIO file for reading'
print *, 'rc = ', rc
stop -1
endif
call run(f)
rc = trexio_close(f)
call trexio_assert(rc, TREXIO_SUCCESS)
end end
subroutine run subroutine run(f)
use trexio use trexio
use map_module use map_module
implicit none implicit none
@ -10,7 +24,7 @@ subroutine run
! Program to import integrals from TREXIO ! Program to import integrals from TREXIO
END_DOC END_DOC
integer(trexio_t) :: f ! TREXIO file handle integer(trexio_t), intent(in) :: f ! TREXIO file handle
integer(trexio_exit_code) :: rc integer(trexio_exit_code) :: rc
integer ::i,j,k,l integer ::i,j,k,l
@ -25,16 +39,6 @@ subroutine run
double precision, allocatable :: V(:) double precision, allocatable :: V(:)
integer , allocatable :: Vi(:,:) integer , allocatable :: Vi(:,:)
double precision :: s double precision :: s
PROVIDE ao_num
f = trexio_open(trexio_filename, 'r', TREXIO_AUTO, rc)
if (f == 0_8) then
print *, 'Unable to open TREXIO file for reading'
print *, 'rc = ', rc
stop -1
endif
if (trexio_has_nucleus_repulsion(f) == TREXIO_SUCCESS) then if (trexio_has_nucleus_repulsion(f) == TREXIO_SUCCESS) then
rc = trexio_read_nucleus_repulsion(f, s) rc = trexio_read_nucleus_repulsion(f, s)

View File

@ -72,6 +72,8 @@ def write_ezfio(trexio_filename, filename):
print("Nuclei\t\t...\t", end=' ') print("Nuclei\t\t...\t", end=' ')
charge = [0.]
if trexio.has_nucleus(trexio_file):
charge = trexio.read_nucleus_charge(trexio_file) charge = trexio.read_nucleus_charge(trexio_file)
ezfio.set_nuclei_nucl_num(len(charge)) ezfio.set_nuclei_nucl_num(len(charge))
ezfio.set_nuclei_nucl_charge(charge) ezfio.set_nuclei_nucl_charge(charge)
@ -89,6 +91,12 @@ def write_ezfio(trexio_filename, filename):
label = [p.sub("", x).capitalize() for x in label] label = [p.sub("", x).capitalize() for x in label]
ezfio.set_nuclei_nucl_label(label) ezfio.set_nuclei_nucl_label(label)
else:
ezfio.set_nuclei_nucl_num(1)
ezfio.set_nuclei_nucl_charge([0.])
ezfio.set_nuclei_nucl_coord([0.,0.,0.])
ezfio.set_nuclei_nucl_label(["X"])
print("OK") print("OK")
@ -104,6 +112,9 @@ def write_ezfio(trexio_filename, filename):
except: except:
num_alpha = sum(charge) - num_beta num_alpha = sum(charge) - num_beta
if num_alpha == 0:
print("\n\nError: There are zero electrons in the TREXIO file.\n\n")
sys.exit(1)
ezfio.set_electrons_elec_alpha_num(num_alpha) ezfio.set_electrons_elec_alpha_num(num_alpha)
ezfio.set_electrons_elec_beta_num(num_beta) ezfio.set_electrons_elec_beta_num(num_beta)
@ -111,10 +122,11 @@ def write_ezfio(trexio_filename, filename):
print("Basis\t\t...\t", end=' ') print("Basis\t\t...\t", end=' ')
shell_num = 0
try: try:
basis_type = trexio.read_basis_type(trexio_file) basis_type = trexio.read_basis_type(trexio_file)
if basis_type.lower() != "gaussian": if basis_type.lower() not in ["gaussian", "slater"]:
raise TypeError raise TypeError
shell_num = trexio.read_basis_shell_num(trexio_file) shell_num = trexio.read_basis_shell_num(trexio_file)
@ -173,14 +185,19 @@ def write_ezfio(trexio_filename, filename):
print("AOS\t\t...\t", end=' ') print("AOS\t\t...\t", end=' ')
ao_shell = trexio.read_ao_shell(trexio_file) try:
cartesian = trexio.read_ao_cartesian(trexio_file) cartesian = trexio.read_ao_cartesian(trexio_file)
except:
cartesian = True
if not cartesian: if not cartesian:
raise TypeError('Only cartesian TREXIO files can be converted') raise TypeError('Only cartesian TREXIO files can be converted')
ao_num = trexio.read_ao_num(trexio_file) ao_num = trexio.read_ao_num(trexio_file)
ezfio.set_ao_basis_ao_num(ao_num) ezfio.set_ao_basis_ao_num(ao_num)
if shell_num > 0:
ao_shell = trexio.read_ao_shell(trexio_file)
at = [ nucl_index[i]+1 for i in ao_shell ] at = [ nucl_index[i]+1 for i in ao_shell ]
ezfio.set_ao_basis_ao_nucl(at) ezfio.set_ao_basis_ao_nucl(at)