CSMSL.Chemistry.PeriodicTable.GetIsotope C# (CSharp) Method

GetIsotope() static private method

Get an isotope based on its unique isotope id
static private GetIsotope ( int uniqueId ) : Isotope
uniqueId int The unique isotope id of isotope to get
return Isotope
        internal static Isotope GetIsotope(int uniqueId)
        {
            return _isotopes[uniqueId];
        }

Same methods

PeriodicTable::GetIsotope ( string element, int atomicNumber ) : Isotope

Usage Example

        public static IEnumerable <IChemicalFormula> Validate(this IEnumerable <IChemicalFormula> formulas, FilterTypes filters = FilterTypes.All)
        {
            bool useValence             = filters.HasFlag(FilterTypes.Valence);
            bool useHydrogenCarbonRatio = filters.HasFlag(FilterTypes.HydrogenCarbonRatio);

            foreach (IChemicalFormula formula in formulas)
            {
                if (useHydrogenCarbonRatio)
                {
                    double ratio = formula.ChemicalFormula.GetCarbonHydrogenRatio();

                    if (ratio < 0.5 || ratio > 2.0)
                    {
                        continue;
                    }
                }

                if (useValence)
                {
                    int   totalValence = 0;
                    int   maxValence   = 0;
                    int   oddValences  = 0;
                    int   atomCount    = 0;
                    int[] isotopes     = formula.ChemicalFormula.GetIsotopes();
                    for (int i = 0; i < isotopes.Length; i++)
                    {
                        int numAtoms = isotopes[i];
                        if (numAtoms != 0)
                        {
                            continue;
                        }
                        Isotope isotope = PeriodicTable.GetIsotope(i);

                        int numValenceElectrons = isotope.ValenceElectrons;
                        totalValence += numValenceElectrons * numAtoms;
                        atomCount    += numAtoms;
                        if (numValenceElectrons > maxValence)
                        {
                            maxValence = numValenceElectrons;
                        }
                        if (numValenceElectrons % 2 != 0)
                        {
                            oddValences += numAtoms;
                        }
                    }
                    if (!((totalValence % 2 == 0 || oddValences % 2 == 0) && (totalValence >= 2 * maxValence) && (totalValence >= ((2 * atomCount) - 1))))
                    {
                        continue;
                    }
                }

                yield return(formula);
            }
        }
All Usage Examples Of CSMSL.Chemistry.PeriodicTable::GetIsotope