Cube (.cub, .cube)
Background & Context
-
- MIME type: chemical/x-cubeGaussian cube file.
- Used by electronic structure programs to store orbital or density values on a three-dimensional grid.
- Plain-text format.
- Can contain volumetric data for an arbitrary number of orbitals.
- Maintained by Gaussian, Inc.
Import & Export
- Import["file.cub"] imports a list of molecules from a Cube file.
- Export["file.cub",expr] exports a molecule or list of molecules to a Cube file.
- Import["file.cub",elem] imports the specified element from a Cube file.
- Import["file.cub",{{elem1,elem2,…}}] imports multiple elements.
- The import format can be specified with Import["file","Cube"] or Import["file",{"Cube",elem,…}].
- Export["file.cub",mol] creates a Cube file from a molecule containing a "VolumetricData" key in its MetaInformation.
- Export["file.cub",{expr1,expr2,…},{{elem1,elem2,…}}] treats each expri as specifying the corresponding elemi.
- Export["file.cub",expr,opt1->val1,…] exports expr with the specified option elements taken to have the specified values.
- Export["file.cub",{elem1->expr1,elem2->expr2,…},"Rules"] uses rules to specify the elements to be exported.
- When creating a Cube file, volumetric data can be either in the molecule expression as MetaInformation or given to Export as a separate element.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data elements:
-
"Molecule" a symbolic representation of the molecule model "VolumetricData" an Association containing the electronic orbital information "Graphics3D" a 3D graphic containing a model of the molecule along with contours representing electronic isosurfaces - The "VolumetricData" element contains the following keys:
-
"DataRange" a list of bounding box coordinates {{xmin,xmax},{ymin,ymax},{zmin,zmax}} "Data" a list of three-dimensional arrays specifying the value of the orbital wavefunction or density on a grid "OrbitalNumber" an optional list specifying numerical values for the orbitals
Options
- General Import options:
-
IncludeMetaInformation True whether to include the volumetric data in the molecule's MetaInformation - For the "Graphics3D" element, Import has the same options as ContourPlot3D and MoleculePlot3D, with the following changes:
-
Contours {-.03,.03} specifies the values for the drawn isosurfaces ContourStyle Opacity[0.8] specifies the style for the isosurfaces - Export options:
-
"Header" Automatic header information from the file "Comment" None comment to write on the second line
Examples
open all close allBasic Examples (3)
Import and plot the electronic density from a Cube file:
Import["ExampleData/Pyridinecarbonitrile_DEN.cub", "Graphics3D"]Import and plot a Cube file containing two orbitals:
Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D"]Import a molecule from a Cube file:
mol = Import["ExampleData/Pyridinecarbonitrile_DEN.cub"]Find a matching Entity for the molecule:
ToEntity@molFind the volumetric data in the molecule's MetaInformation:
mol["MetaInformation"]Export the molecule to a Cube file:
Export["test.cub", mol]Import Elements (1)
Import the volumetric data for two molecular orbitals from a Cube file:
volData = Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "VolumetricData"]ListDensityPlot3D[volData[["Data", 1]], DataRange -> volData["DataRange"], BoxRatios -> Automatic]Export Elements (1)
Export a molecule and data to a Cube file:
mol = Molecule[{Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["C"], Atom["N"], Atom["H"], Atom["H"],
Atom["H"], Atom["H"], Atom["C"], Atom["N"]}, {Bond[{1, 2}, "Aromatic"], Bond[{2, 3}, "Aromatic"],
Bond[{3, 4}, "Aromatic"], Bond[{4, 5}, "Aromat ... 267874284}, {0., 2.167739145652817, 0.389417833298357},
{0., -2.167739145652817, 0.389417833298357}, {0., -2.077788538513299, -2.136138267874284},
{0., 0., 2.120315868129184}, {0., 0., 3.280315790471602}}, "Angstroms", {{1}, {2}}}]]];
volData = <|"Data" -> {NumericArray[{{{9.532699550618418*^-6, 0.000010906699571933132, 0.00001232249996974133,
0.000013743099771090783, 0.000015124000128707848, 0.000016414500350947492,
0.000017559099433128722, 0.000018499800717108883, 0.0000191787003132049, 0.000019 ... 632355*^-6, -1.5902099903541966*^-6, -1.4878800129736192*^-6, -1.366959963888803*^-6,
-1.2345200275376556*^-6, -1.0970200037263567*^-6, -9.59980980042019*^-7, -8.278730092570186*^-7,
-7.040640070954396*^-7, -5.908499929319078*^-7}}}, "Real32"]}, "DataRange" -> {{-3.44, 3.43}, {-4.65, 4.70}, {-5.14, 6.15}}|>;Export["test.cub", {mol, volData}, {{"Molecule", "VolumetricData"}}]Import Options (2)
Specify the value and style for the orbital isosurface:
First@Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D", Contours -> {-0.04, 0.04}, ContourStyle -> {Red, Blue}]Use textures for the surfaces:
First@Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D", Contours -> {-0.04, 0.04}, ContourStyle -> {Texture[[image]], Texture[[image]]}]When importing the "Graphics3D" element, it is possible pass in options for MoleculePlot3D or ListContourPlot3D.
Specify a specific PlotTheme:
Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D", PlotTheme -> "Tubes"]Control the display of the output with Graphics3D options:
First@Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D", Boxed -> True, Axes -> True, ViewPoint -> {2, -2.4, 2.}]Use a custom ColorFunction:
First@Import["ExampleData/Pyridinecarbonitrile_MO_25_29.cub", "Graphics3D", ColorFunction -> Function[{x, y, z, f}, Hue[z + x y]], PlotTheme -> "Wireframe"]History
Introduced in 2020 (12.1)