Package _global.tri.oxidationstates.util
Class Composition
java.lang.Object
_global.tri.oxidationstates.util.Composition
A utility class to represent a composition
-
Constructor Summary
ConstructorsConstructorDescriptionComposition(String composition) Create a composition from the given composition stringComposition(String[] symbols, double[] counts) Create a composition from the given symbols and counts.Composition(String[] symbols, int[] counts) Create a composition from the given symbols and counts.Composition(Map map) Create a composition from a map in which the keys are ion type symbols and the values are amounts. -
Method Summary
Modifier and TypeMethodDescriptionReturns a map representation of this composition in which the keys are symbols and the values are amounts.doubleReturns the amount of the given symbol in this composition.matsci.Element[]Returns the distinct elements in the compound represented by this composition.Return the composition in terms of elements.Returns a map in which the keys are the distinct elements in the compound represented by this composition, and the values are the corresponding amounts.Returns this composition in terms of known ion types, including polyatomic ions.Returns a composition in terms of known ion types, including polyatomic ions.For compositions with integer (or near-integer) counts for all symbols, returns the composition with all counts divided by their greater common factor.Returns a standardized string representation of this composition.getStandardizedCompositionString(String delimiter) Returns a standardized string representation of this composition, using the given delimiter to separate terms.Returns the symbols for this compositionbooleanisChargeBalanced(double tolerance) Returns true if this composition is charge balanced within the given charge sum tolerance, or false if it is not.booleanmatches(Composition composition, double tolerance) Returns true if the given composition matches this one, within the given tolerance for amounts.
-
Constructor Details
-
Composition
Create a composition from a map in which the keys are ion type symbols and the values are amounts.- Parameters:
map- a map in which the keys are symbols and the values are amounts.
-
Composition
Create a composition from the given symbols and counts.- Parameters:
symbols- The symbols for tne ion types in this composition (or similar molecular units)counts- The amounds for each symbol. The indices of this array correspond to those for the symbols array.
-
Composition
Create a composition from the given symbols and counts.- Parameters:
symbols- The symbols for tne ion types in this composition (or similar molecular units)counts- The amounds for each symbol. The indices of this array correspond to those for the symbols array.
-
Composition
Create a composition from the given composition string- Parameters:
composition- A string representation of the composition
-
-
Method Details
-
getReducedComposition
For compositions with integer (or near-integer) counts for all symbols, returns the composition with all counts divided by their greater common factor.- Returns:
- the composition with all counts divided by their greater common factor for compositions with integer (or near-integer) counts for all symbols
-
getSymbols
Returns the symbols for this composition- Returns:
- the symbols for this composition
-
getCount
Returns the amount of the given symbol in this composition.- Parameters:
symbol- The given symbol (typically an element symbol or ion type).- Returns:
- the amount of the given symbol in this composition.
-
getCompositionMap
Returns a map representation of this composition in which the keys are symbols and the values are amounts. The map is sorted by symbol.- Returns:
- a map representation of this composition in which the keys are symbols and the values are amounts. The map is sorted by symbol.
-
getElementalComposition
Return the composition in terms of elements. E.g. all symbols for polyatomic ion types will be replaced by the symbols for the corresponding elements.- Returns:
- the composition in terms of elements. E.g. all symbols for polyatomic ion types will be replaced by the symbols for the corresponding elements.
-
getDistinctElements
public matsci.Element[] getDistinctElements()Returns the distinct elements in the compound represented by this composition.- Returns:
- the distinct elements in the compound represented by this composition.
-
getElementalCompositionMap
Returns a map in which the keys are the distinct elements in the compound represented by this composition, and the values are the corresponding amounts.- Returns:
- a map in which the keys are the distinct elements in the compound represented by this composition, and the values are the corresponding amounts.
-
getKnownIonComposition
Returns this composition in terms of known ion types, including polyatomic ions.- Returns:
- this composition in terms of known ion types, including polyatomic ions.
-
getKnownIonCompositionMap
Returns a composition in terms of known ion types, including polyatomic ions.- Returns:
- a composition in terms of known ion types, including polyatomic ions.
-
getStandardizedCompositionString
Returns a standardized string representation of this composition.- Returns:
- a standardized string representation of this composition.
-
getStandardizedCompositionString
Returns a standardized string representation of this composition, using the given delimiter to separate terms.- Parameters:
delimiter- The delimiter used to separate terms.- Returns:
- a standardized string representation of this composition, using the given delimiter to separate terms.
-
matches
Returns true if the given composition matches this one, within the given tolerance for amounts.- Parameters:
composition- The given composition.tolerance- The given tolerance for amounts.- Returns:
- true if the given composition matches this one, within the given tolerance for amounts.
-
isChargeBalanced
public boolean isChargeBalanced(double tolerance) Returns true if this composition is charge balanced within the given charge sum tolerance, or false if it is not.- Parameters:
tolerance- The given charge sum tolerance- Returns:
- true if this composition is charge balanced within the given charge sum tolerance, or false if it is not.
-