# Write density on grid of my choice

Matthias Krack matthia... at psi.ch
Tue Apr 15 17:12:34 CEST 2014

```Hi Sascha,

cp2k calculates the density at the FFT grid points. You may calculate the
density yourself as you describe, but it is possibly easier to use a fine
grid by specifying a relatively large cutoff and then to read the cube file
with an external program which evaluates the density at the points you are
interested in by (trilinear) interpolation.

Matthias

On Tuesday, April 15, 2014 3:11:44 PM UTC+2, Sascha Brück wrote:
>
> Hi,
>
> in cp2k, i can write out the density into a cube file, but it will be
> evaluated at grid points computed by cp2k. If I like to use my own grid
> with different points where I want to evaluate the density, is there a way
> to read in that information?
>
> If not, it should be easy to evaluate the density by oneself by just
> summing the density matrix and the basis functions
>
> rho(x_grid,y_grid,z_grid)=sum_{i,j} P_{i,j} * phi_i
> (x_grid-x_atom(i),y_grid-y_atom(i),z_grid-z_atom(i)) * phi_j
> (x_grid-x_atom(j),y_grid-y_atom(j),z_grid-z_atom(j))
>
> where phi_i (x,y,z)=norm_i * pow(x,lx_i) * pow(y,ly_i)* pow(z,lz_i) * exp(
> -alpha_i*(x^2+y^2+z^2));
>
> all coordinates are in bohr radius and alpha_i is from the basis file and
> the angular momenta are ordered like 1s 1px 1py 1pz 2s 2px 2py 2pz ...
>
> Is this formula right? Or do I have to transform to spherical basis
> functions (even for s and p)? How do i compute the norm?
>
> Best regards
> Sascha
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cp2k.org/archives/cp2k-user/attachments/20140415/9ed8e894/attachment.html>
```