10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-07-17 00:20:41 +02:00
QuantumPackage/src/utils_complex/create_ezfio_complex_3idx.py

165 lines
5.9 KiB
Python
Raw Normal View History

2020-02-10 15:34:51 +01:00
#!/usr/bin/env python
from ezfio import ezfio
import h5py
import sys
import numpy as np
2020-02-10 15:34:51 +01:00
filename = sys.argv[1]
h5filename = sys.argv[2]
#num_elec, nucl_num, mo_num = map(int,sys.argv[2:5])
#nuclear_repulsion = float(sys.argv[5])
#ao_num = int(sys.argv[6])
#n_kpts = int(sys.argv[7])
#n_aux = int(sys.argv[8])
ezfio.set_file(filename)
2020-02-11 23:39:08 +01:00
qph5=h5py.File(h5filename,'r')
2020-02-10 15:34:51 +01:00
2020-02-11 23:39:08 +01:00
kpt_num = qph5['nuclei'].attrs['kpt_num']
ezfio.set_nuclei_kpt_num(kpt_num)
kpt_pair_num = (kpt_num*kpt_num + kpt_num)//2
ezfio.set_nuclei_kpt_pair_num(kpt_pair_num)
2020-02-11 23:39:08 +01:00
# these are totals (kpt_num * num_per_kpt)
# need to change if we want to truncate orbital space within pyscf
2020-02-10 15:34:51 +01:00
ezfio.electrons_elec_alpha_num = qph5['electrons'].attrs['elec_alpha_num']
ezfio.electrons_elec_beta_num = qph5['electrons'].attrs['elec_beta_num']
nucl_num = qph5['nuclei'].attrs['nucl_num']
2020-02-11 23:39:08 +01:00
nucl_num_per_kpt = nucl_num // kpt_num
2020-02-10 15:36:11 +01:00
ao_num = qph5['ao_basis'].attrs['ao_num']
2020-02-10 15:34:51 +01:00
mo_num = qph5['mo_basis'].attrs['mo_num']
2020-02-11 23:39:08 +01:00
2020-02-10 15:34:51 +01:00
ezfio.set_mo_basis_mo_num(mo_num)
2020-02-11 23:39:08 +01:00
##ao_num = mo_num
##Important !
#import math
#nelec_per_kpt = num_elec // n_kpts
#nelec_alpha_per_kpt = int(math.ceil(nelec_per_kpt / 2.))
#nelec_beta_per_kpt = int(math.floor(nelec_per_kpt / 2.))
#
#ezfio.electrons_elec_alpha_num = int(nelec_alpha_per_kpt * n_kpts)
#ezfio.electrons_elec_beta_num = int(nelec_beta_per_kpt * n_kpts)
2020-02-10 15:34:51 +01:00
#ezfio.electrons_elec_alpha_num = int(math.ceil(num_elec / 2.))
#ezfio.electrons_elec_beta_num = int(math.floor(num_elec / 2.))
#ezfio.set_utils_num_kpts(n_kpts)
#ezfio.set_integrals_bielec_df_num(n_aux)
2020-02-11 23:39:08 +01:00
#(old)Important
#ezfio.set_nuclei_nucl_num(nucl_num)
#ezfio.set_nuclei_nucl_charge([0.]*nucl_num)
#ezfio.set_nuclei_nucl_coord( [ [0.], [0.], [0.] ]*nucl_num )
#ezfio.set_nuclei_nucl_label( ['He'] * nucl_num )
ezfio.set_nuclei_nucl_num(nucl_num_per_kpt)
nucl_charge=qph5['nuclei/nucl_charge'][()].tolist()
ezfio.set_nuclei_nucl_charge(nucl_charge)
nucl_coord=qph5['nuclei/nucl_coord'][()].T.tolist()
ezfio.set_nuclei_nucl_coord(nucl_coord)
nucl_label=qph5['nuclei/nucl_label'][()].tolist()
ezfio.set_nuclei_nucl_label(nucl_label)
2020-02-10 15:34:51 +01:00
ezfio.set_nuclei_io_nuclear_repulsion('Read')
2020-02-11 23:39:08 +01:00
nuclear_repulsion = qph5['nuclei'].attrs['nuclear_repulsion']
2020-02-10 15:34:51 +01:00
ezfio.set_nuclei_nuclear_repulsion(nuclear_repulsion)
# Ao num
#ao_num = mo_num
2020-02-13 23:33:11 +01:00
#ezfio.set_ao_basis_ao_basis("Dummy one. We read MO")
2020-02-10 15:34:51 +01:00
ezfio.set_ao_basis_ao_num(ao_num)
2020-02-13 23:33:11 +01:00
#ezfio.set_ao_basis_ao_nucl([1]*ao_num) #Maybe put a realy incorrect stuff
2020-02-10 15:34:51 +01:00
2020-02-13 23:33:11 +01:00
ezfio.set_ao_basis_ao_basis(qph5['ao_basis'].attrs['ao_basis'])
ezfio.set_ao_basis_ao_nucl(qph5['ao_basis/ao_nucl'][()].tolist())
2020-02-11 23:39:08 +01:00
#Just need one (can clean this up later)
2020-02-10 15:34:51 +01:00
ao_prim_num_max = 5
d = [ [0] *ao_prim_num_max]*ao_num
ezfio.set_ao_basis_ao_prim_num([ao_prim_num_max]*ao_num)
ezfio.set_ao_basis_ao_power(d)
ezfio.set_ao_basis_ao_coef(d)
ezfio.set_ao_basis_ao_expo(d)
ezfio.set_mo_basis_mo_num(mo_num)
2020-02-11 23:39:08 +01:00
#c_mo = [[1 if i==j else 0 for i in range(mo_num)] for j in range(ao_num)]
#ezfio.set_mo_basis_mo_coef([ [0]*mo_num] * ao_num)
##ezfio.set_mo_basis_mo_coef_real(c_mo)
mo_coef_re0 = qph5['mo_basis/mo_coef_real'][()].T
mo_coef_im0 = qph5['mo_basis/mo_coef_imag'][()].T
mo_coef_cmplx0 = np.stack((mo_coef_re0,mo_coef_im0),axis=-1).tolist()
2020-02-11 23:39:08 +01:00
#ezfio.set_mo_basis_mo_coef_real(qph5['mo_basis/mo_coef_real'][()].tolist())
#ezfio.set_mo_basis_mo_coef_imag(qph5['mo_basis/mo_coef_imag'][()].tolist())
ezfio.set_mo_basis_mo_coef_complex(mo_coef_cmplx0)
2020-02-11 23:39:08 +01:00
#maybe fix qp so we don't need this?
2020-02-13 23:33:11 +01:00
#ezfio.set_mo_basis_mo_coef([[i for i in range(mo_num)] * ao_num])
2020-02-10 15:34:51 +01:00
ezfio.set_nuclei_is_complex(True)
# fortran-ordered re,im parts
kin_ao_re0=qph5['ao_one_e_ints/ao_integrals_kinetic_real'][()].T
kin_ao_im0=qph5['ao_one_e_ints/ao_integrals_kinetic_imag'][()].T
#test where to stack? (axis=0 or -1?)
kin_ao_cmplx0=np.stack((kin_ao_re0,kin_ao_im0),axis=-1).tolist()
ovlp_ao_re0=qph5['ao_one_e_ints/ao_integrals_overlap_real'][()].T
ovlp_ao_im0=qph5['ao_one_e_ints/ao_integrals_overlap_imag'][()].T
#test where to stack? (axis=0 or -1?)
ovlp_ao_cmplx0=np.stack((ovlp_ao_re0,ovlp_ao_im0),axis=-1).tolist()
ne_ao_re0=qph5['ao_one_e_ints/ao_integrals_n_e_real'][()].T
ne_ao_im0=qph5['ao_one_e_ints/ao_integrals_n_e_imag'][()].T
#test where to stack? (axis=0 or -1?)
ne_ao_cmplx0=np.stack((ne_ao_re0,ne_ao_im0),axis=-1).tolist()
ezfio.set_ao_one_e_ints_ao_integrals_kinetic_complex(kin_ao_cmplx0)
ezfio.set_ao_one_e_ints_ao_integrals_overlap_complex(ovlp_ao_cmplx0)
ezfio.set_ao_one_e_ints_ao_integrals_n_e_complex(ne_ao_cmplx0)
2020-02-13 23:33:11 +01:00
ezfio.set_ao_one_e_ints_io_ao_integrals_kinetic('Read')
ezfio.set_ao_one_e_ints_io_ao_integrals_overlap('Read')
ezfio.set_ao_one_e_ints_io_ao_integrals_n_e('Read')
2020-02-19 01:32:47 +01:00
# should this be in ao_basis? ao_two_e_ints?
if 'ao_two_e_ints' in qph5.keys():
df_num = qph5['ao_two_e_ints'].attrs['df_num']
ezfio.set_ao_two_e_ints_df_num(df_num)
if 'df_ao_integrals_real' in qph5['ao_two_e_ints'].keys():
dfao_re0=qph5['ao_two_e_ints/df_ao_integrals_real'][()].transpose((3,2,1,0))
dfao_im0=qph5['ao_two_e_ints/df_ao_integrals_imag'][()].transpose((3,2,1,0))
dfao_cmplx0 = np.stack((dfao_re0,dfao_im0),axis=-1).tolist()
ezfio.set_ao_two_e_ints_df_ao_integrals_complex(dfao_cmplx0)
ezfio.set_ao_two_e_ints_io_df_ao_integrals('Read')
if 'mo_two_e_ints' in qph5.keys():
df_num = qph5['ao_two_e_ints'].attrs['df_num']
2020-02-19 19:13:24 +01:00
ezfio.set_ao_two_e_ints_df_num(df_num)
2020-02-19 01:32:47 +01:00
dfmo_re0=qph5['mo_two_e_ints/df_mo_integrals_real'][()].transpose((3,2,1,0))
dfmo_im0=qph5['mo_two_e_ints/df_mo_integrals_imag'][()].transpose((3,2,1,0))
dfmo_cmplx0 = np.stack((dfmo_re0,dfmo_im0),axis=-1).tolist()
ezfio.set_mo_two_e_ints_df_mo_integrals_complex(dfmo_cmplx0)
ezfio.set_mo_two_e_ints_io_df_mo_integrals('Read')
#TODO: add check and only do this if ints exist
#dfmo_re=qph5['mo_two_e_ints/df_mo_integrals_real'][()].transpose((3,2,1,0)).tolist()
#dfmo_im=qph5['mo_two_e_ints/df_mo_integrals_imag'][()].transpose((3,2,1,0)).tolist()
#ezfio.set_mo_two_e_ints_df_mo_integrals_real(dfmo_re)
#ezfio.set_mo_two_e_ints_df_mo_integrals_imag(dfmo_im)