Changeset b924cd for pcp


Ignore:
Timestamp:
Apr 22, 2008, 12:07:53 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
986488
Parents:
60a9f9
Message:

CalculateChemicalShieldingByReciprocalCurrentDensity(): Linear interpolation to core position R shifted to function LinearInterpolationBetweenGrid()

new function LinearInterpolationBetweenGrid() which does the linear interpolation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/perturbed.c

    r60a9f9 rb924cd  
    30583058  fftw_real *sigma_real[NDIM_NDIM];
    30593059  double sigma,Sigma;
    3060   double x[2][NDIM];
    30613060  int it, ion, in, dex, g, Index, i;
    30623061  int *N = Lev0->Plan0.plan->N;
    30633062  //const double FFTfactor = 1.;///Lev0->MaxN;
    3064   int n[2][NDIM];
    3065   double eta, delta_sigma, S, A, iso, tmp;
     3063  double eta, delta_sigma, S, A, iso;
    30663064  FILE *SigmaFile;
    30673065  char suffixsigma[255];
    3068   const int myPE = P->Par.me_comm_ST_Psi;
    30693066  int cross_lookup[4]; // cross lookup table
    3070   const int N0 = Lev0->Plan0.plan->local_nx;
    30713067  const double factorDC = R->FactorDensityC;
    30723068  gsl_matrix_complex *H = gsl_matrix_complex_calloc(NDIM,NDIM);
     
    31443140        for (ion=0; ion < I->I[it].Max_IonsOfType; ion++) { // and each ion of type
    31453141          // read transformed sigma at core position and MPI_Allreduce
    3146           for (g=0;g<NDIM;g++) {
    3147             n[0][g] = floor(I->I[it].R[NDIM*ion+g]/sqrt(Lat->RealBasisSQ[g])*(double)N[g]);
    3148             n[1][g] = ceil(I->I[it].R[NDIM*ion+g]/sqrt(Lat->RealBasisSQ[g])*(double)N[g]);
    3149             x[1][g] = I->I[it].R[NDIM*ion+g]/sqrt(Lat->RealBasisSQ[g])*(double)N[g] - (double)n[0][g];
    3150             x[0][g] = 1. - x[1][g];
    3151             //fprintf(stderr,"(%i) n_floor[%i] = %i\tn_ceil[%i] = %i --- x_floor[%i] = %e\tx_ceil[%i] = %e\n",P->Par.me, g,n[0][g], g,n[1][g], g,x[0][g], g,x[1][g]);
    3152           }
    3153           sigma = 0.;
    3154           for (i=0;i<2;i++) { // interpolate linearly between adjacent grid points per axis
    3155             if ((n[i][0] >= N0*myPE) && (n[i][0] < N0*(myPE+1))) {
    3156 //              fprintf(stderr,"(%i) field[%i]: sigma = %e\n", P->Par.me,  n[i][2]+N[2]*(n[i][1]+N[1]*(n[i][0]-N0*myPE)), sigma);
    3157               sigma += (x[i][0]*x[0][1]*x[0][2])*sigma_real[in+dex*NDIM][n[0][2]+N[2]*(n[0][1]+N[1]*(n[i][0]-N0*myPE))]*mu0; // if it's local and factor from inverse fft
    3158               //fprintf(stderr,"(%i) field[%i]: sigma += %e * %e \n", P->Par.me,  n[i][2]+N[2]*(n[i][1]+N[1]*(n[i][0]-N0*myPE)), (x[i][0]*x[0][1]*x[0][2]), field[n[0][2]+N[2]*(n[0][1]+N[1]*(n[i][0]-N0*myPE))]*mu0);
    3159               sigma += (x[i][0]*x[0][1]*x[1][2])*sigma_real[in+dex*NDIM][n[1][2]+N[2]*(n[0][1]+N[1]*(n[i][0]-N0*myPE))]*mu0; // if it's local and factor from inverse fft
    3160               //fprintf(stderr,"(%i) field[%i]: sigma += %e * %e \n", P->Par.me,  n[i][2]+N[2]*(n[i][1]+N[1]*(n[i][0]-N0*myPE)), (x[i][0]*x[0][1]*x[1][2]), field[n[1][2]+N[2]*(n[0][1]+N[1]*(n[i][0]-N0*myPE))]*mu0);
    3161               sigma += (x[i][0]*x[1][1]*x[0][2])*sigma_real[in+dex*NDIM][n[0][2]+N[2]*(n[1][1]+N[1]*(n[i][0]-N0*myPE))]*mu0; // if it's local and factor from inverse fft
    3162               //fprintf(stderr,"(%i) field[%i]: sigma += %e * %e \n", P->Par.me,  n[i][2]+N[2]*(n[i][1]+N[1]*(n[i][0]-N0*myPE)), (x[i][0]*x[1][1]*x[0][2]), field[n[0][2]+N[2]*(n[1][1]+N[1]*(n[i][0]-N0*myPE))]*mu0);
    3163               sigma += (x[i][0]*x[1][1]*x[1][2])*sigma_real[in+dex*NDIM][n[1][2]+N[2]*(n[1][1]+N[1]*(n[i][0]-N0*myPE))]*mu0; // if it's local and factor from inverse fft
    3164               //fprintf(stderr,"(%i) field[%i]: sigma += %e * %e \n", P->Par.me,  n[i][2]+N[2]*(n[i][1]+N[1]*(n[i][0]-N0*myPE)), (x[i][0]*x[1][1]*x[1][2]), field[n[1][2]+N[2]*(n[1][1]+N[1]*(n[i][0]-N0*myPE))]*mu0);
    3165             }
    3166           }
    3167           sigma *= -R->FactorDensityR; // factor from inverse fft? (and its defined as negative proportionaly factor)
     3142          sigma = -LinearInterpolationBetweenGrid(P, Lat, Lev0, &I->I[it].R[NDIM*ion], sigma_real[in+dex*NDIM]) * R->FactorDensityR; // factor from inverse fft
     3143
    31683144          MPI_Allreduce ( &sigma, &Sigma, 1, MPI_DOUBLE, MPI_SUM, P->Par.comm_ST_Psi);  // sum local to total
    31693145          I->I[it].sigma_rezi[ion][in+dex*NDIM] = Sigma;
Note: See TracChangeset for help on using the changeset viewer.