def cube_generator_dftbplus(project_name, time_step, min_band, max_band,
                            waveplot_exe, isUKS):
    """
    This function generates the cube files by first forming the 'fchk' file from 'chk' file.
    Then it will generate the cube files from min_band to max_band the same as CP2K naming.
    This will helps us to use the read_cube and integrate_cube functions easier.

    Args:

        project_name (string): The project_name.

        time_step (integer): The time step.

        min_band (integer): The minimum state number.

        max_band (integer): The maximum state number.

        waveplot_exe (str): Location of the executable for the waveplot program of the dftb+ software package

        isUKS (integer): The unrestricted spin calculation flag. 1 is for spin unrestricted calculations.
                         Other numbers are for spin restricted calculations

    Returns:

        None

    """

    # Make the cubefiles. For dftb+, this simply means executing the waveplot program
    # The min and max band are already defind in the waveplot template. So, we just use
    # them here for renaming the cubefiles
    os.system(waveplot_exe)

    # For now, only spin-restricted
    for state in range(min_band, max_band + 1):
        # Use cp2k names because the rest of the code expects this format
        state_name = CP2K_methods.state_num_cp2k(state)
        cube_name = '%s-%d-WFN_%s_1-1_0.cube' % (project_name, time_step,
                                                 state_name)
        print('Renaming cube for state %d' % state)
        # Now, rename the cubefile from what waveplots calls it to the standard format
        os.system("mv *" + str(state) + "-real.cube " + cube_name)
Esempio n. 2
0
def cube_generator_gaussian( project_name, time_step, min_band, max_band, nprocs, sample_cube_file, isUKS ):
    """
    This function generates the cube files by first forming the 'fchk' file from 'chk' file.
    Then it will generate the cube files from min_band to max_band the same as CP2K naming.
    This will helps us to use the read_cube and integrate_cube functions easier.

    Args:

        project_name (string): The project_name.

        time_step (integer): The time step.

        min_band (integer): The minimum state number.

        max_band (integer): The maximum state number.

        nprocs (integer): The number of processors used to generate the cubes using 'cubegen'.

        sample_cube_file (str): The path to a sample cube file. This file is used to generate the cube
                                files according the mesh of this file. Therefore the integration will be plausible.

        isUKS (integer): The unrestricted spin calculation flag. 1 is for spin unrestricted calculations.
                         Other numbers are for spin restricted calculations

    Returns:

        None

    """

    # Form the fchk file from the chk file
    os.system('formchk %s-%d.chk %s-%d.fchk'%(project_name, time_step, project_name, time_step))
    # Print the commands...
    print('formchk %s-%d.chk %s-%d.fchk'%(project_name, time_step, project_name, time_step))
    # Generate the sample cube file, if it exists it will not create it again
    if not os.path.isfile(sample_cube_file):
        # Generate the sample cube file with the maximum fineness ---> 100 as in Gaussian website
        os.system('cubegen %d MO=H**o %s-%d.fchk %s 100 h'%(nprocs, project_name, time_step, sample_cube_file))
    # For spin unrestricted
    if isUKS == 1:
        # Generate the names and cube files for each state. Here we use the cube names by CP2K. This will increase the speed of our work.
        for state in range(min_band,max_band+1):
            # State name in CP2K format
            state_name = CP2K_methods.state_num_cp2k(state)
            # Cube file name 
            cube_name = '%s-%d-WFN_%s_1-1_0.cube'%(project_name, time_step, state_name)
            print('Generating cube for state %d'%state)
            # Generate cube files for alpha spin using the 'cubegen'
            os.system('cubegen %d AMO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))
            print('cubegen %d AMO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))
            cube_name = '%s-%d-WFN_%s_2-1_0.cube'%(project_name, time_step, state_name)
            print('Generating cube for state %d'%state)
            # Generate cube files for beta spin using the 'cubegen'
            os.system('cubegen %d BMO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))
            print('cubegen %d BMO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))
    # Spin restricted case
    else:
        for state in range(min_band,max_band+1):
            # Use cp2k names because the rest of the code expects this format
            state_name = CP2K_methods.state_num_cp2k(state)
            cube_name = '%s-%d-WFN_%s_1-1_0.cube'%(project_name, time_step, state_name)
            print('Generating cube for state %d'%state)
            # Generate the cubes for alpha spin only
            os.system('cubegen %d MO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))
            print('cubegen %d MO=%d %s-%d.fchk %s -1 h %s'%(nprocs, state, project_name, time_step, cube_name, sample_cube_file))