# Inquiry over the "elements" criteria - number of atoms

#1

I’ve been successfully using MaterialsProject in Python via MPDataRetrieval, and have generally found it very intuitive.

This may be a very stupid question. However, I cannot find the answer to my question despite searches and hence must ask it here.

If one wanted to search for materials containing sodium, phosphorus, and oxygen, the criteria could be defined as

``````"elements": {"\$all": ["Na","P","O"]
``````

However, what if you wanted exactly 4 oxygen atoms in your results? How would you specify that?

Thank you

#2

Use the reduced_cell_formula field:

``````{"elements": {"\$all": ["Na","P","O"]}, "reduced_cell_formula.O": 4}
``````

Best,
Donny

#3

Hi Donny

Thank you for the rapid reply

I used the following criteria
“elements”: {"\$all": [“Na”,“P”,“O”]},
“reduced_cell_formula”: {“O”:4},

But the resulting csv is completely empty. Have I missed out something?

#4

There is a subtle but impactful difference between the criteria

``````{"reduced_cell_formula.O": 4} # expression "A"
``````

and

``````{"reduced_cell_formula": {"O":4}} # expression "B"
``````

In expression “A”, MongoDB’s so-called “dot notation” (use of the period “.” to separate field names) is used to say something like “find me entries that have a field `reduced_cell_formula` that, in turn, have a field within them called `O` (oxygen) with an assigned value of 4.”

In contrast, expression “B” says something like "find me entries that have a field `reduced_cell_formula` with an assigned value of `{"O": 4}`, that is, the reduced cell formula is interpretable as four oxygen atoms and no number of any other elements. Clearly, there will be no material with such a reduced cell formula - even elemental oxygen compounds will have `{"O": 1}` as their `reduced_cell_formula` value.

I hope this helps.