NAMD
Classes | Macros | Typedefs | Functions
ComputeMsmSerial.C File Reference
#include "InfoStream.h"
#include "Node.h"
#include "PatchMap.h"
#include "PatchMap.inl"
#include "AtomMap.h"
#include "ComputeMsmSerial.h"
#include "ComputeMsmSerialMgr.decl.h"
#include "PatchMgr.h"
#include "Molecule.h"
#include "ReductionMgr.h"
#include "ComputeMgr.h"
#include "ComputeMgr.decl.h"
#include "Debug.h"
#include "SimParameters.h"
#include "WorkDistrib.h"
#include "varsizemsg.h"
#include "msm.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "ComputeMsmSerialMgr.def.h"

Go to the source code of this file.

Classes

struct  ComputeMsmSerialAtom
 
class  MsmSerialCoordMsg
 
class  MsmSerialForceMsg
 
class  ComputeMsmSerialMgr
 

Macros

#define MIN_DEBUG_LEVEL   3
 

Typedefs

typedef Force MsmSerialForce
 

Functions

static void rescale_nonperiodic_cell (Vector &u, Vector &v, Vector &w, Vector &c, Vector &ru, Vector &rv, Vector &rw, int isperiodic, int numatoms, const ComputeMsmSerialAtom *coord, double padding, double gridspacing)
 

Macro Definition Documentation

◆ MIN_DEBUG_LEVEL

#define MIN_DEBUG_LEVEL   3

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 20 of file ComputeMsmSerial.C.

Typedef Documentation

◆ MsmSerialForce

Definition at line 37 of file ComputeMsmSerial.C.

Function Documentation

◆ rescale_nonperiodic_cell()

static void rescale_nonperiodic_cell ( Vector u,
Vector v,
Vector w,
Vector c,
Vector ru,
Vector rv,
Vector rw,
int  isperiodic,
int  numatoms,
const ComputeMsmSerialAtom coord,
double  padding,
double  gridspacing 
)
static

Definition at line 170 of file ComputeMsmSerial.C.

References NL_MSM_PERIODIC_VEC1, NL_MSM_PERIODIC_VEC2, NL_MSM_PERIODIC_VEC3, numatoms, ComputeMsmSerialAtom::position, Vector::rlength(), Vector::x, Vector::y, and Vector::z.

Referenced by ComputeMsmSerialMgr::recvCoord().

