Class QCSchemaUnits
java.lang.Object
org.qcschema.QCSchemaUnits
A general Java class for working with QCShema units and array types.
j2sNative blocks can be ignored -- they just increase efficiency in the JavaScript rendition of Jmol.
for examples of use, see
org.jmol.adapters.readers.quantum.QCJSONReader
org.jmol.adapters.writers.QCJSONWriter extends org.jmol.util.JSONWriter
- Author:
- Bob Hanson
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final doublestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleconvertValue(Map<String, Object> valueUnits, String toUnits) Read a {value:xxxx, units:["name",toAU]} map, converting it to the desired units.static doubleGet the necessary conversion factor to the desired units from a key_units or atomic unitsstatic doublegetConversionFactorTo(ArrayList<Object> unitsFactor, String unitsDesired) For a reader, use the JSON [units, factor] along with a desired unit to get the conversion factor from file values to desired units.static doubleReads a value from an associative array, converting it to the desired units.static double[]getDoubleArray(Object mapOrList, String key) Retrieve a double array, possibly unpacking it if it is run-length encoded.static doublegetFactorToAU(String units) Get the standard conversion factor to atomic units for this unit.static int[]getIntArray(Object mapOrList, String key) Retrieve an int array, possibly unpacking it if it is run-length encoded.Retrieve an array of any sort as a list of objects, possibly unpacking it if it is run-length encoded.static String[]getStringArray(Object mapOrList, String key) Retrieve a String array, possibly unpacking it if it is run-length encoded.static doublegetUnitConversion(String fromUnits, String toUnits) Calculate the unit conversion between two units, using a static unit-to-unit cache for efficiency.static ObjectgetUnitsJSON(String name, boolean asArray) Get the [name, toAU] JSON code or just a new String[] {name, toAU}.newList()
-
Field Details
-
version
-
UNITS_FRACTIONAL
- See Also:
-
UNITS_AU
- See Also:
-
TOAU_AU
public static final double TOAU_AU- See Also:
-
UNITS_CM
- See Also:
-
TOAU_CM
public static final double TOAU_CM- See Also:
-
UNITS_M
- See Also:
-
TOAU_M
public static final double TOAU_M- See Also:
-
UNITS_ANGSTROMS
- See Also:
-
TOAU_ANGSTROMS
public static final double TOAU_ANGSTROMS- See Also:
-
UNITS_BOHR
- See Also:
-
TOAU_BOHR
public static final double TOAU_BOHR- See Also:
-
UNITS_HARTREE
- See Also:
-
TOAU_HARTREE
public static final double TOAU_HARTREE- See Also:
-
UNITS_EV
- See Also:
-
TOAU_EV
public static final double TOAU_EV- See Also:
-
UNITS_CM_1
- See Also:
-
TOAU_CM_1
public static final double TOAU_CM_1- See Also:
-
UNITS_KJ_MOL
- See Also:
-
TOAU_KJ_MOL
public static final double TOAU_KJ_MOL- See Also:
-
UNITS_KCAL_MOL
- See Also:
-
TOAU_KCAL_MOL
public static final double TOAU_KCAL_MOL- See Also:
-
-
Constructor Details
-
QCSchemaUnits
public QCSchemaUnits()
-
-
Method Details
-
getFactorToAU
Get the standard conversion factor to atomic units for this unit.- Parameters:
units-- Returns:
- the nominal conversion factor or 0 ("fractional") or Double.NaN (unknown)
-
getUnitConversion
-
getConversionFactorTo
For a reader, use the JSON [units, factor] along with a desired unit to get the conversion factor from file values to desired units. Currently, this method only looks at the factor in the JSON if we do not already know the conversion factor.- Parameters:
unitsFactor- [units, factor] list or null if to AU is desired.unitsDesired-- Returns:
- the conversion factor or Double.NaN if not uncodable
-
convertValue
-
getUnitsJSON
-
getConversionFactor
Get the necessary conversion factor to the desired units from a key_units or atomic units- Parameters:
map-key- map key that has associated key_units element or null for "from atomic units"toUnits-- Returns:
- conversion factor
-
getDouble
-
getList
-
newList
-
getDoubleArray
-
getIntArray
Retrieve an int array, possibly unpacking it if it is run-length encoded. Any error causes this method to return null.- Parameters:
mapOrList- the list to unpack, or map to pull the list form using the keykey- the map key, or null if mapOrList is already a list- Returns:
- unpacked int[] or null if mapOrList is null or there is an error
-
getStringArray
Retrieve a String array, possibly unpacking it if it is run-length encoded. Any "null" string is read as null.- Parameters:
mapOrList- the list to unpack, or map to pull the list form using the keykey- the map key, or null if mapOrList is already a list- Returns:
- unpacked string[] or null if mapOrList is null
-