[CP2K:2847] how to output current density

Urban Borštnik urban.b... at gmail.com
Fri Sep 17 09:36:26 CEST 2010


>   I have figured out a way to build up the density matrix I need. But
> my density matrix is in the form of two dimensional array, i.e.,

Please have a look at dbcsr_example2.F in the CP2K src/lib directory.
It's a brief example of how to fill in a dbcsr matrix.

It starts with some code on how to initialize/create the matrix; however
at the point in the program where you are working you probably have an
existing density matrix that you can use as a template to create yours.
This way you have the parallel distribution, the atomic row/column block
sizes, ... all set up. Something along the lines of (unchecked code):

        TYPE(dbcsr_obj) :: my_density_matrix
        CALL cp_dbcsr_init (my_density_matrix, error)
        CALL cp_dbcsr_create (my_density_matrix, &
        	name = "My Density Matrix", &
        	matrix_type = dbcsr_type_antisymmetric, &
        	template = existing_density_matrix, &
        CALL cp_dbcsr_finalize (my_density_matrix)
        !Now you fill it in block-by-block
        !End with
        CALL cp_dbcsr_finalize (my_density_matrix)
        ! Call routines with it
        CALL ......
        ! Free it
        CALL cp_dbcsr_release (my_density_matrix)

>   Could you tell me how to convert the 2D array into dbscr_obj matrix
> that is needed by the subroutine "collocate_pgf_product_rspace"?

There is no one-line function to do that. It is possible but I'm
convinced it would be much less painful for you to build the density
matrix as a dbcsr matrix and not as standard 2D array.

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