Class EmpiricalFormulaUtil

java.lang.Object
io.github.monomer.Chem.Core.EmpiricalFormulaUtil

public final class EmpiricalFormulaUtil extends Object
A utility class for manipulating and generating empirical formulas.
See Also:
  • Constructor Details

    • EmpiricalFormulaUtil

      public EmpiricalFormulaUtil()
  • Method Details

    • getEmpiricalFormulaFromPercentComposition

      public static String getEmpiricalFormulaFromPercentComposition(Map<Element,Float> percentComposition) throws IOException
      A method for building an empirical formula from a mapping of Elements to their constituent relative frequencies in the Compound.
      Parameters:
      percentComposition - A HashMap of Element objects and proportions in floating-point precision
      Returns:
      The empirical formula that corresponds to such a percent composition as a String
      Throws:
      IOException - Incase the Element object does not exist
    • getHydrocarbonFromCombustion

      public static String getHydrocarbonFromCombustion(float CO2, float H2O) throws IOException
      A method for building the empirical formula of a hydrocarbon given the grams of CO2 and grams of H2O formed in its combustion.
      Parameters:
      CO2 - The grams of carbon dioxide formed as a result of the combustion of the hydrocarbon
      H2O - The grams of water formed as a result of the combustion of the hydrocarbon
      Returns:
      The empirical formula of the hydrocarbon
      Throws:
      IOException