Changeset 9bdd86


Ignore:
Timestamp:
Apr 22, 2008, 1:18:55 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
4f1369
Parents:
cc9c36
Message:

sawtooth() now takes array as second argument instead of double, index is third parameter anyway.

This is basically the step before changing to matrix transformations.

Location:
pcp/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pcp/src/perturbed.c

    rcc9c36 r9bdd86  
    999999        //else fprintf(stderr,"(%i) WCentre[%i] = %e \n",P->Par.me, index_r, Wcentre[index_r]);
    10001000        MinImageConv(Lat,x, Wcentre, X);
    1001         vector = sawtooth(Lat,X[index_r],index_r);
     1001        vector = sawtooth(Lat,X,index_r);
    10021002        //vector = 1.;//sin((double)(n[index_r])/(double)((N[index_r]))*2*PI);     
    10031003         PsiCR[iS] = vector * TempPsiR[i0];
     
    12721272        MinImageConv(Lat, x, Wcentre, X);
    12731273         PsiCR[iS] = //vector * TempPsiR[i0];
    1274           sawtooth(Lat,X[index[0]],index[0]) * TempPsiR [i0]
    1275          -sawtooth(Lat,X[index[2]],index[2]) * TempPsi2R[i0];
     1274          sawtooth(Lat,X,index[0]) * TempPsiR [i0]
     1275         -sawtooth(Lat,X,index[2]) * TempPsi2R[i0];
    12761276//          ShiftGaugeOrigin(P,X,index[0]) * TempPsiR [i0]
    12771277//         -ShiftGaugeOrigin(P,X,index[2]) * TempPsi2R[i0];
     
    16161616 * \param index component index for Lattice#RealBasisSQ
    16171617 */
    1618 inline double sawtooth(struct Lattice *Lat, double L, const int index)
     1618inline double sawtooth(struct Lattice *Lat, double L[NDIM], const int index)
    16191619{
    16201620  double axis = sqrt(Lat->RealBasisSQ[index]);
     
    16261626  //fprintf(stderr, "sawstart: %e\tsawend: %e\tsawfactor: %e\tL: %e\n", sawstart, sawend, sawfactor, L);
    16271627  // transform and return (sawtooth profile checked, 04.08.06)
    1628   L += axis/2.; // transform to 0 ... L
    1629   if (L < (sawstart*axis)) return (-axis/(2*sawfactor)*sin(L/(sawstart*axis)*PI/2.));  // first smooth transition from 0 ... -L/2
    1630   if (L > (sawend*axis)) return ( axis/(2*sawfactor)*cos((L-sawend*axis)/(sawstart*axis)*PI/2.));  // second smooth transition from +L/2 ... 0
     1628  L[index] += axis/2.; // transform to 0 ... L
     1629  if (L[index] < (sawstart*axis)) return (-axis/(2*sawfactor)*sin(L[index]/(sawstart*axis)*PI/2.));  // first smooth transition from 0 ... -L/2
     1630  if (L[index] > (sawend*axis)) return ( axis/(2*sawfactor)*cos((L[index]-sawend*axis)/(sawstart*axis)*PI/2.));  // second smooth transition from +L/2 ... 0
    16311631  //fprintf(stderr,"L %e\t sawstart %e\t sawend %e\t sawfactor %e\t axis%e\n", L, sawstart, sawend, sawfactor, axis);
    16321632  //return ((L - sawstart*axis) - axis/(2*sawfactor));  // area in between scale to -L/2 ... +L/2
    1633   return (L - axis/2);  // area in between return as it was
     1633  return (L[index] - axis/2);  // area in between return as it was
    16341634}
    16351635
     
    16631663      }
    16641664 
    1665   return(sawtooth(Lat,x[index],index));  // still use sawtooth due to the numerical instability around the border region of the cell
     1665  return(sawtooth(Lat,x,index));  // still use sawtooth due to the numerical instability around the border region of the cell
    16661666}
    16671667
     
    16871687    //fprintf(stderr,"(%i) x %e\t Axis/2 %e\n",P->Par.me, x, sqrt(Lat->RealBasisSQ[index])/2. );     
    16881688          MinImageConv(Lat, n, Lat->RealBasisCenter, x);
    1689         fprintf(stderr,"%e\t%e\n", n[index], sawtooth(Lat,n[index],index)); 
     1689        fprintf(stderr,"%e\t%e\n", n[index], sawtooth(Lat,n,index)); 
    16901690  }
    16911691}
     
    22652265                MinImageConv(Lat, x, Psi->AddData[k].WannierCentre, X);
    22662266                for (i=0;i<NDIM;i++) // build gauge-translated r_bar evaluation point
    2267                   r_bar[i] = sawtooth(Lat,X[i],i);
     2267                  r_bar[i] = sawtooth(Lat,X,i);
    22682268//                    ShiftGaugeOrigin(P,X,i);
    22692269                    //X[i];
  • pcp/src/perturbed.h

    rcc9c36 r9bdd86  
    4343void ReadSrcPerturbedPsis(struct Problem *P, enum PsiTypeTag type);
    4444inline double ShiftGaugeOrigin(struct Problem *P, double r[NDIM], const int index);
    45 inline double sawtooth(struct Lattice *Lat, const double L, const int index);
     45inline double sawtooth(struct Lattice *Lat, double L[NDIM], const int index);
    4646inline void MinImageConv(struct Lattice *Lat, const double R[NDIM], const double r[NDIM], double *result);
    4747void test_fft_symmetry(struct Problem *P, const int l);
Note: See TracChangeset for help on using the changeset viewer.