Example #1
0
/****************************************
 Function name	  : paw_find_word
 Description	    : gives the location of the word
                    in the file;
                    if successfull returns 0 and places
                    the file pointer right after the word;
                    if fails returns 1
 Return type		  : int
 Argument         : char* my_word
 Argument         : FILE *fp
 Author     		  : Marat Valiev
 Date & Time		  : 1/7/99 3:58:25 PM
****************************************/
int paw_find_word(char* my_word, FILE *fp)
{

    char *w;

    rewind(fp);
    w = paw_get_word(fp);
    if (strcmp(my_word,w)!=0)
    {
        rewind(fp);
        w = paw_get_word(fp);
        while ((w!=NIL) && (strcmp(my_word,w)!=0))
            w = paw_get_word(fp);
    }


    if (w==NIL)
    {
        if (paw_debug()) printf("warning: %s section not found\n",my_word);
        return 1;
    }
    else
    {
        return 0;
    }

}
Example #2
0
/****************************************
 Function name	  : paw_init_orbitals
 Description	    :
 Return type		  : void
 Argument         : FILE *fp
 Author     		  : Marat Valiev
 Date & Time		  : 3/30/99 11:47:04 PM
****************************************/
void paw_init_orbitals_from_file(FILE *fp)
{
    int     i;
    char   input[20];
    char *w;

    rewind(fp);

    strcpy(input,"<orbitals>");
    if (paw_find_word(input,fp) != 0)
    {
        printf("orbital section not found\n");
        printf("Aborting the program\n");
        exit(1);
    }
    else
    {
        /* read number of core, valence and virtual orbitals */
        fscanf(fp,"%d %d %d",&Nvalence,&Nvirt,&Nscat);

        Nbound   = Nvalence+Nvirt;
        Ntotal   = Nvalence+Nvirt+Nscat;

        /* set orbital indexes arrays */
        n          = (int *) malloc(Ntotal*sizeof(int));
        l          = (int *) malloc(Ntotal*sizeof(int));
        orb_type   = (int *) malloc(Ntotal*sizeof(int));
        fill       = (double *) malloc(Ntotal*sizeof(double));
        eigenvalue = (double *) malloc(Ntotal*sizeof(double));


        /*read orbital indexes arrays*/
        for (i=0; i<Nbound; ++i)
            fscanf(fp,"%d %d %lf",&n[i],&l[i],&fill[i]);

        for (i=Nbound; i<Ntotal; ++i)
            fscanf(fp,"%d %d %lf %lf",&n[i],&l[i],&fill[i],&eigenvalue[i]);

    }

    /*allocating additional memory*/
    psi       = (double **) malloc(Ntotal*sizeof(double*));
    psi_prime = (double **) malloc(Ntotal*sizeof(double*));
    for (i=0; i<Ntotal; i++)
    {
        psi[i]       = paw_alloc_LogGrid();
        psi_prime[i] = paw_alloc_LogGrid();
    }

    rho     = paw_alloc_LogGrid();

    psi_tmp   = paw_alloc_LogGrid();

    for (i=0; i<= Nvalence-1; i++)
        orb_type[i] = bound;

    for (i=Nvalence; i<= Nbound-1; i++)
        orb_type[i] = virt;

    for (i=Nbound; i<= Nbound+Nscat-1; i++)
        orb_type[i] = scattering;

    rewind(fp);
    if (paw_find_word("<solver>",fp) == 0)
    {
      w = paw_get_word(fp);
      if (strcmp ("schrodinger", w) == 0)
        Solver_Type = Schrodinger;
      if (strcmp ("pauli", w) == 0)
        Solver_Type = Pauli;
      if (strcmp ("dirac", w) == 0)
        Solver_Type = Dirac;
      if (strcmp ("zora", w) == 0)
        Solver_Type = ZORA;
    }
    else
        Solver_Type = Pauli;
}