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) 0.5 # output from program print a.convertTo(nanometer) 0.5 nm
The following units are made available when importing either of the two modules ATK.KohnSham or ATK.TwoProbe:
Table 3: Units available in ATK.KohnSham or ATK.TwoProbe
| Unit type | Name |
|---|---|
| Length units | nanometer |
| Ang | |
| Angstrom | |
| Bohr | |
| Energy units | Rydberg |
| electronVolt | |
| eV | |
| Hartree | |
| Force units | Newton |
| nanoNewton | |
| Temperature unit | Kelvin |
| Conductivity related units, (not available in ATK.KohnSham) | Ampere |
| Volt | |
| Siemens | |
| Spin unit | hbar |
| Angle units | radians |
| degrees |
By importing the ATK.Units module (as shown below), the following additional shorthand versions of the units, as well as all the units above, become available:
Table 4: Units available in ATK.Units
| Unit type | Shorthand notation from ATK.Units |
|---|---|
| Length units | nm |
| Energy units | Ry |
| meV | |
| Ha | |
| Angle units | rad |
| deg |
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 5.0 Bohr # output from program
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 nanometer 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 25*eV # output from program
Importing ATK.Units:
from ATK.Units import * energy = 1.2*Ry default_angle = 20*rad