25 #include <basic/database/open.hh>
26 #include <basic/options/option.hh>
27 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
30 #include <utility/io/izstream.hh>
32 #include <numeric/conversions.hh>
37 #include <basic/options/keys/OptionKeys.hh>
39 #include <utility/vector1.hh>
40 #include <numeric/xyzVector.hh>
45 namespace carbon_hbonds {
51 aroC_scale_factor_( 2.0 ),
52 num_carbon_donor_atoms_( 5 ),
54 rna_cos_theta_cutoff_( cos( numeric::conversions::radians( 60.0 ) ) ),
55 rna_cos_theta_fade_zone_( 0.2 ),
56 rna_ch_o_bond_distance_( 2.35 )
68 if (*iter == element)
return count;
71 vec.push_back( element );
79 using namespace basic::options;
80 using namespace basic::options::OptionKeys::corrections::score;
83 utility::io::izstream stream;
86 stream.open( option[ ch_o_bond_potential ] );
88 if ( !stream.good() ) {
90 basic::database::open( stream, option[ ch_o_bond_potential ] );
97 ObjexxFCL::FArray1D<Real> new_array;
103 if ( !stream.good() ) utility_exit_with_message(
"Unable to open ch_o_bond_potential!" );
106 Real bin_min, bin_max, value;
109 while ( getline( stream, line ) ) {
110 std::istringstream l( line );
111 l >> atom_name >> bin_min >> bin_max >> value;
136 Size const standard_atomtype_index = atom_type_set.atom_type_index(
carbon_donors_[i] );
171 bool const & update_deriv,
176 Real const r = r_vec.length();
177 Real const z = dot( z_i, r_vec );
178 Real const cos_kappa = z / r;
181 Real angle_fade_value( 1.0 ), angle_fade_deriv( 0.0 );
183 Real score = angle_fade_value;
186 Real const d_H_A = r_vec.length();
189 Real const lj_style_distance_dependence = ( 1.0/std::pow(scaled_dist_H_A, 8) - 2.0/std::pow(scaled_dist_H_A, 4) );
190 score *= lj_style_distance_dependence;
192 Real distance_fade_value( 1.0 ), distance_fade_deriv( 0.0 );
194 score *= distance_fade_value;
196 if ( update_deriv ) {
197 Real const dEdcoskappa( angle_fade_deriv * lj_style_distance_dependence);
199 Real dEdr = angle_fade_value * distance_fade_value * ( -8.0/
rna_ch_o_bond_distance_ ) * ( 1.0/std::pow( scaled_dist_H_A, 9) - 1.0/std::pow( scaled_dist_H_A, 5) );
200 dEdr += angle_fade_value * distance_fade_deriv * lj_style_distance_dependence;
203 Vector x_i = r_vec - z_i * dot(r_vec,z_i);
204 Real const x = x_i.length();
205 x_i = x_i.normalize();
207 Real const dEdx = dEdr * (x/r) + ( - x * z ) * dEdcoskappa / (r * r * r);
208 Real const dEdz = dEdr * (z/r) + ( r*r - z*z) * dEdcoskappa / (r * r * r);
210 deriv_vector = dEdx * x_i + dEdz * z_i;
221 Size const & atom_type_index,
222 Vector const & H_A_vector,
223 Vector const & D_H_vector,
224 Vector const & B_A_vector,
225 bool calculate_deriv,
231 Real dist_H_A = H_A_vector.length();
232 Vector H_A_norm_vector ( H_A_vector ); H_A_norm_vector.normalize();
233 Vector D_H_norm_vector ( D_H_vector ); D_H_norm_vector.normalize();
234 Vector B_A_norm_vector ( B_A_vector ); B_A_norm_vector.normalize();
236 Real neg_cos_theta = dot ( H_A_norm_vector, D_H_norm_vector );
237 Real neg_cos_psi = -dot ( H_A_norm_vector, B_A_norm_vector );
240 if ( carbon_donor_index == 0 )
return 0.0;
242 Real dist_value( 0.0 );
247 dist_H_A, dist_value, dEdHA );
249 Real theta_fade_value( 1.0 ), theta_fade_deriv( 0.0 );
250 Real psi_fade_value( 1.0 ), psi_fade_deriv( 0.0 );
254 Real const value( dist_value * theta_fade_value * psi_fade_value );
256 if ( ! calculate_deriv )
return value;
258 deriv_vector = -dEdHA * theta_fade_value * psi_fade_value * H_A_norm_vector;
260 Real neg_sin_theta = -(cross(D_H_norm_vector, H_A_norm_vector)).length();
261 Vector theta_i = -cross( cross(D_H_norm_vector, H_A_norm_vector), H_A_norm_vector);
263 Vector theta_fade_gradient = (1./ dist_H_A) * theta_fade_deriv * neg_sin_theta * theta_i;
264 deriv_vector += dist_value * psi_fade_value * theta_fade_gradient;
266 Real neg_sin_psi = -(cross(B_A_norm_vector, H_A_norm_vector)).length();
267 Vector psi_i = cross( cross(B_A_norm_vector, H_A_norm_vector), H_A_norm_vector);
269 Vector psi_fade_gradient = (1. / dist_H_A) * psi_fade_deriv * neg_sin_psi * psi_i;
270 deriv_vector += dist_value * theta_fade_value * psi_fade_gradient;
309 Size const & atom_type_index,
310 Vector const & H_A_vector,
311 Vector const & D_H_vector,
316 return get_potential(atom_type_index, H_A_vector, D_H_vector, B_A_vector,
false, deriv_vector);