Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

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.

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 ADD_TENSOR_OBJECT, ADD_VECTOR_OBJECT, BigReal, CompAtom::charge, SimParameters::dt, SimParameters::eField, SimParameters::eFieldFreq, SimParameters::eFieldPhase, Results::f, Patch::flags, Force, SubmitReduction::item(), Patch::lattice, Node::Object(), Lattice::origin(), outer(), PI, Position, 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   Force *forces = r->f[Results::normal];
00043   BigReal energy = 0;
00044   Force extForce = 0.;
00045   Tensor extVirial;
00046 
00047   //  Loop through and check each atom
00048   for (int i=0; i<numAtoms; i++) {
00049     Force force = p[i].charge * eField1; 
00050     forces[i] += force;
00051     extForce += force;
00052     Position vpos = homePatch->lattice.reverse_transform(
00053                 p[i].position, p[i].transform );
00054     energy -= force * (vpos - homePatch->lattice.origin());
00055     extVirial += outer(force,vpos);
00056   }
00057 
00058   reduction->item(REDUCTION_MISC_ENERGY) += energy;
00059   ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce);
00060   ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial);
00061   reduction->submit();
00062 
00063 }


Member Data Documentation

SubmitReduction* ComputeEField::reduction
 

Definition at line 22 of file ComputeEField.h.

Referenced by ComputeEField(), and doForce().


The documentation for this class was generated from the following files:
Generated on Sat Sep 6 04:07:44 2008 for NAMD by  doxygen 1.3.9.1