Technical Documentation
ATOM VECTOR: Methods

A number of methods are defined for AtomVector objects. These methods are applied to an AtomVector object using the dot operator.

AV.fill()

Fill AV with values specified in the argument

AV.frompy()

Fill AV with values converted from the tuples specified in the argument

AV.intopy()

Returns a tuple of tuples containing the values in AV

AV.scale()

Multiply the value or values in the argument into AV

AV.shift()

Add the value or values in the argument into AV

AV.rotate()

Rotate AV about the axis running through the two given points by the specified angle.

AV.transform()

Assign to AV, the result of a rotation and translation of a source AtomVector in the global coordinate frame

AV.readavf()

Loads AV with the contents of the Atom Vector File specified in the argument

AV.writeavf()

Writes the contents of AV to an Atom Vector File.


The fill() method fills the target AV from various sources: a single value, a column or a row or another AV, or a sample from a distribution.

Method Name
Argument Keywords
Return Value
fill
"value", "spread", "copy", "sample"
None
Keyword
Argument
Value
Preset Value
value
specify none or specify one
integer or floating point value
0
spread
an AV for one atom and the same number of dimensions as the target or and AV for the same number of atoms as the target and one dimension
-
copy
an AV with the same number of atoms and dimension as the target
-
sample
"UNIFORM", "GAUSSIAN", "INVERSEMASS" or "CHARGE"
-

Calling fill() without an argument list is equivalent to specifying: value=0.

The value argument specifies a single number that will be used to fill the target AV.

The spread argument specifies an AV that has a single dimension in one axis: either the number of atoms is one or the number of dimensions is one. The other axis must be of the same length as the corresponding axis in the target. The single row or column is copied to every row or column in the target.

The copy argument specifies an AV that must have the same shape as the target AV. The values are copied to the target AV.

The sample argument specifies the name of a distribution: "UNIFORM" for the Uniform distribution of range -1 to +1 and "GAUSSIAN" for the normal distribution of mean 0 and standard deviation of 1. The target AV is filled with numbers from the requested distribution. With "INVERSEMASS", the AV is filled with the inverse mass of the atoms and "CHARGE" will fill the AV with the atomic charges.

>>> from Yup.Taro.AtomVect import *
>>> A = AtomVector( numatom=3 )
AtomVector[3:3] {
0 0 0
0 0 0
0 0 0
}

>>> A.fill(3)
>>> A
AtomVector[3:3] {
3 3 3
3 3 3
3 3 3
}

>>> A.fill( sample='GAUSSIAN' )
>>> A
AtomVector[3:3] {
1.19382 1.42131 1.62444
-0.756584 -1.36036 -1.0419
1.35633 -0.774865 1.02747
}

>>> A.fill()
>>> A
AtomVector[3:3] {
0 0 0
0 0 0
0 0 0
}

>>>

The example shows that a newly created AV (A) is filled with zeroes. Next we fill the AV with a single value 3. Since value is the first argument we can leave out the keyword as we have done here. Next, we fill the AV with numbers from the Normal distribution. Finally, we apply the fill() method on A with an empty argument list. This fills the AV with zeroes.

Return to Top.


In the transform() method, a source Atom Vector, specified in the first argument, is rotated successively about the Z, new Y (once rotated) and new Z (twice rotated) axes of the global coordinate frame. The rotation angles are specified in the next argument. The source Atom Vector is then translated in the X, Y and Z directions by the amounts specified in the last argument. Finally, the results are assigned to the target Atom Vector.

Method Name
Number of Arguments
Return Value
transform
3
None
Argument
Value
Preset Value
#1
Atom Vector
None
#2
tuple of three floating point values (radians)
None
#3 (optional)
tuple of three floating point values (Angstroms)
( 0.0, 0.0, 0.0 )

Argument #1 contains the source or origin Atom Vector. The transforms will be carried out on it (leaving the origin unchanged unless the origin and the target are the same) and the results will be assigned to the target Atom Vector. If the source and the target are the same Atom Vectors, the results are not what one would expect.

Argument #2 is a tuple of three floating numbers that are the angles of rotation (radians) about the Z-, rotated Y- and twice rotated Z- axes in the global coordinate frame. The source Atom Vector is rotated about the global Z-axis, then about the new Y-axis and finally about the twice-transformed Z-axis.

Argument #3 (optional) is a tuple of three floating point numbers that are the displacements in the X-, Y- and Z- axes of the global coordinate frame.

