ComputeEField Class Reference

#include <ComputeEField.h>

Inheritance diagram for ComputeEField:

ComputeHomePatch Compute List of all members.

Public Member Functions

 ComputeEField (ComputeID c, PatchID pid)
virtual ~ComputeEField ()
virtual void doForce (FullAtom *p, Results *r)

Public Attributes

SubmitReductionreduction

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().

00015   : ComputeHomePatch(c,pid)
00016 {
00017 
00018         reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00019 
00020 }

ComputeEField::~ComputeEField (  )  [virtual]

Definition at line 24 of file ComputeEField.C.

References reduction.

00026 {
00027         delete reduction;
00028 }


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(), 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_EXT_FORCE_NORMAL, REDUCTION_MISC_ENERGY, REDUCTION_VIRIAL_NORMAL, Lattice::reverse_transform(), Node::simParameters, simParams, Flags::step, SubmitReduction::submit(), and TWOPI.

00032                                                    {
00033 
00034   SimParameters *simParams = Node::Object()->simParameters;
00035   Vector eField = simParams->eField;
00036   // Calculate the angular frequency in 1/fs.
00037   BigReal omega = TWOPI * simParams->eFieldFreq / 1000.;
00038   BigReal phi = PI/180.* simParams->eFieldPhase;
00039   BigReal t = patch->flags.step * simParams->dt;
00040   Vector eField1 = cos(omega * t - phi) * eField;
00041 
00042   const int normalized = simParams->eFieldNormalized;
00043   if ( normalized ) {
00044     Lattice &l = homePatch->lattice;
00045     eField1 = Vector(l.a_r()*eField1, l.b_r()*eField1, l.c_r()*eField1);
00046   }
00047 
00048   Force *forces = r->f[Results::normal];
00049   BigReal energy = 0;
00050   Force extForce = 0.;
00051   Tensor extVirial;
00052 
00053   //  Loop through and check each atom
00054   for (int i=0; i<numAtoms; i++) {
00055     Force force = p[i].charge * eField1; 
00056     forces[i] += force;
00057     Position vpos = homePatch->lattice.reverse_transform(
00058                 p[i].position, p[i].transform );
00059     energy -= force * (vpos - homePatch->lattice.origin());
00060     if ( ! normalized ) {
00061       extForce += force;
00062       extVirial += outer(force,vpos);
00063     }
00064   }
00065 
00066   reduction->item(REDUCTION_MISC_ENERGY) += energy;
00067   if ( ! normalized ) {
00068     ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce);
00069     ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial);
00070   }
00071   reduction->submit();
00072 
00073 }


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:
Generated on Sat Sep 23 01:17:18 2017 for NAMD by  doxygen 1.4.7