Skip to content

Commit

Permalink
Merge pull request #249 from JoonhoLee-Group/fix_qmcpack_read
Browse files Browse the repository at this point in the history
Fix qmcpack read
  • Loading branch information
fdmalone authored Aug 26, 2023
2 parents 1c48e41 + 671cdfc commit b9973b6
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions ipie/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@


def write_hamiltonian(
hcore: numpy.ndarray,
LXmn: numpy.ndarray,
e0: float,
filename: str = "hamiltonian.h5",
hcore: numpy.ndarray, LXmn: numpy.ndarray, e0: float, filename: str = "hamiltonian.h5"
) -> None:
assert len(hcore.shape) == 2, "Incorrect shape for hcore, expected 2-dimensional array"
nmo = hcore.shape[0]
Expand Down Expand Up @@ -219,10 +216,7 @@ def write_json_input_file(
):
na, nb = nelec
basic = {
"system": {
"nup": na,
"ndown": nb,
},
"system": {"nup": na, "ndown": nb},
"hamiltonian": {"name": "Generic", "integrals": hamil_filename},
"qmc": {
"dt": timestep,
Expand Down Expand Up @@ -554,8 +548,8 @@ def from_qmcpack_sparse(filename):
hcore = hcore.view(numpy.complex128).reshape(nmo, nmo)
except KeyError:
# Old sparse format.
hcore = numpy.ndarray(fh5["Hamiltonian/H1"][:]).view(numpy.complex128).ravel()
idx = numpy.ndarray(fh5["Hamiltonian/H1_indx"][:])
hcore = numpy.array(fh5["Hamiltonian/H1"][:]).view(numpy.complex128).ravel()
idx = fh5["Hamiltonian/H1_indx"][:]
row_ix = idx[::2]
col_ix = idx[1::2]
hcore = scipy.sparse.csr_matrix((hcore, (row_ix, col_ix))).toarray()
Expand All @@ -575,18 +569,14 @@ def from_qmcpack_sparse(filename):
col_ix = numpy.zeros(nval, dtype=numpy.int32)
s = 0
for ic, bs in enumerate(block_sizes):
ixs = numpy.ndarray(fh5["Hamiltonian/Factorized/index_%i" % ic][:])
ixs = fh5["Hamiltonian/Factorized/index_%i" % ic][:]
row_ix[s : s + bs] = ixs[::2]
col_ix[s : s + bs] = ixs[1::2]
if real_ints:
vals[s : s + bs] = numpy.real(
numpy.ndarray(fh5["Hamiltonian/Factorized/vals_%i" % ic][:])
).ravel()
vals[s : s + bs] = numpy.real(fh5["Hamiltonian/Factorized/vals_%i" % ic][:]).ravel()
else:
vals[s : s + bs] = (
numpy.ndarray(fh5["Hamiltonian/Factorized/vals_%i" % ic][:])
.view(numpy.complex128)
.ravel()
fh5["Hamiltonian/Factorized/vals_%i" % ic][:].view(numpy.complex128).ravel()
)
s += bs
nalpha = dims[4]
Expand Down

0 comments on commit b9973b6

Please sign in to comment.