|
|
ChemShell Tutorial |
|
The ChemShell matrix object stores a general matrix of rank 2.
Within ChemShell matrix objects serve many purposes, the most important ones for (geometry) optimisation is the storage and manipulation of function values, gradients and Hessians.
A matrix object is generated by the command create_matrix. As an example, consider a 4x4 matrix:
% create_matrix matrix=a datatype=real dimensions= {4 4} name=A {
1. 3. 5. -6.3
12.8 2.9 -0.3 2.0
-1.2 4.5 6. 9.
-2.5 3.2 8.6 0.3
}
% print_matrix matrix=a
listing of matrix A
1 2 3 4
1 : 1.0000 3.0000 5.0000 -6.3000
2 : 12.8000 2.9000 -0.3000 2.0000
3 : -1.2000 4.5000 6.0000 9.0000
4 : -2.5000 3.2000 8.6000 0.3000
%
Note that from Tcl, the matrix is referred to by the name given by the matrix= argument. The name= argument serves to give the matrix a title, which shows up in e.g. the output of the print_matrix command.
A complete set of matrix algebra operations is available.
Here we give a few as examples.
% diagonalise_matrix matrix=a evals=evals_a evecs=evecs_a
% print_matrix matrix=evals_a
listing of matrix A eigenvalues
1
1 : -12.2850
2 : -5.8306
3 : 11.7436
4 : 16.5720
% print_matrix matrix=evecs_a
listing of matrix A eigenvectors
1 2 3 4
1 : 0.6974 -0.0631 -0.5474 0.4582
2 : -0.6674 0.1269 -0.3072 0.6664
3 : 0.0959 -0.6172 0.6057 0.4929
4 : 0.2428 0.7739 0.4889 0.3211
% get_matrix_element matrix=evecs_a indices= {0 0} format=%f
0.697422
% set_matrix_element matrix=evecs_a indices= {0 0} value=0.3
% print_matrix matrix=evecs_a
listing of matrix A eigenvectors
1 2 3 4
1 : 0.3000 -0.0631 -0.5474 0.4582
2 : -0.6674 0.1269 -0.3072 0.6664
3 : 0.0959 -0.6172 0.6057 0.4929
4 : 0.2428 0.7739 0.4889 0.3211
%
Further examples can be found in chemsh/examples/matrix
back to the main tutorial