I am trying to dump cube files using psi4.core.CubeProperties.compute_density() method in the python interface and it gives an error message regarding arguments types. The strange point is that while a psi4 matrix object is given it requests again for a psi4 matrix object.
psi4.core.CubeProperties.compute_density(wfn.Da())
TypeError: compute_density(): incompatible function arguments. The following argument types are supported:
1. (self: psi4.core.CubeProperties, D: psi::Matrix, key: str) → None
Invoked with: <psi4.core.Matrix object at 0x2ae0e5260720>
Any help will be appreciated.
Ehsan
There’s nothing strange about it; the error message tells you precisely what the problem is.
The function expects a second argument, key
, which needs to be a string. This string tells Psi4 what kind of density you’re asking it to plot. Here, you want to send it the string "Da"
.
If I can ask, what properties are you trying to get? Most users shouldn’t need to use the psi4.core.CubeProperties
object directly but should be able to use psi4.cubeprop(wfn)
, with the appropriate tasks set.
Thank you for your reply. Unfortunately, it does not work even by passing the second argument, which must be of the string type, let’s say here “Da”. Still, I find it strange because it shows the type of given arguments, which are exactly what the method expects, and the error message is only about the incompatibility of the type of arguments NOT the minimum number of required arguments (e.g. something like “TypeError: missing positional argument” is not displayed):
psi4.core.CubeProperties.compute_density(wfn.Da(), “Da”)
TypeError: compute_density(): incompatible function arguments. The following argument types are supported:
1. (self: psi4.core.CubeProperties, D: psi::Matrix, key: str) → None
Invoked with: <psi4.core.Matrix object at 0x2b1cf4ec5590>, ‘Da’
Concerning the use of psi4.cubeprop(wfn)
, it is possible to get the cube files from wfn with the python driver by using psi4.set_options({‘cubeprop_tasks’: [‘density’]}) instead of set cubeprop_tasks [‘density’], however I am looking for a way to directly get the cube files from a density matrix, or from densities on the grids. In principle, the most desirable thing for me is to plot densities on a grid of choice.