Nearest Neighbor, API

I am using the “get_nn_info” function of “BrunnerNN_real” class:
struct = structure of Silicon(mp-149) using MPRester
Code–> BrunnerNN_real.get_nn_info(struct,1)

I am not able to understand the output, specifically of ‘site’.
Can anyone help me in the above ?

Thanks in advance.

------**OUTPUT**------------------------------------------------------------
*[{'image': (0, 0, 0),*
*  'site': PeriodicSite: Si (0.0000, 0.0000, 0.0000) [0.0000, 0.0000, 0.0000],*
*  'site_index': 0,*
*  'weight': 1.0},*
* {'image': (0, 0, 1),*
*  'site': PeriodicSite: Si (0.0000, 0.0000, 3.8676) [0.0000, 0.0000, 1.0000],*
*  'site_index': 0,*
*  'weight': 1.0},*
* {'image': (1, 0, 0),*
*  'site': PeriodicSite: Si (3.3494, 0.0000, 1.9338) [1.0000, 0.0000, 0.0000],*
*  'site_index': 0,*
*  'weight': 0.9999999995270631},*
* {'image': (0, 1, 0),*
*  'site': PeriodicSite: Si (1.1165, 3.1578, 1.9338) [0.0000, 1.0000, 0.0000],*
*  'site_index': 0,*
*  'weight': 0.9999999992707674}]*
---------------------------------------------------------------------------------------------------------

Hi @Rajesh_Sharma,

When provided with a crystal and an atom of interest, pymatgen has several algorithms to try and determine that atom’s neighbors (in other words, which other atoms in the crystal it is likely bonded to). BrunnerNN is one of these algorithms.

You’ve used BrunnerNN correctly here: you’ve asked pymatgen for information on the neighbors of the atom at site 1 in your Si crystal using get_nn_info(struct, 1). Bear in mind that sites are 0-indexed, so the first site is site 0, as is conventional with Python.

It has returned a list of four entries: your Si atom has four neighbors (as you would expect). The site key of each entry tells you the position and species of that neighbor, so hear all four neighbors are Si atoms. And then the image key tells you whether the neighboring atom is in your origin unit cell at image (0, 0, 0) or whether the neighboring atom is in an adjacent cell, for example the next cell over in the +x direction would be image (1, 0, 0). Given that many primitive unit cells might only have one or two atoms, it makes sense that the neighboring atoms are therefore in adjacent images.

On a more technical note, the site key returns an object of kind PeriodicSite, this is simply a container for how pymatgen stores information about a periodic site, in other words the site’s co-ordinates, its lattice, and the occupancy of the site. You can find more information on PeriodicSite here.

Hope this helps!

Matthew

Thanks a lot for the explaination @mkhorton.

Hi @mkhorton
Do you know any method (via API) to find out the co-ordinates of the site index which we are passing as an argument in the function to find nearest neighbor.

As I am interested to find out the distance between site index and the nearest neighbouring site.

Thanks in advance.
Regards,
Rajesh Sharma

Hi @Rajesh_Sharma, please do not double-post your questions.

If you’re calling get_nn_info(struct, 1) you already have the structure object itself, therefore you can ask for struct[1] to get the site, and that has the struct[1].frac_coords for fractional co-ordinates and struct[1].coords for Cartesian co-ordinates of that site.

Hi @mkhorton
Using the above code(struct[1].coords) I am getting negative coordinates but when I am cross-validating with another software(XCrystan and VESTA), I am getting different coordinates.

Any suggestions and corrections from your side?

Regards,
Rajesh Sharma

Hi @Rajesh_Sharma,

I’d need more information to comment further – e.g. screenshots of the results from XCrysDen and VESTA compared to MP for the same structure, and also the structure itself.

In general, as far as structure co-ordinates go, I would be surprised if there’s a bug in either pymatgen or in VESTA/XCrysDen, since this functionality is very widely used. My guess is that it’s probably some inconsistency in the structure supplied or subtlety in interpretation.

Best,

Matt

Hi @mkhorton,
I will be able to send you the screenshots of the results only day after tomorrow(still not sure about that) because of some serious technical issue on my server.
Till then, Can you please tell me the way to verify(check the correctness) the co-ordinates that I have fetched via API ?
As it might clear my previous query.

Regards,
Rajesh Sharma

Hi @Rajesh_Sharma, the co-ordinates returned from the API for Si (mp-149) are correct. Note that this may not be in the crystallographic setting you’re used to; it’s in a primitive setting, not the conventional setting.