Closed rkingsbury closed 1 year ago
Looks like oxidation state of 0 for diatomic molecules isn't specified in Element.icsd_oxidation_states
or Element.oxidation_states
here
Not sure if the better solution is to update that data or just hard-code a special case for single-element diatomic molecules in oxi_state_guesses()
:
if len(self.elements) == 1 and self.element_composition[self.elements[0]] == 2:
return ({self.elements[0].symbol: 0.0},)
Maybe @shyuep or @mkhorton want to weigh in?
I discovered this morning that this can be partially solved by passing all_oxi_states=True
, but there still appears to be data missing for F2
.
Given how commonly diatomic gases arise in, e.g., formation energy calcs, I also think we should not require a non-default kwarg just to get the correct oxidation state for these substances.
>>> Composition('O2').oxi_state_guesses(all_oxi_states=True)
({'O': 0.0},)
>>> Composition('Cl2').oxi_state_guesses(all_oxi_states=True)
({'Cl': 0.0},)
>>> Composition('F2').oxi_state_guesses(all_oxi_states=True)
[]
>>> Composition('I2').oxi_state_guesses(all_oxi_states=True)
({'I': 0.0},)
>>> Composition('Br2').oxi_state_guesses(all_oxi_states=True)
({'Br': 0.0},)
>>> Composition('N2').oxi_state_guesses(all_oxi_states=True)
({'N': 0.0},)
>>> Composition('H2').oxi_state_guesses(all_oxi_states=True)
({'H': 0.0},)
I am not actually sure who relies on oxi_state_guesses. As their name implies, they are guesses. The guesses are probably not very useful. For diatomic gases, I would simply set oxidation state to 0 since that's the only possible charge neural solution. In fact, all elemental systems (be it metals, gases or whatever) should have an oxidation state of 0. @janosh Can you correct your recent PR to reflect this?
Thanks for the quick action @janosh and @shyuep 👍🏻
Email (Optional)
No response
Version
latest from git as of 2023.09.14
Which OS(es) are you using?
What happened?
Ion.oxi_state_guesses
to determine oxidation states of elements in aqueous species. This method inherits fromComposition
O2
. Subsequent testing revealed thatO2,
,Cl2
, andF2
return empty lists[]
, whereasN2
andH2
return tuples of dicts, as expected.Element.common_oxidation_states
for each of these elements, but none contains 0 as a common oxi state. Nevertheless, 0 is correctly returned byComposition.oxi_state_guesses
for two of them.Code snippet
Log output
No response
Code of Conduct