1 |
#include <cstdlib> |
2 |
|
3 |
|
4 |
#include "Molecule.hpp" |
5 |
|
6 |
|
7 |
|
8 |
Molecule::Molecule( void ){ |
9 |
|
10 |
myAtoms = NULL; |
11 |
myBonds = NULL; |
12 |
myBends = NULL; |
13 |
myTorsions = NULL; |
14 |
|
15 |
} |
16 |
|
17 |
|
18 |
|
19 |
Molecule::~Molecule( void ){ |
20 |
int i; |
21 |
|
22 |
if( myAtoms != NULL ){ |
23 |
for(i=0; i<nAtoms; i++) if(myAtoms[i] != NULL ) delete myAtoms[i]; |
24 |
delete[] myAtoms; |
25 |
} |
26 |
|
27 |
if( myBonds != NULL ){ |
28 |
for(i=0; i<nBonds; i++) if(myBonds[i] != NULL ) delete myBonds[i]; |
29 |
delete[] myBonds; |
30 |
} |
31 |
|
32 |
if( myBends != NULL ){ |
33 |
for(i=0; i<nBends; i++) if(myBends[i] != NULL ) delete myBends[i]; |
34 |
delete[] myBends; |
35 |
} |
36 |
|
37 |
if( myTorsions != NULL ){ |
38 |
for(i=0; i<nTorsions; i++) if(myTorsions[i] != NULL ) delete myTorsions[i]; |
39 |
delete[] myTorsions; |
40 |
} |
41 |
|
42 |
if( myExcludes != NULL ){ |
43 |
for(i=0; i<nExcludes; i++) if(myExcludes[i] != NULL ) delete myExcludes[i]; |
44 |
delete[] myExcludes; |
45 |
} |
46 |
} |
47 |
|
48 |
|
49 |
void Molecule::initialize( molInit &theInit ){ |
50 |
|
51 |
nAtoms = theInit.nAtoms; |
52 |
nMembers = nAtoms; |
53 |
nBonds = theInit.nBonds; |
54 |
nBends = theInit.nBends; |
55 |
nTorsions = theInit.nTorsions; |
56 |
nExcludes = theInit.nExcludes; |
57 |
nOriented = theInit.nOriented; |
58 |
|
59 |
myAtoms = theInit.myAtoms; |
60 |
myBonds = theInit.myBonds; |
61 |
myBends = theInit.myBends; |
62 |
myTorsions = theInit.myTorsions; |
63 |
myExcludes = theInit.myExcludses; |
64 |
|
65 |
} |
66 |
|
67 |
void Molecule::calcForces( void ){ |
68 |
|
69 |
int i; |
70 |
|
71 |
for(i=0; i<nBonds; i++){ |
72 |
myBonds[i]->calc_forces(); |
73 |
} |
74 |
|
75 |
for(i=0; i<nBends; i++){ |
76 |
myBends[i]->calc_forces(); |
77 |
} |
78 |
|
79 |
for(i=0; i<nTorsions; i++){ |
80 |
myTorsions[i]->calc_forces(); |
81 |
} |
82 |
} |
83 |
|
84 |
|
85 |
void Molecule::getPotential( void ){ |
86 |
|
87 |
int i; |
88 |
double myPot = 0.0; |
89 |
|
90 |
for(i=0; i<nBonds; i++){ |
91 |
myPot += myBonds[i]->get_potential(); |
92 |
} |
93 |
|
94 |
for(i=0; i<nBends; i++){ |
95 |
myPot += myBends[i]->get_potential(); |
96 |
} |
97 |
|
98 |
for(i=0; i<nTorsions; i++){ |
99 |
myPot += myTorsions[i]->get_potential(); |
100 |
} |
101 |
|
102 |
return myPot; |
103 |
} |