PhysicalConstantsContext

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

Bases: object

CODATA physical constants set from NIST.

Parameters

context (str) – {‘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[str, 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

ureg

Returns the internal Pint units registry.

Methods Summary

Quantity(data)

Returns a Pint Quantity.

conversion_factor(base_unit, conv_unit)

Provides the conversion factor from one unit to another.

get(physical_constant[, return_tuple])

Access a physical constant, physical_constant.

string_representation()

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

Attributes Documentation

ureg

Returns the internal Pint units registry.

Returns

The pint context

Return type

UnitRegistry

Methods Documentation

Quantity(data)[source]

Returns a Pint Quantity.

Return type

quantity._Quantity

Parameters

data (str) –

conversion_factor(base_unit, conv_unit)[source]

Provides the conversion factor from one unit to another.

The conversion factor is based on the current contexts CODATA.

Parameters
Return type

float

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

Parameters
  • base_unit (Union[str, quantity._Quantity]) –

  • conv_unit (Union[str, quantity._Quantity]) –

get(physical_constant, return_tuple=False)[source]

Access a physical constant, physical_constant.

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

  • return_tuple (bool) – 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()[source]

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

Return type

str