This is a technical question. I have a real-space representation of a potential in a grid of points, however I have the grid in the format:

x y z w v

meaning: the coordinates of each point, the weight and the value of the potential.

I would like to visualize this potential but I need to re-write this potential in a cube file. I haven't found any particular software or script to do that.

I know how to get the header of the cube file. However I don't know how to re-write the points.

Is there a specific format to write the points?

Thank you

  • 2
    $\begingroup$ I'm voting to close this question as off-topic because it's not about chemistry. $\endgroup$ – Mithoron Dec 7 '18 at 21:57
  • 1
    $\begingroup$ The cube files by Gaussian are documented (e.g., paulbourke.net/dataformats/cube, or h5cube-spec.readthedocs.io/en/latest/cubeformat.html). Or, is it a question how to fill them with data? Then it were more on the side of writing a script which reads your data from one source and injects them into this format. The first source has an example that may serve as comparison when setting up a looped script them, e.g. by Python. $\endgroup$ – Buttonwood Dec 7 '18 at 22:04
  • $\begingroup$ @Buttonwood. Thank you, yes my question is more related in how to fill them with data. I am not sure how to rearrange the points that I have. $\endgroup$ – Pablor Dec 7 '18 at 22:14
  • 4
    $\begingroup$ This is very related to (technical aspects of) computational chemistry. It's been lightly discussed in the past and turning our noses up to these types of inquiries would only serve to lower the quality of our site and limit our audience. $\endgroup$ – LordStryker Dec 7 '18 at 22:33

I would recommend using the functional PySCF cubegen script as a starting point for your own script. (https://sunqm.github.io/pyscf/_modules/pyscf/tools/cubegen.html)

If we have a grid defined with nx ny and nz points along the three axes, generating the cube file is just a nested loop over z, y, and x. (In that order) You should end up with nz lines of output each with nx*ny entries.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.