Physical quantities and units


Physical quantities and units

Units are a key concept in ATK. All parameters that correspond to physical quantities, such as lengths, energies, voltages, etc, should be specified with an explicit unit. Similarly, all results returned from calculations in ATK also contain an explicit unit.

All physical quantities (that is, objects associated with a unit) have two query methods:

  • Float inUnitsOf(Unit): Returns the numerical value in the specified unit as a float object. See below for physical units available in NanoLanguage.

  • PhysicalQuantity convertTo(Unit): Returns the value of the PhysicalQuantity as a new PhysicalQuantity object in the specified unit.

a = 5*Angstrom
print a.inUnitsOf(nanoMeter)

generates

0.5

while

print a.convertTo(nanoMeter)

gives

0.5 nm

Physical quantities can be transformed with x**n, for instance

a = 2. * Meter *Second**-2
v = (2 * a * (1*Meter))**0.5
print v
    

gives

2.0 m/s 

Specify inverse units by using the exponent operator **, i.e.

f = 2.2/Second
print f.inUnitsOf(Second**-1)

The following units are made available when importing NanoLanguage:

Table 24: Units available in NanoLanguage

Unit type Name
Length units nanoMeter
Ang
Angstrom
Bohr
Units.nm
Meter
Energy units Rydberg
electronVolt
eV
Hartree
Units.Ry
Units.meV
Units.Ha
Joule
Calorie
Force units Newton
nanoNewton
Mass unit kiloGram
Units.kg
Temperature unit Kelvin
Time unit Second
Conductivity related units Ampere
Volt
Siemens
G0
Coulomb
Spin unit hbar
number unit Units.Mol
Angle units Radians
Degrees
Constants boltzmann_constant
planck_constant
avogadro_number
speed_of_light
atomic_mass_unit
hbar
electron_mass
electron_charge
vacuum_permitivity

Units are attached to values by multiplication. Thus, to specify a length of 5 Bohr, use

a = 5*Bohr

By printing the value of the variable a, the unit will automatically be displayed also:

print a

gives

5.0 Bohr

Units can also be composite. The unit for force is Newton, which is Joule per Meter. This is a rather awkward unit for nanoscale calculations, where instead something like electron volt per nm makes more sense. Any energy divided by a length is however a valid force unit, so to specify a force, write

F = 5*eV/Bohr

Now, multiply this by a length again and the result will be an energy:

b = F*5*Bohr
print b

generates the output

25*eV

Some unit abbreviations are only available with the Units prefix

b = 5.1*Units.Ry
print b

gives

5.1 Rydberg

Units which by default are specified without a prefix, can also be given with a prefix, for example

b = 5.1*Rydberg
c = 5.1*Units.Rydberg