Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseEtableEnergy.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/etable/EtableEnergy.hh
11 /// @brief Etable energy method class declaration
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay
14 /// @author Oliver Lange
15 
16 /***********************************************************************
17 ++++++++++++++++++++++++++++ WARNING +++++++++++++++++++++++++++++++++++
18 
19 the CoarseEtable is currently not threadsafe, since it has the
20 "mutable" element seq_dist...
21 
22 could move seq_dist into CoarseEtableEnergy --> then at least the
23 CoarseEtable can be shared between threads
24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 ************************************************************************/
26 
27 
28 #ifndef INCLUDED_core_scoring_etable_BaseEtableEnergy_hh
29 #define INCLUDED_core_scoring_etable_BaseEtableEnergy_hh
30 
31 // Unit headers
32 // #include <core/scoring/etable/BaseEtableEnergy.fwd.hh> -- file doesn't exist?
33 
34 // Package headers
38 
39 
45 
47 
48 // Project headers
50 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
51 // AUTO-REMOVED #include <core/chemical/AtomTypeSet.hh>
52 // AUTO-REMOVED #include <core/chemical/AtomType.hh>
53 #include <core/pose/Pose.fwd.hh>
55 
57 
58 #include <ObjexxFCL/FArray3D.hh>
59 
64 #include <utility/vector1.hh>
65 
66 namespace core {
67 namespace scoring {
68 namespace etable {
69 
70 // PyRosetta: Python can't pass reference to value, so we have to create data holding structure for atom_pair_energy* functions.
77 };
78 
79 
80 
81 template < class Derived >
83 {
84 public:
87 
88 public:
89 
90  /// construction with an etable
93  Etable const & etable_in,
94  methods::EnergyMethodOptions const & options
95  );
96 
97  /// @brief explicit copy constructor, since the BaseEtableEnergy now contains OP data
99 
100 
101  /// NO! friend class core::scoring::rna::RNA_FullAtomVDW_BasePhosphateCreator;
102 
103  /////////////////////////////////////////////////////////////////////////////
104  // methods for ContextIndependentTwoBodyEnergies
105  /////////////////////////////////////////////////////////////////////////////
106 
107  /// @brief The neighborlist-autoupdate algorithm requires that the EtableEnergy
108  /// be able to control the definition and update for its atom-neighbors. This
109  /// will bypass the standard neighborlist evaluation inside the ScoreFunction,
110  /// avoiding the use the MinimizationGraph.
111  virtual
112  bool
114 
115  /// @brief stashes nblist if pose.energies().use_nblist_auto_update() is true
116  /// This is only invoked, now, if the neighborlist-autoupdate flag is on.
117  virtual
118  void
120  pose::Pose & pose,
121  ScoreFunction const & sfxn,
122  kinematics::MinimizerMapBase const & min_map
123  ) const;
124 
125  /// @brief check compatibility with atomtypeset
126  virtual
127  void
128  setup_for_scoring( pose::Pose &pose, ScoreFunction const &scfxn ) const;
129 
130  virtual
131  void
133  pose::Pose &pose,
134  ScoreFunction const &scfxn
135  ) const;
136 
137  // The EtableEnergy method stores a vector of rotamer trie objects in the Energies
138  // object for use in rapid rotamer/background energy calculations. Overrides default
139  // do-nothing behavior.
140  virtual
141  void
143 
144  // Creates a rotamer trie for the input set of rotamers and stores the trie
145  // in the rotamer set.
146  virtual
147  void
149  pose::Pose const & pose,
151  ) const;
152 
153  // Updates the cached rotamer trie for a residue if it has changed during the course of
154  // a repacking
155  virtual
156  void
157  update_residue_for_packing( pose::Pose & pose, Size resid ) const;
158 
159 
162  Size res1,
163  Size res2,
164  pose::Pose const & pose,
165  ScoreFunction const & sfxn
166  ) const;
167 
170  conformation::Residue const & res1,
171  conformation::Residue const & res2,
172  pose::Pose const & pose,
173  ScoreFunction const & sfxn
174  ) const;
175 
178  conformation::Residue const & res,
179  pose::Pose const & pose,
180  ScoreFunction const & sfxn
181  ) const;
182 
183  ///
184  virtual
185  void
187  conformation::Residue const & rsd1,
188  conformation::Residue const & rsd2,
189  pose::Pose const & pose,
190  ScoreFunction const & sfxn,
191  EnergyMap & emap
192  ) const;
193 
194  /// APL -- note, new
195  virtual
196  bool
198 
199  /// APL -- note, new
200  virtual
201  void
203  conformation::Residue const & rsd1,
204  conformation::Residue const & rsd2,
205  ResPairMinimizationData const & min_data,
206  pose::Pose const & pose,
207  ScoreFunction const & sfxn,
208  EnergyMap & emap
209  ) const;
210 
211 
212  /// APL -- note, new
213  virtual
214  void
216  conformation::Residue const & rsd1,
217  conformation::Residue const & rsd2,
218  pose::Pose const & pose,
219  ScoreFunction const & sfxn,
220  kinematics::MinimizerMapBase const & minmap,
221  ResSingleMinimizationData const & res1_data_cache,
222  ResSingleMinimizationData const & res2_data_cache,
223  ResPairMinimizationData & min_data
224  ) const;
225 
226  /// @brief Does this EnergyMethod require the opportunity to examine the residue before scoring begins? Not
227  /// all energy methods would. The ScoreFunction will not ask energy methods to examine residues that are uninterested
228  /// in doing so.
229  virtual
230  bool
232 
233  /// @brief Do any setup work should the coordinates of this residue (who is still guaranteed to be
234  /// of the same residue type as when setup_for_minimizing_for_residue was called) have changed so dramatically
235  /// as to possibly require some amount of setup work before scoring should proceed.
236  /// This function is used for both intra-residue setup and pre-inter-residue setup
237  virtual
238  void
240  conformation::Residue const & rsd,
241  pose::Pose const & pose,
242  ScoreFunction const &,
243  ResSingleMinimizationData & min_data
244  ) const;
245 
246  /// @brief Does this EnergyMethod require the opportunity to examine each residue before derivative evaluation begins? Not
247  /// all energy methods would. The ScoreFunction will not ask energy methods to examine residue pairs that are uninterested
248  /// in doing so.
249  virtual
250  bool
252 
253  /// @brief Do any setup work necessary before evaluating the derivatives for this residue
254  virtual
255  void
257  conformation::Residue const & rsd,
258  pose::Pose const & pose,
259  ScoreFunction const &,
260  ResSingleMinimizationData & min_data
261  ) const;
262 
263  /// @brief Does this EnergyMethod require the opportunity to examine each residue pair before scoring begins? Not
264  /// all energy methods would. The ScoreFunction will not ask energy methods to examine residue pairs that are uninterested
265  /// in doing so.
266  virtual
267  bool
269 
270  /// @brief Do any setup work should the coordinates of a pair of residues, who are still guaranteed to be
271  /// of the same residue type as when setup_for_minimizing_for_residue was called, have changed so dramatically
272  /// as to possibly require some amount of setup work before scoring should proceed
273  virtual
274  void
276  conformation::Residue const & rsd1,
277  conformation::Residue const & rsd2,
278  ResSingleMinimizationData const & minsingle_data1,
279  ResSingleMinimizationData const & minsingle_data2,
280  pose::Pose const & pose,
281  ScoreFunction const &,
282  ResPairMinimizationData & data_cache
283  ) const;
284 
285  /// @brief Does this EnergyMethod require the opportunity to examine each residue pair before derivative evaluation begins? Not
286  /// all energy methods would. The ScoreFunction will not ask energy methods to examine residue pairs that are uninterested
287  /// in doing so.
288  virtual
289  bool
291 
292  /// @brief Do any setup work necessary before evaluating the derivatives for this residue pair
293  virtual
294  void
296  conformation::Residue const & rsd1,
297  conformation::Residue const & rsd2,
298  ResSingleMinimizationData const & minsingle_data1,
299  ResSingleMinimizationData const & minsingle_data2,
300  pose::Pose const & pose,
301  ScoreFunction const &,
302  ResPairMinimizationData & data_cache
303  ) const;
304 
305  /// APL -- note, new
306  /*virtual
307  void
308  eval_atom_derivative_for_residue_pair(
309  Size const atom_index,
310  conformation::Residue const & rsd1,
311  conformation::Residue const & rsd2,
312  ResSingleMinimizationData const & minsingle_data1,
313  ResSingleMinimizationData const & minsingle_data2,
314  ResPairMinimizationData const & min_data,
315  pose::Pose const & pose, // provides context
316  kinematics::DomainMap const & domain_map,
317  ScoreFunction const & sfxn,
318  EnergyMap const & weights,
319  Vector & F1,
320  Vector & F2
321  ) const;*/
322 
323  virtual
324  void
326  conformation::Residue const & rsd1,
327  conformation::Residue const & rsd2,
330  ResPairMinimizationData const & min_data,
331  pose::Pose const & pose, // provides context
332  EnergyMap const & weights,
335  ) const;
336 
337  ///@brief Evaluates the interaction between the backbone of rsd1 and the
338  /// backbone of rsd2 and accumulates the unweighted energy.
339  virtual
340  void
342  conformation::Residue const & rsd1,
343  conformation::Residue const & rsd2,
344  pose::Pose const & pose,
345  ScoreFunction const & sfxn,
346  EnergyMap & emap
347  ) const;
348 
349 
350  ///@brief Evaluates the interaction between the backbone of rsd1 and the
351  /// sidechain of rsd2 and accumulates the unweighted energy.
352  virtual
353  void
355  conformation::Residue const & rsd1,
356  conformation::Residue const & rsd2,
357  pose::Pose const & pose,
358  ScoreFunction const & sfxn,
359  EnergyMap & emap
360  ) const;
361 
362  ///@brief Evaluates the interaction between the sidechain of rsd1 and the
363  /// sidechain of rsd2 and accumulates the unweighted energy.
364  virtual
365  void
367  conformation::Residue const & rsd1,
368  conformation::Residue const & rsd2,
369  pose::Pose const & pose,
370  ScoreFunction const & sfxn,
371  EnergyMap & emap
372  ) const;
373 
374  virtual
375  void
377  conformation::RotamerSetBase const & set1,
378  conformation::RotamerSetBase const & set2,
379  pose::Pose const & pose,
380  ScoreFunction const & sfxn,
381  EnergyMap const & weights,
382  ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
383  ) const;
384 
385 
386  //@brief overrides default rotamer/background energy calculation and uses
387  // the trie-vs-trie algorithm instead
388  virtual
389  void
391  conformation::RotamerSetBase const & set,
392  conformation::Residue const & residue,
393  pose::Pose const & pose,
394  ScoreFunction const & sfxn,
395  EnergyMap const & weights,
397  ) const;
398 
399  /// APL -- note, new
400  virtual
401  bool
403 
404  /// APL -- note, new
405  virtual
406  void
408  conformation::Residue const & rsd,
409  ResSingleMinimizationData const & min_data,
410  pose::Pose const & pose,
411  ScoreFunction const & sfxn,
412  EnergyMap & emap
413  ) const;
414 
415  /// APL -- note, new
416  virtual
417  void
419  conformation::Residue const & rsd,
420  pose::Pose const & pose,
421  ScoreFunction const & sfxn,
422  kinematics::MinimizerMapBase const & minmap,
423  ResSingleMinimizationData & min_data
424  ) const;
425 
426  void
428  conformation::Residue const & rsd,
429  ResSingleMinimizationData const & min_data,
430  pose::Pose const & pose,
431  EnergyMap const & weights,
433  ) const;
434 
435  virtual
436  void
438  conformation::Residue const & rsd1,
439  conformation::Residue const & rsd2,
440  pose::Pose const & pose,
441  ScoreFunction const & sfxn,
442  EnergyMap & emap
443  ) const;
444 
445  virtual
446  void
448  conformation::Residue const & rsd1,
449  conformation::Residue const & rsd2,
450  pose::Pose const & pose,
451  ScoreFunction const & sfxn,
452  EnergyMap & emap
453  ) const;
454 
455 
456  /// called at the end of energy evaluation
457  virtual
458  void
460  pose::Pose & pose,
461  ScoreFunction const &,
462  EnergyMap & totals
463  ) const;
464 
465 
466  /// called during gradient-based minimization inside dfunc
467  /**
468  F1 and F2 are not zeroed -- contributions from this atom are
469  just summed in
470  **/
471  virtual
472  void
474  id::AtomID const & id,
475  pose::Pose const & pose,
476  kinematics::DomainMap const &, // domain_map,
477  ScoreFunction const & sfxn,
478  EnergyMap const & weights,
479  Vector & F1,
480  Vector & F2
481  ) const;
482 
483 
484  /////////////////////////////////////////////////////////////////////////////
485  // methods specific to EtableEnergy:
486  /////////////////////////////////////////////////////////////////////////////
487  /// Should/Could these inlined" in a separate .inline.hh?
488 
489  // for some reason the virtual-function call to residue_pair_energy does not get passed thru to
490  // CoarseEnergyEtable... Use template based call instead...
491  ///
492  inline
493  void
495  Size const res1,
496  Size const res2,
497  pose::Pose const & pose
498  ) const {
499  static_cast< Derived const* > (this) -> derived_prepare_for_residue_pair(res1,res2,pose);
500  }
501 
502  ///
503  //inline
504  //void
505  //virtual_atom_pair_energy(EnergyMap & emap) const{
506  // emap[st_atr_]+=0.0;
507  // emap[st_rep_]+=0.0;
508  // emap[st_sol_]+=0.0;
509  // emap[coarse_beadlj]+=0.0;
510  //}
511 
512 
513  ///
514  inline
515  void
517  conformation::Atom const & atom1,
518  conformation::Atom const & atom2,
519  Real const weight,
520  EnergyMap & emap,
521  Real & dsq
522  ) const {
523  static_cast< Derived const & > (*this).interres_evaluator().atom_pair_energy(atom1,atom2,weight,emap,dsq);
524  }
525 
526  /// @brief for the trie-vs-trie algorithm; could test if the other
527  /// atom pair energy function could inline this function to avoid
528  /// the table reading code duplication.
529  inline
530  void
532  conformation::Atom const & atom1,
533  conformation::Atom const & atom2,
534  Real const weight,
535  Energy & atr,
536  Energy & rep,
537  Energy & solv,
538  Energy & bb,
539  Real & dsq
540  ) const {
541  // std::cerr << __FILE__<< ' ' << __LINE__ << std::endl;
542  ///static_cast< Derived const* > (this) -> atom_pair_energy_(atom1,atom2,weight,atr,rep,solv,bb,dsq);
543  bb = 0; /// <-- need to kill this parameter
544  static_cast< Derived const & > (*this).interres_evaluator().atom_pair_energy( atom1, atom2, weight, atr, rep, solv, dsq );
545  }
546 
547  /// APL -- consider reinstating this function!
548  // PyRosetta friendly version
549  inline void atom_pair_energy(
550  conformation::Atom const & atom1,
551  conformation::Atom const & atom2,
552  Real const weight,
553  AtomPairEnergy & ape)
554  const {
555  atom_pair_energy(atom1, atom2, weight, ape.attractive, ape.repulsive, ape.solvation, ape.bead_bead_interaction, ape.distance_squared);
556  }
557 
558 
559  ///
560  //inline
561  //void
562  //pair_energy_H(
563  // conformation::Atom const & atom1,
564  // conformation::Atom const & atom2,
565  // Real weight,
566  // Energy & atr,
567  // Energy & rep,
568  // Energy & solv,
569  // Energy & bb
570  //) const {
571  // return static_cast< Derived const* > (this) -> pair_energy_H_(atom1,atom2,weight,atr,rep,solv,bb);
572  //};
573 
574  /// APL -- Consider reinstating this function!
575  // PyRosetta friendly version
576  // inline
577  // void
578  // pair_energy_H(
579  // conformation::Atom const & atom1,
580  // conformation::Atom const & atom2,
581  // Real weight,
582  // AtomPairEnergy & ape
583  // ) const {
584  // ape.distance_squared = 0.0;
585  // pair_energy_H(atom1, atom2, weight, ape.attractive, ape.repulsive, ape.solvation, ape.bead_bead_interaction);
586  // }
587 
588  ///
589  inline
590  void
592  conformation::Atom const & atom1,
593  conformation::Atom const & atom2,
594  Real weight,
595  EnergyMap &emap
596  ) const
597  {
598  Real d2;
599  (static_cast< Derived const * > (this))->interres_evaluator().atom_pair_energy( atom1, atom2, weight, emap, d2 );
600  }
601 
602 
603 
604  ///
605 // inline
606 // Real
607 // eval_dE_dR_over_r(
608 // conformation::Atom const & atom1,
609 // conformation::Atom const & atom2,
610 // EnergyMap const & weights,
611 // Vector & f1,
612 // Vector & f2
613 // ) const {
614 // return static_cast< Derived const* > (this) -> eval_dE_dR_over_r_(atom1,atom2,weights,f1,f2);
615 // };
616 
617  ///
618  Real
620  {
622  }
623 
624  /// @brief Etable atomic distance cutoff is 5.5 A
625  virtual
626  Distance
628 
629  virtual
630  bool
632  {
633  return true;
634  }
635 
636 
637  virtual
638  void indicate_required_context_graphs( utility::vector1< bool > & /*context_graphs_required*/ ) const;
639 
640  /// Inline Methods For Trie-vs-Trie Algorithm
641 // inline
642 // Energy sum_energies ( Real atr, Real rep, Real solv, Real bb ) const {
643 // return weights_[ st_atr_ ] * atr
644 // + weights_[ st_rep_ ] * rep
645 // + weights_[ st_sol_ ] * solv
646 // + weights_ [ coarse_beadlj ] * bb;
647 // }
648 //
649 // inline
650 // Energy heavyatom_heavyatom_energy(
651 // etrie::EtableAtom const & at1,
652 // etrie::EtableAtom const & at2,
653 // DistanceSquared & d2,
654 // Size & /*path_dist*/
655 // ) const
656 // {
657 // Energy atr(0.0), rep(0.0), solv(0.0), bb(0.0);
658 // atom_pair_energy( at1, at2, 1.0, atr, rep, solv, bb, d2 );
659 // return sum_energies( atr, rep, solv, bb );
660 // }
661 //
662 // inline
663 // Energy heavyatom_hydrogenatom_energy(
664 // etrie::EtableAtom const & at1,
665 // etrie::EtableAtom const & at2,
666 // Size & /*path_dist*/
667 // ) const
668 // {
669 // Energy atr(0.0), rep(0.0), solv(0.0), bb(0.0);
670 // pair_energy_H( at1, at2, 1.0, atr, rep, solv, bb );
671 // return sum_energies( atr, rep, solv, bb );
672 // }
673 //
674 // inline
675 // Energy hydrogenatom_heavyatom_energy(
676 // etrie::EtableAtom const & at1,
677 // etrie::EtableAtom const & at2,
678 // Size & /*path_dist*/
679 // ) const
680 // {
681 // Energy atr(0.0), rep(0.0), solv(0.0), bb(0.0);
682 // pair_energy_H( at1, at2, 1.0, atr, rep, solv, bb );
683 // return sum_energies( atr, rep, solv, bb );
684 // }
685 //
686 // inline
687 // Energy hydrogenatom_hydrogenatom_energy(
688 // etrie::EtableAtom const & at1,
689 // etrie::EtableAtom const & at2,
690 // Size & /*path_dist*/
691 // ) const
692 // {
693 // Energy atr(0.0), rep(0.0), solv(0.0), bb(0.0);
694 // pair_energy_H( at1, at2, 1.0, atr, rep, solv, bb );
695 // return sum_energies( atr, rep, solv, bb );
696 // }
697 
698 protected: //protected methods that may be used by derived classes
699 
702  conformation::RotamerSetBase const & set1,
703  conformation::RotamerSetBase const & set2,
704  pose::Pose const & pose,
705  ScoreFunction const & sfxn
706  ) const;
707 
710  conformation::Residue const & res1,
711  conformation::Residue const & res2,
714  pose::Pose const & pose,
715  ScoreFunction const & sfxn
716  ) const;
717 
718  /*count_pair::CPResidueConnectionType
719  determine_residue_connection(
720  conformation::Residue const & res1,
721  conformation::Residue const & res2,
722  pose::Pose const &
723  ) const;*/
724 
727  conformation::Residue const & res1,
728  conformation::Residue const & res2,
729  pose::Pose const &,
730  ScoreFunction const & sfxn
731  ) const;
732 
735  conformation::RotamerSetBase const & rotset,
736  pose::Pose const & pose // will be need to create tries for disulfides
737  ) const;
738 
741  conformation::Residue const & residue,
742  pose::Pose const & // will be need to create tries for disulfides
743  ) const;
744 
747  conformation::RotamerSetBase const & rotset
748  ) const;
749 
752  conformation::RotamerSetBase const & rotset,
753  Size connection_type // HACK: 1 for lower connect, 2 for upper connect. Replace this with an enum(?)
754  ) const;
755 
756 protected:
757 
758  // implementation for quasi-virtual functions
759  // rename this derived_atom_pair_energy
760  //inline
761  //void
762  //atom_pair_energy_(
763  // conformation::Atom const & atom1,
764  // conformation::Atom const & atom2,
765  // Real const weight,
766  // Real &atr,
767  // Real &rep,
768  // Real &solv,
769  // Real &bb,
770  // Real & dsq
771  //) const;
772  //
773  /////
774  //inline
775  //void
776  //pair_energy_H_(
777  // conformation::Atom const & atom1,
778  // conformation::Atom const & atom2,
779  // Real const weight,
780  // Real &atr,
781  // Real &rep,
782  // Real &solv,
783  // Real &bb
784  //) const;
785 
786  ///
787  inline
788  Real
790  conformation::Atom const & atom1,
791  conformation::Atom const & atom2,
792  EnergyMap const & weights,
793  Vector & f1,
794  Vector & f2
795  ) const;
796 
797  void
799  Size const,
800  Size const,
801  pose::Pose const &
802  ) const
803  { //do nothing if the derived class does not override this method
804  }
805 
806 
807  //little helper methods for interpolation:
808  bool interpolate_bins(
809  conformation::Atom const & atom1,
810  conformation::Atom const & atom2,
811  Real &d2,
812  int &disbin,
813  Real &frac
814  ) const;
815 
816  //void
817  //set_scoretypes(
818  // ScoreType atr_type,
819  // ScoreType rep_type,
820  // ScoreType sol_type
821  //) const;
822 
823  ScoreType
824  rep_scoretype() const;
825 
826  /////////////////////////////////////////////////////////////////////////////
827  // data
828  /////////////////////////////////////////////////////////////////////////////
829 
830 protected:
831  Etable const & etable() const { return etable_; }
832 
833 private:
834  Etable const & etable_; // held as a const reference instead of as a pointer for fast access.
835 
838 
839  // temporary hack -- make this configurable/cleaner, Phil
841 
842 };
843 
844 
845 ///////////////////////////////////////////////////////////////////////////////
846 // inline methods
847 ///////////////////////////////////////////////////////////////////////////////
848 
849 
850 ///////////////////////////////////////////////////////////////////////////////
851 // inline methods
852 ///////////////////////////////////////////////////////////////////////////////
853 //template < class Derived >
854 //inline
855 //bool
856 //BaseEtableEnergy< Derived >::interpolate_bins(
857 // conformation::Atom const & atom1,
858 // conformation::Atom const & atom2,
859 // Real &d2,
860 // int &disbin,
861 // Real &frac
862 //) const
863 //{
864 // d2 = atom1.xyz().distance_squared( atom2.xyz() );
865 //
866 // if ( ( d2 >= safe_max_dis2 ) || ( d2 == Real(0.0) ) ) {
867 // return false;
868 // }
869 //
870 // // bin by distance:
871 // Real const d2_bin = d2 * etable_bins_per_A2;
872 // disbin = static_cast< int >( d2_bin ) + 1;
873 // // int const disbin2 = disbin + 1;
874 // frac = d2_bin - ( disbin - 1 );
875 // return true;
876 // //ctsa
877 // //ctsa tables have been hacked so that if disbin2 = lastbin, all values = 0.
878 // //ctsa
879 //}
880 
881 //template <class Derived>
882 //inline
883 //void
884 //BaseEtableEnergy< Derived>::atom_pair_energy_(
885 // conformation::Atom const & atom1,
886 // conformation::Atom const & atom2,
887 // Real const weight,
888 // Real &atr,
889 // Real &rep,
890 // Real &solv,
891 // Real &bb,
892 // Real & d2
893 //) const
894 //{
895 // bb = 0;
896 // etable_evaluator_->atom_pair_energy( atom1, atom2, weight, atr, rep, solv, d2 );
897 //
898 // assert( ljatr_.active() );
899 // bb = 0.0; //bead-bead interaction energy only in CoarseTable
900 // int disbin; Real frac;
901 // atr = rep = solv = bb = 0.0;
902 //
903 // //etable_.interpolated_analytic_etable_evaluation( atom1, atom2, atr, rep, solv, d2 );
904 // etable_.analytic_etable_evaluation( atom1, atom2, atr, rep, solv, d2 );
905 // atr *= weight;
906 // rep *= weight;
907 // solv *= weight;
908 // return;
909 //
910 // if (interpolate_bins(atom1,atom2,d2,disbin,frac)) {
911 //
912 //
913 // // std::cerr << "atom_pair_energy... " << disbin << ' ' << d2 << ' ' << frac << ' ' << ljatr.size() << std::endl;
914 // // l1 and l2 are FArray LINEAR INDICES for fast lookup:
915 // // [ l1 ] == (disbin,attype2,attype1)
916 // // [ l2 ] == (disbin2,attype2,attype1)
917 //
918 // int const l1 = ljatr_.index( disbin, atom1.type(), atom2.type()),
919 // l2 = l1 + 1;
920 //
921 // Real e1 = ljatr_[ l1 ];
922 // atr = weight * ( e1 + frac * ( ljatr_[ l2 ] - e1 ) );
923 //
924 // e1 = ljrep_[ l1 ];
925 // rep = weight * ( e1 + frac * ( ljrep_[ l2 ] - e1 ) );
926 //
927 // e1 = solv1_[ l1 ] + solv2_[ l1 ];
928 // solv = weight * ( e1 + frac * ( solv1_[ l2 ] + solv2_[l2] - e1 ) );
929 // // std::cout << "solv " << solv << std::endl;
930 // // std::cerr << "finished evaluating atom _pair energy " << std::endl;
931 //
932 // } //if within cutoff
933 //}
934 
935 /////////////////////////////////////////////////////////////////////////////////
936 //template <class Derived>
937 //inline
938 //Real
939 //BaseEtableEnergy< Derived >::eval_dE_dR_over_r_(
940 // conformation::Atom const & atom1,
941 // conformation::Atom const & atom2,
942 // EnergyMap const & weights,
943 // Vector & f1,
944 // Vector & f2
945 //) const
946 //{
947 // return etable_evaluator_->eval_dE_dR_over_r( atom1, atom2, weights, f1, f2 );
948 //
949 // Real d2,frac;
950 // int disbin;
951 //
952 // if ( atom1.xyz().distance_squared( atom2.xyz() ) > safe_max_dis2 ) return 0.;
953 //
954 // f1 = atom1.xyz().cross( atom2.xyz() );
955 // f2 = atom1.xyz() - atom2.xyz();
956 //
957 // Real datr, drep, dsol, invd;
958 // etable_.analytic_etable_derivatives( atom1, atom2, datr, drep, dsol, invd );
959 // return ( weights[ fa_atr ] * datr + weights[ fa_rep ] * drep + weights[ fa_sol ] * dsol ) * invd;
960 //
961 //
962 // if ( interpolate_bins(atom1,atom2,d2,disbin,frac) ) {
963 //
964 //
965 // f1 = atom1.xyz().cross( atom2.xyz() );
966 // f2 = atom1.xyz() - atom2.xyz();
967 //
968 // // l1 and l2 are FArray LINEAR INDICES for fast lookup:
969 // // [ l1 ] == (disbin ,attype2,attype1)
970 // // [ l2 ] == (disbin+1,attype2,attype1)
971 //
972 // /// BEGIN DERIVATIVE INTERPOLATION
973 // Real deriv = 0.0;
974 //
975 // int const l1 = dljatr_.index( disbin, atom1.type(), atom2.type()),
976 // l2 = l1 + 1;
977 //
978 // Real e1 = dljatr_[ l1 ];
979 // deriv = weights[ st_atr_] * ( e1 + frac * ( dljatr_[ l2 ] - e1 ) );
980 //
981 // e1 = dljrep_[ l1 ];
982 // deriv += weights[ st_rep_ ] * ( e1 + frac * ( dljrep_[ l2 ] - e1 ) );
983 //
984 // e1 = dsolv_[ l1 ];
985 // deriv += weights[ st_sol_ ] * ( e1 + frac * ( dsolv_[ l2 ] - e1 ) );
986 //
987 // return deriv / std::sqrt( d2 );
988 //
989 // /// BEGIN EXACT DERIVATIVE CALCULATION
990 //
991 // /*Real deriv( 0.0 );
992 // int const l1 = ljatr_.index( disbin, atom1.type(), atom2.type()),
993 // l2 = l1 + 1;
994 //
995 // // d g(x) / dx with g(x) = x^2 ---> 2x; x is the distance
996 // // we want to avoid the sqrt. Since at1-at2 (f2) already is the right length, consider it pre-multiplied by sqrt(d2).
997 // // so what we have below is 2x / ( d2step * x ) = 2 / d2step = 2 * inv(d2step). This will be multiplied by the un-normalized f1 and f2 vectors.
998 // Real dxsquared_dx_times_x2step_over_x = 2 * etable_bins_per_A2;
999 //
1000 // Real const atr1 = ljatr_[ l1 ];
1001 // Real const atr2 = ljatr_[ l2 ];
1002 // Real const rep1 = ljrep_[ l1 ];
1003 // Real const rep2 = ljrep_[ l2 ];
1004 // Real const sol1 = solv1_[ l1 ] + solv2_[ l1 ];
1005 // Real const sol2 = solv1_[ l2 ] + solv2_[ l2 ];
1006 //
1007 // deriv = weights[ st_atr_ ] * ( atr2 - atr1 );
1008 // deriv += weights[ st_rep_ ] * ( rep2 - rep1 );
1009 // deriv += weights[ st_sol_ ] * ( sol2 - sol1 );
1010 //
1011 // return deriv * dxsquared_dx_times_x2step_over_x;*/
1012 //
1013 // /// TEMP
1014 // /*
1015 // std::cout << "Testing numerically: ";
1016 // Real f11( 0.0 );
1017 // Real step = 0.00001;
1018 // {// scope
1019 // Real altd = std::sqrt( d2 ) - step;
1020 // Real altd2 = altd*altd;
1021 // Real altfrac = ( altd2 * etable_bins_per_A2 - ( disbin - 1 ) );
1022 // int const altl1 = ljatr_.index( disbin, atom1.type(), atom2.type()),
1023 // altl2 = altl1 + 1;
1024 //
1025 //
1026 // Real e1 = ljatr_[ altl1 ];
1027 // f11 = weights[ st_atr_ ] * ( e1 + altfrac * ( ljatr_[ altl2 ] - e1 ) );
1028 //
1029 // e1 = ljrep_[ altl1 ];
1030 // f11 += weights[ st_rep_ ] * ( e1 + altfrac * ( ljrep_[ altl2 ] - e1 ) );
1031 //
1032 // e1 = solv1_[ altl1 ] + solv2_[ altl1 ];
1033 // f11 += weights[ st_sol_ ] * ( e1 + altfrac * ( solv1_[ altl2 ] + solv2_[altl2] - e1 ) );
1034 // }
1035 //
1036 // Real f22(0.0);
1037 // {// scope
1038 // Real altd = std::sqrt( d2 ) + step;
1039 // Real altd2 = altd*altd;
1040 // Real altfrac = ( altd2 * etable_bins_per_A2 - ( disbin - 1 ) );
1041 // int const altl1 = ljatr_.index( disbin, atom1.type(), atom2.type()),
1042 // altl2 = altl1 + 1;
1043 //
1044 //
1045 // Real e1 = ljatr_[ altl1 ];
1046 // f22 = weights[ st_atr_ ] * ( e1 + altfrac * ( ljatr_[ altl2 ] - e1 ) );
1047 //
1048 // e1 = ljrep_[ altl1 ];
1049 // f22 += weights[ st_rep_ ] * ( e1 + altfrac * ( ljrep_[ altl2 ] - e1 ) );
1050 //
1051 // e1 = solv1_[ altl1 ] + solv2_[ altl1 ];
1052 // f22 += weights[ st_sol_ ] * ( e1 + altfrac * ( solv1_[ altl2 ] + solv2_[altl2] - e1 ) );
1053 // }
1054 // std::cout << "Deriv discrep: " << ( f22 - f11 ) / (2 * step ) << " vs " << deriv * dxsquared_dx_times_x2step_over_x * std::sqrt( d2 ) << std::endl;
1055 // */
1056 //
1057 // } else {
1058 // return 0.0;
1059 // }
1060 //}
1061 
1062 
1063 //template < class Derived >
1064 //inline
1065 //void
1066 //BaseEtableEnergy< Derived >::pair_energy_H(
1067 // conformation::Atom const & atom1,
1068 // conformation::Atom const & atom2,
1069 // Real weight,
1070 // EnergyMap &emap
1071 //) const {
1072 // Energy atr(0.0);
1073 // Energy rep(0.0);
1074 // Energy solv(0.0);
1075 // Energy bb(0.0);
1076 // pair_energy_H(atom1,atom2,weight,atr,rep,solv,bb);
1077 // emap[st_atr_]+=atr;
1078 // emap[st_rep_]+=rep;
1079 // emap[st_sol_]+=solv;
1080 // emap[ coarse_beadlj ]+=bb;
1081 //}
1082 
1083 
1084 
1085 ///////////////////////////////////////////////////////////////////////////////
1086 //template < class Derived >
1087 //inline
1088 //void
1089 //BaseEtableEnergy< Derived >::pair_energy_H_(
1090 // conformation::Atom const & atom1,
1091 // conformation::Atom const & atom2,
1092 // Real const weight,
1093 // Real &atr,
1094 // Real &rep,
1095 // Real &solv,
1096 // Real &bb
1097 //) const
1098 //{
1099 // bb = 0;
1100 // Real dis2;
1101 // return etable_evaluator_->atom_pair_energy( atom1, atom2, weight, atr, rep, solv, dis2 );
1102 // assert( ljrep_.active() );
1103 // Real d2,frac;
1104 // int disbin;
1105 // atr = rep = solv = bb = 0.0;
1106 // //etable_.interpolated_analytic_etable_evaluation( atom1, atom2, atr, rep, solv, d2 );
1107 // etable_.analytic_etable_evaluation( atom1, atom2, atr, rep, solv, d2 );
1108 // atr *= weight;
1109 // rep *= weight;
1110 // solv *= weight;
1111 // return;
1112 //
1113 // if (interpolate_bins(atom1,atom2,d2,disbin,frac)) {
1114 //
1115 //
1116 //
1117 // //ctsa
1118 // //ctsa tables have been hacked so that if disbin2 = lastbin, all values = 0.
1119 // //ctsa
1120 //
1121 // // l is an FArray LINEAR INDICES for fast lookup:
1122 // // [ ll ] == (disbin,attype2,attype1)
1123 //
1124 // int l1 = ljrep_.index( disbin, atom1.type(), atom2.type() );
1125 // int l2 = l1+1;
1126 //
1127 // Real const rep_e1( ljrep_[ l1 ] );
1128 // rep = weight * ( rep_e1 + frac * ( ljrep_[ l2 ] - rep_e1 ) );
1129 //
1130 // Real const atr_e1 = ljatr_[ l1 ];
1131 // atr = weight * ( atr_e1 + frac * ( ljatr_[ l2 ] - atr_e1 ) );
1132 // // std::cerr << __FILE__<< ' ' << __LINE__ << std::endl;
1133 //
1134 // }
1135 //}
1136 
1137 } // etable
1138 } // scoring
1139 } // core
1140 
1141 
1142 #endif // INCLUDED_core_scoring_EtableEnergy_HH