Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CartBondedParameters.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/CartBondedParameters.hh
11 /// @brief
12 /// @author
13 
14 #ifndef INCLUDED_core_scoring_methods_CartBondedParameters_hh
15 #define INCLUDED_core_scoring_methods_CartBondedParameters_hh
16 
17 #include <core/types.hh>
18 #include <utility/pointer/owning_ptr.hh>
19 #include <utility/pointer/access_ptr.hh>
20 #include <numeric/angle.functions.hh>
21 #include <numeric/constants.hh>
22 #include <utility/pointer/ReferenceCount.hh>
23 #include <numeric/interpolation/spline/Bicubic_spline.hh>
24 #include <numeric/MathMatrix.hh>
25 
26 #include <ObjexxFCL/FArray2D.hh>
27 
28 namespace core {
29 namespace scoring {
30 namespace methods {
31 
32 // Unit headers
34 public:
35  virtual
36  Real mu(Real phi, Real psi) const = 0;
37 
38  virtual
39  Real K(Real phi, Real psi) const = 0;
40 
41  virtual
42  Size period() const = 0;
43 
44  virtual
45  Real dmu_dphi(Real /*phi*/, Real /*psi*/) const {
46  return 0;
47  }
48 
49  virtual
50  Real dK_dphi(Real /*phi*/, Real /*psi*/) const {
51  return 0;
52  }
53 
54  virtual
55  Real dmu_dpsi(Real /*phi*/, Real /*psi*/) const {
56  return 0;
57  }
58 
59  virtual
60  Real dK_dpsi(Real /*phi*/, Real /*psi*/) const {
61  return 0;
62  }
63 
64  virtual
65  bool is_null() const {
66  return false;
67  }
68 };
69 
70 
72 public:
74  K0_ = 0; // K==0 is a null constraint
75  mu0_ = 0;
76  period_ = 0;
77  }
78 
80  mu0_ = mu0_in;
81  K0_ = K0_in;
82  period_ = period_in;
83  }
84 
85  virtual
86  Real mu(Real , Real ) const {
87  return mu0_;
88  }
89 
90  virtual
91  Real K(Real , Real ) const {
92  return K0_;
93  }
94 
95  virtual
96  Size period() const {
97  return period_;
98  }
99 
100  virtual
101  bool is_null() const {
102  return (K0_==0);
103  }
104 
105 private:
108 };
109 
111 public:
113 
115  ObjexxFCL::FArray2D< core::Real > const &mu,
116  ObjexxFCL::FArray2D< core::Real > const &Ks,
117  std::string tag_in="" ) {
118  init( mu, Ks );
119  tag_ = tag_in;
120  }
121 
122  // init
123  void init ( ObjexxFCL::FArray2D< core::Real > const &mu, ObjexxFCL::FArray2D< core::Real > const &Ks) {
124  using namespace numeric;
125  using namespace numeric::interpolation::spline;
126  MathMatrix< Real > mu_copy( 36, 36 ), Ks_copy( 36, 36 );
127  for ( Size jj = 0; jj < 36; ++jj ) {
128  for ( Size kk = 0; kk < 36; ++kk ) {
129  mu_copy( jj, kk ) = mu(jj+1,kk+1);
130  Ks_copy( jj, kk ) = Ks(jj+1,kk+1);
131  }
132  }
133  init( mu_copy, mus_spline_);
134  init( Ks_copy, Ks_spline_);
135  }
136 
137  void init ( numeric::MathMatrix< Real > const &x, numeric::interpolation::spline::BicubicSpline &x_spline) {
138  using namespace numeric;
139  using namespace numeric::interpolation::spline;
140 
141  BorderFlag periodic_boundary[2] = { e_Periodic, e_Periodic };
142  Real start_vals[2] = {5.0, 5.0};
143  Real deltas[2] = {10.0, 10.0};
144  bool lincont[2] = {false,false};
145  std::pair< Real, Real > unused[2];
146  unused[0] = std::make_pair( 0.0, 0.0 );
147  unused[1] = std::make_pair( 0.0, 0.0 );
148  x_spline.train( periodic_boundary, start_vals, deltas, x, lincont, unused );
149  }
150 
151  // interpolate mu
152  virtual
153  Real mu (Real phi, Real psi) const { return mus_spline_.F(phi,psi); }
154 
155  // interpolate Ks
156  virtual
157  Real K (Real phi, Real psi) const {
158  core::Real retval = Ks_spline_.F(phi,psi);
159  //if (retval<0) {
160  // std::cerr << tag_ << " K(" << phi << "," << psi << ") = " << Ks_spline_.F(phi,psi) << std::endl;
161  //}
162  return retval;
163  }
164 
165  // get dmu_dphi
166  virtual
167  Real dmu_dphi (Real phi, Real psi) const { return mus_spline_.dFdx(phi,psi); }
168 
169  // get dmu_dpsi
170  virtual
171  Real dmu_dpsi (Real phi, Real psi) const { return mus_spline_.dFdy(phi,psi); }
172 
173  // get dmu_dphi
174  virtual
176  //std::cerr << " dKs_dphi(" << phi << "," << psi << ") = " << Ks_spline_.dFdx(phi,psi) << std::endl;
177  return Ks_spline_.dFdx(phi,psi);
178  }
179 
180  // get dmu_dpsi
181  virtual
183  //std::cerr << " dKs_dpsi(" << phi << "," << psi << ") = " << Ks_spline_.dFdy(phi,psi) << std::endl;
184  return Ks_spline_.dFdy(phi,psi);
185  }
186 
187  Size period() const {
188  return 1;
189  }
190 
191 private:
192  numeric::interpolation::spline::BicubicSpline mus_spline_;
193  numeric::interpolation::spline::BicubicSpline Ks_spline_;
195 };
196 
197 // owning pointers
202 
203 
204 
205 } // namespace methods
206 } // namespace scoring
207 } // namespace core
208 
209 
210 #endif // INCLUDED_core_scoring_methods_CartesianBondedEnergy_HH