/*
    DFT++ is a density functional package developed by the research group
    of Professor Tomas Arias

    Copyright 1996-2003 Sohrab Ismail-Beigi

    This file is part of DFT++.

    DFT++ is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DFT++ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DFT++; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    Please see the file CREDITS for a list of authors.

    For academic users, we request that publications using results obtained with
    this software reference

    "New algebraic formulation of density functional calculation," by Sohrab Ismail-Beigi
    and T.A. Arias, Computer Physics Communications 128:1-2, 1-45 (June 2000).

    and, if using the wavelet basis, further reference

    "Multiresolution analysis of electronic structure: semicardinal and wavelet bases,"
    T.A. Arias, Reviews of Modern Physics 71:1, 267-311 (January 1999).

    and 

    "Robust ab initio calculation of condensed matter: transparent convergence through
    semicardinal multiresolution analysis,'' I.P. Daykov, T.A. Arias, and
    Torkel D. Engeness, Physical Review Letters, 90:21, 216402 (May 2003).

    For your convenience, preprints of the above articles may be obtained from
    http://arXiv.org/abs/cond-mat/9909130, 9805262, and 0204411, respectively.
*/

#ifndef PW_IONICPOTENTIAL_H
#define PW_IONICPOTENTIAL_H

#define DFT_MIT_PSP   1
#define DFT_FHI_PSP   2

class PW_IonicPotential
{
 public: 
  // For Pulay correction
  real dEperNatoms_dNGperVol; /* Derivative of total energy per number of
                                 atoms versus the number of planewaves
                                 per volume */

  char potfilename[DFT_MSG_LEN], pulayfilename[DFT_MSG_LEN];


  int potential_type;  // specify the type of potential: DFT_MIT_PSP  or DFT_FHI_PSP

  real Z; 

  /* local pseudopotential */
  int ngrid_loc;     /* number of points on the q-grid describing
                        the local pseudopotential */
  real dq_loc;       /* grid spacing */
  real *V_loc;       /* V[q]: the local pseudopotential in q space */
  /* nonlocal pseudopotentials: multiple-projector extension of
     Kleinman-Bylander */  
  int nlm;          /* number of (l,m) states */
  int *l,*m;        /* l and m values for each of the nlm states */
  int *ngamma;      /* Number of states for given (l,m) */
  ComplexMatrix *M; /* ngamma[lm]^2 sized matrix describing the potential */
  int **ngrid_nl;   /* ngrid[lm][gamma] is the q-grid size for flq which
                       describes the non-local potential */
  real **dq_nl;     /* grid spacing: dq[lm][gamma] */
  real ***flq;      /* flq[lm][gamma][] describes the non-local potential */
  

  /* projector information */
  int projectorp;              /* flag to indicate if we have projectors */
  int p_nl;                    /* numer of l states */
  int *p_l;                    /* l values for each projectors */
  int *p_np;                   /* number of projectors for a given l */
  int **p_ngrid_nl;            /* p_ngrid_nl[l][p] is the q-grid size */
  real **p_dq_nl;              /* grid spacing p_dq_nl[l][gamma] */
  real ***p_flq;               /* p_flq[l][p][] describes the projector
                                  in q space */

  /* The following is to support FHI type pseudopotential. */
  char fhi_max_l, fhi_loc_l;
  int fhi_ngrid_loc, fhi_ngrid_nl;
  real fhi_dq_loc, fhi_dq_nl;


  PW_IonicPotential();
  ~PW_IonicPotential();

  void read_dft_psp();
  void read_fhi_psp();
  void setup(Everything &e){
    // Read the pseudopot. files and setup pulay (if any)
    if (potential_type == DFT_FHI_PSP)
      read_fhi_psp();
    else
      read_dft_psp();
    setup_pulay(e);
  }

  void setup_pulay(Everything &everything);

};


#endif // PW_IONICPOTENTIAL_H


syntax highlighted by Code2HTML, v. 0.9.1