exa-analytics / exatomic

A unified platform for theoretical and computational chemists
https://exa-analytics.github.io/exatomic
Apache License 2.0
19 stars 12 forks source link

Extending the sym2mass mapper to account for isotopes of elements #172

Closed herbertludowieg closed 4 years ago

herbertludowieg commented 5 years ago

Is your feature request related to a problem? Please describe. There seems to be an issue when comparing the atomic mass values reported by quantum codes and the reported values from the exatomic.base.sym2mass mapper. It seems that, in quantum codes, the values they use are specific to the isotope whereas the exatomic.base.sym2mass mapper uses the weighted averages from NIST as should be the case in most applications.

However, if there is a need for an isotope dependent mass property this treatment is no longer valid and as such I propose some new way of converting the masses from the symbols. Where, we can have some input for the isotope of interest and if it is not given then we assume the most abundant isotope. We already have this information in the exa.util.isotopes.##['iso'].af and exa.util.isotopes.##['iso'].mass.

An initial thought for the code structure would be:

from exa.util import isotope

def some_function_to_determine_most_abundant(sym_dict):
    # iterate over available isotopes? very inefficient for now
    mass = sym_dict[str(determined_isotope)].mass
    return mass

def isotopemapper(symbol, isotope=None):
    if isotope is None:
        # assume the most abundant species
        mass = some_function_to_determine_most_abundant(isotope.symbol)
    else:
        # use the isotope input
        mass = isotope.symbol[str(isotope)].mass
    return mass

Additional context The following code can be used to see the difference.

from exa.util import isotopes
from exatomic.base import sym2mass

sym2mass['Pt']
isotopes.Pt['195'].af
isotopes.Pt['195'].mass

Where, the isotope 195 for Pt is the most abundant at 33%

avmarchenko commented 5 years ago

I think the code and explanation are logical. I think the expectation should be that the mass of an isotope is the mass of that isotope and the mass of the element is calculated as the weighted (abundance fraction) mass. As long as the proposed changes don't limit those constraints, I think this is a valuable enhancement. Does that make sense?

herbertludowieg commented 5 years ago

Yeah, so this is something I am trying out as a working first draft, sym2isomass.txt Basically, I wanted to make a new function that can generate a mapper like sym2mass, where, you give the function the symbols and isotopes and it will spit back the masses. Maybe there is a way to combine them, but that is not immediately obvious to me at the moment.

I'm not planning to push code until I figure out what's going on with the categoricals.