iodata.formats.cube module

Gaussian Cube file format.

Cube files are generated by various QC codes these days, including Gaussian, CP2K, GPAW, Q-Chem, …

Note that the second column in the geometry specification of the cube file is interpreted as the effective core charges.

dump_one(f, data)[source]

Dump a single frame into a Gaussian Cube file.

Parameters:
  • f (TextIO) – A writeable file object.

  • data (IOData) – An IOData instance which must have the following attributes initialized: atcoords, atnums, cube. If the following attributes are present, they are also dumped into the file: title, atcorenums.

Notes

load_one(lit)[source]

Load a single frame from a Gaussian Cube file.

Parameters:

lit (LineIterator) – The line iterator to read the data from.

Return type:

dict

Returns:

result (dict) – A dictionary with IOData attributes. The following attributes are guaranteed to be loaded: atcoords, atcorenums, atnums, cellvecs, cube.

prepare_dump(data, allow_changes, filename)[source]

Check the compatibility of the IOData object with the Gaussian Cube format.

Parameters:
  • data (IOData) – The IOData instance to be checked.

  • allow_changes (bool) – Whether conversion of the IOData object to a compatible form is allowed or not.

  • filename (str) – The file to be written to, only used for error messages.

Return type:

IOData

Returns:

data – The given IOData object, or a copy with a title on a single line.

Raises:

PrepareDumpError – If the title has more than one line and allow_changes is False.