19 #include <numeric/deriv/angle_deriv.hh>
20 #include <numeric/deriv/distance_deriv.hh>
32 #include <basic/Tracer.hh>
34 #include <utility/vector1.hh>
36 #include <numeric/xyzVector.hh>
37 #include <numeric/conversions.hh>
42 #include <basic/options/keys/OptionKeys.hh>
43 #include <basic/options/keys/in.OptionKeys.gen.hh>
44 #include <basic/options/option.hh>
69 static basic::Tracer
TR(
"core.scoring.orbitals_hpol");
73 lookup_table_(core::scoring::
ScoringManager::get_instance()->get_OrbitalsLookupTable()),
74 max_orbital_dist_squared_(9),
78 if(basic::options::option[ basic::options::OptionKeys::in::add_orbitals] != 1){
79 utility_exit_with_message(
"Trying to run features test without orbitals! Pass the flag -add_orbitals!" );
225 }
else {
return false;}
296 chemical::AtomIndices::const_iterator
299 Aindex != Aindex_end; ++Aindex
303 chemical::AtomIndices::const_iterator
306 Dindex != Dindex_end; ++Dindex
313 res1_orb = res1_orbs.begin(),
314 res1_orb_end = res1_orbs.end();
315 res1_orb != res1_orb_end; ++res1_orb
321 res2_orb = res2_orbs.begin(),
322 res2_orb_end = res2_orbs.end();
323 res2_orb != res2_orb_end; ++res2_orb
330 core::Real const orb1_orb2_dist= res1_Orbxyz.distance_squared(res2_Orbxyz);
331 if(orb1_orb2_dist < 16){
332 core::Real const dist(std::sqrt(orb1_orb2_dist));
335 core::Real const cosAOD(cos_of(Axyz, res1_Orbxyz, Dxyz));
336 core::Real const cosDOA(cos_of(Dxyz, res2_Orbxyz, Axyz));
340 add_orb_orb_E +=orb_orb_E;
343 add_orb_orb_E +=orb_orb_E;
354 orb_orb_E=add_orb_orb_E;
366 chemical::AtomIndices::const_iterator
369 atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
375 chemical::AtomIndices::const_iterator
378 haro_index != haro_end; ++haro_index
382 core::Real temp_dist = Axyz.distance_squared(Hxyz);
383 if ( temp_dist < max_dist_squared ) {
404 chemical::AtomIndices::const_iterator
407 atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
412 chemical::AtomIndices::const_iterator
415 hpol_index != hpol_end; ++hpol_index
426 core::Real temp_dist = Axyz.distance_squared(Hxyz);
427 if ( temp_dist < max_dist_squared ) {
459 orbital_index = orbital_indices.begin(),
460 orbital_index_end = orbital_indices.end();
461 orbital_index != orbital_index_end; ++orbital_index
465 core::Real temp_dist_squared = Orbxyz.distance_squared( Hxyz );
474 core::Real cosDHO(cos_of(Dxyz, Hxyz, Orbxyz));
475 core::Real cosAOH(cos_of(Axyz, Orbxyz, Hxyz));
476 core::Real dist(std::sqrt(temp_dist_squared));
479 added_bb_h_energy += bb_h_energy;
482 added_bb_h_energy += bb_h_energy;
485 added_sc_energy += sc_energy;
492 if(*orbital_index<=2){
494 added_sc_energy += sc_energy;
498 added_sc_energy += sc_energy;
502 added_sc_energy += sc_energy;
507 bb_h_energy = added_bb_h_energy;
508 sc_energy = added_sc_energy;
556 chemical::AtomIndices::const_iterator
559 atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
564 chemical::AtomIndices::const_iterator
567 haro_index != haro_end; ++haro_index
572 core::Real temp_dist = Axyz.distance_squared(Hxyz);
573 if ( temp_dist < max_dist_squared ) {
577 res1, res2, atom_index, Axyz, H_index, Hxyz,
597 chemical::AtomIndices::const_iterator
600 atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
604 chemical::AtomIndices::const_iterator
607 hpol_index != hpol_end; ++hpol_index
617 core::Real temp_dist = Axyz.distance_squared(Hxyz);
618 if ( temp_dist < max_dist_squared ) {
623 res1, res2, atom_index, Axyz, H_index, Hxyz,
628 res1, res2, atom_index, Axyz, H_index, Hxyz,
648 chemical::AtomIndices::const_iterator
651 Aindex != Aindex_end; ++Aindex
655 chemical::AtomIndices::const_iterator
658 Dindex != Dindex_end; ++Dindex
666 res1_orb = res1_orbs.begin(),
667 res1_orb_end = res1_orbs.end();
668 res1_orb != res1_orb_end; ++res1_orb
674 res2_orb = res2_orbs.begin(),
675 res2_orb_end = res2_orbs.end();
676 res2_orb != res2_orb_end; ++res2_orb
682 core::Real orb1_orb2_dist= res1_Orbxyz.distance_squared(res2_Orbxyz);
683 if(orb1_orb2_dist < 16){
687 core::Real cosAOD(cos_of(Axyz, res1_Orbxyz, Dxyz));
688 core::Real cosDOA(cos_of(Dxyz, res2_Orbxyz, Axyz));
709 numeric::deriv::angle_p1_deriv( pD, pDH, pO, tau, f1ab, f2ab );
710 numeric::deriv::angle_p2_deriv( pD, pDH, pO, tau, f1ao, f2ao );
711 numeric::deriv::angle_p1_deriv( pO, pDH, pD, tau, f1h, f2h );
714 Real neg_sine_tau = -sin( tau );
717 r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
718 r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
720 r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
721 r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
723 r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1h;
724 r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2h;
729 numeric::deriv::distance_f1_f2_deriv( pDH, res1_Orbxyz, dis, f1ao, f2ao );
731 r2_atom_derivs[ *Dindex ].f1() += weight * d_deriv * f1ao;
732 r2_atom_derivs[ *Dindex ].f2() += weight * d_deriv * f2ao;
734 r1_atom_derivs[ *Aindex ].f1() -= weight * d_deriv * f1ao;
735 r1_atom_derivs[ *Aindex ].f2() -= weight * d_deriv * f2ao;
749 f1ab=f2ab=f1ao=f2ao=f1h=f2h=0;
754 numeric::deriv::angle_p1_deriv( pAB, pAO, pH, tau, f1ab, f2ab );
755 numeric::deriv::angle_p2_deriv( pAB, pAO, pH, tau, f1ao, f2ao );
756 numeric::deriv::angle_p1_deriv( pH, pAO, pAB, tau, f1h, f2h );
758 neg_sine_tau = -sin( tau );
761 r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
762 r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
764 r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
765 r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
767 r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1h;
768 r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2h;
772 numeric::deriv::distance_f1_f2_deriv( pAO, res2_Orbxyz, dis, f1ao, f2ao );
774 r1_atom_derivs[ *Aindex ].f1() += weight * d_deriv * f1ao;
775 r1_atom_derivs[ *Aindex ].f2() += weight * d_deriv * f2ao;
777 r2_atom_derivs[ *Dindex ].f1() -= weight * d_deriv * f1ao;
778 r2_atom_derivs[ *Dindex ].f2() -= weight * d_deriv * f2ao;
826 orbital_index = orbital_indices.begin(),
827 orbital_index_end = orbital_indices.end();
828 orbital_index != orbital_index_end; ++orbital_index
832 core::Real temp_dist_squared = Orbxyz.distance_squared( Hxyz );
848 core::Real cosDHO(cos_of(Dxyz, Hxyz, Orbxyz ));
849 core::Real OrbHdist(std::sqrt(temp_dist_squared));
865 core::Size orbital_surrogate_atom_index = atom_index;
867 numeric::deriv::angle_p1_deriv( pD, pDH, pO, tau, f1ab, f2ab );
868 numeric::deriv::angle_p2_deriv( pD, pDH, pO, tau, f1ao, f2ao );
869 numeric::deriv::angle_p1_deriv( pO, pDH, pD, tau, f1h, f2h );
872 Real neg_sine_tau = -sin( tau );
875 r2_atom_derivs[ H_index ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
876 r2_atom_derivs[ H_index ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
878 r2_atom_derivs[ donor_index ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
879 r2_atom_derivs[ donor_index ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
881 r1_atom_derivs[ atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1h;
882 r1_atom_derivs[ atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2h;
887 numeric::deriv::distance_f1_f2_deriv( pDH, pO, dis, f1ao, f2ao );
889 r2_atom_derivs[ donor_index ].f1() += weight * d_deriv * f1ao;
890 r2_atom_derivs[ donor_index ].f2() += weight * d_deriv * f2ao;
892 r1_atom_derivs[ atom_index ].f1() -= weight * d_deriv * f1ao;
893 r1_atom_derivs[ atom_index ].f2() -= weight * d_deriv * f2ao;
899 core::Real cosAOH(cos_of(Axyz, Orbxyz, Hxyz));
906 if(*orbital_index<=2){
923 f1ab=f2ab=f1ao=f2ao=f1h=f2h=0;
928 numeric::deriv::angle_p1_deriv( pAB, pAO, pH, tau, f1ab, f2ab );
929 numeric::deriv::angle_p2_deriv( pAB, pAO, pH, tau, f1ao, f2ao );
930 numeric::deriv::angle_p1_deriv( pH, pAO, pAB, tau, f1h, f2h );
932 neg_sine_tau = -sin( tau );
935 r1_atom_derivs[ atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
936 r1_atom_derivs[ atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
938 r1_atom_derivs[ orbital_surrogate_atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
939 r1_atom_derivs[ orbital_surrogate_atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
941 r2_atom_derivs[ H_index ].f1() += weight * neg_sine_tau * a_deriv * f1h;
942 r2_atom_derivs[ H_index ].f2() += weight * neg_sine_tau * a_deriv * f2h;
946 numeric::deriv::distance_f1_f2_deriv( pAO, pH, dis, f1ao, f2ao );
948 r1_atom_derivs[ orbital_surrogate_atom_index ].f1() += weight * d_deriv * f1ao;
949 r1_atom_derivs[ orbital_surrogate_atom_index ].f2() += weight * d_deriv * f2ao;
951 r2_atom_derivs[ H_index ].f1() -= weight * d_deriv * f1ao;
952 r2_atom_derivs[ H_index ].f2() -= weight * d_deriv * f2ao;