OpenAtom  Version1.5a
AtomsCompute.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////=
2 ///////////////////////////////////////////////////////////////////////////c
3 ///////////////////////////////////////////////////////////////////////////=
4 /** \file AtomsCompute.h
5  */
6 ///////////////////////////////////////////////////////////////////////////=
7 #ifndef ATOMSCOMPUTE_H
8 #define ATOMSCOMPUTE_H
9 #include "Atoms.h"
10 
11 struct EnergyStruct;
12 
13 #include "Atoms.decl.h"
14 #include "atomMessages.h"
15 #include "CPcharmParaInfo.decl.h"
16 
17 
18 #include "uber/Uber.h"
19 ///////////////////////////////////////////////////////////////////////////=
20 ///////////////////////////////////////////////////////////////////////////c
21 ///////////////////////////////////////////////////////////////////////////=
22 
23 
24 /** \file AtomsCompute.h
25 
26  * \brief Accepts reduction of forces from AtomsCache,
27  * integrates forces to produce new coordinates,
28  * distributes new coordinates to AtomsCache.
29 
30  * If PIMD, then PIMD coordination is done before producing the
31  * updated coordinates.
32 
33  * If Tempers, then Temperature exchange is done before producing the
34  * updated coordinates.
35  * @addtogroup Atoms
36  * @{
37  */
38 ///////////////////////////////////////////////////////////////////////////=
40 ///////////////////////////////////////////////////////////////////////////=
41  public:
42  const UberCollection thisInstance;
43  /* inherited all the vars from the old AtomsGrp */
44  int natm;
45  int natm_nl;
46  int len_nhc;
47  int iextended_on;
48  int cp_min_opt;
49  int cp_wave_opt;
50  int *iteration;
51  int isokin_opt;
52  int countAtm;
53  int nAtomsPerChare;
54  int nChareAtoms;
55  int nAtmMsgRecv;
56  int PIBeadIndex;
57  int TemperIndex;
58  int numPIMDBeads;
59  unsigned int handleForcesCount;
60  double kT; // temperature
61  double pot_ewd_rs; // total real space ewald energy
62  double potPerdCorr;
63  double potPIMDChain; // Path integral chain energy :computed in u space
64  double vself, vbgr;
65  double eKinetic; // kinetic energy
66  double eKineticNhc; // NHC kinetic energy
67  double potNhc; // NHC potential energy
68  double **px;
69  double *ftot;
70  double tau,beta,omega2PIMD;
71  double *massPIMDScal; // veig of PINY : length numPIMDBeads
72  CkReductionMsg *contribMsg[2];
73  Atom *atoms;
74  AtomNHC *atomsNHC;
75  FastAtoms fastAtoms;
76  PIMD_CM PIMD_CM_Atoms;
77  CProxySection_AtomsCompute proxyHeadBeads;
78  CProxySection_AtomsCompute proxyAllBeads;
79  bool atomsCMrecv,atomsPIMDXrecv;
80  bool amBeadRoot, amZerothBead;
81  int acceptCountfu;
82  int acceptCountX;
83  int acceptCountu;
84 
85  int ktemps;
86  FILE *temperScreenFile;
87 
88  AtomsCompute(CkMigrateMessage *m) {}
89  AtomsCompute(int,int,int,int, int ,int ,int,double ,Atom *,AtomNHC *, int nChareAtoms, UberCollection thisInstance);
90  void init();
91  ~AtomsCompute();
92  void integrateAtoms();
93  void accept_PIMD_x(double _x, double _y, double _z, int atomI);
94  void accept_PIMD_Fu(double _fxu, double _fyu, double _fzu, int atomI);
95  void accept_PIMD_Fu_and_u(double _fxu, double _fyu, double _fzu, double _xu, double _yu, double _zu, int atomI);
96  void accept_PIMD_CM(AtomXYZMsg *m);
97  void accept_PIMD_u(double _ux, double _uy, double _uz, int atomI);
98  void acceptNewTemperature(double temp);
99  void recvContribute(CkReductionMsg *);
100  void recvContributeForces(CkReductionMsg *);
101  void atomsDone(CkReductionMsg *);
102  void send_PIMD_u();
103  void send_PIMD_Fx();
104  void send_PIMD_Fx_and_x();
105  void send_PIMD_x();
106  void sendAtoms(double,double ,double,double,int,int,int);
107  void acceptAtoms(AtomMsg *);
108  void outputAtmEnergy();
109  void bcastAtomsToAtomCache();
110  void startRealSpaceForces();
111  void releaseGSP();
112  void handleForces();
113 ///////////////////////////////////////////////////////////////////////////=
114  void zeroforces() {
115  double *fx = fastAtoms.fx;
116  double *fy = fastAtoms.fy;
117  double *fz = fastAtoms.fz;
118  for(int i=0; i<natm; i++){
119  atoms[i].fx = 0;
120  atoms[i].fy = 0;
121  atoms[i].fz = 0;
122  fx[i] = 0;
123  fy[i] = 0;
124  fz[i] = 0;
125  }//endfor
126  }//end routine
127 ///////////////////////////////////////////////////////////////////////////=
128  void zeronhc(){for(int i=0;i<natm;i++){atomsNHC[i].posKT = 0;}}
129 ///////////////////////////////////////////////////////////////////////////=
130  void copySlowToFast(){
131  double *x = fastAtoms.x;
132  double *y = fastAtoms.y;
133  double *z = fastAtoms.z;
134  double *fx = fastAtoms.fx;
135  double *fy = fastAtoms.fy;
136  double *fz = fastAtoms.fz;
137  for(int i=0;i<natm;i++){
138  x[i] = atoms[i].x;
139  y[i] = atoms[i].y;
140  z[i] = atoms[i].z;
141  fx[i] = atoms[i].fx;
142  fy[i] = atoms[i].fy;
143  fz[i] = atoms[i].fz;
144  }//endfor
145  }//end routine
146 ///////////////////////////////////////////////////////////////////////////=
147  void copyFastToSlow(){
148  double *x = fastAtoms.x;
149  double *y = fastAtoms.y;
150  double *z = fastAtoms.z;
151  double *fx = fastAtoms.fx;
152  double *fy = fastAtoms.fy;
153  double *fz = fastAtoms.fz;
154  for(int i=0;i<natm;i++){
155  atoms[i].x = x[i];
156  atoms[i].y = y[i];
157  atoms[i].z = z[i];
158  atoms[i].fx = fx[i];
159  atoms[i].fy = fy[i];
160  atoms[i].fz = fz[i];
161  }//endfor
162  }//end routine
163 ///////////////////////////////////////////////////////////////////////////=
164  void initPIMD(){
165  beta = 1.0/kT;
166  tau = beta/((double)numPIMDBeads);
167  omega2PIMD = 1.0/(tau*beta);
168  massPIMDScal[0] = 1.0; // vieg[0]=0; careful
169  for(int ip=2;ip<=numPIMDBeads;ip++){
170  massPIMDScal[(ip-1)] = ((double)(ip))/((double)(ip-1));
171  }//endfor
172  }//end routine
173 ///////////////////////////////////////////////////////////////////////////=
174  void switchPIMDBeadForceMass(int mybead, int natmStr, int natmEnd, double *pot){
175 #define _CHECK_PIMD_TRANSFORMS_OFF_
176 #ifdef _CHECK_PIMD_TRANSFORMS_
177  CkPrintf("switchPIMDBeadForceMass: I am bead %d strt dumping stuff\n",mybead);
178 #endif
179  for(int i=natmStr;i<natmEnd;i++){
180 #ifdef _CHECK_PIMD_TRANSFORMS_
181  CkPrintf("b=%d atm=%d : %g %g %g : %g %g %g : %g %g %g : %g %g %g\n",
182  mybead,i,
183  atoms[i].x,atoms[i].y,atoms[i].z,atoms[i].xu,atoms[i].yu,atoms[i].zu,
184  atoms[i].fx,atoms[i].fy,atoms[i].fz,atoms[i].fxu,atoms[i].fyu,atoms[i].fzu);
185 #endif
186  atoms[i].fx = atoms[i].fxu;
187  atoms[i].fy = atoms[i].fyu;
188  atoms[i].fz = atoms[i].fzu;
189  atoms[i].xold = atoms[i].x;
190  atoms[i].yold = atoms[i].y;
191  atoms[i].zold = atoms[i].z;
192  atoms[i].x = atoms[i].xu;
193  atoms[i].y = atoms[i].yu;
194  atoms[i].z = atoms[i].zu;
195  }//endfor
196 #ifdef _CHECK_PIMD_TRANSFORMS_
197  CkPrintf("switchPIMDBeadForceMass: I am bead %d end dumping stuff\n",mybead);
198 #endif
199  if(mybead>1){ // mybead goes from 1 to numPIMDBead
200  int mybead1 = mybead-1;
201  pot[0] = 0.0;
202  for(int i=natmStr;i<natmEnd;i++){
203  atoms[i].m *= massPIMDScal[mybead1];
204  atoms[i].fx -= omega2PIMD*atoms[i].m*atoms[i].x;
205  atoms[i].fy -= omega2PIMD*atoms[i].m*atoms[i].y;
206  atoms[i].fz -= omega2PIMD*atoms[i].m*atoms[i].z;
207  pot[0] += omega2PIMD*atoms[i].m*(
208  atoms[i].x*atoms[i].x
209  +atoms[i].y*atoms[i].y
210  +atoms[i].z*atoms[i].z);
211  }//endfor
212  pot[0] *= 0.5;
213  }//endif
214  }//end routine
215 ///////////////////////////////////////////////////////////////////////////=
216  void unswitchPIMDMass(int mybead, int natmStr, int natmEnd){
217  int mybead1 = mybead-1;
218  for(int i=natmStr;i<natmEnd;i++){
219  atoms[i].m /= massPIMDScal[mybead1]; // =1 for mybead=0
220  atoms[i].xu = atoms[i].x;
221  atoms[i].yu = atoms[i].y;
222  atoms[i].zu = atoms[i].z;
223  }//endfor
224  }//end routine
225 ///////////////////////////////////////////////////////////////////////////=
226 
227 ///////////////////////////////////////////////////////////////////////////=
228  }; //end class
229 ///////////////////////////////////////////////////////////////////////////=
230 /*@}*/
231 #endif // ATOMSCOMPUTE_H
void outputAtmEnergy()
= Atom energy output
Definition: AtomsCompute.C:658
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
void recvContributeForces(CkReductionMsg *)
recvContributeForces Every Array member has all the forces at present.
Definition: AtomsCompute.C:294
void accept_PIMD_Fu_and_u(double _fxu, double _fyu, double _fzu, double _xu, double _yu, double _zu, int atomI)
= is broadcast to us
void send_PIMD_u()
void send_PIMD_Fx_and_x()
Definition: AtomsCompute.C:736
void acceptAtoms(AtomMsg *)
Take packed message of a chunk of the atoms with updated positions.
Definition: AtomsCompute.C:896
void startRealSpaceForces()
trigger force computation based on real forces available in each processor's chare then contribute to...
Definition: AtomsCompute.C:602
void accept_PIMD_u(double _ux, double _uy, double _uz, int atomI)
= done during initialization in 1st iteration
void recvContribute(CkReductionMsg *)
recvContribute Every Array member is sent all the forces at present.
Definition: AtomsCompute.C:250
~AtomsCompute()
Destructor.
Definition: AtomsCompute.C:167
void integrateAtoms()
Integrate atoms.
Definition: AtomsCompute.C:420
Definition: Atoms.h:129
Definition: Atoms.h:20
void send_PIMD_x()
= done during initialization in 1st iteration
void sendAtoms(double, double, double, double, int, int, int)
This thing is sending its updated atoms to all elements.
Definition: AtomsCompute.C:780
Definition: Atoms.h:114
void accept_PIMD_Fu(double _fxu, double _fyu, double _fzu, int atomI)
= is broadcast to us
void handleForces()
Definition: AtomsCompute.C:317
void accept_PIMD_x(double _x, double _y, double _z, int atomI)
void init()
= Bead root is the 0th element.
Definition: AtomsCompute.C:197
void send_PIMD_Fx()
Definition: AtomsCompute.C:711
void bcastAtomsToAtomCache()
For dynamics we have to update all the caches with the new coordinates.
Definition: AtomsCompute.C:838