cube_file_methods

libra_py.cube_file_methods.grid_volume(filename: str)[source]

This function reads the wavefunction from a cube file and calculate the grid volum using the X-, Y- and Z-axis of the volumetric region which are placed in the 4th, 5th and 6th line of the cube file structure

Parameters

filename (string) – The name of the .cube file to read.

Returns

The grid volume in Bohr^3.

Return type

dv (float)

libra_py.cube_file_methods.integrate_cube(cube_A, cube_B, grid_volume)[source]

This function calculates the element-wise multiplication of two numpy arrays and sums their product. Then, it will multiply the sum by ‘dv’ element to compute the integral of two wavefunction represented as .cube files. :param cube_A: The elements of the cube files in a 1D array

obtained from the ‘read_cube’ function.

Parameters
  • cube_B (numpy array) – The elements of the cube files in a 1D array obtained from the ‘read_cube’ function.

  • grid_volume (float) – The volume of the voxel obtained from grid_volume function.

Returns

The integration between two wavefunction in the .cube files.

Return type

integral (float)

libra_py.cube_file_methods.plot_cubes(params)[source]

This function plots the cubes for selected energy levels using VMD.

Parameters

params (dict) –

min_band (int): The minimum state number.

states_to_be_plotted (list): The list containing the Kohn-Sham orbitals to be plotted by VMD. This list is defined in the submit file.

path_to_tcl_file (str): The path to the tcl file which contains the input for plotting the cubes in VMD.

MO_images_directory (str): The molecular orbitals images directory.

isUKS (int): This parameter is set for spin restricted and unrestricted calculations. When it is

set to 1 it means that unrestricted calculations were set in the input file otherwise it is restricted.

curr_step (int): The current time step used to save the images of the MOs.

phase_factor_visual (numpy array): The phase correction factor list for each MOs for the current step.

Returns

None

libra_py.cube_file_methods.read_cube(filename: str)[source]

This function reads the wavefunction from a cube file and stores it in a 1D numpy array :param filename: the name of the .cube file to read :type filename: string

Returns

the 1D array of the wavefunctions for all the points on the grid

Return type

isovalues (numpy.array)

libra_py.cube_file_methods.read_volumetric_data(filename: str)[source]

This function reads the volumetric data in a format used for plotting of the data. The difference between ‘read_cube’ function is that it will show the data in a 3D array which has the shape as the number of grid points for each of the X-, Y-, and Z-axis in the 4th to 6th line of the cube file. This function will return the grid points in each axis, the coordinates of the structure and the spacing vector which is used to plot the isosurfaces of the molecular orbitals.

Parameters

filename (string) – The name of the .cube file.

Returns

The coordinates of the molecule structure in

the same format shown in the .cube file.

x_grid, y_grid, z_grid (3D numpy array): Containing the grid points for each of the X-,

Y-, and Z- axis.

wave_fun (3D numpy array): The volumetric data in a 3D numpy array format.

spacing_vector (numpy 1D array): The spacing vector used for plotting the isosurfaces.

Return type

coordinates (2D numpy array)