2
$\begingroup$

As can be read in the pyscf.dft documentation, there should be the possibility of generating the coordinates of the grid for numerical integration. According to the documentation, one can generate the coordinates with the get_partition function, which is part of the pyscf.dft.gen_grid module.

My question is the following: If the get_partition function returns the mesh grid coordinates and the corresponding grid weights, how can one directly access and manipulate the generated data (printing, shaping arrays, etc.)? I tried to print the grid coordinates, which are returned as an array according to the documentation, but it is not specified under which name the grid coordinates are returned.

$\endgroup$
1
  • $\begingroup$ Can you explain in more detail what you want to know? It seems to me like you already have the answer: get_partition gives you the coordinates of the grid points and the weights (returned arg 1 and 2 respectively). Is your question how to integrate quantities on the generated grid? $\endgroup$ Jun 29, 2022 at 14:31

1 Answer 1

3
$\begingroup$

What I usually do is I generate the grid with pyscf.dft.gen_grid as you mentioned, for example

def __init__(self, mol, calc):
    self._grid = pyscf.dft.gen_grid.Grids(self._mol)
    self._grid.level = 8 # level of accuracy of the grid. 8 is pretty dense, you might be OK with the default (maybe 5?)
    self._grid.build()

Doing this I will have access to self._grid.coords and self._grid.weights. Then all you need to do is apply whatever function you want to the coordinates and take the dot product of this quantity with the weights to do a quadrature

desired_quantity = apply_function(self._grid.coords)
res = self._grid.coords * self._grid.weights
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .