Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MMBondAngleScore.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/scoring/mm/MMBondAngleScore.cc
11 /// @brief Molecular mechanics bond angle score class
12 /// @author Colin A. Smith (colin.smith@ucsf.edu)
13 
14 // Unit headers
19 
20 // Project headers
22 // AUTO-REMOVED #include <core/chemical/MMAtomTypeSet.hh>
23 
25 
26 // Utility header
27 // AUTO-REMOVED #include <utility/keys/Key4Tuple.hh>
28 #include <utility/keys/Key3Tuple.hh>
29 #include <utility/pointer/access_ptr.hh>
30 #include <utility/pointer/owning_ptr.hh>
31 #include <utility/pointer/ReferenceCount.hh>
32 
33 // AUTO-REMOVED #include <numeric/conversions.hh>
34 
35 // C++ headers
36 #include <iostream>
37 #include <string>
38 #include <map>
39 // AUTO-REMOVED #include <math.h>
40 
41 #include <utility/vector1.hh>
42 #include <utility/keys/Key2Tuple.hh>
43 
44 
45 namespace core {
46 namespace scoring {
47 namespace mm {
48 
49 /// @details Auto-generated virtual destructor
51 
53  mm_bondangle_library_( scoring::ScoringManager::get_instance()->get_MMBondAngleLibrary() )
54 { }
55 
57  mm_bondangle_library_( mmtl )
58 { }
59 
60 /// @details score takes Ktheta, theta0, and an angle in radians and returns
61 /// an energy.
62 Real
63 MMBondAngleScore::score( Real Ktheta, Real theta0, Real angle ) const
64 {
65  Real const angle_diff( angle - theta0 );
66  return Ktheta * angle_diff * angle_diff;
67 }
68 
69 /// @details Score take a set of 3 mm atom types in the form of an mm_bondangle_tri and an angle in radians and returns
70 /// an energy. This is done by first looking up the set(s) of bond angle parameters in the library and then calculating
71 /// the score given an angle in radians.
72 Real
73 MMBondAngleScore::score( mm_bondangle_atom_tri mm_atomtype_set, Real angle ) const
74 {
75  Real score = 0;
76 
77  // lookup
79  mm_atomtype_set.key1(),
80  mm_atomtype_set.key2(),
81  mm_atomtype_set.key3() );
82 
83  // calc score
84  for ( mm_bondangle_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
85 
86  score += this->score( (i->second).key1(), (i->second).key2(), angle );
87 
88  //std::cout << "[" << mm_atomtype_set.key1() << "," <<mm_atomtype_set.key2() << "," << mm_atomtype_set.key3() << ": " << numeric::conversions::degrees( angle ) << " " << numeric::conversions::degrees((i->second).key2()) << " " << (i->second).key1() << ": " << (i->second).key1() * angle_diff * angle_diff << "]" << std::endl;
89  }
90 
91  /* Debug virtual atom scores
92  if ( mm_atomtype_set.key1() == 38
93  || mm_atomtype_set.key2() == 38
94  || mm_atomtype_set.key3() == 38 ) {
95  std::cout << "MM virtual score: " << score << std::endl;
96  if ( score != 0.0 ) {
97  for ( mm_bondangle_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
98  std::cout << "(i->second).key1() " << (i->second).key1();
99  std::cout << " (i->second).key2() " << (i->second).key2() << std::endl;
100  }
101 
102  }
103  }
104  */
105 
106  return score;
107 }
108 
109 /// @details dscore takes Ktheta, theta0, and an angle in radians and returns
110 /// an energy derivative.
111 Real
112 MMBondAngleScore::dscore( Real Ktheta, Real theta0, Real angle ) const
113 {
114  Real const angle_diff( angle - theta0 );
115  return 2 * Ktheta * angle_diff;
116 }
117 
118 /// @details dScore take a set of 3 mm atom types in the form of an mm_bondangle_tri and an angle in radians and returns
119 /// an energy derivative. This is done by first looking up the set(s) of bond angle parameters in the library and then calculating
120 /// the dscore_dang.
121 Real
122 MMBondAngleScore::dscore( mm_bondangle_atom_tri mm_atomtype_set, Real angle ) const
123 {
124  Real dscore_dang = 0;
125 
126  // lookup
128  mm_atomtype_set.key1(),
129  mm_atomtype_set.key2(),
130  mm_atomtype_set.key3() );
131 
132  // calc score
133  for ( mm_bondangle_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
134  dscore_dang += dscore( (i->second).key1(), (i->second).key2(), angle );
135  //std::cout << "core.mm.MMBondAngleEnergy: dscore_dang = " << dscore_dang <<
136  //" sc: " << score( mm_atomtype_set, angle ) << " +d " << score( mm_atomtype_set, angle + 1e-4 ) <<
137  //" -d " << score( mm_atomtype_set, angle - 1e-4 ) << " numderiv: " << (score( mm_atomtype_set, angle + 1e-4 ) - score( mm_atomtype_set, angle - 1e-4 ) ) / 2e-4 << std::endl;
138  }
139 
140  return dscore_dang;
141 }
142 
143 } // namespace mm
144 } // namespace scoring
145 } // namespace core