pymatgen
pymatgen copied to clipboard
[feature request] embedding structure in another
I'd like to be able to embed one structure inside another. Roughly speaking, some of the sites should match exactly, while others may be quite different. The application that I have in mind is embedding a defect from a small supercell inside a larger supercell to cut down on the computational cost of the relaxation.
It seems like this almost does part of what I need. Although, it looks like mode == 'delete' (which I need) is not implemented.
Is this functionality implemented anywhere in pymatgen? I can work on it if not, but no sense in duplicating work.
I don't think this functionality is implemented as a method anywhere, but I am unclear whether this requires its own method at all. Thinking about it in my head, this should not require more than 10 lines of code to do?
For this specific case, the merge_sites
docstring claims mode=='delete'
exists, does this definitely not work? An omission if so.
I have not tested, but it seems that it should work. Delete is basically the default option where you don't even "merge" sites per se. That is why in the code it says "if mode == "sum". That is when you need to combine site species. For delete, the overlapping site is just ignored.
For merge_sites
, I would expect that for mode == 'delete'
, the coordinates would not be averaged over each of the sites being merged.
I agree that a naive implementation making certain assumptions might take 10 lines of code (definitely if merge_sites
behaves how I expect), but if you want to be more robust, it could get long. The naive implementation might assume the lattices are similar, but this doesn't have to be the case. For example, you might start with the a 3x3x3 cubic primitive cell and want to embed this in a conventional standard supercell. Also, you may only need to determine a translation to align the atoms in the cell, but there could be rotations also, which will get complex.
Hi @mturiansky, As I understand you want to implant a smaller SC in a large (non-diagonal) SC. there might be a way of doing this with a ghost unit cell.
The setup will be:
- Get a reference base unit cell used for both SCs.
- Use the StructureMatcher module to get the mapping between the pure UC and the SC for both supercells. <-- these is gonna be nice and invertible.
- The you can get put those two transformations together to implant the smaller SC into the larger SC.
I'm adding a simpler version of this that only deals with just mapping positions from SC to UC to pymatgen-diffusion but it should also be portable for this case provided the defect is center-cell and you add some logic to lock down the atoms at the boundary during the mapping.
Thanks for the suggestion. Since no one seemed to be interested in a more general version, I just kept it simple for what I needed. I ended up slightly modifying the merge_sites function on my fork to check for a "keep" site property. This way I can just tag the sites that I want to keep before adding them to the supercell and running merge_sites. I just figured out the translation vector to line the sites up by hand. This won't work for vacancies of course, but it won't really care if your defect is in the center of the cell.