Example #1
0
void String::Format (LPCTSTR  const pszFormat,...)
{
  va_list args;
  va_start(args, pszFormat);
  vFormat(pszFormat,args);
  va_end(args);
}
/** build a Local Pseudopotential
 *
 * For numerical stability, the radial function of the local pseudopotential is stored
 * as \f$rV(r)/Z_{eff}/Z_{e}\f$ for the distance r and \f$Z_e = -1\f$.
 * The coulomb factor $Z_{e}Z_{eff}/r$ is applied by LocalECPotential
 * (see LocalECPotential::evaluate).
 */
void ECPComponentBuilder::buildLocal(xmlNodePtr cur)
{
  if(pp_loc)
    return; //something is wrong
  string vFormat("V");
  const xmlChar* vptr=xmlGetProp(cur,(const xmlChar*)"format");
  if(vptr != NULL)
  {
    vFormat=(const char*)vptr;
  }
  int vPowerCorrection=1;
  if(vFormat == "r*V")
  {
    app_log() << "  Local pseudopotential format = r*V" << endl;
    vPowerCorrection=0;
  }
  else
  {
    app_log() << "  Local pseudopotential format = V" << endl;
  }
  typedef GaussianTimesRN<RealType> InFuncType;
  GridType* grid_local=0;
  InFuncType vr;
  bool bareCoulomb=true;
  cur=cur->children;
  while(cur != NULL)
  {
    string cname((const char*)cur->name);
    if(cname == "grid")
    {
      grid_local=createGrid(cur,true);
    }
    else
      if(cname == "basisGroup")
      {
        vr.putBasisGroup(cur,vPowerCorrection);
        bareCoulomb=false;
      }
      else
        if(cname == "data")
        {
          pp_loc=createVrWithData(cur,grid_local,vPowerCorrection);
          app_log() << "  Local pseduopotential in a <data/>" << endl;
          return;
        }
    cur=cur->next;
  }
  if(grid_local == 0)
  {
    if(grid_global == 0)
    {
      APP_ABORT("ECPComponentBuilder::buildLocal Missing grid information. ");
    }
    grid_local=grid_global;
  }
  if(grid_local->GridTag == CUSTOM_1DGRID)
  {
    APP_ABORT("ECPComponentBuilder::buildLocal Custom grid is used. Need to recast to the linear grid");
  }
  else
  {
    vector<RealType> v;
    if(bareCoulomb)
    {
      app_log() << "   Bare Coulomb potential is used." << endl;
      grid_local->set(0.0,1.,3);
      v.resize(3);
      for(int ig=0; ig<3; ig++)
        v[ig]=1.0;
      pp_loc=new RadialPotentialType(grid_local,v);
      pp_loc->spline(0,0.0,2,0.0);
    }
    else
    {
      app_log() << "   Guassian basisGroup is used: base power " << vr.basePower << endl;
      const RealType eps=1e-12;//numeric_limits<RealType>::epsilon();//1e-12;
      RealType zinv=1.0/Zeff;
      RealType r=10.;
      bool ignore=true;
      int last=grid_local->size()-1;
      while(ignore&&last)
      {
        r=(*grid_local)[last];
        ignore=(abs(zinv*vr.f(r))<eps);
        --last;
      }
      if(last ==0)
      {
        app_error() << "  Illegal Local Pseudopotential " <<endl;
      }
      //Add the reset values here
      int ng=static_cast<int>(r/1e-3)+1;
      app_log() << "     Use a Linear Grid: [0,"<< r << "] Number of points = " << ng << endl;
      grid_local->set(0.0,r,ng);
      v.resize(ng);
      for(int ig=1; ig<ng-1; ig++)
      {
        double r=(*grid_local)[ig];
        v[ig]=1.0-zinv*vr.f(r);
      }
      v[0]=2.0*v[1]-v[2];
      v[ng-1]=1.0;
      pp_loc=new RadialPotentialType(grid_local,v);
      pp_loc->spline(); //use the fixed conditions
    }
  }
}