How to get the coordination number

Hi all, I have a problem getting the coordination numbers as shown in the page “”.

I could not get the coordination number from the code below:

data = m.query(criteria={“task_id”: “mp-2334”},
properties=[“pretty_formula”, “material_id”,‘’])


It seems that the “coordination_no” has been removed from “properties” ? May I know how to get it from a structure? Thanks!

Yes, this is not present at the moment, though should be added back. The schema is out of data and needs to be updated.

Co-ordination numbers depend on the algorithm you use to determine bonding/local environments, so they’re not uniquely determined. This is in part why they’re ambiguous and more thought is being put into how we report them. Currently, we recommend one of the NearNeighbor classes in pymatgen.analysis.local_env and in particular CrystalNN, if you get your structure you can then do:

from pymatgen.analysis.local_env import CrystalNN
nn = CrystalNN()
nn.get_cn(your_structure, your_site_index)

You can then decorate all sites of your structure in this way, e.g.

                              [nn.get_cn(your_struct, idx)
                               for idx in range(len(your_struct))])
1 Like

Follow up question to above answer: As you mentioned the coordination number depends on the algorithm and cannot be uniquely determined. My naive thinking is why so? For example in Mn2V2O7-mp-19142, some algorithms gives the coordination number for V as 5, while some gives 4. When I look at the structure in VESTA, it shows the 5 coordination. This number change occurs when I use CrystalNN(search_cutoff = 3.5, distance_cutoffs = None, x_diff_weight=0.0, porous_adjustment=False ) rather than CrystalNN(). One approach determines the VESTA type for one compound while the other one determines for next compound. Its really difficult to make a decision, which one shall we use?

Unfortunately, there’s no good answer to this. CrystalNN is the latest algorithm we’ve developed (development led by Anubhav Jain, paper pending), and this is generally more reliable than other methods, but it isn’t perfect. Often, decorating your structure with oxidation state information leads to a more reliable result since the algorithm can make use of its knowledge of ionic radii.