qimpy.io.Unit

class Unit(value, unit)

Bases: object

Represent value and unit combination.

Parameters:
  • value (float) –

  • unit (str) –

__init__(value, unit)
Parameters:
  • value (float) –

  • unit (str) –

Return type:

None

Methods

__init__

convert

Convert value_au in atomic units to the selected unit.

format

String representation with custom format_string.

parse

Extract value and unit from text representation.

Attributes

MAP

Mapping from unit names to values

value

unit

static convert(value_au, unit)

Convert value_au in atomic units to the selected unit.

Parameters:
  • value_au (float) –

  • unit (str) –

Return type:

Unit

format(format_string)

String representation with custom format_string.

Parameters:

format_string (str) –

Return type:

str

static parse(text)

Extract value and unit from text representation.

Parameters:

text (str) –

Return type:

Unit

MAP: ClassVar[dict[str, float]] = {'A': 150.9748847445556, 'Angstrom': 1.8897261246257702, 'C': 6.241509074460763e+18, 'E_h': 1.0, 'GPa': 3.398930921755723e-05, 'Ha': 1.0, 'Hz': 2.4188843265857e-17, 'J': 2.293712278404799e+17, 'K': 3.1668115634673077e-06, 'L': 6.748334494600376e+27, 'MPa': 3.3989309217557226e-08, 'N': 12137802.661002168, 'Ohm': 0.00024341348057969593, 'Pa': 3.398930921755723e-14, 'Ry': 0.5, 'T': 4.2543821573420775e-06, 'V': 0.036749322175790716, 'a_0': 1.0, 'amu': 1822.888486217313, 'bar': 3.398930921755723e-09, 'c': 137.03599908381668, 'cm^-1': 4.5563352529119736e-06, 'e': 1.0, 'eV': 0.036749322175790716, 'fs': 41.34137333518211, 'g_e': 2.00231930436256, 'h': 6.283185307179586, 'hbar': 1.0, 'kJ/mol': 0.0003808798847147504, 'kPa': 3.398930921755723e-11, 'kcal/mol': 0.0015936014376465154, 'kg': 1.0977691057577633e+30, 'm': 18897261246.2577, 'm_e': 1.0, 'mmHg': 4.531535851471396e-12, 'mol': 6.02214076e+23, 'mu_B': 0.5, 'nm': 18.897261246257703, 'ps': 41341.373335182114, 's': 4.134137333518211e+16, 'Ω': 0.00024341348057969593, 'μ_B': 0.5, 'Å': 1.8897261246257702}

Mapping from unit names to values