ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Rattle.cpp
Revision: 1232
Committed: Thu Jun 3 21:51:55 2004 UTC (20 years, 11 months ago) by tim
File size: 2245 byte(s)
Log Message:
new implementation of constraint

File Contents

# Content
1 #include "Rattle.hpp"
2 #include <cmath>
3 #include "SimInfo.hpp"
4
5 ////////////////////////////////////////////////////////////////////////////////
6 //Implementation of DCRattleBFunctor
7 ////////////////////////////////////////////////////////////////////////////////
8 int DCRattleBFunctor::operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2){
9 double posA[3], posB[3];
10 double velA[3], velB[3];
11 double vxab, vyab, vzab;
12 double rab[3];
13 double rma, rmb;
14 double dx, dy, dz;
15 double rvab;
16 double gab;
17
18 consAtom1->getVel(velA);
19 consAtom2->getVel(velB);
20
21 vxab = velA[0] - velB[0];
22 vyab = velA[1] - velB[1];
23 vzab = velA[2] - velB[2];
24
25 consAtom1->getPos(posA);
26 consAtom2->getPos(posB);
27
28 rab[0] = posA[0] - posB[0];
29 rab[1] = posA[1] - posB[1];
30 rab[2] = posA[2] - posB[2];
31
32 info->wrapVector(rab);
33
34 rma = 1.0 / consAtom1->getMass();
35 rmb = 1.0 / consAtom2->getMass();
36
37 rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab;
38
39 gab = -rvab / ((rma + rmb) * curPair->getBondLength2());
40
41 if (fabs(gab) > consTolerance){
42 dx = rab[0] * gab;
43 dy = rab[1] * gab;
44 dz = rab[2] * gab;
45
46 velA[0] += rma * dx;
47 velA[1] += rma * dy;
48 velA[2] += rma * dz;
49
50 consAtom1->setVel(velA);
51
52 velB[0] -= rmb * dx;
53 velB[1] -= rmb * dy;
54 velB[2] -= rmb * dz;
55
56 consAtom2->setVel(velB);
57 }
58 return consSuccess;
59 }
60
61
62
63 int DCRattleBFunctor::operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB){
64 return consElemHandlerFail;
65 }
66
67 int DCRattleBFunctor::operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2){
68 return consElemHandlerFail;
69 }
70
71 ////////////////////////////////////////////////////////////////////////////////
72 //Implementation of JCRattleBFunctor
73 ////////////////////////////////////////////////////////////////////////////////
74 int JCRattleBFunctor::operator()(ConstraintAtom* consAtom1, ConstraintAtom* consAtom2){
75 return consElemHandlerFail;
76 }
77
78
79
80 int JCRattleBFunctor::operator()(ConstraintAtom* consAtom,ConstraintRigidBody* consRB){
81 return consElemHandlerFail;
82 }
83
84 int JCRattleBFunctor::operator()(ConstraintRigidBody* consRB1, ConstraintRigidBody* consRB2){
85 return consElemHandlerFail;
86 }

Properties

Name Value
svn:executable *