Esempio n. 1
0
IMPATOM_BEGIN_INTERNAL_NAMESPACE

void add_dihedral_to_list(const CHARMMParameters *param, kernel::Particle *p1,
                          kernel::Particle *p2, kernel::Particle *p3,
                          kernel::Particle *p4, kernel::Particles &ps) {
  try {
    base::Vector<CHARMMDihedralParameters> p = param->get_dihedral_parameters(
        CHARMMAtom(p1).get_charmm_type(), CHARMMAtom(p2).get_charmm_type(),
        CHARMMAtom(p3).get_charmm_type(), CHARMMAtom(p4).get_charmm_type());
    for (base::Vector<CHARMMDihedralParameters>::const_iterator it = p.begin();
         it != p.end(); ++it) {
      Dihedral dd = Dihedral::setup_particle(
          new kernel::Particle(p1->get_model()), core::XYZ(p1), core::XYZ(p2),
          core::XYZ(p3), core::XYZ(p4));
      dd.set_ideal(it->ideal / 180.0 * PI);
      dd.set_multiplicity(it->multiplicity);
      if (it->force_constant < 0.0) {
        dd.set_stiffness(-std::sqrt(-it->force_constant * 2.0));
      } else {
        dd.set_stiffness(std::sqrt(it->force_constant * 2.0));
      }
      ps.push_back(dd);
    }
  }
  catch (const base::IndexException &e) {
    // If no parameters, warn, and create an empty dihedral
    IMP_WARN(e.what() << std::endl);
    Dihedral dd = Dihedral::setup_particle(
        new kernel::Particle(p1->get_model()), core::XYZ(p1), core::XYZ(p2),
        core::XYZ(p3), core::XYZ(p4));
    ps.push_back(dd);
  }
}
Esempio n. 2
0
void CHARMMParameters::add_angle(kernel::Particle *p1, kernel::Particle *p2,
                                 kernel::Particle *p3,
                                 kernel::Particles &ps) const {
  IMP_OBJECT_LOG;
  Angle ad = Angle::setup_particle(new kernel::Particle(p1->get_model()),
                                   core::XYZ(p1), core::XYZ(p2), core::XYZ(p3));
  try {
    const CHARMMBondParameters &p = get_angle_parameters(
        CHARMMAtom(p1).get_charmm_type(), CHARMMAtom(p2).get_charmm_type(),
        CHARMMAtom(p3).get_charmm_type());
    ad.set_ideal(p.ideal / 180.0 * PI);
    ad.set_stiffness(std::sqrt(p.force_constant * 2.0));
  }
  catch (const base::IndexException &e) {
    // If no parameters, warn only
    IMP_WARN(e.what());
  }
  ps.push_back(ad);
}