Skip to content

Commit

Permalink
Support complex U in interaction=file mode
Browse files Browse the repository at this point in the history
  • Loading branch information
j-otsuki committed Apr 25, 2024
1 parent 968db6e commit cba5282
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dcore/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,16 @@ def _generate_umat_file(p: Dict):
try:
if os.path.splitext(file)[1] == ".npy":
umat = numpy.load(file)
assert umat.shape == u_shape, f"inconsistent shape: require {u_shape}, but {umat.shape} is given"
assert umat.shape == u_shape, f"inconsistent shape: require {u_shape}, but {umat.shape} is given."
else:
umat_1d = numpy.loadtxt(file)
umat = umat_1d.reshape(u_shape)
if umat_1d.shape == (numpy.prod(u_shape),): # real U
umat = umat_1d.reshape(u_shape)
elif umat_1d.shape == (numpy.prod(u_shape), 2): # complex U
# float (norb^4, 2) -> complex (norb^4, 1) -> complex (norb,norb,norb,norb)
umat = umat_1d.view(complex).reshape(u_shape)
else:
raise Exception(f"inconsisten shape: require {(numpy.prod(u_shape),)} for real U or {(numpy.prod(u_shape), 2)} for complex U, but {umat_1d.shape} is given.")
except Exception as e:
print(f"\nError in reading file '{file}' for ish={ish}", file=sys.stderr)
print(e, file=sys.stderr)
Expand Down

0 comments on commit cba5282

Please sign in to comment.