NAMD
ComputeEwald.h
Go to the documentation of this file.
1 
7 /*
8  Compute reciprocal space contribution to pressure profile using
9  Ewald sums.
10 */
11 
12 #ifndef COMPUTEEWALD_H
13 #define COMPUTEEWALD_H
14 
15 #include "ComputeHomePatches.h"
16 #include "NamdTypes.h"
17 #include "ComputeMgr.decl.h"
18 
19 class floatcomplex {
20 public:
21  float r, i;
23  floatcomplex(float c) : r(c), i(0) {}
24  floatcomplex(float a, float b) : r(a), i(b) {}
26 
27  // complex conjuate
28  floatcomplex star() const
29  {
30  return floatcomplex(r, -i);
31  }
32  // square modulus
33  float mod2() const
34  {
35  return r*r + i*i;
36  }
37  // scalar assignment
38  floatcomplex &operator=(const float &c)
39  {
40  r = c;
41  i = 0;
42  return *this;
43  }
44  // complex add
46  {
47  r += d.r;
48  i += d.i;
49  return *this;
50  }
51  // scalar multiply
52  floatcomplex &operator*=(const float &c)
53  {
54  r *= c;
55  i *= c;
56  return *this;
57  }
58  // complex multiply
60  {
61  float re = r*d.r - i*d.i;
62  float im = r*d.i + i*d.r;
63  r = re;
64  i = im;
65  return *this;
66  }
67 };
68 
69 class ComputeEwaldMsg : public CMessage_ComputeEwaldMsg {
70 public:
71  float *eik;
72 };
73 
74 class EwaldParticle;
75 class ComputeMgr;
76 class SubmitReduction;
77 
79 public:
81  virtual ~ComputeEwald();
82  void doWork();
83  void recvData(ComputeEwaldMsg *);
85 
86  int getMasterNode() const { return masterNode; }
87 
88 private:
89  ComputeMgr *comm;
90  SubmitReduction *reduction;
91  int masterNode;
92  int numWorkingPes;
93  int recvCount;
94 
95  // Cached copy of coordinates and charges
96  EwaldParticle *localAtoms;
97  int *localPartitions;
98  int numLocalAtoms;
99 
100  // pressure profile arrays
101  int pressureProfileSlabs;
102  int pressureProfileAtomTypes;
103  float pressureProfileMin, pressureProfileThickness;
104  float *pressureProfileData;
105 
106  // maximum k in x, y, z directions
107  int kxmax, kymax, kzmax;
108 
109  // number of k vectors is (kxmax+1) + (2*kymax+1) + (2*kzmax+1)
110  int ktot;
111 
112  // Ewald coefficient
113  float kappa;
114 
115  // summed eik
116  float *eiktotal;
117 
118  // space for temporary arrays
119  floatcomplex *eiky, *eikz;
120  float *expx, *expy, *expz;
121  float *Qk;
122 
123  // support for multiple atom types
124  // table of mappings from atom type to grid number. Table for atom
125  // of type i starts at offset n*i, where n=#of atom types.
126  int *gridsForAtomType;
127  int numAtomTypes;
128 
129 
130  // cache the Lattice in doWork.
131  Lattice lattice;
132 
133  // Store structure factor from localAtoms in given array
134  void compute_structurefactor(float *);
135 
136  // compute reciprocal space contribute to pressure using
137  // summation over local particles.
138  void computePprofile(const float *eik) const;
139 };
140 
141 #endif
142 
void recvData(ComputeEwaldMsg *)
Definition: ComputeEwald.C:187
void recvResults(ComputeEwaldMsg *)
Definition: ComputeEwald.C:204
int ComputeID
Definition: NamdTypes.h:183
ComputeEwald(ComputeID, ComputeMgr *)
Definition: ComputeEwald.C:51
floatcomplex & operator*=(const floatcomplex &d)
Definition: ComputeEwald.h:59
floatcomplex & operator*=(const float &c)
Definition: ComputeEwald.h:52
floatcomplex star() const
Definition: ComputeEwald.h:28
floatcomplex(float a, float b)
Definition: ComputeEwald.h:24
int getMasterNode() const
Definition: ComputeEwald.h:86
floatcomplex & operator+=(const floatcomplex &d)
Definition: ComputeEwald.h:45
floatcomplex(float c)
Definition: ComputeEwald.h:23
float mod2() const
Definition: ComputeEwald.h:33
virtual ~ComputeEwald()
Definition: ComputeEwald.C:97
floatcomplex & operator=(const float &c)
Definition: ComputeEwald.h:38