54 |
|
#include "types/BondType.hpp" |
55 |
|
|
56 |
|
namespace oopse { |
57 |
< |
|
57 |
> |
|
58 |
|
class Bond { |
59 |
|
public: |
60 |
< |
Bond(Atom* atom1, Atom* atom2, BondType* bt) : atom1_(atom1), atom2_(atom2), bondType_(bt) {} |
60 |
> |
Bond(Atom* atom1, Atom* atom2, BondType* bt) : atom1_(atom1), |
61 |
> |
atom2_(atom2), |
62 |
> |
bondType_(bt) {} |
63 |
|
virtual ~Bond() {} |
64 |
|
void calcForce() { |
65 |
< |
double len; |
66 |
< |
double dvdr; |
65 |
> |
RealType len; |
66 |
> |
RealType dvdr; |
67 |
|
Vector3d r12; |
68 |
|
Vector3d force; |
69 |
< |
|
69 |
> |
|
70 |
|
r12 = atom2_->getPos() - atom1_->getPos(); |
71 |
|
len = r12.length(); |
72 |
|
bondType_->calcForce(len, potential_, dvdr); |
73 |
< |
|
73 |
> |
|
74 |
|
force = r12 * (-dvdr / len); |
75 |
< |
|
75 |
> |
|
76 |
|
atom1_->addFrc(-force); |
77 |
|
atom2_->addFrc(force); |
78 |
|
} |
79 |
< |
|
80 |
< |
double getPotential() { |
79 |
> |
|
80 |
> |
RealType getPotential() { |
81 |
|
return potential_; |
82 |
|
} |
83 |
< |
|
83 |
> |
|
84 |
|
Atom* getAtomA() { |
85 |
|
return atom1_; |
86 |
|
} |
87 |
< |
|
87 |
> |
|
88 |
|
Atom* getAtomB() { |
89 |
|
return atom2_; |
90 |
|
} |
91 |
< |
|
91 |
> |
|
92 |
|
BondType* getBondType() { |
93 |
|
return bondType_; |
94 |
|
} |
95 |
< |
|
95 |
> |
|
96 |
|
private: |
97 |
< |
double potential_; |
97 |
> |
RealType potential_; |
98 |
|
Atom* atom1_; |
99 |
|
Atom* atom2_; |
100 |
|
BondType* bondType_; /**< bond type */ |
101 |
< |
|
101 |
> |
|
102 |
|
}; |
101 |
– |
|
102 |
– |
|
103 |
– |
|
103 |
|
} //end namespace oopse |
104 |
|
#endif //PRIMITIVES_BOND_HPP |