ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/Atom.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/primitives/Atom.cpp (file contents):
Revision 1492 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC

# Line 1 | Line 1
1 < #include <iostream>
2 <
3 < using namespace std;
4 <
5 < #include "utils/simError.h"
1 > /*
2 > * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 > *
4 > * The University of Notre Dame grants you ("Licensee") a
5 > * non-exclusive, royalty free, license to use, modify and
6 > * redistribute this software in source and binary code form, provided
7 > * that the following conditions are met:
8 > *
9 > * 1. Acknowledgement of the program authors must be made in any
10 > *    publication of scientific results based in part on use of the
11 > *    program.  An acceptable form of acknowledgement is citation of
12 > *    the article in which the program was described (Matthew
13 > *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 > *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 > *    Parallel Simulation Engine for Molecular Dynamics,"
16 > *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 > *
18 > * 2. Redistributions of source code must retain the above copyright
19 > *    notice, this list of conditions and the following disclaimer.
20 > *
21 > * 3. Redistributions in binary form must reproduce the above copyright
22 > *    notice, this list of conditions and the following disclaimer in the
23 > *    documentation and/or other materials provided with the
24 > *    distribution.
25 > *
26 > * This software is provided "AS IS," without a warranty of any
27 > * kind. All express or implied conditions, representations and
28 > * warranties, including any implied warranty of merchantability,
29 > * fitness for a particular purpose or non-infringement, are hereby
30 > * excluded.  The University of Notre Dame and its licensors shall not
31 > * be liable for any damages suffered by licensee as a result of
32 > * using, modifying or distributing the software or its
33 > * derivatives. In no event will the University of Notre Dame or its
34 > * licensors be liable for any lost revenue, profit or data, or for
35 > * direct, indirect, special, consequential, incidental or punitive
36 > * damages, however caused and regardless of the theory of liability,
37 > * arising out of the use of or inability to use software, even if the
38 > * University of Notre Dame has been advised of the possibility of
39 > * such damages.
40 > */
41 >
42   #include "primitives/Atom.hpp"
43 + namespace oopse {
44  
45 < Atom::Atom(int theIndex, SimState* theConfig) {
46 <
10 <  objType = OT_ATOM;
11 <  myConfig = theConfig;
12 <  hasCoords = false;
13 <
14 <  has_dipole = 0;
15 <  has_charge = 0;
16 <  
17 <  index = theIndex;
18 <  offset = 0;
19 <  offsetX = offset;
20 <  offsetY = offset+1;
21 <  offsetZ = offset+2;
22 <  
23 <  Axx = 0;
24 <  Axy = Axx+1;
25 <  Axz = Axx+2;
26 <  
27 <  Ayx = Axx+3;
28 <  Ayy = Axx+4;
29 <  Ayz = Axx+5;
30 <  
31 <  Azx = Axx+6;
32 <  Azy = Axx+7;
33 <  Azz = Axx+8;
45 > Atom::Atom(AtomType* at) : StuntDouble(otAtom, &Snapshot::atomData) ,atomType_(at) {
46 > mass_ = at->getMass();
47   }
48  
49 < void Atom::setIndex(int theIndex) {
50 <  index = theIndex;
51 < }
49 > Mat3x3d Atom::getI() {
50 >    return Mat3x3d::identity();
51 > }    
52  
53 < void Atom::setCoords(void){
53 > std::vector<double> Atom::getGrad() {
54 >     std::vector<double> grad(3);
55 >    Vector3d force= getFrc();
56  
57 <  if( myConfig->isAllocated() ){
58 <
59 <    myConfig->getAtomPointers( index,
45 <                     &pos,
46 <                     &vel,
47 <                     &frc,
48 <                     &trq,
49 <                     &Amat,
50 <                     &mu,  
51 <                     &ul);
52 <  }
53 <  else{
54 <    sprintf( painCave.errMsg,
55 <             "Attempted to set Atom %d  coordinates with an unallocated "
56 <             "SimState object.\n", index );
57 <    painCave.isFatal = 1;
58 <    simError();
59 <  }
60 <  
61 <  hasCoords = true;
62 <  
63 < }
64 <
65 < void Atom::getPos( double theP[3] ){
66 <  
67 <  if( hasCoords ){
68 <    theP[0] = pos[offsetX];
69 <    theP[1] = pos[offsetY];
70 <    theP[2] = pos[offsetZ];
71 <  }
72 <  else{
73 <
74 <    sprintf( painCave.errMsg,
75 <             "Attempt to get Pos for atom %d before coords set.\n",
76 <             index );
77 <    painCave.isFatal = 1;
78 <    simError();
79 <  }
80 < }
81 <
82 < void Atom::setPos( double theP[3] ){
83 <
84 <  if( hasCoords ){
85 <    pos[offsetX] = theP[0];
86 <    pos[offsetY] = theP[1];
87 <    pos[offsetZ] = theP[2];
88 <  }
89 <  else{
90 <
91 <    sprintf( painCave.errMsg,
92 <             "Attempt to set Pos for atom %d before coords set.\n",
93 <             index );
94 <    painCave.isFatal = 1;
95 <    simError();
96 <  }
97 < }
98 <
99 < void Atom::getVel( double theV[3] ){
100 <  
101 <  if( hasCoords ){
102 <    theV[0] = vel[offsetX];
103 <    theV[1] = vel[offsetY];
104 <    theV[2] = vel[offsetZ];
105 <  }
106 <  else{
57 >    grad[0] = -force[0];
58 >    grad[1] = -force[1];
59 >    grad[2] = -force[2];
60      
61 <    sprintf( painCave.errMsg,
62 <             "Attempt to get vel for atom %d before coords set.\n",
110 <             index );
111 <    painCave.isFatal = 1;
112 <    simError();
113 <  }
61 >    return grad;
62 > }    
63  
64 < }
64 > void Atom::accept(BaseVisitor* v) {
65 >    v->visit(this);
66 > }    
67  
117 void Atom::setVel( double theV[3] ){
118  
119  if( hasCoords ){
120    vel[offsetX] = theV[0];
121    vel[offsetY] = theV[1];
122    vel[offsetZ] = theV[2];
123  }
124  else{
125    
126    sprintf( painCave.errMsg,
127             "Attempt to set vel for atom %d before coords set.\n",
128             index );
129    painCave.isFatal = 1;
130    simError();
131  }
68   }
133
134 void Atom::getFrc( double theF[3] ){
135  
136  if( hasCoords ){
137    theF[0] = frc[offsetX];
138    theF[1] = frc[offsetY];
139    theF[2] = frc[offsetZ];
140  }
141  else{
142    
143    sprintf( painCave.errMsg,
144             "Attempt to get frc for atom %d before coords set.\n",
145             index );
146    painCave.isFatal = 1;
147    simError();
148  }
149 }
150
151 void Atom::addFrc( double theF[3] ){
152  
153  if( hasCoords ){
154    frc[offsetX] += theF[0];
155    frc[offsetY] += theF[1];
156    frc[offsetZ] += theF[2];
157  }
158  else{
159    
160    sprintf( painCave.errMsg,
161             "Attempt to add frc for atom %d before coords set.\n",
162             index );
163    painCave.isFatal = 1;
164    simError();
165  }
166 }
167
168
169 void Atom::zeroForces( void ){
170  
171  if( hasCoords ){
172    frc[offsetX] = 0.0;
173    frc[offsetY] = 0.0;
174    frc[offsetZ] = 0.0;
175  }
176  else{
177    
178    sprintf( painCave.errMsg,
179             "Attempt to zero frc for atom %d before coords set.\n",
180             index );
181    painCave.isFatal = 1;
182    simError();
183  }
184 }
185

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines