prev
up
next
Constants and functions

The user may define constants and functions in the input file, and apply them subsequently in expressions. The input file is read sequentially and constants and functions must be defined before they can be used.

The argument list of a function must be enclosed in parentheses and the arguments, if more than one, separated by commas.

The following functions are predefined in adf and can be used directly in input:

sin, cos, tan, asin, acos, atan, exp, log, sqrt, nint. Each of them has one argument. log is the natural logarithm (base e).

No constants are predefined.

The angular argument to the trigonometric functions cos, sin, tan is in the unit for angles as defined by units, provided the unit has been set before it is applied. For the result of the inverse trigonometric functions the same holds.

Constants and functions can be defined with the block key DEFINE:

DEFINE
 angle=54
 ab = sin(angle/3)
 s13 = 14*sqrt(2)
 func(x,y,z) = x*ab+y**2-y*z
end

The constants angle, ab, and s13 are defined together with a function func, using the predefined functions sin and sqrt. These can then be applied to assign values elsewhere in input.

In the example above, the constant angle is used in the definition of ab, and ab is used in turn to define func; these constructions are allowed because angle is defined before ab, and ab is defined before func.

The replacement of constants, functions, and other expressions by their numerical values may considerably increase the length of the input record, in particular when real values are being generated (by the parser) in the standard format E22.14. Take care that the resulting record does not exceed 80 characters. The program will abort or may run into an error if this is violated.

The input-reading routine applies the constants and functions wherever it is allowed to do so. To prevent any unwanted replacements in the input file you should avoid very short identifiers for constants and functions.

Warning example:

DEFINE
 A=3.18
 C=4.12
end
...
atoms
 C 0.00 1.05 -3.22
...

The program will apply the definition of the variable C and read:

DEFINE
 A=3.18
 C=4.12
end
...
atoms
 4.12 0.00 1.05 -3.22
...

Avoid single-character identifiers!

SCM Home Page
Quality Software. Quantum Science
*
*
Copyright Terms of UsePrivacy Policy
Home Products Try & Buy Downloads Documentation Support News About SCM Contact
Home     Products     Try & Buy     Downloads     Documentation     Support     News     About SCM     Contact