The following are rules for the argument values but these rules are not enforced. If the rules are not followed, the calculation may fail or the results may be wrong. [1] the target must not be the same as the source (#1); [2] the target and the source must be conformal, i.e., both have the same number of atoms and dimensions; [3] the target and the source must have exactly three dimensions; [4] the supplied angles (#2) must be in radians and be between minus and plus PI.

The order of rotation is not as important as the transformation matrix itself. This can be used to transform the original coordinates to obtain the conformation that results from a Monte Carlo calculation. The transformation matrix is available through the TransMatrix() function.

Return to Top.


In the rotate() method, the target Atom Vector is rotated about the axis running through the two Atom Vectors specified in the first argument by an angle specified in the second argument.

Method Name
Number of Arguments
Return Value
rotate
2
None
Argument
Value
Preset Value
#1
tuple of two Atom Vectors
None
#2
floating point value (radians)
None

Argument #1 is a tuple containing two Atom Vectors for two atoms that define the starting and end points respectively of the axis of rotation.

Argument #2 specifies the angle of rotation in radians. The value must be between minus and plus PI.

Viewing from the starting point towards the end point of the axis of rotation, a clockwise rotation results from a positive angle.

The following rules are not enforced: [1] the Atom Vectors that define the axis of rotation must contain exactly one atom each and [2] all Atom Vectors must have exactly three dimensions.

Return to Top.


The scale() method multiplies the target AV with the value or values specified in the argument.

Method Name
Number of Arguments
Return Value
scale
1
None
Argument
Value
Preset Value
#1
Integer, floating-point or Atom Vector
None

If #1 is a single integer it is converted to a double-precision floating number which is then multiplied into every component of the target Atom Vector. If #1 is a single floating-point number, this number is multiplied into every component of the target Atom Vector.

If #1 is an Atom Vector, then at least one dimension (either number-of-atoms or number-of-dimensions) must match that of the target Atom Vector. If so, #1 is augmented by spreading the non-matching dimension to that of the target Atom Vector. #1 (possibly augmented) is then multiplied (side-by-side) into the target Atom Vector.

This method operates in place. No intermediate storage is allocated and the location of the target Atom Vector is unchanged.

Return to Top.


The shift() method adds the value or values specified in the argument to the target Atom Vector.

Method Name
Number of Arguments
Return Value
shift
1
None
Argument
Value
Preset Value
#1
Integer, floating-point or Atom Vector
None

If #1 is a single integer it is converted to a double-precision floating number which is then added to every component of the target Atom Vector. If #1 is a single floating-point number, this number is added to every component of the target Atom Vector.

If #1 is an Atom Vector, then at least one dimension (either number-of-atoms or number-of-dimensions) must match that of the target Atom Vector. If so, #1 is augmented by spreading the non-matching dimension to that of the target Atom Vector. #1 (possibly augmented) is then added (side-by-side) into the target Atom Vector.

This method operates in place. No intermediate storage is allocated and the location of the target Atom Vector is unchanged.

Return to Top.


The intopy() method creates a new tuple, copies the values of the target Atom Vector to the tuple and returns the tuple.

Method Name
Number of Arguments
Return Value
intopy
0
Tuple of tuple of Doubles

The tuple returned by this method has as many items as there are atoms in the target Atom Vector. The inner tuples are each as long as there are as many dimensions in the target Atom Vector. Each item of the inner tuples is a copy of the values of the target Atom Vector.

Example:

>>> from Yup.Taro.AtomVect import AtomVector
>>> A = AtomVector( numatom=3 )
>>> A.fill( sample='UNIFORM' )
>>> print A
AtomVector[3:3] {
        -0.0277413      0.648549        0.382733
        -0.0690634      -0.89526        0.656545
        -0.404462       0.547166        0.0104678
}
                           
>>> B = A.intopy()
>>> print B
((-0.027741325113681548, 0.64854884487441633, 0.38273262733848079), 
(-0.069063386944181682, -0.89526047547837773, 0.65654469435712759),
(-0.40446180608539084, 0.54716635639515365, 0.010467848750267073)) >>>

Return to Top.


The frompy() method copies the values in the tuple of tuples specified in the argument into the target Atom Vector. An exception is raised if the source and destination are not conformal.

Method Name
Number of Arguments
Return Value
frompy
1
None
Argument
Value
Preset Value
#1
Tuple of Tuple of Doubles
None

Example:

>>> from Yup.Taro.AtomVect import AtomVector
>>> A = ( ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) )
>>> B = AtomVector( numatom=3 )
>>> B.frompy( A )
>>> print B
AtomVector[3:3] {
        1       0       0
        0       1       0
        0       0       1
}
                           
>>>

Return to Top.

Intro
New
Print
Compare
Operators
Data
Methods
Functions
Subscript
Files

Technical
Introduction
Directory
Vectors
Energy
Model
Assembly
Methods
FPF
FFF
AVF
TaroScript
YammpScript
Python
Utilities

Home
Information
News
User
Technical
Programmer
iYup
Download
Showcase
ETC