Exemple #1
0
def BUILD_ESP_MAT_EXACT_ROT(params, Gs, Gr, mol_xyz, irun):

    r_array = Gr.flatten()

    VG = []
    counter = 0
    if params[
            'molec_name'] == "chiralium":  # test case for chiralium. We have analytic potential on the radial grid and we want to use Lebedev quadratures for matrix elements

        # 1. Read potential

        start_time = time.time()
        vLM, rgrid_anton = read_potential(params)
        end_time = time.time()

        lmax_multi = params['multi_lmax']

        for k in range(len(r_array) - 1):
            sph = np.zeros(Gs[k].shape[0], dtype=complex)
            print("No. spherical quadrature points  = " + str(Gs[k].shape[0]) +
                  " at grid point " + str('{:10.3f}'.format(r_array[k])))
            for s in range(Gs[k].shape[0]):

                #entire potential block
                for L in range(0, lmax_multi + 1):
                    for M in range(-L, L + 1):

                        #Gs[k][s,0] = theta
                        sph[s] += vLM[k, L, L + M] * sph_harm(
                            M, L, Gs[k][s, 1] + np.pi, Gs[k][s, 0])
                counter += 1

            VG.append(sph)

        return VG

    if os.path.isfile(params['job_directory'] + "esp/" + str(irun) + "/" +
                      params['file_esp']):
        print(params['file_esp'] + " file exist")

        #os.remove(params['working_dir'] + "esp/" + params['file_esp'])

        if os.path.getsize(params['job_directory'] + "esp/" + str(irun) + "/" +
                           params['file_esp']) == 0:

            print("But the file is empty.")
            os.remove(params['job_directory'] + "esp/" + str(irun) + "/" +
                      params['file_esp'])
            os.remove(params['job_directory'] + "esp" + str(irun) + "/" +
                      "grid.dat")

            grid_xyz = GRID.GEN_XYZ_GRID(
                Gs, Gr, params['job_directory'] + "esp/" + str(irun) + "/")
            grid_xyz = np.asarray(grid_xyz)
            V = GRID.CALC_ESP_PSI4(
                params['job_directory'] + "esp/" + str(irun) + "/", params)
            V = -1.0 * np.asarray(V)
            esp_grid = np.hstack((grid_xyz, V[:, None]))
            fl = open(
                params['job_directory'] + "esp/" + str(irun) + "/" +
                params['file_esp'], "w")
            np.savetxt(fl, esp_grid, fmt='%10.6f')

        else:
            print("The file is not empty.")
            flpot1 = open(
                params['job_directory'] + "esp/" + str(irun) + "/" +
                params['file_esp'], "r")
            V = []
            for line in flpot1:
                words = line.split()
                potval = float(words[3])
                V.append(potval)
            V = np.asarray(V)

    else:
        print(params['file_esp'] + " file does not exist")

        #os.remove(params['working_dir'] + "esp/grid.dat")

        grid_xyz = GRID.GEN_XYZ_GRID(
            Gs, Gr, params['job_directory'] + "esp/" + str(irun) + "/")
        grid_xyz = np.asarray(grid_xyz)
        V = GRID.CALC_ESP_PSI4_ROT(
            params['job_directory'] + "esp/" + str(irun) + "/", params,
            mol_xyz)
        V = -1.0 * np.asarray(V)

        esp_grid = np.hstack((grid_xyz, V[:, None]))
        fl = open(
            params['job_directory'] + "esp/" + str(irun) + "/" +
            params['file_esp'] + "_" + str(irun), "w")
        np.savetxt(fl, esp_grid, fmt='%10.6f')

    r_array = Gr.flatten()

    VG = []
    counter = 0
    if params['molec_name'] == "h":  # test case of shifted hydrogen
        r0 = 1.0
        for k in range(len(r_array) - 1):
            sph = np.zeros(Gs[k].shape[0], dtype=float)
            print("No. spherical quadrature points  = " + str(Gs[k].shape[0]) +
                  " at grid point " + str('{:10.3f}'.format(r_array[k])))
            for s in range(Gs[k].shape[0]):
                sph[s] = -1.0 / np.sqrt(r_array[k]**2 + r0**2 - 2.0 *
                                        r_array[k] * r0 * np.cos(Gs[k][s, 0]))
                #sph[s] = -1.0 / (r_array[k])
                counter += 1

            VG.append(sph)

    else:
        for k in range(len(r_array) - 1):
            sph = np.zeros(Gs[k].shape[0], dtype=float)
            print("No. spherical quadrature points  = " + str(Gs[k].shape[0]) +
                  " at grid point " + str('{:10.3f}'.format(r_array[k])))
            for s in range(Gs[k].shape[0]):
                sph[s] = V[counter]
                counter += 1

            VG.append(sph)

    return VG
Exemple #2
0
def BUILD_ESP_MAT_EXACT(params, Gs, Gr):

    if os.path.isfile(params['working_dir'] + "esp/" + params['file_esp']):
        print(params['file_esp'] + " file exist")

        #os.remove(params['working_dir'] + "esp/" + params['file_esp'])

        if os.path.getsize(params['job_directory'] + "esp/" +
                           params['file_esp']) == 0:

            print("But the file is empty.")
            os.remove(params['working_dir'] + "esp/" + params['file_esp'])
            os.remove(params['working_dir'] + "esp/grid.dat")

            grid_xyz = GRID.GEN_XYZ_GRID(Gs, Gr,
                                         params['job_directory'] + "esp/")
            grid_xyz = np.asarray(grid_xyz)
            V = GRID.CALC_ESP_PSI4(params['job_directory'] + "esp/", params)
            V = -1.0 * np.asarray(V)
            esp_grid = np.hstack((grid_xyz, V[:, None]))
            fl = open(params['job_directory'] + "esp/" + params['file_esp'],
                      "w")
            np.savetxt(fl, esp_grid, fmt='%10.6f')

        else:
            print("The file is not empty.")
            flpot1 = open(params['working_dir'] + "esp/" + params['file_esp'],
                          "r")
            V = []
            for line in flpot1:
                words = line.split()
                potval = float(words[3])
                V.append(potval)
            V = np.asarray(V)

    else:
        print(params['file_esp'] + " file does not exist")

        #os.remove(params['working_dir'] + "esp/grid.dat")

        grid_xyz = GRID.GEN_XYZ_GRID(Gs, Gr, params['working_dir'] + "esp/")
        grid_xyz = np.asarray(grid_xyz)
        V = GRID.CALC_ESP_PSI4(params['working_dir'] + "esp/", params)
        V = -1.0 * np.asarray(V)

        esp_grid = np.hstack((grid_xyz, V[:, None]))
        fl = open(params['working_dir'] + "esp/" + params['file_esp'], "w")
        np.savetxt(fl, esp_grid, fmt='%10.6f')

    r_array = Gr.flatten()

    VG = []
    counter = 0
    for k in range(len(r_array) - 1):
        sph = np.zeros(Gs[k].shape[0], dtype=float)
        print("No. spherical quadrature points  = " + str(Gs[k].shape[0]) +
              " at grid point " + str(r_array[k]))
        for s in range(Gs[k].shape[0]):
            sph[s] = V[counter]
            counter += 1

        VG.append(sph)
    return VG