174  {
175  const double NL_ZERO_TOLERANCE = 1e-4;
176  double xlen = 1, inv_xlen = 1; /* don't rescale periodic directions */
177  double ylen = 1, inv_ylen = 1;
178  double zlen = 1, inv_zlen = 1;
179  double ulen_1 = u.rlength();
180  double vlen_1 = v.rlength();
181  double wlen_1 = w.rlength();
182  double rpadx = padding * ulen_1; /* padding distance in recip space */
183  double rpady = padding * vlen_1;
184  double rpadz = padding * wlen_1;
185  double rhx = gridspacing * ulen_1; /* grid spacing in recip space */
186  double rhy = gridspacing * vlen_1;
187  double rhz = gridspacing * wlen_1;
188  Vector s, d;
189  Vector rc = 0; // don't move center along periodic directions
190  double xmin, xmax, ymin, ymax, zmin, zmax;
191  int is_periodic_x = (isperiodic & NL_MSM_PERIODIC_VEC1);
192  int is_periodic_y = (isperiodic & NL_MSM_PERIODIC_VEC2);
193  int is_periodic_z = (isperiodic & NL_MSM_PERIODIC_VEC3);
194  int i;
195 
196  /* affine linear transformation of coordinates to reciprocal space,
197  * where periodic vector directions map into [-0.5, 0.5) */
198  //printf("*** center=%.4f %.4f %.4f\n", c.x, c.y, c.z);
199  d = coord[0].position - c;
200  s.x = ru * d; // dot product
201  s.y = rv * d;
202  s.z = rw * d;
203  xmin = xmax = s.x;
204  ymin = ymax = s.y;
205  zmin = zmax = s.z;
206  for (i = 1; i < numatoms; i++) {
207  d = coord[i].position - c;
208  s.x = ru * d; // dot product
209  s.y = rv * d;
210  s.z = rw * d;
211  if (s.x < xmin) xmin = s.x;
212  else if (s.x > xmax) xmax = s.x;
213  if (s.y < ymin) ymin = s.y;
214  else if (s.y > ymax) ymax = s.y;
215  if (s.z < zmin) zmin = s.z;
216  else if (s.z > zmax) zmax = s.z;
217  }
218 #if 0
219  printf("*** xmin=%.4f xmax=%.4f\n", xmin, xmax);
220  printf("*** ymin=%.4f ymax=%.4f\n", ymin, ymax);
221  printf("*** zmin=%.4f zmax=%.4f\n", zmin, zmax);
222 #endif
223 
224  if ( ! is_periodic_x) {
225  xmax += rpadx; /* pad the edges */
226  xmin -= rpadx;
227  if (rhx > 0) { /* restrict center to rhx lattice points */
228  double mupper = ceil(xmax / (2*rhx));
229  double mlower = floor(xmin / (2*rhx));
230  xmax = 2*rhx*mupper;
231  xmin = 2*rhx*mlower;
232  }
233  rc.x = 0.5*(xmin + xmax);
234  xlen = xmax - xmin;
235  if (xlen < NL_ZERO_TOLERANCE) {
236  xlen = 1; /* leave scaling unchanged */
237  }
238  else {
239  inv_xlen = 1/xlen;
240  }
241  }
242 
243  if ( ! is_periodic_y) {
244  ymax += rpady; /* pad the edges */
245  ymin -= rpady;
246  if (rhy > 0) { /* restrict center to rhy lattice points */
247  double mupper = ceil(ymax / (2*rhy));
248  double mlower = floor(ymin / (2*rhy));
249  ymax = 2*rhy*mupper;
250  ymin = 2*rhy*mlower;
251  }
252  rc.y = 0.5*(ymin + ymax);
253  ylen = ymax - ymin;
254  if (ylen < NL_ZERO_TOLERANCE) {
255  ylen = 1; /* leave scaling unchanged */
256  }
257  else {
258  inv_ylen = 1/ylen;
259  }
260  }
261 
262  if ( ! is_periodic_z) {
263  zmax += rpadz; /* pad the edges */
264  zmin -= rpadz;
265  if (rhz > 0) { /* restrict center to rhz lattice points */
266  double mupper = ceil(zmax / (2*rhz));
267  double mlower = floor(zmin / (2*rhz));
268  zmax = 2*rhz*mupper;
269  zmin = 2*rhz*mlower;
270  }
271  rc.z = 0.5*(zmin + zmax);
272  zlen = zmax - zmin;
273  if (zlen < NL_ZERO_TOLERANCE) {
274  zlen = 1; /* leave scaling unchanged */
275  }
276  else {
277  inv_zlen = 1/zlen;
278  }
279  }
280 
281 #if 0
282  printf("xmin=%g xmax=%g\n", xmin, xmax);
283  printf("ymin=%g ymax=%g\n", ymin, ymax);
284  printf("zmin=%g zmax=%g\n", zmin, zmax);
285  printf("xlen=%g ylen=%g zlen=%g\n", xlen, ylen, zlen);
286  printf("rc_x=%g rc_y=%g rc_z=%g\n", rc.x, rc.y, rc.z);
287 #endif
288 
289  /* transform new center back to real space, then rescale basis vectors */
290  c.x = (u.x*rc.x + v.x*rc.y + w.x*rc.z) + c.x;
291  c.y = (u.y*rc.x + v.y*rc.y + w.y*rc.z) + c.y;
292  c.z = (u.z*rc.x + v.z*rc.y + w.z*rc.z) + c.z;
293 
294 #if 0
295  printf("c_x=%g c_y=%g c_z=%g\n", c.x, c.y, c.z);
296 #endif
297 
298  u *= xlen;
299  v *= ylen;
300  w *= zlen;
301 
302  ru *= inv_xlen;
303  rv *= inv_ylen;
304  rw *= inv_zlen;
305 }
Definition: Vector.h:72
static int numatoms
Definition: ScriptTcl.C:65
BigReal z
Definition: Vector.h:74
BigReal x
Definition: Vector.h:74
BigReal y
Definition: Vector.h:74
NAMD_HOST_DEVICE BigReal rlength(void) const
Definition: Vector.h:210