Finding electron count of MP_API CHGCAR

Hello! I browsed the forum for similar questions in the past and didn’t find any that answered my question, so I’m posting it below. I apologize if any of this should be obvious to a more experienced user!

I am trying to use Bader analysis to obtain oxidation states of some structures. To do this, I downloaded the CHGCARs from the MP_API and run Bader on the files. I then subtracted the Bader charge of each atom from the total number of valence electrons of that atom using a POTCAR that I have generated. My issue is that I am getting some odd values: for example, in mp-1220693, I get a charge of 16.5 and therefore an oxidation state of -5.5 on the Cu atom. While troubleshooting, I noticed that the total number of electrons (55 e-) from the Bader analysis is far fewer than I would expect from the total charge density of this structure. I am unsure how many electrons were originally included in the CHGCAR calculation for any given atom, which I suspect is where my problem is coming from. This brings me to my question: is there a way to see what pseudopotentials were used, and from there, see how many electrons would be included for each atom? Additionally, can I expect pseudopotentials to be consistent across MP and assume that an atom of element X would have the same number of electrons in two different structures?

TL:DR: To obtain Bader-approximated oxidation states, I am essentially trying to determine the correct number of electrons from which to subtract the Bader charge, which would be however many electrons are used in the CHGCAR calculation for that atom. I am looking for a way to determine the number of electron electrons that are accounted for in each atom in the pseudopotential.

Hi @ehrhardtk, this should do it:

chgcar, tdoc = mpr.get_charge_density_from_material_id("mp-48", inc_task_doc=True)
tdoc.input.parameters["NELECT"]

If you want the specific POTCARs that data is also nested in tdoc somewhere.

Hi @jshen,

Thanks for your reply! It seems that using the NELECT parameter is lightly different from what I am looking for, because it returns the total number of electrons in the entire structure while I am looking for this information on an atom-by-atom basis. The POTCAR would work perfectly for my needs, if I can figure out how to obtain it! Taking a look around some documentation didn’t help me much; would you mind pointing me in the right direction?

Thanks!

I think the closest thing I can find in the document model is this:

print(tdoc.calcs_reversed[0].input.potcar_spec)
# [PotcarSpec(titel='PAW_PBE C 08Apr2002', hash='c0a8167dbb174fe492a3db7f5006c0f8', summary_stats=None)]

I’m not sure if the number of electrons associated with each “titel” is stored anywhere in the codebase so you might have to parse and store that youself.