Example #1
0
/****************************************
 Function name	  : paw_solve_pseudo_orbitals
 Description	    :
 Return type		  : void
 Author     		  : Marat Valiev
 Date & Time		  : 5/15/00
****************************************/
void paw_scattering_test(double e1,double e2,int number_points ,int l, double r )
{

    int i;
    int k;
    int i_end_point;
    int Ngrid;
    double *rgrid;
    FILE   *fp;
    double *V_ks;


    double *psi1;
    double *psi1_prime;

    double *psi;
    double *psi_prime;

    double *log_grid_ae;
    double *log_grid_paw;

    double de;
    double* e3;
    double e_test;
    double log_amesh;

    /*char output[30];*/
    char data_filename[300];
    char script_filename[300];

    Ngrid = paw_N_LogGrid();
    rgrid = paw_r_LogGrid();
    log_amesh = paw_log_amesh_LogGrid();

    psi1       = paw_alloc_LogGrid();
    psi1_prime = paw_alloc_LogGrid();

    psi       = paw_alloc_LogGrid();
    psi_prime = paw_alloc_LogGrid();

    log_grid_ae = paw_alloc_1d_array(number_points);
    log_grid_paw = paw_alloc_1d_array(number_points);
    e3 = paw_alloc_1d_array(number_points);

    de = (e2-e1)/number_points;
    V_ks = paw_get_kohn_sham_potential();

    i_end_point = paw_get_grid_index(r);

    for (i=0;i<= number_points-1;i++)
    {
        e_test = e1+de*i;
        e3[i] = e_test;


        paw_solve_paw_scattering(l, r, e_test, psi,psi_prime);

        paw_R_Schrodinger_Fixed_E(
            l,
            V_ks,
            i_end_point,
            e_test,
            psi1,
            psi1_prime
        );




        log_grid_ae[i] =  psi1_prime[i_end_point-1]/(psi1[i_end_point-1]*rgrid[i_end_point-1]*log_amesh);
        log_grid_paw[i]  =  psi_prime[i_end_point-1]/(psi[i_end_point-1]*rgrid[i_end_point-1]*log_amesh);

    }

    if (paw_debug())
    {
        sprintf(data_filename,"%s%s_%s_scat_test.dat", paw_sdir(),paw_get_atom_name(),paw_spd_Name(l));
        fp = fopen(data_filename,"w+");

        for (k=0; k<=number_points-1; k++)
        {
            fprintf(fp,"%le\t%le\t%le\n", e3[k],log_grid_ae[k],log_grid_paw[k]);

        }
        fclose(fp);

        sprintf(script_filename,"%s%s_%s_scat_test.plt", paw_sdir(),paw_get_atom_name(),paw_spd_Name(l));
        printf("script_filename: %s\n",script_filename);
        fp = fopen(script_filename,"w+");

        fprintf(fp,"set style data lines \n");
        fprintf(fp,"set nolabel \n");
        fprintf(fp,"set autoscale \n");
        fprintf(fp,"set xr[%f:%f] \n",e1,e2);
        fprintf(fp,"set grid \n");
        fprintf(fp,"set nolabel \n");

        fprintf(fp,"set xlabel \"e (Hartree)\" \n");
        fprintf(fp,"set ylabel \"logarithmic derivative at r=%f\" \n",r);
        fprintf(fp,"set title \" %s %s channel scattering test\n",paw_get_atom_name(),paw_spd_Name(l));

        fprintf(fp,"plot \"%s\" using 1:2 title \"all electron\",",data_filename);
        fprintf(fp,"\"\" using 1:3 title \"paw\" \n");

        fprintf(fp,"\n");
        fprintf(fp,"pause -1\n");
        fclose(fp);
    }


}
Example #2
0
/****************************************
 Function name	  : paw_solve_unoccupied_orbitals
 Description	    :
 Return type		  : void
 Author     		  : Marat Valiev
 Date & Time		  : 4/10/99 6:13:39 PM
****************************************/
void paw_solve_unoccupied_orbitals()
{
    int i;
    int j;
    int k;
    int state;
    int Ngrid;
    int status;
    double sum;
    double *V;
    double *rgrid;
    double Zion;


    Ngrid = paw_N_LogGrid();
    rgrid = paw_r_LogGrid();
    Zion = paw_get_ion_charge();

    /*check if the occupied orbitals are done*/
    if (!(occupied_orbitals_done))
    {
        printf("cannot calculate unoccupied states\n");
        printf("calculate occupied states first\n");
    }

    /*get Kohn-Sham potential*/
    V = paw_get_kohn_sham_potential();

    for (i=Nvalence; i<= Nbound-1; i++)
    {

        state=paw_bound_state_test(l[i],V);
        if (state==0)
        {
            printf("This potential has no bound states with n=%d l=%d\n",n[i],l[i]);
            printf("please change your input file\n");
            exit(1);
        }
        else
        {
            if (Solver_Type==Schrodinger)
            {
               status = paw_R_Schrodinger(n[i],l[i],V,
                                          &eigenvalue[i],psi[i],psi_prime[i]);
            }
            else
            {
               status = paw_R_Pauli(n[i],l[i],Zion,V,
                                          &eigenvalue[i],psi[i],psi_prime[i]);
            }

        }

        if (!(status))
        {
            printf("This potential has no bound states with n=%d l=%d\n",n[i],l[i]);
            printf("please change your input file\n");
            exit(1);
        }


        /*orthogonalize to lower orbitals*/
        for (j=0;j<=i-1;j++)
        {
            if (l[i]==l[j])
            {
                sum = paw_dot_product(psi[i],psi[j]);
                for (k=0;k<=Ngrid-1;k++)
                    psi[i][k] = psi[i][k] - sum*psi[j][k];
            }

        }

        for (k=0;k<=Ngrid-1;k++)
            psi_tmp[k] = pow((psi[i][k]/rgrid[k]),2.0);

        sum = paw_Integrate_LogGrid(psi_tmp);

        for (k=0;k<=Ngrid-1;k++)
            psi[i][k]=psi[i][k]/pow(sum,0.5);
    }


}
Example #3
0
/****************************************
 Function name	  : paw_solve_scattering_orbitals
 Description	    :
 Return type		  : void
 Author     		  : Marat Valiev
 Date & Time		  : 4/10/99 4:58:27 PM
****************************************/
void paw_solve_scattering_orbitals()
{
    int i;
    int j;
    int k;
    int i_match;
    int Ngrid;
    double sum;
    double *V;
    double *rgrid;
    double r_sphere;
    double Zion;

    Ngrid = paw_N_LogGrid();
    rgrid = paw_r_LogGrid();
    Zion = paw_get_ion_charge();

    /*normalization sphere radius*/
    r_sphere = 2.0;

    /*check if the occupied orbitals are done*/
    if (!(occupied_orbitals_done))
    {
        printf("cannot calculate scattering orbitals\n");
        printf("calculate occupied states first\n");
    }


    /*get Kohn-Sham potential*/
    V = paw_get_kohn_sham_potential();


    for (i=Nbound;i<Ntotal;i++)
    {

        /*set the end point*/
        i_match = Ngrid-1;

        if (Solver_Type==Schrodinger)
        {
           paw_R_Schrodinger_Fixed_E(l[i],V,i_match,eigenvalue[i],psi[i],psi_prime[i]);
        }
        else
        {
           paw_R_Pauli_Fixed_E(n[i],l[i],Zion,V,i_match,eigenvalue[i],psi[i],psi_prime[i]);
        }

        for (j=0;j<i-1;j++)
        {

            if (l[i]==l[j])
            {
                sum = paw_dot_product(psi[i],psi[j]);
                for (k=0;k<Ngrid;++k)
                    psi[i][k] = psi[i][k] - sum*psi[j][k];
            }

        }

        /*normalize*/
        sum = paw_dot_product1(paw_get_grid_index(r_sphere),psi[i],psi[i]);
        sum = 1.0/sqrt(sum);

        for (k=0;k<Ngrid;++k)
        {
            psi[i][k] = psi[i][k]*sum;
            psi_prime[i][k] = psi_prime[i][k]*sum;

        }


    }

    /*debug
    printf("orthogonality\n");
    for(i=0;i<=Ntotal-1;i++)
    {
        for(j=0;j<=Ntotal-1;j++)
        {
          if(l[i]==l[j])
          {
            printf("%d\t %d\t %f\n",i,j, paw_dot_product(psi[i],psi[j]));
          }
      
        }  
     }
        exit(1);
    end debug  */
}
Example #4
0
/****************************************
 Function name	  :  paw_solve_occupied_orbitals
 Description	    :
 Return type		  : void
 Author     		  : Marat Valiev
 Date & Time		  : 4/10/99 6:13:22 PM
****************************************/
void   paw_solve_occupied_orbitals()
{
    int   i;
    int   j;
    int  k;
    int  it;
    int  converged;
    int   Ngrid;
    int   max_iter;
    double sum;
    double Etmp;
    double thl;
    double sn;
    double sd;
    double dr;
    double rl0;
    double rl1;
    double vn;
    double Zion;
    double *Vo;
    double *Vo1;
    double *Vi1;
    double *Vi;
    double *rgrid;

    max_iter = 100;

    Ngrid = paw_N_LogGrid();
    rgrid = paw_r_LogGrid();

    /* allocate temporary grids */
    Vi      = paw_alloc_LogGrid();
    Vo1     = paw_alloc_LogGrid();
    Vi1     = paw_alloc_LogGrid();

    /* set initial guess for KS potential as Thomas-Fermi*/
    Zion = paw_get_ion_charge();
    paw_Thomas_Fermi(Zion,Vi);

    /*initial guess for the eigenvalues*/
    paw_guess_eigenvalues(Zion,Vi);

    it = 0;
    converged = False;
    while ((!converged) && (it < max_iter))
    {

        it        = it + 1;
        converged = True;

        /* solve for each of the eigenstates */
        for (i=0; i<= Nvalence-1; i++)
        {

            Etmp = eigenvalue[i];

            if (Solver_Type==Schrodinger)
            {
               paw_R_Schrodinger(n[i],l[i],Vi,
                                 &Etmp,psi[i],psi_prime[i]);
            }
            else
            {
               paw_R_Pauli(n[i],l[i],Zion,Vi,
                           &Etmp,psi[i],psi_prime[i]);
            }

            if (fabs(eigenvalue[i] - Etmp) >1.0e-10)
                converged = False;

            eigenvalue[i]=Etmp;


            /*orthogonalize to lower orbitals*/
            for (j=0;j<=i-1;j++)
            {
                if (l[i]==l[j])
                {
                    sum = paw_dot_product(psi[i],psi[j]);
                    for (k=0;k<Ngrid;++k)
                        psi[i][k] = psi[i][k] - sum*psi[j][k];
                }

            }

            /*normalize the orbital*/
            for (k=0; k<=Ngrid-1; k++)
                psi_tmp[k] = pow((psi[i][k]/rgrid[k]),2.0);

            sum = paw_Integrate_LogGrid(psi_tmp);

            for (k=0; k<=Ngrid-1; k++)
                psi[i][k]=psi[i][k]/pow(sum,0.5);

        }

        /*get new density*/
        paw_generate_density(rho);

        /*get new potential*/
        paw_set_kohn_sham_potential(rho);
        Vo = paw_get_kohn_sham_potential();


        /*****************************************/
        /* Generate the next iteration potential */
        /* using D.G. Anderson method            */
        /*****************************************/
        thl = 0.0;
        if (it > 1)
        {
            sn = 0.0;
            sd = 0.0;

            for (k=0; k<Ngrid; ++k)
            {
                rl0 = Vo[k]  - Vi[k];
                rl1 = Vo1[k] - Vi1[k];
                dr  = rl0 - rl1;
                sn = sn + rl0*dr*(rgrid[k]*rgrid[k]);
                sd = sd +  dr*dr*(rgrid[k]*rgrid[k]);
            }


            thl = sn/sd;

        }

        for (k=0; k<=Ngrid-1; k++)
        {

            vn = (1.0-0.5)*( (1.0-thl)*Vi[k] + thl*Vi1[k] )
                 + 0.5 *( (1.0-thl)*Vo[k] + thl*Vo1[k] );
            Vi1[k] = Vi[k];
            Vo1[k] = Vo[k];
            Vi[k]  = vn;

        }


    } /* end while */

    if (!converged)
    {
        printf("Not Converged\n");
        exit(1);
    }

    occupied_orbitals_done = True;
    paw_generate_density(rho);
    paw_set_kohn_sham_potential(rho);



    /* free up temporary memory */
    paw_dealloc_LogGrid(Vi);
    paw_dealloc_LogGrid(Vo1);
    paw_dealloc_LogGrid(Vi1);

}