NAMD
Public Member Functions | Public Attributes | List of all members
ComputeEField Class Reference

#include <ComputeEField.h>

Inheritance diagram for ComputeEField:
ComputeHomePatch Compute

Public Member Functions

 ComputeEField (ComputeID c, PatchID pid)
 
virtual ~ComputeEField ()
 
virtual void doForce (FullAtom *p, Results *r)
 
- Public Member Functions inherited from ComputeHomePatch
 ComputeHomePatch (ComputeID c, PatchID pid)
 
virtual ~ComputeHomePatch ()
 
virtual void initialize ()
 
virtual void atomUpdate ()
 
virtual void doWork ()
 
- Public Member Functions inherited from Compute
 Compute (ComputeID)
 
int type ()
 
virtual ~Compute ()
 
void setNumPatches (int n)
 
int getNumPatches ()
 
virtual void patchReady (PatchID, int doneMigration, int seq)
 
virtual int noWork ()
 
virtual void finishPatch (int)
 
int sequence (void)
 
int priority (void)
 
int getGBISPhase (void)
 
virtual void gbisP2PatchReady (PatchID, int seq)
 
virtual void gbisP3PatchReady (PatchID, int seq)
 

Public Attributes

SubmitReductionreduction
 
- Public Attributes inherited from Compute
const ComputeID cid
 
LDObjHandle ldObjHandle
 
LocalWorkMsg *const localWorkMsg
 

Additional Inherited Members

- Protected Member Functions inherited from Compute
void enqueueWork ()
 
- Protected Attributes inherited from ComputeHomePatch
int numAtoms
 
Patchpatch
 
HomePatchhomePatch
 
- Protected Attributes inherited from Compute
int computeType
 
int basePriority
 
int gbisPhase
 
int gbisPhasePriority [3]
 

Detailed Description

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

Definition at line 13 of file ComputeEField.h.

Constructor & Destructor Documentation

ComputeEField::ComputeEField ( ComputeID  c,
PatchID  pid 
)

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

Definition at line 14 of file ComputeEField.C.

References ReductionMgr::Object(), reduction, REDUCTIONS_BASIC, and ReductionMgr::willSubmit().

15  : ComputeHomePatch(c,pid)
16 {
17 
19 
20 }
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
SubmitReduction * reduction
Definition: ComputeEField.h:22
ComputeHomePatch(ComputeID c, PatchID pid)
ComputeEField::~ComputeEField ( )
virtual

Definition at line 24 of file ComputeEField.C.

References reduction.

26 {
27  delete reduction;
28 }
SubmitReduction * reduction
Definition: ComputeEField.h:22

Member Function Documentation

void ComputeEField::doForce ( FullAtom p,
Results r 
)
virtual

Implements ComputeHomePatch.

Definition at line 32 of file ComputeEField.C.

References Lattice::a_r(), ADD_TENSOR_OBJECT, ADD_VECTOR_OBJECT, Lattice::b_r(), Lattice::c_r(), CompAtom::charge, SimParameters::dt, SimParameters::eField, SimParameters::eFieldFreq, SimParameters::eFieldNormalized, SimParameters::eFieldPhase, Results::f, Patch::flags, forces, ComputeHomePatch::homePatch, SubmitReduction::item(), Patch::lattice, Results::normal, ComputeHomePatch::numAtoms, Node::Object(), Lattice::origin(), outer(), ComputeHomePatch::patch, PI, reduction, REDUCTION_MISC_ENERGY, Lattice::reverse_transform(), Node::simParameters, simParams, Flags::step, SubmitReduction::submit(), and TWOPI.

32  {
33 
35  Vector eField = simParams->eField;
36  // Calculate the angular frequency in 1/fs.
37  BigReal omega = TWOPI * simParams->eFieldFreq / 1000.;
38  BigReal phi = PI/180.* simParams->eFieldPhase;
39  BigReal t = patch->flags.step * simParams->dt;
40  Vector eField1 = cos(omega * t - phi) * eField;
41 
42  const int normalized = simParams->eFieldNormalized;
43  if ( normalized ) {
45  eField1 = Vector(l.a_r()*eField1, l.b_r()*eField1, l.c_r()*eField1);
46  }
47 
49  BigReal energy = 0;
50  Force extForce = 0.;
51  Tensor extVirial;
52 
53  // Loop through and check each atom
54  for (int i=0; i<numAtoms; i++) {
55  Force force = p[i].charge * eField1;
56  forces[i] += force;
58  p[i].position, p[i].transform );
59  energy -= force * (vpos - homePatch->lattice.origin());
60  if ( ! normalized ) {
61  extForce += force;
62  extVirial += outer(force,vpos);
63  }
64  }
65 
67  if ( ! normalized ) {
68  ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce);
69  ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial);
70  }
71  reduction->submit();
72 
73 }
static Node * Object()
Definition: Node.h:86
Vector a_r() const
Definition: Lattice.h:268
Lattice & lattice
Definition: Patch.h:126
Definition: Vector.h:64
BigReal eFieldFreq
#define ADD_TENSOR_OBJECT(R, RL, D)
Definition: ReductionMgr.h:43
SimParameters * simParameters
Definition: Node.h:178
Vector c_r() const
Definition: Lattice.h:270
static __thread float4 * forces
BigReal & item(int i)
Definition: ReductionMgr.h:312
Vector origin() const
Definition: Lattice.h:262
Vector b_r() const
Definition: Lattice.h:269
Flags flags
Definition: Patch.h:127
BigReal eFieldPhase
Charge charge
Definition: NamdTypes.h:54
#define PI
Definition: common.h:81
Force * f[maxNumForces]
Definition: PatchTypes.h:67
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
#define TWOPI
Definition: common.h:85
#define simParams
Definition: Output.C:127
SubmitReduction * reduction
Definition: ComputeEField.h:22
Position reverse_transform(Position data, const Transform &t) const
Definition: Lattice.h:138
Definition: Tensor.h:15
#define ADD_VECTOR_OBJECT(R, RL, D)
Definition: ReductionMgr.h:27
void submit(void)
Definition: ReductionMgr.h:323
HomePatch * homePatch
double BigReal
Definition: common.h:112
int step
Definition: PatchTypes.h:16

Member Data Documentation

SubmitReduction* ComputeEField::reduction

Definition at line 22 of file ComputeEField.h.

Referenced by ComputeEField(), doForce(), and ~ComputeEField().


The documentation for this class was generated from the following files: