feat: Add structure adapter to convert ASE.Atom objects to diffpy.structure.Structure objects and additional useful methods#187
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
==========================================
+ Coverage 98.93% 98.99% +0.05%
==========================================
Files 13 13
Lines 1884 1987 +103
==========================================
+ Hits 1864 1967 +103
Misses 20 20
🚀 New features to boost your workflow:
|
| # We set the expected error message to None because this expectation is | ||
| # out of our control, but it is good to make sure that we are | ||
| # raising the error from ASE. | ||
| (["get_magnetic_moments"], RuntimeError, None), |
There was a problem hiding this comment.
This basically is a test for ase and not diffpy.structure. do you think its okay to leave this?
|
@sbillinge ready for review. ase to diffpy.structure adapter. |
|
Let's chat about this. It seems that adding ase as a dependency is a big step and we need to understand better the use-cases. Let's start with use-cases, then we can work on design and tests. Then we can code. Especially when we have AI to write the code, this process is the most important because the code-writing is the lowest cost now and the biggest risk is to introduce bloat and entropy because the AI doesn't care too much about that it seems like. |
|
@sbillinge Here's the UCs i thought of and is what guided the code on this PR. Only option 2 is included here. Option 1 would be on a different PR. Both 1a and 1b would be things that would need to be implemented in
Any other use cases you could think of? Also, we might be able to get away with this without adding it as a dependency. The only use for it is an |
|
The main question is serialization. I think that if it is possible to serialize ASE objects we can read them without an ASE dependency. We can also have code to write them. Your UCs are good for some kind of high throughout pipeline where ASE is generating large numbers of objects that are being passed to Diffpy and serialization would be a serious performance bottleneck. However I do see the use and convenience. It occured to me that we could make an ASE pack so we don't pick up a new dependency in the core. |
|
I think that thinking of actual UCs could be good. The one highest on my list would be to take an MD simulation and Compute the PDF. Another would be to support something like Soham's cluster mining. We should maybe check how he did it as he may already have some code. I would guess that the code is on gitlab |
|
For these UCs do you know if it is Atoms objects or Some other kind of ASE objects that is passed? |
See news file for all the methods that are added.
This converts
ase-->diffpy.structure. The method also includes the optionallost_infoinput. Here, the user can provide an attribute or method of thease.Atomsobject as a string or list of strings to get additional information that is available in ase that is not supported in diffpy.structure (magnetic moments, velocities, etc).