コード例 #1
0
ModelObjectsTemp WeightedDerivativesToRefined::do_get_inputs(
    Model *m, const ParticleIndexes &pis) const {
  ModelObjectsTemp ret = refiner_->get_inputs(m, pis);
  for (unsigned int i = 0; i < pis.size(); ++i) {
    ret +=
        IMP::get_particles(m, refiner_->get_refined_indexes(m, pis[i]));
  }
  ret += IMP::get_particles(m, pis);
  return ret;
}
コード例 #2
0
ファイル: BondedPairFilter.cpp プロジェクト: AljGaber/imp
ModelObjectsTemp BondedPairFilter::do_get_inputs(
    Model *m, const ParticleIndexes &pis) const {
  ModelObjectsTemp ret = IMP::get_particles(m, pis);
  for (unsigned int i = 0; i < pis.size(); ++i) {
    if (Bonded::get_is_setup(m, pis[i])) {
      Bonded b(m, pis[i]);
      for (unsigned int i = 0; i < b.get_number_of_bonds(); ++i) {
        ret.push_back(b.get_bond(i));
      }
    }
  }
  return ret;
}
コード例 #3
0
void MolecularDynamics::propagate_velocities(const ParticleIndexes &ps,
                                             double ts) {
  for (unsigned int i = 0; i < ps.size(); ++i) {
    Float invmass = 1.0 / Mass(get_model(), ps[i]).get_mass();
    core::XYZ d(get_model(), ps[i]);
    algebra::Vector3D dcoord = d.get_derivatives();
    LinearVelocity v(get_model(), ps[i]);
    // calculate velocity at t+(delta t) from that at t+(delta t/2)
    algebra::Vector3D velocity = v.get_velocity();
    velocity += 0.5 * dcoord * deriv_to_acceleration * invmass * ts;
    v.set_velocity(velocity);
  }
}
コード例 #4
0
ファイル: tunneler_helpers.cpp プロジェクト: salilab/imp
Coord get_coordinates_from_rbs(Model* m, ParticleIndexes pis,
                               ParticleIndex refidx) {
  // get current reference frame of rbs
  Referential ref(m, refidx);
  // get x
  Coord x;
  for (unsigned i = 0; i < pis.size(); i++) {
    internal::Referential target(m, pis[i]);
    x.coms.push_back(ref.get_local_coords(target.get_centroid()));
    x.quats.push_back(ref.get_local_rotation(target.get_rotation()));
  }
  return x;
}
コード例 #5
0
ModelObjectsTemp SameResiduePairFilter::do_get_inputs(
    Model *m, const ParticleIndexes &pis) const {
  ModelObjectsTemp ret = IMP::get_particles(m, pis);
  for (unsigned int i = 0; i < pis.size(); ++i) {
    if (Atom::get_is_setup(m, pis[i])) {
      Particle *parent = Hierarchy(m, pis[i]).get_parent();
      if (parent) {
        ret.push_back(parent);
      }
    }
  }
  return ret;
}
コード例 #6
0
/* This is implemented like this so that it doesn't read any particles other
   than a and b. To do otherwise would make it rather annoying to use in
   evaluate.
*/
Bond get_bond(Bonded a, Bonded b) {
  if (a == b) return Bond();
  ParticleIndexes ba = a.get_bond_indexes();
  ParticleIndexes bb = b.get_bond_indexes();
  std::sort(bb.begin(), bb.end());
  for (unsigned int i = 0; i < ba.size(); ++i) {
    if (std::binary_search(bb.begin(), bb.end(), ba[i])) {
      return Bond(a.get_model(), ba[i]);
    }
  }
  return Bond();
}
コード例 #7
0
ファイル: RevoluteJointMover.cpp プロジェクト: salilab/imp
core::MonteCarloMoverResult RevoluteJointMover::do_propose() {
  IMP_OBJECT_LOG;
  boost::normal_distribution<double> mrng(0, stddev_);
  boost::variate_generator<RandomNumberGenerator &,
                           boost::normal_distribution<double> >
      sampler(random_number_generator, mrng);

  for (unsigned int i = 0; i < joints_.size(); ++i) {
    originals_[i] = joints_[i]->get_angle();
    joints_[i]->set_angle(originals_[i] + sampler());
  }
  //get changed particles' coordinates
  ParticleIndexes idx;
  core::RigidMembers tmp(joints_[0]->get_parent_node().get_rigid_members());
  for (unsigned int i = 0; i < tmp.size(); ++i)
      idx.push_back(tmp[i]->get_index());
  for (unsigned int j = 0; j < joints_.size(); ++j) {
      tmp = joints_[j]->get_child_node().get_rigid_members();
      for (unsigned int i = 0; i < tmp.size(); ++i)
          idx.push_back(tmp[i]->get_index());
  }
  return core::MonteCarloMoverResult(idx, 1.0);
}
コード例 #8
0
void MolecularDynamics::setup_degrees_of_freedom(
    const ParticleIndexes &ps) {
  degrees_of_freedom_ = 3 * ps.size();

  // If global rotation and translation have been removed, reduce degrees
  // of freedom accordingly (kind of ugly...)
  for (OptimizerStateIterator o = optimizer_states_begin();
       o != optimizer_states_end(); ++o) {
    OptimizerState *os = *o;
    if (dynamic_cast<RemoveRigidMotionOptimizerState *>(os)) {
      degrees_of_freedom_ -= 6;
      break;
    }
  }
}
コード例 #9
0
ファイル: MolecularDynamics.cpp プロジェクト: drussel/imp
void MolecularDynamics::propagate_velocities(const ParticleIndexes &ps,
                                             double ts)
{
  for (unsigned int i=0; i< ps.size(); ++i) {
    Float invmass = 1.0 / Mass(get_model(), ps[i]).get_mass();
    for (unsigned j = 0; j < 3; ++j) {
      core::XYZ d(get_model(), ps[i]);
      Float dcoord = d.get_derivative(j);

      // calculate velocity at t+(delta t) from that at t+(delta t/2)
      Float velocity = get_model()->get_attribute(vs_[j], ps[i]);
      velocity += 0.5 * dcoord * deriv_to_acceleration * invmass * ts;

      get_model()->set_attribute(vs_[j], ps[i], velocity);
    }
  }
}
コード例 #10
0
void HierarchyLoadXYZs::setup_particle(
    RMF::NodeConstHandle n, Model *m, ParticleIndex p,
    const ParticleIndexes &rigid_bodies) {
  if (!ip_factory_.get_is(n)) return;
  if (!core::XYZ::get_is_setup(m, p)) core::XYZ::setup_particle(m, p);
  /* If there is a rigid body parent set up, add this particle as a child
     (unless it's an old-style rigid body, in which case this has been
     done already) */
  if (!rigid_bodies.empty()
      && !(rigid_bodies.size()==1 && rigid_bodies.back() == p)
      && !n.get_has_value(rb_index_key_)) {
    core::RigidBody rb(m, rigid_bodies.back());
    /* For nested rigid bodies, this XYZ particle is *also* the rigid body.
       So don't make ourselves our own child - add to the parent rigid body
       instead. */
    if (rigid_bodies.back() == p) {
      IMP_INTERNAL_CHECK(rigid_bodies.size() >= 2,
                     "Nested rigid body " << m->get_particle_name(p)
                     << " but could not find parent rigid body");
      rb = core::RigidBody(m, rigid_bodies[rigid_bodies.size() - 2]);
    }
    rb.add_member(p);
    if (reference_frame_factory_.get_is(n)
        && !reference_frame_factory_.get_is_static(n)) {
      IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p)
                      << " is not static and is also a rigid body"
                      << std::endl);
      rb.set_is_rigid_member(p, false);
    } else if (!ip_factory_.get_is_static(n)) {
      IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p)
                                         << " is not static" << std::endl);
      rb.set_is_rigid_member(p, false);
    } else {
      IMP_LOG_VERBOSE("Member particle " << m->get_particle_name(p)
                                         << " is static" << std::endl);
      rb.set_is_rigid_member(p, true);
      core::RigidBodyMember(m, p)
          .set_internal_coordinates(get_coordinates(n, ip_factory_));
    }
  }
  link_particle(n, m, p, rigid_bodies);
}
コード例 #11
0
void XYZRMovedSingletonContainer::validate() const {
  IMP_OBJECT_LOG;
  ParticleIndexes pis = get_singleton_container()->get_indexes();
  IMP_USAGE_CHECK(pis.size() == backup_.size(), "Backup is not the right size");
}