The vectors described in the notes on minimization correspond to vectors in 3N-dimensional space. Therefore, the dot products for the conjugate gradient formulas indicate the multidimensional dot product in 3N-dimensional space. In other words
f^N . f^N = fx,1^2 + fy,1^2 + fz,1^2 + fx,2^2 + ... + fz,N^2
The result should be a scalar.
You will be working with (N,3) arrays in NumPy. For these kinds of arrays, NumPy's dot product will not give you the behavior above, since this function is a generalized matrix multiplication and NumPy will think your two-dimensional array is intended as a matrix, not a 3N-dimensional vector.
Instead you want to use something like:
np.sum(Forces**2)
Or,
np.sum((Forces - OldForces) * Forces)
Here, this code indicates that the Forces array will be squared on an element-by-element basis, and then these 3N elements will be summed.
Cheers,
MSS
Monday, April 13, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment