
Most importantly, the function calculator has access to spock's atom and vertex property variables: q (charge), sa (surface area), d (distance), p (potential), ap1, ap2 (atom properties 1 and 2), dpartner (distance partner), vp (vertex potential), vd (vertex distance), vp1 and vp2 (vertex properties 1 and 2). The vertex properties are indexed by atom or vertex number, so the simple command #q(1) will print the charge property for the first atom. Similarly, the command #q(1)=ap1(1) + d(1) will assign the appropriate value to the charge for the first atom. This provides an additional (more powerful) way to alter atom and vertex properties, distinct from the set-style commands, like set charge=1, described in §5.2.4. If no atoms or vertices are defined, attempting to use their associated properties will generate an error. It is also possible to operate on the entire array of atom or vertex properties. For instance, to set all atom distance properties to 0, one could use the command #d()=0.0. The ``()'' pair with no index indicates that this command is to operate on the entire array, rather than just a specified element of it. More complicated assignments of this type are possible, for instance: ap1()=exp(sin(ap2()) + cos(d()) + besj0(q())). If there is an invalid calculation (e.g. #log(0)), spock will print an error message, and the atom/vertex number of the offending command. Atom or vertex properties prior to the one on specified in the error message have been altered.
Users may define new functions in terms of the atom properties for later
use. For instance #f(x)=ap1(x) + ap2(x) defines the new function
f. Later, a command such as: q()=f() will use the previous
definition of f(x). Finally, a parenthesis pair by itself stands
for the index number. For instance q()=() will assign q=1 for the
first atom, q=2 for the second atom, and so on.
Much of the functionality of the Calculate
Properties math
menu (§6.6.2) is accessible via the command line
calculator, specifically the ability to add, subtract, multiply and divide
properties, or add a constant, etc. One important difference between the
command line-calculator and the Properties math menu is that operations
entered via the command line calculator apply to all atoms or
vertices, while in the Properties math menu operations only apply to the
atoms/vertices specified via the ``Enter new selection string'' menu
option. Look on the Properties math as a complement to, not a replacement
of, the command line calculator. In the Properties math menu, there is an
entry ``Apply a function''. This entry prompts for a command which is
passed to the command-line calculator (no leading ``#'' is necessary).
Unlike calculations entered directly from the command line, the selection
string is applied, so calculations are performed only on the selected
atoms/vertices.
The ``Use DP's property
two'' option of the Properties math menu may be duplicated on the command
via a command of the type: ap1()=ap2(dpartner()), which, in this
example would set ap1 for each atom to the ap2 of that atom's distance
partner. When the dpartner property is included in a calculation, entries
for which the dpartner is undefined (0) are skipped.
The command-line calculator also has access
to the electrostatic potential maps (phimap1 and phimap2) and the electron
density maps (emap1 through emap8). The maps are treated as single
dimensional arrays, so if you want to access a particular element you'll
have to calculate the offset to it. However, spock can easily operate on
the entire map via the ``()'' operator. For instance, to scale a map, you
could use the command #emap1()=emap1()/5.0. You can also add and
subtract maps in this manner. One caveat is that the map must already be
defined before it can be used in the command line calculator. If only one
density map is read in, the command #emap2()=emap1() will not work.
Of course, to operate on more than one map, they must be of equal size.
The calculator also understands any environment variables specified, so
you could scale a map via the command #emap1()=emap1()/$SP_SD.
(Recall that the ``Simple statistics'' option of the ``Calculate
properties math'' menu sets several environment variables
when it's used to calculate statistics on a property or map. See §
6.6.2).
There are a few commands that may be passed to the calculator besides arithmetic expressions:
Some useful examples of the use of math environment variables are:
