Back to main menu
Writing functions
When running in interactive mode, Atomsk may be used as a calculator to evaluate some basic operations. Some options, like the option "-properties", also allow to define functions that take a different value for each atom in the system, depending on its coordinates (x,y,z). This page describes how to define such functions for Atomsk to interpret.
The following mathematical operators are supported, by order of priority:
- ^ Exponent
- e Power of 10
- * Multiplication
- / Division
- + Addition
- - Subtraction
The following mathematical functions are supported:
- abs(x) Absolute value of x
- int(x) Nearest integer to x
- x! Factorial of integer part of x
- a%b Remainder of the division a/b
- sqrt(x) Square root of x
- exp(x) Exponential of x
- ln(x) Natural logarithm of x
- log(x) Base-10 logarithm of x
- cos(x) Cosinus of x (x must be in radians)
- sin(x) Sinus of x (x must be in radians)
- tan(x) Tangent of x (x must be in radians)
- acos(x) Arccosinus of x (x must be between -1 and 1)
- asin(x) Arcsinus of x (x must be between -1 and 1)
- atan(x) Arctangent of x (x must be between -1 and 1)
- atan2(x,y) 2-arguments arctangent (x must be non-zero)
The following mathematical and physical constants are replaced by their corresponding value:
- pi π ≈ 3.141592...
- kB Boltzmann's constant kB = 1.3806504·10-23 J·K-1
- qe Elementary electric charge e = 1.60217646·10-19 C
- Navo Avogadro constant NA = 6.02214179·1023
- rand A random real number between 0 and 1
Finally, the following keywords relative to the current atomic system can be used (only when an atomic system is actually defined):
- Hx Current box dimension along Cartesian X axis
- Hy Current box dimension along Cartesian Y axis
- Hz Current box dimension along Cartesian Z axis
- x Current atom's x coordinate
- y Current atom's y coordinate
- z Current atom's z coordinate
Examples
sqrt(2)
3*cos(pi/2)
3.2*atan2(x/y)
3*cos(pi*x/Hx) + 2*sin(pi*y/Hy)
Back to main menu