The samson.SBQuantity sub-module contains Python bindings for SBDQuantity from SAMSON API - it contains all classes related to handling physical units in SAMSON. It allows you to operate with all the possible units from SAMSON API, create your own quantities, and do arithmetic operations on them.

The next unit systems are available:

Each unit system has an according base class and a set of convenience constructors for the most used units (see the description for each unit system). These convenience constructors present each unit in the unit system and their combinations and they internally call the unit system’s base class with proper SBQuantity units. In the case if there is no convenience constructor for a quantity in a unit system that you want to use, you can create it using the unit system’s base class by providing exponents and scales or by combining quantities with existing convenience constructors using arithmetic operations.



For now, unit systems support only the integer-based scales, e.g, SI unit system supports square length but not length to the power of 3/2.

See also

SAMSON SDK: The SBDQuantity Library

SAMSON SDK: SBDQuantity for the comprehensive list of available physical units.


To initialize a physical quantity you can use either the full name of the quantity or its short-name. For example, the next two definitions are equivalent:

# is the same as

print(SBQuantity.picometer(1.23) ==    # True

It is possible to initialize quantities based on quantites of the same type, e.g.:

# is the same as

print(SBQuantity.angstrom(SBQuantity.nm(1)) == SBQuantity.angstrom(10)) # True

You can get a floating-point value of quantities in the next way:

l = SBQuantity.nanometer(1.2)
t = SBQuantity.femtosecond(0.5)
# the same using short-names:
l = SBQuantity.nm(1.2)
t = SBQuantity.fs(0.5)

# get floating-point value

You can convert them to another quantity, like this:

# the same using short-names

SBQuantity.force(1.0).nN # force in nano Newtons

Arithmetic operations can be used with quantities, for example:

SBQuantity.nanometer(1.2) / SBQuantity.femtosecond(0.5)   # equal to SBQuantity.picometerPerSecond(0.6)
# or using short-names:
SBQuantity.nm(1.2) / SBQuantity.fs(0.5)                   # equal to SBQuantity.pmPerS(0.6)

Mathematical functions#

The samson.SBQuantity module also provides a set of mathematical functions that can be used with quantities:

Conversion between unit systems#

An SBQuantity object in each unit system has attributes that provide the possibility of converting it into an appropriate SBQuantity object in another unit systems, if possible.

# energy in the SI units
energy =
# conversion to eV in the Electronvolt Unit System

# mass in SI units
mass = SBQuantity.yoctogram(12)
# from yoctogram to dalton (or using short names: mass.Da)
mass_in_dalton = mass.dalton
# from yoctogram to auMass
mass_in_au = mass.auMass

# energy in SI units
energy = SBQuantity.kilojoule(13)
# from joule to joulePerMole (or using short names: energy.JPerMol)
energy_in_JPerMol = energy.joulePerMole
# from joule to electronvolt (or using short-names: energy.eV)
energy_in_eV = energy.electronvolt
# from joule to kilocaloriePerMole (or using short-names: energy.kcalPerMol)
energy_in_kcalPerMol = energy.kilocaloriePerMole
# from joule to hartree (or using short-names: energy.Eh)
energy_in_hartree = energy.hartree

The following conversions are defined:

Unit systems#

This module provides the possibility to operate with quantities in the following unit systems:

See the list of all available units:

Physical constants#