# pymatgen.core.ion module

Module containing class to create an ion

class Ion(composition, charge=0.0, properties=None)

  Bases: `pymatgen.core.composition.Composition`, `monty.json.MSONable`, `pymatgen.util.string.Stringify`

  Ion object. Just a Composition object with an additional variable to store charge.

  The net charge can either be represented as Mn++, Mn+2, Mn[2+], Mn[++], or Mn[+2]. Note the order of the sign and magnitude in each representation.

  Flexible Ion construction, similar to Composition. For more information, please see pymatgen.core.Composition

  property alphabetical_formula: str

    Returns a formula string, with elements sorted by alphabetically and appended charge

  property anonymized_formula: str

    An anonymized formula. Appends charge to the end of anonymized composition

  as_dict() → Dict[str, float]
    Returns

      dict with composition, as well as charge

  property charge: float

    Charge of the ion

  property composition: pymatgen.core.composition.Composition

    Composition of ion.

  property formula: str

    Returns a formula string, with elements sorted by electronegativity, e.g., Li4 Fe4 P4 O16.

  classmethod from_dict(d) → pymatgen.core.ion.Ion

    Generates an ion object from a dict created by as_dict().

    Parameters

      d – {symbol: amount} dict.

  classmethod from_formula(formula: str) → pymatgen.core.ion.Ion

    Creates Ion from formula. The net charge can either be represented as Mn++, Mn+2, Mn[2+], Mn[++], or Mn[+2]. Note the order of the sign and magnitude in each representation.

    Also note that (aq) can be included in the formula, e.g. “NaOH (aq)”.

    Parameters

      formula –

    Returns

      Ion

  get_reduced_formula_and_factor(iupac_ordering: bool = False, hydrates: bool = True) → Tuple[str, float]

    Calculates a reduced formula and factor.

    Similar to Composition.get_reduced_formula_and_factor except that O-H formulas receive special handling to differentiate between hydrogen peroxide and OH-. Formulas containing HO are written with oxygen first (e.g. ‘Fe(OH)2’ rather than ‘Fe(HO)2’), and special formulas that apply to solids (e.g. Li2O2 instead of LiO) are not used.

    Note that the formula returned by this method does not contain a charge. To include charge, use formula or reduced_formula instead.

    Parameters

      - iupac_ordering (bool, optional) – Whether to order the formula by the iupac “electronegativity” series, defined in Table VI of “Nomenclature of Inorganic Chemistry (IUPAC Recommendations 2005)”. This ordering effectively follows the groups and rows of the periodic table, except the Lanthanides, Actanides and hydrogen. Note that polyanions will still be determined based on the true electronegativity of the elements.

      - hydrates – If True (default), attempt to recognize hydrated metal complexes and separate out the H2O in the reduced formula. For example, Zr(OH)4 becomes ZrO2.2H2O. Applies only to Ions containing metals.

    Returns

      A pretty normalized formula and a multiplicative factor, i.e., H4O4 returns (‘H2O2’, 2.0).

  property reduced_formula: str

    Returns a reduced formula string with appended charge. The charge is placed in brackets with the sign preceding the magnitude, e.g., ‘Ca[+2]’.

  to_pretty_string() → str
    Returns

      Pretty string with proper superscripts.

  property to_reduced_dict: dict

    Returns: dict with element symbol and reduced amount e.g., {“Fe”: 2.0, “O”:3.0}.