10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-13 17:43:50 +01:00

working on complex converter

This commit is contained in:
Kevin Gasperich 2020-02-11 16:39:08 -06:00
parent a28244e1d1
commit 8472e71df4
4 changed files with 92 additions and 33 deletions

View File

@ -18,3 +18,8 @@ interface: ezfio,provider,ocaml
default: False
ezfio_name: direct
[df_num]
type: integer
doc: Size of df basis
interface: ezfio, provider

View File

@ -1,17 +1,18 @@
#!/bin/bash
ezfio=$1
h5file=$2
# Create the integral
echo 'Create Integral'
echo 'Create EZFIO'
read nel nmo natom <<< $(cat param)
read e_nucl <<< $(cat e_nuc)
read nao <<< $(cat num_ao)
read nkpts <<< $(cat num_kpts)
read ndf <<< $(cat num_df)
#./create_ezfio_complex_4idx.py $ezfio $nel $natom $nmo $e_nucl $nao $nkpts
./create_ezfio_complex_3idx.py $ezfio $nel $natom $nmo $e_nucl $nao $nkpts $ndf
#read nel nmo natom <<< $(cat param)
#read e_nucl <<< $(cat e_nuc)
#read nao <<< $(cat num_ao)
#read nkpts <<< $(cat num_kpts)
#read ndf <<< $(cat num_df)
##./create_ezfio_complex_4idx.py $ezfio $nel $natom $nmo $e_nucl $nao $nkpts
./create_ezfio_complex_3idx.py $ezfio $h5file #$nel $natom $nmo $e_nucl $nao $nkpts $ndf
#Handle the orbital consitensy check
qp_edit -c $ezfio &> /dev/null
cp $ezfio/{ao,mo}_basis/ao_md5
@ -23,7 +24,7 @@ echo 'Read Integral'
################################################
## using AO mono, 4-idx from pyscf ##
################################################
qp_run import_integrals_ao_periodic $ezfio
#qp_run import_integrals_ao_periodic $ezfio
################################################

View File

@ -489,6 +489,7 @@ def pyscf2QP2(cell,mf, kpts, kmesh=None, cas_idx=None, int_threshold = 1E-8,
from pyscf.pbc import ao2mo
from pyscf.pbc import tools
from pyscf.pbc.gto import ecp
from pyscf.data import nist
import h5py
import scipy
@ -507,9 +508,21 @@ def pyscf2QP2(cell,mf, kpts, kmesh=None, cas_idx=None, int_threshold = 1E-8,
natom = cell.natm
nelec = cell.nelectron
atom_xyz = mf.cell.atom_coords()
if not(mf.cell.unit.startswith(('B','b','au','AU'))):
atom_xyz /= nist.BOHR # always convert to au
strtype=h5py.special_dtype(vlen=str)
atom_dset=qph5.create_dataset('nuclei/nucl_label',(natom,),dtype=strtype)
for i in range(natom):
atom_dset[i] = mf.cell.atom_pure_symbol(i)
qph5.create_dataset('nuclei/nucl_coord',data=atom_xyz)
qph5.create_dataset('nuclei/nucl_charge',data=mf.cell.atom_charges())
print('n_atom per kpt', natom)
print('num_elec per kpt', nelec)
mo_coeff = mf.mo_coeff
# Mo_coeff actif
mo_k = np.array([c[:,cas_idx] for c in mo_coeff] if cas_idx is not None else mo_coeff)
@ -523,14 +536,20 @@ def pyscf2QP2(cell,mf, kpts, kmesh=None, cas_idx=None, int_threshold = 1E-8,
naux = mf.with_df.auxcell.nao
print("n df fitting functions", naux)
#in old version: param < nelec*Nk, nmo*Nk, natom*Nk
#in old version: param << nelec*Nk, nmo*Nk, natom*Nk
qph5['electrons'].attrs['elec_alpha_num']=nelec*Nk
qph5['electrons'].attrs['elec_beta_num']=nelec*Nk
qph5['mo_basis'].attrs['mo_num']=Nk*nmo
qph5['ao_basis'].attrs['ao_num']=Nk*nao
qph5['nuclei'].attrs['nucl_num']=Nk*natom
qph5['nuclei'].attrs['kpt_num']=Nk
qph5['ao_basis'].attrs['df_num']=naux
qph5.create_group('ao_two_e_ints')
qph5['ao_two_e_ints'].attrs['df_num']=naux
qph5['ao_basis'].attrs['ao_basis']=mf.cell.basis
ao_nucl=[mf.cell.bas_atom(i)+1 for i in range(nao)]
qph5.create_dataset('ao_basis/ao_nucl',data=Nk*ao_nucl)
# _
# |\ | _ | _ _. ._ |_) _ ._ | _ o _ ._

View File

@ -12,28 +12,38 @@ h5filename = sys.argv[2]
#n_kpts = int(sys.argv[7])
#n_aux = int(sys.argv[8])
ezfio.set_file(filename)
qph5=h5py.File(h5filename.'r')
qph5=h5py.File(h5filename,'r')
kpt_num = qph5['nuclei'].attrs['kpt_num']
ezfio.set_nuclei_kpt_num(kpt_num)
# should this be in ao_basis? ao_two_e_ints?
df_num = qph5['ao_two_e_ints'].attrs['df_num']
ezfio.set_ao_two_e_ints_df_num(df_num)
# these are totals (kpt_num * num_per_kpt)
# need to change if we want to truncate orbital space within pyscf
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']
kpt_num = qph5['nuclei'].attrs['kpt_num']
df_num = qph5['ao_basis'].attrs['df_num']
nucl_num_per_kpt = nucl_num // kpt_num
ao_num = qph5['ao_basis'].attrs['ao_num']
mo_num = qph5['mo_basis'].attrs['mo_num']
ezfio.set_mo_basis_mo_num(mo_num)
#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)
##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)
#ezfio.electrons_elec_alpha_num = int(math.ceil(num_elec / 2.))
#ezfio.electrons_elec_beta_num = int(math.floor(num_elec / 2.))
@ -41,13 +51,26 @@ ezfio.electrons_elec_beta_num = int(nelec_beta_per_kpt * n_kpts)
#ezfio.set_utils_num_kpts(n_kpts)
#ezfio.set_integrals_bielec_df_num(n_aux)
#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 )
#(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)
ezfio.set_nuclei_io_nuclear_repulsion('Read')
nuclear_repulsion = qph5['nuclei'].attrs['nuclear_repulsion']
ezfio.set_nuclei_nuclear_repulsion(nuclear_repulsion)
# Ao num
@ -56,7 +79,11 @@ ezfio.set_ao_basis_ao_basis("Dummy one. We read MO")
ezfio.set_ao_basis_ao_num(ao_num)
ezfio.set_ao_basis_ao_nucl([1]*ao_num) #Maybe put a realy incorrect stuff
#Just need one
#ezfio.set_ao_basis_ao_basis(qph5['ao_basis'].attrs['ao_basis'])
#ezfio.set_ao_basis_ao_nucl(qph5['ao_basis/ao_nucl'][()].tolist())
#Just need one (can clean this up later)
ao_prim_num_max = 5
d = [ [0] *ao_prim_num_max]*ao_num
@ -72,8 +99,15 @@ ezfio.set_mo_basis_ao_md5(ao_md5)
ezfio.set_mo_basis_mo_num(mo_num)
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)
#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)
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())
#maybe fix qp so we don't need this?
ezfio.set_mo_basis_mo_coef([[i for i in range(mo_num)] * ao_num])
ezfio.set_nuclei_is_periodic(True)