public class CompositionEntry extends MultiPropertyEntry
Equality is computed based on the composition, and the attributes. In most cases, entries with the same composition will have the same attributes. However, one may introduce properties as attributes PropertyAsAttributeGenerator, which can cause entries witht the same composition to have different attributes.
Modifier and Type | Field and Description |
---|---|
protected int[] |
Element
Elements present in composition
|
protected java.lang.String[] |
ElementNames
Names of each element
|
protected double[] |
Fraction
Fraction of each element
|
boolean |
HTMLFormat
Whether to print composition in HTML Format
|
protected double |
NumberInCell
Number of atoms in cell (used to convert when printing)
|
protected int[] |
SortingOrder
Rank of each element (used in display order)
|
Modifier | Constructor and Description |
---|---|
protected |
CompositionEntry()
Allows the creation of arbitrary constructors for superclasses.
|
|
CompositionEntry(int[] Element,
double[] Amount)
Given the element numbers (probably Z-1) and fractions, create an entry
|
|
CompositionEntry(java.lang.String Composition)
Make a new instance by parsing the composition of an object, provided by a string.
|
Modifier and Type | Method and Description |
---|---|
CompositionEntry |
clone()
Generates a clone of an entry.
|
void |
combineCompositions(java.util.Map<java.lang.Integer,java.lang.Double> totalComp,
java.util.Map<java.lang.Integer,java.lang.Double> addComp,
double multiplier)
Add composition from one map to another
|
int |
compare(java.lang.Object A_obj,
java.lang.Object B_obj) |
boolean |
equals(java.lang.Object other) |
double |
getAverageDeviation(double[] Lookup)
Calculate the mean deviation of a property from the average.
|
double |
getAverageDeviation(double[] Lookup,
double mean)
Calculate the mean deviation of a property from the average.
|
double |
getElementFraction(int element)
Return the fraction of a certain element found in an entry
|
double |
getElementFraction(java.lang.String elem)
Return the fraction of a certain element found in an entry
|
int[] |
getElements() |
double[] |
getFractions() |
double |
getMaxDifference(double[] Lookup)
Calculate maximum difference between the properties of two elements that
are present in this entry
|
double |
getMaximum(double[] Lookup)
Get the maximum of an elemental property
|
double |
getMean(double[] Lookup)
Calculate the alloy mean of a property
|
double |
getMinimum(double[] Lookup)
Get the minimum of an elemental property
|
double |
getMost(double[] Lookup)
Get the elemental property of the most-prevalent element.
|
int[] |
getSortingOrder() |
int |
hashCode() |
static java.lang.String[] |
printNumber(double[] fraction,
double NInFormulaUnit)
Print out the number of atoms in a formula unit for each element given its fraction
|
void |
rectifyEntry(boolean toSort)
Makes sure this entry is in a proper format.
|
protected void |
setComposition(int[] elements,
double[] amount,
boolean toSort)
Set the composition of this entry.
|
java.lang.String |
toHTMLString()
Print entry in a HTML-friendly format.
|
org.json.JSONObject |
toJSON()
Print entry as a JSON object
|
java.lang.String |
toString() |
addProperty, addProperty, addProperty, clearPropertyData, deleteMeasuredClass, deletePredictedClass, getClassProbilities, getMeasuredClass, getMeasuredProperties, getMeasuredProperty, getPredictedClass, getPredictedProperty, getPropertyClassProbabilties, getTargetProperty, hasClassProbabilities, hasMeasuredProperty, hasMeasurement, hasPredictedProperty, hasPrediction, hasPropertyClassProbabilities, NProperties, setClassProbabilities, setMeasuredClass, setMeasuredProperties, setMeasuredProperty, setNProperties, setPredictedClass, setPredictedProperty, setPredictedProperty, setTargetProperty, usingPropertyAsClass
addAttribute, addAttributes, clearAttributes, compareTo, getAttribute, getAttributes, NAttributes, reduceMemoryFootprint, setAttribute, setAttributes
public boolean HTMLFormat
protected java.lang.String[] ElementNames
protected int[] SortingOrder
protected int[] Element
protected double[] Fraction
protected double NumberInCell
protected CompositionEntry()
public CompositionEntry(java.lang.String Composition) throws java.lang.Exception
First splits using the regex [A-Z][^A-Z]
to separate each component of the alloy.
This assumes that capitalization is used property. Then, splits each component into the Alphabetical part
(assumed to be the element name) and the numeric part (amount of element). If no numeric part is present, 1 is assumed.
An element can be appear more than once.
Composition
- Composition of entryjava.lang.Exception
- If parse failspublic CompositionEntry(int[] Element, double[] Amount)
Element
- Numbers of element in ElementListAmount
- Amount of each element presentpublic static java.lang.String[] printNumber(double[] fraction, double NInFormulaUnit)
fraction
- Fractions to be printedNInFormulaUnit
- Number of atoms in a formula unitpublic void combineCompositions(java.util.Map<java.lang.Integer,java.lang.Double> totalComp, java.util.Map<java.lang.Integer,java.lang.Double> addComp, double multiplier)
totalComp
- Composition to be added toaddComp
- Composition to addmultiplier
- Multiplier for added partprotected final void setComposition(int[] elements, double[] amount, boolean toSort)
Checks to make sure all elements have positive amounts.
elements
- Elements in sample (listed by index
in LookupData.ElementNames)amount
- Amount of each elementtoSort
- Whether to store elements in sorted orderpublic CompositionEntry clone()
BaseEntry
clone
in class MultiPropertyEntry
public int[] getSortingOrder()
public int[] getElements()
public double[] getFractions()
getElements()
public double getElementFraction(java.lang.String elem)
elem
- Abbreviation of elementpublic double getElementFraction(int element)
element
- Index of element (usually: AtomicNumber - 1)public int compare(java.lang.Object A_obj, java.lang.Object B_obj)
public boolean equals(java.lang.Object other)
public final void rectifyEntry(boolean toSort)
Performs the following operations:
toSort
- Whether to sort elements in "Sorting order"public double getMean(double[] Lookup)
Lookup
- Lookup table of elemental propertiespublic double getMaxDifference(double[] Lookup)
Lookup
- Lookup table of elemental propertiespublic double getAverageDeviation(double[] Lookup)
df = sum[ xi * (fi - fmean) ]
Lookup
- Lookup table of elemental propertiespublic double getAverageDeviation(double[] Lookup, double mean)
df = sum[ xi * (fi - fmean) ]
Lookup
- Lookup table of elemental propertiesmean
- Mean as computed using "getMean"public double getMaximum(double[] Lookup)
Lookup
- Lookup table of elemental propertiespublic double getMinimum(double[] Lookup)
Lookup
- Lookup table of elemental propertiespublic double getMost(double[] Lookup)
Lookup
- Lookup table of elemental propertiespublic java.lang.String toHTMLString()
BaseEntry
toHTMLString
in class BaseEntry
public org.json.JSONObject toJSON()
BaseEntry
toJSON
in class MultiPropertyEntry