Package io.github.monomer.Chem.Core
Class EmpiricalFormulaUtil
java.lang.Object
io.github.monomer.Chem.Core.EmpiricalFormulaUtil
A utility class for manipulating and generating empirical formulas.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getEmpiricalFormulaFromPercentComposition
(Map<Element, Float> percentComposition) A method for building an empirical formula from a mapping of Elements to their constituent relative frequencies in the Compound.static String
getHydrocarbonFromCombustion
(float CO2, float H2O) A method for building the empirical formula of a hydrocarbon given the grams of CO2 and grams of H2O formed in its combustion.
-
Constructor Details
-
EmpiricalFormulaUtil
public EmpiricalFormulaUtil()
-
-
Method Details
-
getEmpiricalFormulaFromPercentComposition
public static String getEmpiricalFormulaFromPercentComposition(Map<Element, Float> percentComposition) throws IOExceptionA 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
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 hydrocarbonH2O
- The grams of water formed as a result of the combustion of the hydrocarbon- Returns:
- The empirical formula of the hydrocarbon
- Throws:
IOException
-