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

Fix missing stress unit conversion (kBar->eV/A^3) in json_to_extxyz.py #61

Merged
merged 25 commits into from
Nov 22, 2023

Conversation

chiang-yuan
Copy link
Contributor

No description provided.

@janosh janosh added data Data loading and processing fix Bug fix labels Nov 22, 2023
Copy link
Owner

@janosh janosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chiang-yuan Thanks for noticing and submitting fix! 👍


block = json_data[material_id][trajectory_id]
for trajectory_id in json_data[material_id]:
block = copy.deepcopy(json_data[material_id][trajectory_id])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is copy.deepcopy really needed? This might slow down the conversion substantially. Is it to avoid errors on processing twice? Maybe better to keep a dict that maps processed IDs to processed results. That way you can check in constant time whether you should skip an ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since I use dict.pop the error will raise if size of dictionary changes within a for loop. copy will avoid that. The speed is doable for now it is roughly one hour processing time

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always good to leave why comments in the code. Why are you doing something (if it's not obvious).

2nd question: Why are you using pop? What's wrong with get?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don’t want repeated forces, stress, magmoms, energy show up in atoms.info

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow. get also returns None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but get will not remove the key value pair from the dictionary and those will all go into atoms.info

for key, value in block.items():
atoms.info[key] = value

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's just use set arithmetic to exempt those keys from double processing then.

@janosh janosh changed the title add stress unit conversion to json_to_extxyz.py Fix missing stress unit conversion (kBar->eV/A^3) in json_to_extxyz.py Nov 22, 2023
@janosh janosh merged commit 50f720b into janosh:main Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Data loading and processing fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants