Changeset f72dc1 for pcp/src


Ignore:
Timestamp:
Apr 22, 2008, 9:02:23 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
0f2c43
Parents:
ce81a3a
Message:

CalculateIonLocalForce(): added XC force

Force from XC potential was missing so far, is now included if ion's are CoreCorrected. In order to do that CalculateXCPotentialNoRT() has to be called beforehand.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/pseudo.c

    rce81a3a rf72dc1  
    10681068}
    10691069
    1070 /** Calculates the local force acting on ion.
     1070/** Calculates the local force acting on each ion.
    10711071 * \param *P Problem at hand
    10721072 */
     
    10801080  struct RunStruct *R = &P->R;
    10811081  struct LatticeLevel *Lev0 = R->Lev0;
     1082  struct LatticeLevel *LevS = R->LevS;
    10821083  struct Density *Dens = Lev0->Dens;
     1084  struct  fft_plan_3d *plan = L->plan;
     1085  fftw_complex *work = Dens->DensityCArray[TempDensity];
     1086  fftw_complex *HGC = Dens->DensityCArray[HGDensity];
     1087  fftw_real *HGCR = (fftw_real *)HGC;
    10831088  double ForceFac = L->Volume;
    10841089  double force, *dsum;
    10851090  fftw_complex cv;
     1091 
     1092  // precalc V_XC(r) and fft
     1093  //debug(P,"precalc V_XC\n");
     1094  SetArrayToDouble0((double *)HGCR, Dens->TotalSize*2);
     1095  CalculateXCPotentialNoRT(P, HGCR);
     1096  fft_3d_real_to_complex(plan, LevS->LevelNo, FFTNF1, HGC, work);
     1097  //debug(P,"precalc V_XC finished\n");
    10861098  for (is=0; is < I->Max_Types; is++) {
    10871099    SetArrayToDouble0(I->FTemp, NDIM*I->I[is].Max_IonsOfType);
     
    10961108                c_re(cv) = c_re(PP->VCoulombc[g2])*PP->FacGauss[is][g2]+PP->phi_ps_loc[is][g2]*c_re(Dens->DensityCArray[TotalDensity][Index])*R->HGcFactor;
    10971109                c_im(cv) = c_im(PP->VCoulombc[g2])*PP->FacGauss[is][g2]-PP->phi_ps_loc[is][g2]*c_im(Dens->DensityCArray[TotalDensity][Index])*R->HGcFactor;
     1110        if (I->I[is].corecorr == CoreCorrected) {
     1111          // this summand was missing before, is not thoroughly tested
     1112          //debug(P,"V_XC summand in CalculateIonLocalForce()\n");
     1113          c_re(cv) +=  (PP->formfCore[is][g2]*c_re(HGC[Index]))*R->HGcFactor;
     1114          c_im(cv) += -(PP->formfCore[is][g2]*c_im(HGC[Index]))*R->HGcFactor;
     1115          //fprintf(stderr, "(%i) FormfCore %lg\tHGC %lg+i%lg\n",P->Par.me, PP->formfCore[is][g2],c_re(HGC[Index]),c_im(HGC[Index]));
     1116        }
    10981117                force = c_re(PP->ei[is][ia][g2])*c_im(cv)+c_im(PP->ei[is][ia][g2])*c_re(cv);
    1099                 dsum[0] += 2.*(-G[0]*force);
    1100                 dsum[1] += 2.*(-G[1]*force);
    1101                 dsum[2] += 2.*(-G[2]*force);
     1118                dsum[0] += 2.*(-G[0]*force); //2.* ... why? Nowhere from derivative!
     1119                dsum[1] += 2.*(-G[1]*force); //2.*
     1120                dsum[2] += 2.*(-G[2]*force); //2.*
    11021121      }
    11031122    }
     
    11051124    for (ia=0;ia< I->I[is].Max_IonsOfType; ia++)
    11061125      for (i=0; i<NDIM; i++)
    1107                 I->I[is].FIonL[i+NDIM*ia] *= ForceFac;
     1126                                I->I[is].FIonL[i+NDIM*ia] *= ForceFac;
    11081127  }
    11091128}
Note: See TracChangeset for help on using the changeset viewer.