# ComputeEwald.h

Go to the documentation of this file.
```00001
00007 /*
00008    Compute reciprocal space contribution to pressure profile using
00009    Ewald sums.
00010 */
00011
00012 #ifndef COMPUTEEWALD_H
00013 #define COMPUTEEWALD_H
00014
00015 #include "ComputeHomePatches.h"
00016 #include "NamdTypes.h"
00017 #include "ComputeMgr.decl.h"
00018
00019 class floatcomplex {
00020 public:
00021   float r, i;
00022   floatcomplex() {}
00023   floatcomplex(float c) : r(c), i(0) {}
00024   floatcomplex(float a, float b) : r(a), i(b) {}
00025   ~floatcomplex() {}
00026
00027   // complex conjuate
00028   floatcomplex star() const
00029   {
00030     return floatcomplex(r, -i);
00031   }
00032   // square modulus
00033   float mod2() const
00034   {
00035     return r*r + i*i;
00036   }
00037   // scalar assignment
00038   floatcomplex &operator=(const float &c)
00039   {
00040     r = c;
00041     i = 0;
00042     return *this;
00043   }
00045   floatcomplex &operator+=(const floatcomplex &d)
00046   {
00047     r += d.r;
00048     i += d.i;
00049     return *this;
00050   }
00051   // scalar multiply
00052   floatcomplex &operator*=(const float &c)
00053   {
00054     r *= c;
00055     i *= c;
00056     return *this;
00057   }
00058   // complex multiply
00059   floatcomplex &operator*=(const floatcomplex &d)
00060   {
00061     float re = r*d.r - i*d.i;
00062     float im = r*d.i + i*d.r;
00063     r = re;
00064     i = im;
00065     return *this;
00066   }
00067 };
00068
00069 class ComputeEwaldMsg : public CMessage_ComputeEwaldMsg {
00070 public:
00071   float *eik;
00072 };
00073
00074 class EwaldParticle;
00075 class ComputeMgr;
00076 class SubmitReduction;
00077
00078 class ComputeEwald : public ComputeHomePatches {
00079 public:
00080   ComputeEwald(ComputeID, ComputeMgr*);
00081   virtual ~ComputeEwald();
00082   void doWork();
00083   void recvData(ComputeEwaldMsg *);
00084   void recvResults(ComputeEwaldMsg *);
00085
00086   int getMasterNode() const { return masterNode; }
00087
00088 private:
00089   ComputeMgr *comm;
00090   SubmitReduction *reduction;
00091   int masterNode;
00092   int numWorkingPes;
00093   int recvCount;
00094
00095   // Cached copy of coordinates and charges
00096   EwaldParticle *localAtoms;
00097   int *localPartitions;
00098   int numLocalAtoms;
00099
00100   // pressure profile arrays
00101   int pressureProfileSlabs;
00102   int pressureProfileAtomTypes;
00103   float pressureProfileMin, pressureProfileThickness;
00104   float *pressureProfileData;
00105
00106   // maximum k in x, y, z directions
00107   int kxmax, kymax, kzmax;
00108
00109   // number of k vectors is (kxmax+1) + (2*kymax+1) + (2*kzmax+1)
00110   int ktot;
00111
00112   // Ewald coefficient
00113   float kappa;
00114
00115   // summed eik
00116   float *eiktotal;
00117
00118   // space for temporary arrays
00119   floatcomplex *eiky, *eikz;
00120   float *expx, *expy, *expz;
00121   float *Qk;
00122
00123   // support for multiple atom types
00124   // table of mappings from atom type to grid number.  Table for atom
00125   // of type i starts at offset n*i, where n=#of atom types.
00126   int *gridsForAtomType;
00127   int numAtomTypes;
00128
00129
00130   // cache the Lattice in doWork.
00131   Lattice lattice;
00132
00133   // Store structure factor from localAtoms in given array
00134   void compute_structurefactor(float *);
00135
00136   // compute reciprocal space contribute to pressure using
00137   // summation over local particles.
00138   void computePprofile(const float *eik) const;
00139 };
00140
00141 #endif
00142
```

Generated on Fri May 25 01:17:11 2018 for NAMD by  1.4.7