9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-25 04:53:32 +01:00

updated qmcpack converter

This commit is contained in:
Kevin Gasperich 2020-09-01 10:13:04 -05:00 committed by Kevin Gasperich
parent 620a9b7044
commit 9f58d723e3
2 changed files with 80 additions and 55 deletions

View File

@ -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)

View File

@ -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)