[CP2K:2846] operations on dbscr_obj
Urban Borštnik
urban.b... at gmail.com
Fri Sep 17 07:19:44 UTC 2010
Hello,
> 1. How to obtain the size of a dbcsr_obj matrix?
If by "size" you mean the storage requirement, then use the function
cp_dbcsr_get_dat_size from the cp_dbcsr_interface module.
FUNCTION cp_dbcsr_get_data_size (matrix) RESULT (data_size)
TYPE(cp_dbcsr_type), INTENT(IN) :: matrix
INTEGER :: data_size
If you mean the the dimensions (in scalar elements) of the matrix, then
use the cp_dbcsr_nfullrows_total or cp_dbcsr_nfullcols_total, both of
which are found in the above-mentioned module and have a similar
interface.
> 2. How to set the value for an individual element of the matrix?
These matrices are block-based and not element based. Elements are
blocked according to atoms: since most matrix access or modifications
are based on atoms this simplifies user programming. See, e.g., the
calculate_rho_elec subroutine (in the qs_collocate_density module).
So if you really want to set just one individual element, you still have
to find which block it belongs to
* calculate which block and its offset within the block. There is no
supplied function for this so you have to do it manually. You can
retrieve the starting offsets of each block in the rows of the matrix
using a call row_offsets => array_data (rcp_dbcsr_row_block_offsets) for
INTEGER, DIMENSION(:), POINTER :: row_offsets. Similary for column block
offsets. The rest is just a search within the array and a final
subtraction.
* Now that you went from element to block matrix coordinates, you can
retrieve the block from the matrix (cp_dbcsr_get_block_p) and change the
one element.
Best regards,
Urban
--
Dr. Urban Borštnik <u.bor... at pci.uzh.ch>
Institute of Physical Chemistry, University of Zurich
Winterthurerstrasse 190, 8057 Zurich, Switzerland
tel.: +41 44 635-4498; fax.: +41 44 635 68 38
More information about the CP2K-user
mailing list