PhysicalConstantsContext

class qcelemental.PhysicalConstantsContext(context='CODATA2014')[source]

Bases: object

CODATA physical constants set from NIST.

Parameters

context ({'CODATA2014', 'CODATA2018'}) – Origin of loaded data.

doi

The DOI of the current context.

Type

str

name

The name of the context (‘CODATA2014’)

Type

str

pc

Each physical constant is an entry in pc, where key is the lowercased string of the NIST name (or any alias) and the value is a Datum object with lbl the exact NIST name string, units, data value as Decimal object, and any uncertainty in the comment field.

Type

dict of Datum

raw_codata

A dictionary representation of the raw context data.

Type

Dict[str, Any]

year

The year the context was created.

Type

int

Attributes Summary

conversion_factor

Provides the conversion factor from one unit to another.

ureg

Returns the internal Pint units registry.

Methods Summary

Quantity(data)

Returns a Pint Quantity.

get(physical_constant[, return_tuple])

Access a physical constant, physical_constant.

PhysicalConstantsContext.run_comparison

string_representation()

Print name, value, and units of all physical constants.

PhysicalConstantsContext.write_c_header

Attributes Documentation

conversion_factor[source]

Provides the conversion factor from one unit to another.

The conversion factor is based on the current contexts CODATA.

Parameters
  • base_unit (Union[str, 'Quantity']) – The original units

  • conv_unit (Union[str, 'Quantity']) – The units to convert to

Examples

>>> conversion_factor("meter", "picometer")
1e-12
>>> conversion_factor("feet", "meter")
0.30479999999999996
>>> conversion_factor(10 * ureg.feet, "meter")
3.0479999999999996
Returns

The requested conversion factor

Return type

float

ureg

Returns the internal Pint units registry.

Returns

The pint context

Return type

UnitRegistry

Methods Documentation

Quantity(data: str) → quantity._Quantity[source]

Returns a Pint Quantity.

get(physical_constant: str, return_tuple: bool = False) → Union[float, qcelemental.datum.Datum][source]

Access a physical constant, physical_constant.

Parameters
  • physical_constant (str) – Case-insensitive string of physical constant with NIST name.

  • return_tuple (bool, optional) – See below.

Returns

When return_tuple=False, value of physical constant. When return_tuple=True, Datum with units, description, uncertainty, and value of physical constant as Decimal.

Return type

Union[float, ‘Datum’]

string_representation() → str[source]

Print name, value, and units of all physical constants.