Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CenHBPotential.hh
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/methods/CenHBPotential.cc
11 /// @brief Smooth, differentiable version of centroid hbond term
12 /// @author Frank DiMaio
13 
14 #ifndef INCLUDED_core_scoring_CenHBPotential_hh
15 #define INCLUDED_core_scoring_CenHBPotential_hh
16 
18 
19 // AUTO-REMOVED #include <core/conformation/Residue.fwd.hh>
20 // AUTO-REMOVED #include <core/pose/Pose.fwd.hh>
21 #include <core/types.hh>
22 
23 #include <numeric/constants.hh>
24 
25 // AUTO-REMOVED #include <basic/datacache/CacheableData.hh>
26 
27 #include <utility/vector1_bool.hh>
28 #include <utility/pointer/ReferenceCount.hh>
29 
30 #include <utility/vector1.hh>
31 #include <numeric/xyzVector.hh>
32 
33 
34 
35 namespace core {
36 namespace scoring {
37 
38 ////////////////////////
39 // fpd helper class holds some # of gaussians
41 public:
43 
44  Size nlr_gaussians() const { return lr_As_.size(); }
45  Size nsr_gaussians() const { return lr_As_.size(); }
46 
47  void clear() {
48  lr_As_.clear( );
49  lr_mus_.clear( );
50  lr_sigmas_.clear( );
51  sr_As_.clear( );
52  sr_mus_.clear( );
53  sr_sigmas_.clear( );
54  }
55 
57  Real A_in,
59  numeric::xyzVector< Real > sigma_in ) {
60  using numeric::constants::f::pi;
61 
62  // normalize terms
63  A_in /= sqrt(2*pi*sigma_in[0]*sigma_in[0]);
64  A_in /= 2*pi*BesselI0(sigma_in[1]);
65  A_in /= 2*pi*BesselI0(sigma_in[2]);
66 
67  sr_As_.push_back( A_in );
68  sr_mus_.push_back( mu_in );
69  sr_sigmas_.push_back( sigma_in );
70  }
71 
73  Real A_in,
75  numeric::xyzVector< Real > sigma_in ) {
76  using numeric::constants::f::pi;
77 
78  // normalize terms
79  A_in /= sqrt(2*pi*sigma_in[0]*sigma_in[0]);
80  A_in /= 2*pi*BesselI0(sigma_in[1]);
81  A_in /= 2*pi*BesselI0(sigma_in[2]);
82 
83  lr_As_.push_back( A_in );
84  lr_mus_.push_back( mu_in );
85  lr_sigmas_.push_back( sigma_in );
86  }
87 
88  void set_cutoff_sr(Real cut_in) { cutoff_sr_ = cut_in; }
89  void set_cutoff_lr(Real cut_in) { cutoff_lr_ = cut_in; }
90 
91  // score
92  Real func( Size seqsep, Real d, Real xd, Real xh ) const;
93 
94  // derivative wrt dist,angle,angle
95  Vector dfunc( Size seqsep, Real d, Real xd, Real xh ) const;
96 
97  // cutoff
98  Real cutoff( Size seqsep ) const { return (seqsep<=4 ? cutoff_sr_:cutoff_lr_); }
99 
100 private:
101  // helper function computes fast approximation to besseli_0
102  inline Real BesselI0( Real X ) {
103  Real Y,P1,P2,P3,P4,P5,P6,P7,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,AX,BX;
104  P1=1.0; P2=3.5156229; P3=3.0899424; P4=1.2067492;
105  P5=0.2659732; P6=0.360768e-1; P7=0.45813e-2;
106  Q1=0.39894228; Q2=0.1328592e-1; Q3=0.225319e-2;
107  Q4=-0.157565e-2; Q5=0.916281e-2; Q6=-0.2057706e-1;
108  Q7=0.2635537e-1; Q8=-0.1647633e-1; Q9=0.392377e-2;
109  if (fabs(X) < 3.75) {
110  Y=(X/3.75)*(X/3.75);
111  return (P1+Y*(P2+Y*(P3+Y*(P4+Y*(P5+Y*(P6+Y*P7))))));
112  } else {
113  AX=fabs(X);
114  Y=3.75/AX;
115  BX=exp(AX)/sqrt(AX);
116  AX=Q1+Y*(Q2+Y*(Q3+Y*(Q4+Y*(Q5+Y*(Q6+Y*(Q7+Y*(Q8+Y*Q9)))))));
117  return (AX*BX);
118  }
119  }
120 
121 private:
126 };
127 
128 
129 
130 } // ns scoring
131 } // ns core
132 
133 #endif