Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HackElecEnergy.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/HackElecEnergy.hh
11 /// @brief Electrostatic energy with a distance-dependant dielectric
12 /// @author Phil Bradley, modifed by James Gleixner
13 
14 
15 #ifndef INCLUDED_core_scoring_hackelec_HackElecEnergy_hh
16 #define INCLUDED_core_scoring_hackelec_HackElecEnergy_hh
17 
18 // Unit Headers
20 
21 // Package headers
23 
24 // Project headers
26 #include <core/pose/Pose.fwd.hh>
32 
34 
35 // Utility headers
36 
37 #include <utility/vector1.hh>
38 
39 // C++ headers
40 
41 #include <cmath>
42 
43 namespace core {
44 namespace scoring {
45 namespace hackelec {
46 
48 {
52 };
53 
54 ///
56 public:
58 public:
59 
60  ///
62 
63  ///
64  HackElecEnergy( HackElecEnergy const & src );
65 
66  /// @brief Initilize constants.
67  void
68  initialize();
69 
70  /// clone
71  virtual
73  clone() const;
74 
75  /// stashes nblist if use_nblist is true
76  virtual
77  void
79  pose::Pose & pose,
80  ScoreFunction const & sfxn,
81  kinematics::MinimizerMapBase const & min_map
82  ) const;
83 
84  virtual
85  void
86  setup_for_derivatives( pose::Pose & pose, ScoreFunction const & ) const;
87 
88  virtual
89  void
90  setup_for_scoring( pose::Pose & pose, ScoreFunction const & ) const;
91 
92  ///
93  virtual
94  void
96  pose::Pose & pose,
99  ) const;
100 
101  // Creates a rotamer trie for the input set of rotamers and stores the trie
102  // in the rotamer set.
103  virtual
104  void
106  pose::Pose const & pose,
107  conformation::RotamerSetBase & set ) const;
108 
109  // Updates the cached rotamer trie for a residue if it has changed during the course of
110  // a repacking
111  virtual
112  void
113  update_residue_for_packing( pose::Pose & pose, Size resid ) const;
114 
115  /////////////////////////////////////////////////////////////////////////////
116  // scoring
117  /////////////////////////////////////////////////////////////////////////////
118 
119  virtual
120  void
122  conformation::Residue const & rsd1,
123  conformation::Residue const & rsd2,
124  pose::Pose const & pose,
125  ScoreFunction const &,
126  EnergyMap & emap
127  ) const;
128 
129  /// @brief Returns true if we're using neighborlist-autoupdate
130  virtual
131  bool
132  minimize_in_whole_structure_context( pose::Pose const & pose ) const;
133 
134  virtual
135  bool
137  conformation::Residue const & res1,
138  conformation::Residue const & res2,
139  bool res_moving_wrt_eachother
140  ) const;
141 
142  virtual
143  bool
145 
146  virtual
147  void
149  conformation::Residue const & rsd1,
150  conformation::Residue const & rsd2,
151  ResPairMinimizationData const & min_data,
152  pose::Pose const & pose,
153  ScoreFunction const & sfxn,
154  EnergyMap & emap
155  ) const;
156 
157  void
159  conformation::Residue const & rsd1,
160  conformation::Residue const & rsd2,
161  pose::Pose const & pose,
162  ScoreFunction const & sfxn,
163  kinematics::MinimizerMapBase const & minmap,
164  ResSingleMinimizationData const & res1_data_cache,
165  ResSingleMinimizationData const & res2_data_cache,
166  ResPairMinimizationData & data_cache
167  ) const;
168 
169  virtual
170  void
172  conformation::Residue const & rsd1,
173  conformation::Residue const & rsd2,
176  ResPairMinimizationData const & min_data,
177  pose::Pose const & pose, // provides context
178  EnergyMap const & weights,
179  utility::vector1< DerivVectorPair > & r1_atom_derivs,
180  utility::vector1< DerivVectorPair > & r2_atom_derivs
181  ) const;
182 
183  virtual
184  void
186  conformation::Residue const & rsd1,
187  conformation::Residue const & rsd2,
188  pose::Pose const & pose,
189  ScoreFunction const & sfxn,
190  EnergyMap & emap
191  ) const;
192 
193  virtual
194  void
196  conformation::Residue const & rsd1,
197  conformation::Residue const & rsd2,
198  pose::Pose const & pose,
199  ScoreFunction const & sfxn,
200  EnergyMap & emap
201  ) const;
202 
203  virtual
204  void
206  conformation::Residue const & rsd1,
207  conformation::Residue const & rsd2,
208  pose::Pose const & pose,
209  ScoreFunction const & sfxn,
210  EnergyMap & emap
211  ) const;
212 
213  void
215  pose::Pose & pose,
216  ScoreFunction const &,
217  EnergyMap & totals
218  ) const;
219 
220  // was private, but outside world wants to call this one:
221  inline
222  Real
224  Vector const & i_xyz,
225  Real const i_charge,
226  Vector const & j_xyz,
227  Real const j_charge
228  ) const;
229 
230 
231  virtual
232  void
234  conformation::Residue const &,
235  pose::Pose const &,
236  ScoreFunction const &,
237  EnergyMap &
238  ) const {}
239 
240  virtual
241  void
243  conformation::RotamerSetBase const & set1,
244  conformation::RotamerSetBase const & set2,
245  pose::Pose const & pose,
246  ScoreFunction const & sfxn,
247  EnergyMap const & weights,
248  ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
249  ) const;
250 
251 
252  //@brief overrides default rotamer/background energy calculation and uses
253  // the trie-vs-trie algorithm instead
254  virtual
255  void
257  conformation::RotamerSetBase const & set,
258  conformation::Residue const & residue,
259  pose::Pose const & pose,
260  ScoreFunction const & sfxn,
261  EnergyMap const & weights,
263  ) const;
264 
265 
266  virtual
267  bool
268  defines_intrares_energy( EnergyMap const & /*weights*/ ) const { return false; }
269 
270  /// @brief Interface function for class NeighborList.
273  conformation::Residue const &,
274  pose::Pose const &,
275  ScoreFunction const &
276  ) const;
277 
278  /// @brief Interface function for class NeighborList.
281  Size const,
282  Size const,
283  pose::Pose const &,
284  ScoreFunction const &
285  ) const;
286 
289  conformation::Residue const & rsd1,
290  conformation::Residue const & rsd2
291  ) const;
292 
293 
294  virtual
295  Distance
297 
298  virtual
299  bool
301  {
302  return true;
303  }
304 
305  virtual
306  void indicate_required_context_graphs( utility::vector1< bool > & context_graphs_required ) const;
307 
308 public:
309  /// @brief How close two heavy atoms have to be such that their hydrogen atoms might interact, squared.
310  Real
312  {
314  }
315 
316  /// @brief How close two heavy atoms have to be such that their hydrogen atoms might interact
317  Real
319  {
321  }
322 
323  inline
325  ElecAtom const & at1,
326  ElecAtom const & at2,
327  DistanceSquared & d2,
328  Size & /*path_dist*/
329  ) const
330  {
331  return hackelec_weight(at1.isbb(),at2.isbb()) * eval_atom_atom_hack_elecE( at1.xyz(), at1.charge(), at2.xyz(), at2.charge(), d2 );
332  }
333 
334  inline
336  ElecAtom const & at1,
337  ElecAtom const & at2,
338  Size & /*path_dist*/
339  ) const
340  {
341  return hackelec_weight(at1.isbb(),at2.isbb()) * eval_atom_atom_hack_elecE( at1.xyz(), at1.charge(), at2.xyz(), at2.charge() );
342  }
343 
344  inline
346  ElecAtom const & at1,
347  ElecAtom const & at2,
348  Size & /*path_dist*/
349  ) const
350  {
351  return hackelec_weight(at1.isbb(),at2.isbb()) * eval_atom_atom_hack_elecE( at1.xyz(), at1.charge(), at2.xyz(), at2.charge() );
352  }
353 
354  inline
356  ElecAtom const & at1,
357  ElecAtom const & at2,
358  Size & /*path_dist*/
359  ) const
360  {
361  return hackelec_weight(at1.isbb(),at2.isbb()) * eval_atom_atom_hack_elecE( at1.xyz(), at1.charge(), at2.xyz(), at2.charge() );
362  }
363 
364  /// @brief This has to go
365  inline
366  Real
367  hackelec_weight( bool at1isbb, bool at2isbb ) const {
368  return ( at1isbb ? ( at2isbb ? wbb_bb_ : wbb_sc_ ) : ( at2isbb ? wbb_sc_ : wsc_sc_ ) );
369  }
370 
371 
372  inline
373  Real
374  hackelec_weight( bool at1isbb, bool at2isbb, weight_triple const & wts ) const {
375  return ( at1isbb ? ( at2isbb ? wts.wbb_bb_ : wts.wbb_sc_ ) : ( at2isbb ? wts.wbb_sc_ : wts.wsc_sc_ ) );
376  }
377 
378 
379 /// Private methods
380 private:
381 
382  void
384  EnergyMap const & weights,
385  weight_triple & wttrip
386  ) const;
387 
388  inline
389  Real
391  Vector const & i_xyz,
392  Real const i_charge,
393  Vector const & j_xyz,
394  Real const j_charge,
395  DistanceSquared & d2
396  ) const;
397 
398 protected:
399  ///@brief Get the key numeric value for derivative calculations
400  /// i.e. the derivative of energy with respect to distance divided by the distance
401  inline
402  Real
404  Real const dis2,
405  Real const q1,
406  Real const q2
407  ) const;
408 
409 private:
412  conformation::RotamerSetBase const & rotset,
413  pose::Pose const & pose
414  ) const;
415 
418  conformation::Residue const & res,
419  pose::Pose const & // will be need to create tries for disulfides
420  ) const;
421 
424  conformation::RotamerSetBase const & set1,
425  conformation::RotamerSetBase const & set2,
426  pose::Pose const & pose,
427  ScoreFunction const & sfxn
428  ) const;
429 
430 
433  conformation::Residue const & res1,
434  conformation::Residue const & res2,
437  pose::Pose const & pose,
438  ScoreFunction const & sfxn
439  ) const;
440 
441  inline
442  Real
444  conformation::Residue const & res1,
445  conformation::Residue const & res2,
446  Size const at1,
447  Size const at2,
448  EnergyMap & emap,
449  Real const cpweight,
450  Real & d2
451  ) const;
452 
453  void
455  core::pose::Pose const & pose
456  ) const;
457 
458  bool
459  monomer_test(
460  Size irsd,
461  Size jrsd
462  ) const;
463 
464 
465 private:
466 
471 
472  bool smooth_hack_elec_; // use sigmoidal functions to eliminate derivative discontinuities?
473  //Real low_fade_start_;
474  //Real low_fade_end_;
475  //Real high_fade_start_;
476  //Real high_fade_end_;
477  //Real low_fade_start2_;
478  //Real low_fade_end2_;
479  //Real high_fade_start2_;
480  //Real high_fade_end2_;
481  //Real low_fade_K_;
482  //Real low_fade_d0_;
483  //Real high_fade_K_;
484  //Real high_fade_d0_;
485 
493 
501 
502 
505 
509 
510  //mutable Real hackelec_weight_; // used during trie-vs-trie algorithm
511  mutable Real wbb_bb_;
512  mutable Real wbb_sc_;
513  mutable Real wsc_sc_;
514 
515  ///@brief Precomputed constants
521 
523 
524  virtual
525  core::Size version() const;
526 
527 };
528 
529 ///////////////////////////////////////////////////////////////////////////////////
530 // The following functions are defined here in the header as they are inlined
531 // and are used in derived classes.
532 
533 inline
534 Real
536  Vector const & i_xyz,
537  Real const i_charge,
538  Vector const & j_xyz,
539  Real const j_charge
540 ) const
541 {
542  Real d2;
543  return eval_atom_atom_hack_elecE(i_xyz, i_charge, j_xyz, j_charge, d2);
544 }
545 
546 /// @brief Use a polynomial to smooth the transition between the
547 /// regions in which the score is changing and the regions
548 /// in which the score is held constant.
549 inline
550 Real
552  Vector const & i_xyz,
553  Real const i_charge,
554  Vector const & j_xyz,
555  Real const j_charge,
556  DistanceSquared & d2
557 ) const
558 {
559  d2 = i_xyz.distance_squared( j_xyz );
560 
561  if ( d2 > max_dis2_ ) {
562  return 0.0;
563  } else if ( d2 < low_poly_start2_ ) {
564  return i_charge * j_charge * min_dis_score_;
565  } else if ( d2 < low_poly_end2_ ) {
566  return i_charge * j_charge * etable::Etable::eval_spline(
567  std::sqrt( d2 ), low_poly_start_, low_poly_end_,
569  } else if ( d2 > hi_poly_start2_ ) {
570  return i_charge * j_charge * etable::Etable::eval_spline(
571  std::sqrt( d2 ), hi_poly_start_, hi_poly_end_,
573  } else if ( no_dis_dep_die_ ) {
574  return i_charge * j_charge * ( C1_ / std::sqrt(d2) - C2_ );
575  } else {
576  return i_charge * j_charge * ( C1_ / d2 - C2_ );
577  }
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////
581 
582 inline
583 Real
585  Real const dis2,
586  Real const q1,
587  Real const q2
588 ) const
589 {
590  if ( dis2 > max_dis2_ ) return 0.0;
591  else if ( dis2 < low_poly_start2_ ) return 0.0; // flat in this region
592 
593  Real q1q2 = q1*q2;
594 
595  if ( dis2 > low_poly_end2_ && dis2 < hi_poly_start2_ ) {
596  if ( no_dis_dep_die_ ) {
597  return dEfac_ * q1q2 / ( dis2 * std::sqrt(dis2) ) ;
598  } else {
599  return dEfac_ * q1q2 / ( dis2 * dis2 );
600  }
601  } else if ( dis2 < low_poly_end2_ ) {
602  Real d = std::sqrt( dis2 );
606  } else {
607  Real d = std::sqrt( dis2 );
611  }
612 }
613 
614 ////////////////////////////////////////////////////////////////////////////
615 
616 } // namespace hackelec
617 } // namespace scoring
618 } // namespace core
619 
620 #endif