Package org.qcschema
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 double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
convertValue
(Map<String, Object> valueUnits, String toUnits) Read a {value:xxxx, units:["name",toAU]} map, converting it to the desired units.static double
Get the necessary conversion factor to the desired units from a key_units or atomic unitsstatic double
getConversionFactorTo
(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 double
Reads 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 double
getFactorToAU
(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 double
getUnitConversion
(String fromUnits, String toUnits) Calculate the unit conversion between two units, using a static unit-to-unit cache for efficiency.static Object
getUnitsJSON
(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
Calculate the unit conversion between two units, using a static unit-to-unit cache for efficiency. Not used in Jmol.- Parameters:
fromUnits
-toUnits
-- Returns:
- conversion factor or Double.NaN if anything goes wrong.
-
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
Read a {value:xxxx, units:["name",toAU]} map, converting it to the desired units.- Parameters:
valueUnits
-toUnits
-- Returns:
- converted value
-
getUnitsJSON
Get the [name, toAU] JSON code or just a new String[] {name, toAU}. If the conversion is not known, return [name, "?"]- Parameters:
name
-asArray
-- Returns:
- String or String[]
-
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
Reads a value from an associative array, converting it to the desired units.- Parameters:
map
-key
-toUnits
-- Returns:
- value
-
getList
Retrieve an array of any sort as a list of objects, possibly unpacking it if it is run-length encoded.- Parameters:
mapOrList
-key
-- Returns:
- unpacked array
-
newList
- Returns:
- ArrayList, or in JavaScript javajs.util.Lst
-
getDoubleArray
Retrieve a double array, possibly unpacking it if it is run-length encoded. Read any error as Double.NaN.- Parameters:
mapOrList
-key
- into mapOrList, or null if mapOrList is a list- Returns:
- unpacked double[]
-
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
-