BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: support.h,v 1.28 2005/12/23 17:01:52 amoll Exp $ 00005 // 00006 00007 00008 #ifndef BALL_MOLMEC_COMMON_SUPPORT_H 00009 #define BALL_MOLMEC_COMMON_SUPPORT_H 00010 00011 #ifndef BALL_COMMON_H 00012 # include <BALL/common.h> 00013 #endif 00014 00015 #ifndef BALL_MATHS_SIMPLEBOX3_H 00016 # include <BALL/MATHS/simpleBox3.h> 00017 #endif 00018 00019 #ifndef BALL_MOLMEC_COMMON_FORCEFIELD_H 00020 # include <BALL/MOLMEC/COMMON/forceField.h> 00021 #endif 00022 00023 #ifndef BALL_MOLMEC_COMMON_ATOMVECTOR_H 00024 # include <BALL/MOLMEC/COMMON/atomVector.h> 00025 #endif 00026 00027 #ifndef BALL_DATATYPE_HASHGRID_H 00028 # include <BALL/DATATYPE/hashGrid.h> 00029 #endif 00030 00031 #ifndef BALL_KERNEL_BOND_H 00032 # include <BALL/KERNEL/bond.h> 00033 #endif 00034 00035 #include <vector> 00036 00037 namespace BALL 00038 { 00039 class Atom; 00040 class System; 00041 00045 namespace MolmecSupport 00046 { 00047 00048 using std::pair; 00049 00053 00057 00060 enum PairListAlgorithmType 00061 { 00064 HASH_GRID, 00065 00068 BRUTE_FORCE 00069 }; 00071 00085 BALL_EXPORT BALL::Size calculateNonBondedAtomPairs 00086 (ForceField::PairVector& pair_vector, 00087 const AtomVector& atom_vector, const SimpleBox3& box, 00088 double distance, bool periodic_boundary_enabled, 00089 PairListAlgorithmType type) 00090 throw(Exception::OutOfMemory); 00091 00099 BALL_EXPORT Size sortNonBondedAtomPairsAfterSelection(ForceField::PairVector& pair_vector); 00100 00114 BALL_EXPORT BALL::Size addNonOverlappingMolecules 00115 (System& system, const HashGrid3<const Atom*>& solute_grid, 00116 const System& solvent, const SimpleBox3& box, double distance); 00117 00130 BALL_EXPORT void adaptWaterBox(System& system, const SimpleBox3& box); 00131 00134 // ????? 00135 BALL_EXPORT void calculateMinimumImage 00136 (Vector3& distance, const Vector3& period); 00137 00145 template <typename TorsionType, typename AtomIteratorType> 00146 Size computeTorsions 00147 (const AtomIteratorType& start, const AtomIteratorType& end, 00148 std::vector<TorsionType>& torsions, bool use_selection = false); 00149 00150 00151 // 00152 template <typename TorsionType, typename AtomIteratorType> 00153 Size computeTorsions 00154 (const AtomIteratorType& start, const AtomIteratorType& end, 00155 std::vector<TorsionType>& torsions, bool use_selection) 00156 { 00157 // pointers to the four atoms 00158 Atom* a1; 00159 Atom* a2; 00160 Atom* a3; 00161 Atom* a4; 00162 00163 Size number_of_added_torsions = 0; 00164 00165 // Iterate over all atoms... 00166 // 00167 AtomIteratorType atom_it = start; 00168 for (; atom_it != end; ++atom_it) 00169 { 00170 // ...and check each bond whether it is part of 00171 // a torsion. 00172 Atom::BondIterator it1 = (*atom_it)->beginBond(); 00173 for (; +it1 ; ++ it1) 00174 { 00175 // Consider each bond just once by making sure that 00176 // our start atom is the *first* atom of the bond. 00177 if (*atom_it == it1->getFirstAtom()) 00178 { 00179 // We know have the two central atoms of a potential 00180 // torsion and store them in a2 and a3. 00181 a2 = *atom_it; 00182 a3 = const_cast<Atom*>(it1->getSecondAtom()); 00183 00184 // Now, find all other atoms (atoms 1 and 4) 00185 Atom::BondIterator it2; 00186 Atom::BondIterator it3; 00187 for (it2 = (*atom_it)->beginBond(); +it2 ; ++it2) 00188 { 00189 if (it2->getSecondAtom() != it1->getSecondAtom()) 00190 { 00191 // determine the first atom 00192 if (it2->getFirstAtom() == *atom_it) 00193 { 00194 a1 = const_cast<Atom*>(it2->getSecondAtom()); 00195 } 00196 else 00197 { 00198 a1 = const_cast<Atom*>(it2->getFirstAtom()); 00199 } 00200 00201 for (it3 = const_cast<Atom*>(it1->getSecondAtom())->beginBond(); +it3 ; ++it3) 00202 { 00203 if (it3->getFirstAtom() != a2 ) 00204 { 00205 // determine the fourth atom a4 00206 if (it3->getFirstAtom() == a3) 00207 { 00208 a4 = const_cast<Atom*>(it3->getSecondAtom()); 00209 } 00210 else 00211 { 00212 a4 = const_cast<Atom*>(it3->getFirstAtom()); 00213 } 00214 00215 if (use_selection == false 00216 || (use_selection == true 00217 && (a1->isSelected() || a2->isSelected() || a3->isSelected() || a4->isSelected()))) 00218 { 00219 // Push the torsion onto the torsion vector. 00220 TorsionType tmp; 00221 tmp.atom1 = a1; 00222 tmp.atom2 = a2; 00223 tmp.atom3 = a3; 00224 tmp.atom4 = a4; 00225 00226 torsions.push_back(tmp); 00227 number_of_added_torsions++; 00228 } 00229 } 00230 } 00231 } 00232 } 00233 } 00234 } 00235 } 00236 00237 // return the number of torsions computed 00238 return number_of_added_torsions; 00239 } 00240 00241 } // namespace MolmecSupport 00242 } // namespace BALL 00243 00244 #endif // BALL_MOLMEC_COMMON_SUPPORT_H