Mod:Hunt Research Group/cube files
Manipulating Cube Files
cubegen
- use the cubegen utility to generate cube files, link
- command format is cubegen nprocs kind fchkfile cubefile npts header
- OR cubegen nprocs kind fchkfile cubefile npts header cubefile2
- some simple examples:
- cubegen 0 density=scf file.chk file_dens.cube 0 h (density)
- cubegen 0 potential=scf file.chk file_esp.cube 0 h (electrostatic potential ESP)
- cubegen 0 mo=14 file.chk file_mo14.cube 0 h (molecular orbital no 14)
- nprocs
- use 0 for the default to use machine specific default value
- kind
- use density=gradient to generate the density and gradient
- use density=lablacian to compute the laplacian
- npts
- normally you would use npts=0 (the default)
- npts default of 0 selects a default value of 803 points distributed evenly over a rectangular grid generated automatically by the program, frequently not a cube!
- npts a positive value specifies the number of points per "side"; e.g., 100 specifies a grid of 1003 points
- npts a negative value of -2, -3 and -4 correspond to Coarse, Medium and Fine grids and to 3 points/Bohr, 6 points/Bohr and 12 points/Bohr (respectively).
- npts a negative values < -5 specifies spacing of npts*10-3 Angstroms between points in the grid.
- npts a negative value of -1 lets you manipulate the files more exactly, information is provided in the input stream
- you can provide the key information yourself in this format
IFlag, X0, Y0, Z0 Output unit number, the reference point for the following N1, X1, Y1, Z1 Number of points and step-size in the X-direction. N2, X2, Y2, Z2 Number of points and step-size in the Y-direction. N3, X3, Y3, Z3 Number of points and step-size in the Z-direction.
- IFlag=output unit number, positive IFlag produces an unformatted file, negative IFlag produces a formatted file
- N1,N2,N3 <0 the input coordinates are in Bohr, otherwise they are in Angstrom
- there are issues with the EOF so in unix terminate with a ^D command if you enter by hand
- example
- we want a box, ie orthogonal vectors
-22, 1.0, 1.0, 1.0 20, 0.25, 0.0, 0.0 20, 0.0, 0.25, 0 20, 0.0, 0.0, 0.25
- output will be a fort.22 file
- the box is positioned to start at 1.0,1.0,1.0
- we take 20 points and place them along the x-direction in intervals of 0.25 ie at 1.0, 1.25, 1.50, 1.75 ...
- we take 20 points and place them along the y-direction in intervals of 0.25 ie at 1.0, 1.25, 1.50, 1.75 ...
- we take 20 points and place them along the z-direction in intervals of 0.25 ie at 1.0, 1.25, 1.50, 1.75 ...
- you can put all of this information into a file and pipe it into the cubgen command
- cubegen 0 MO=14 file.chk file_mo14.cube -1 h (density) < cubegen.dat (NOTE not sure about this!)
- h means include a header, n means don't include a header
- when combining two cube files they must be exactly the same size/type
- you must also have generated the original chk files with the keyword nosymm so that atomic centers are not reoriented
- luckily you don't have to specify the cube file size exactly, there is a shortcut, you can specify an already generated cube file and the new file cube generated will use exactly the same parameters taken from this file
- the first file must have been generated with a header
- and you must use npts=-1
- cubegen 0 density=scf fchkfile cubefile1 -1 h cubefile2
cubman
- use the cubeman utility to generate cube files, link
- if manipulating cube files they must have the same number of points!
- an example output is below cubman
- the information presented is all in shorthand
- input cubes are A and B
- output cube is O
- N for “negative values” or for “nuclear”, depending on the context
- P for “positive values”
- E for “electronic”
- C for “charge”
- Dip for “dipole”
- Sum for ~ldq∑rdq~
- Max for “maximum”
- Min for “minimum.”
- for example
- SumAP is the sum of the positive values in the first cube
- SumBN is the sum of the negative values in the second cube
- SumOP is the sum of the positive values in the output cube
- CBMax is the maximum charge for the second cube
- CBMin is the minimum charge for the second cube
- SumO is the sum of the values in the output cube, including both positive and negative values.
- DipOE is the electronic contribution to the dipole moment in output cube
- DipON is the nuclear contribution to the dipole moment in output cube.
- DipO is the total dipole moment in the output cube
Action [Add, Copy, Difference, Properties, SUbtract, SCale, SQuare, SProd, Vprod, Magnitude, Normalize, SElect, ToXYZ ]? SU First input? bmimCl_front_esp.cube Is it formatted [no,yes,old,veryold,unfold]? y Opened formatted file bmimCl_front_esp.cube. Second input? bmimCl_front_add_esp.cube Is it formatted [no,yes,old,veryold,unfold]? y Opened formatted file bmimCl_front_add_esp.cube. Output file? bmimCl_front_diff_esp.cube Should it be formatted [no,yes]? y Opened formatted file bmimCl_front_diff_esp.cube. Input file titles: Title Card Required potential=scf Electrostatic potential from Total SCF Density Input file titles: Title Card Required potential=scf || Title Card Required potential=scf Electrostatic potential from Total SCF + Electrostatic potential from Total S Warning: Mismatch in files: NAtomA= 26 NAtomB= 25 N1A= 99 N1B= 99 N2A= 88 N2B= 88 N3A= 59 N3B= 59 N4A= 1 N4B= 1 SumAP= 475.8505107503 SumAN= -130.8410024346 SumA= 345.0095083157 CAMax= 106.5150000000 XYZ= 1.3813040000 5.4385200000 -0.3367420000 CAMin= -0.1237780000 XYZ= 1.0991260000 7.6959440000 -2.5941660000 SumBP= 516.9086440282 SumBN= -186.5554469490 SumB= 330.3531970792 CBMax= 106.4860000000 CBMin= -0.1676300000 SumOP= 63.0963538336 SumON= -48.4400425970 SumO= 14.6563112365 COMax= 0.0670800000 COMin= -0.0387900000 DipAE= -96.0692206364 1848.0174549921 -60.0829076681 DipAN= 0.0000060000 -0.0000250000 -0.0000120000 DipA= -96.0692146364 1848.0174299921 -60.0829196681 DipBE= -94.9632888467 2577.9330800437 -90.2148993076 DipBN= -22.7263250000 -94.0295580000 6.4423760000 DipB= -117.6896138467 2483.9035220437 -83.7725233076 DipOE= -1.1059317897 -729.9156250516 30.1319916394 DipON= 0.0000060000 -0.0000250000 -0.0000120000 DipO= -1.1059257897 -729.9156500516 30.1319796394
cube file format
If one wishes to read the values of the density, Laplacian, or potential back into an array dimensioned X(N3,N2,N1), code like the following Fortran loop may be used:
Do 10 I1 = 1, N1
Do 10 I2 = 1, N2
Read(n,'(6E13.5)') (X(I3,I2,I1),I3=1,N3)
10 Continue
where n is the unit number corresponding to the cube file.
If the origin is (X0,Y0,Z0), and the increment is (X1,Y1,Z1), then point (I1,I2,I3) has the coordinates:
X-coordinate: X0+(I1-1)*X1+(I2-1)*X2+(I3-1)*X3
Y-coordinate: Y0+(I1-1)*Y1+(I2-1)*Y2+(I3-1)*Y3
Z-coordinate: Z0+(I1-1)*Z1+(I2-1)*Z2+(I3-1)*Z3
The output is similar if the gradient or gradient and Laplacian of the charge density are also requested, except that in these cases there are two or three records, respectively, written for each pair of I1, I2 values. Thus, if the density and gradient are to be read into arrays D(N3,N2,N1), G(3,N3,N2,N1), RL(N3,N2,N1), a correct set of Fortran loops would be:
Do 10 I1 = 1, N1
Do 10 I2 = 1, N2
Read(n,'(6F13.5)') (D(I3,I2,I1),I3=1,N3)
Read(n,'(6F13.5)') ((G(IXYZ,I3,I2,I1),IXYZ=1,3), I3=1,N3)
10 Continue
where again n is the unit number corresponding to the cube file.