Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some parameter in eval_mu_alpha.py #636

Open
wants to merge 1 commit into
base: mu_alpha
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions mace/cli/eval_mu_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main():

# Load data and prepare input
if args.configs.endswith(".xyz"):
atoms_list = ase.io.read(args.configs, index=":")
atoms_list = ase.io.read(args.configs, index=":", format='extxyz')
if args.output_SFG:
velocities = np.array(
[atoms.arrays[args.velocity_key] for atoms in atoms_list]
Expand Down Expand Up @@ -166,12 +166,12 @@ def main():
dmu_dr = np.split(
torch_tools.to_numpy(output["dmu_dr"]),
indices_or_sections=batch.ptr[1:],
axis=0,
axis=1,
)[:-1]
dalpha_dr = np.split(
torch_tools.to_numpy(output["dalpha_dr"]),
indices_or_sections=batch.ptr[1:],
axis=0,
axis=1,
)[:-1]
dmu_dr_collection.append(dmu_dr)
dalpha_dr_collection.append(dalpha_dr)
Expand Down Expand Up @@ -261,14 +261,18 @@ def main():

if args.compute_dielectric_derivatives:
dmu_dr_list = [
dmu_dr for dmu_dr_list in dmu_dr_collection for dmu_dr in dmu_dr_list
dmu_dr
for dmu_dr_list in dmu_dr_collection
for dmu_dr in dmu_dr_list
]
dalpha_dr_list = [
dalpha_dr
for dalpha_dr_list in dalpha_dr_collection
for dalpha_dr in dalpha_dr_list
]

assert len(atoms_list) == len(dmu_dr_list) == len(dalpha_dr_list)

# Store data in atoms objects
if args.configs.endswith(".xyz"):
for i, (atoms, dmu_dr, dalpha_dr) in enumerate(
Expand All @@ -277,12 +281,8 @@ def main():
atoms.calc = None # crucial
if args.velocity_key in atoms.arrays.keys():
atoms.arrays.pop(args.velocity_key)
atoms.arrays[args.info_prefix + "dmu_dr"] = dmu_dr.reshape(
dmu_dr.shape[0], 9
)
atoms.arrays[args.info_prefix + "dalpha_dr"] = dalpha_dr_list[
i
].reshape(dalpha_dr_list[i].shape[0], 27)
atoms.arrays[args.info_prefix + "dmu_dr"] = dmu_dr.reshape(-1, 9)
atoms.arrays[args.info_prefix + "dalpha_dr"] = dalpha_dr.reshape(-1, 27)
# Write atoms to output path
ase.io.write(args.output, images=atoms_list, format="extxyz")
else:
Expand Down