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