From 9f58d723e351d15dfc9147d241dc6d43af343094 Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Tue, 1 Sep 2020 10:13:04 -0500 Subject: [PATCH] updated qmcpack converter --- bin/qp_convert_h5_to_ezfio | 131 +++++++++++++++----------- src/utils_complex/MolPyscfToQPkpts.py | 4 +- 2 files changed, 80 insertions(+), 55 deletions(-) diff --git a/bin/qp_convert_h5_to_ezfio b/bin/qp_convert_h5_to_ezfio index 28928b88..ff97d612 100755 --- a/bin/qp_convert_h5_to_ezfio +++ b/bin/qp_convert_h5_to_ezfio @@ -3,11 +3,12 @@ convert hdf5 output (e.g. from PySCF) to ezfio Usage: - qp_convert_h5_to_ezfio [-o EZFIO_DIR] FILE + qp_convert_h5_to_ezfio [--qmc] [-o EZFIO_DIR] FILE Options: -o --output=EZFIO_DIR Produced directory by default is FILE.ezfio + --qmc include basis, cell, etc. for QMCPACK """ from ezfio import ezfio @@ -137,7 +138,7 @@ def convert_mol(filename,qph5path): return -def convert_kpts(filename,qph5path): +def convert_kpts(filename,qph5path,qmcpack=False): ezfio.set_file(filename) ezfio.set_nuclei_is_complex(True) @@ -210,61 +211,83 @@ def convert_kpts(filename,qph5path): ########################################## # # - # Basis # + # Basis(Dummy) # # # ########################################## - #with h5py.File(qph5path,'r') as qph5: - # 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 - # 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) - - - ########################################## - # # - # Basis # - # # - ########################################## - with h5py.File(qph5path,'r') as qph5: - do_pseudo = qph5['pseudo'].attrs['do_pseudo'] - ezfio.set_pseudo_do_pseudo(do_pseudo) - if (do_pseudo): - ezfio.set_pseudo_pseudo_lmax(qph5['pseudo'].attrs['pseudo_lmax']) - ezfio.set_pseudo_pseudo_klocmax(qph5['pseudo'].attrs['pseudo_klocmax']) - ezfio.set_pseudo_pseudo_kmax(qph5['pseudo'].attrs['pseudo_kmax']) - ezfio.set_pseudo_nucl_charge_remove(qph5['pseudo/nucl_charge_remove'][()].tolist()) - ezfio.set_pseudo_pseudo_n_k(qph5['pseudo/pseudo_n_k'][()].tolist()) - ezfio.set_pseudo_pseudo_n_kl(qph5['pseudo/pseudo_n_kl'][()].tolist()) - ezfio.set_pseudo_pseudo_v_k(qph5['pseudo/pseudo_v_k'][()].tolist()) - ezfio.set_pseudo_pseudo_v_kl(qph5['pseudo/pseudo_v_kl'][()].tolist()) - ezfio.set_pseudo_pseudo_dz_k(qph5['pseudo/pseudo_dz_k'][()].tolist()) - ezfio.set_pseudo_pseudo_dz_kl(qph5['pseudo/pseudo_dz_kl'][()].tolist()) - - ########################################## - # # - # Basis # - # # - ########################################## - - with h5py.File(qph5path,'r') as qph5: - coeftmp = qph5['ao_basis/ao_coef'][()] - expotmp = qph5['ao_basis/ao_expo'][()] ezfio.set_ao_basis_ao_basis(qph5['ao_basis'].attrs['ao_basis']) ezfio.set_ao_basis_ao_nucl(qph5['ao_basis/ao_nucl'][()].tolist()) - ezfio.set_ao_basis_ao_prim_num(qph5['ao_basis/ao_prim_num'][()].tolist()) - ezfio.set_ao_basis_ao_power(qph5['ao_basis/ao_power'][()].tolist()) - ezfio.set_ao_basis_ao_coef(qph5['ao_basis/ao_coef'][()].tolist()) - ezfio.set_ao_basis_ao_expo(qph5['ao_basis/ao_expo'][()].tolist()) + + + #Just need one (can clean this up later) + 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) + + + ########################################### + ## # + ## Pseudo # + ## # + ########################################### + + #with h5py.File(qph5path,'r') as qph5: + # do_pseudo = qph5['pseudo'].attrs['do_pseudo'] + # ezfio.set_pseudo_do_pseudo(do_pseudo) + # if (do_pseudo): + # ezfio.set_pseudo_pseudo_lmax(qph5['pseudo'].attrs['pseudo_lmax']) + # ezfio.set_pseudo_pseudo_klocmax(qph5['pseudo'].attrs['pseudo_klocmax']) + # ezfio.set_pseudo_pseudo_kmax(qph5['pseudo'].attrs['pseudo_kmax']) + # ezfio.set_pseudo_nucl_charge_remove(qph5['pseudo/nucl_charge_remove'][()].tolist()) + # ezfio.set_pseudo_pseudo_n_k(qph5['pseudo/pseudo_n_k'][()].tolist()) + # ezfio.set_pseudo_pseudo_n_kl(qph5['pseudo/pseudo_n_kl'][()].tolist()) + # ezfio.set_pseudo_pseudo_v_k(qph5['pseudo/pseudo_v_k'][()].tolist()) + # ezfio.set_pseudo_pseudo_v_kl(qph5['pseudo/pseudo_v_kl'][()].tolist()) + # ezfio.set_pseudo_pseudo_dz_k(qph5['pseudo/pseudo_dz_k'][()].tolist()) + # ezfio.set_pseudo_pseudo_dz_kl(qph5['pseudo/pseudo_dz_kl'][()].tolist()) + + ########################################## + # # + # Basis(Dummy) # + # # + ########################################## + + #with h5py.File(qph5path,'r') as qph5: + # coeftmp = qph5['ao_basis/ao_coef'][()] + # expotmp = qph5['ao_basis/ao_expo'][()] + # ezfio.set_ao_basis_ao_basis(qph5['ao_basis'].attrs['ao_basis']) + # ezfio.set_ao_basis_ao_nucl(qph5['ao_basis/ao_nucl'][()].tolist()) + # ezfio.set_ao_basis_ao_prim_num(qph5['ao_basis/ao_prim_num'][()].tolist()) + # ezfio.set_ao_basis_ao_power(qph5['ao_basis/ao_power'][()].tolist()) + # ezfio.set_ao_basis_ao_coef(qph5['ao_basis/ao_coef'][()].tolist()) + # ezfio.set_ao_basis_ao_expo(qph5['ao_basis/ao_expo'][()].tolist()) + + + ########################################## + # # + # Basis(QMC) # + # # + ########################################## + + if qmcpack: + with h5py.File(qph5path,'r') as qph5: + ezfio.set_qmcpack_qmc_nshell(qph5['qmcpack'].attrs['qmc_nshell']) + ezfio.set_qmcpack_qmc_prim_num_max(qph5['qmcpack'].attrs['qmc_prim_num_max']) + ezfio.set_qmcpack_qmc_nucl(qph5['qmcpack/qmc_nucl'][()].tolist()) + ezfio.set_qmcpack_qmc_prim_num(qph5['qmcpack/qmc_prim_num'][()].tolist()) + ezfio.set_qmcpack_qmc_lbas(qph5['qmcpack/qmc_lbas'][()].tolist()) + ezfio.set_qmcpack_qmc_coef(qph5['qmcpack/qmc_coef'][()].tolist()) + ezfio.set_qmcpack_qmc_expo(qph5['qmcpack/qmc_expo'][()].tolist()) + + ezfio.set_qmcpack_qmc_pbc(qph5['qmcpack'].attrs['PBC']) + ezfio.set_qmcpack_supertwist(qph5['qmcpack/Super_Twist'][()].tolist()) + ezfio.set_qmcpack_latticevectors(qph5['qmcpack/LatticeVectors'][()].tolist()) + ezfio.set_qmcpack_qmc_mo_energy(qph5['qmcpack/eigenval'][()].tolist()) @@ -596,17 +619,19 @@ if __name__ == '__main__': ARGUMENTS = docopt(__doc__) FILE = get_full_path(ARGUMENTS['FILE']) - + qmcpack = False if ARGUMENTS["--output"]: EZFIO_FILE = get_full_path(ARGUMENTS["--output"]) else: EZFIO_FILE = "{0}.ezfio".format(FILE) + if ARGUMENTS["--qmc"]: + qmcpack = True with h5py.File(FILE,'r') as qph5: do_kpts = ('kconserv' in qph5['nuclei'].keys()) if (do_kpts): print("converting HDF5 to EZFIO for periodic system") - convert_kpts(EZFIO_FILE,FILE) + convert_kpts(EZFIO_FILE,FILE,qmcpack) else: print("converting HDF5 to EZFIO for molecular system") convert_mol(EZFIO_FILE,FILE) diff --git a/src/utils_complex/MolPyscfToQPkpts.py b/src/utils_complex/MolPyscfToQPkpts.py index e1f7862c..46419ca2 100644 --- a/src/utils_complex/MolPyscfToQPkpts.py +++ b/src/utils_complex/MolPyscfToQPkpts.py @@ -892,9 +892,9 @@ def pyscf2QP2(cell,mf, kpts, kmesh=None, cas_idx=None, int_threshold = 1E-8, with h5py.File(qph5path,'a') as qph5: - qph5.create_dataset('qmcpack/PBE',(1,),dtype="b1",data=True) + qph5['qmcpack'].attrs['PBC']=True qph5.create_dataset('qmcpack/Super_Twist',(1,3),dtype="f8",data=sp_twist) - qph5.create_dataset('qmcpack/LatticeVectors',(3,3),dtype="f8",data=cell.lattice_vectors()) + qph5.create_dataset('qmcpack/LatticeVectors',(3,3),dtype="f8",data=cell.lattice_vectors().T) qph5.create_dataset('qmcpack/eigenval',(1,Nk*nmo),dtype="f8",data=mf.mo_energy)