Exemplo n.º 1
0
BondData &get_bond_data() {
  static BondData d = {
      IntKey("bond type"),                   IntKey("bond order"),
      FloatKey("bond length"),               FloatKey("bond stiffness"),
      IMP::core::internal::GraphData("bond")};
  return d;
}
Exemplo n.º 2
0
void MolecularDynamicsMover::do_reject() {
  IMP_OBJECT_LOG;
  ParticlesTemp ps = md_->get_simulation_particles();
  unsigned nparts = ps.size();
  IMP_USAGE_CHECK(coordinates_.size() == ps.size(),
                  "The list of particles that move has been changed!");
  IMP_USAGE_CHECK(velocities_.size() == ps.size(),
                  "The list of particles that move has been changed!");
  for (unsigned i = 0; i < nparts; i++) {
    bool isnuisance = Nuisance::get_is_setup(ps[i]);
    bool isxyz = core::XYZ::get_is_setup(ps[i]);
    IMP_USAGE_CHECK(isnuisance || isxyz,
                    "Particle " << ps[i] << " is neither nuisance nor xyz!");
    if (isnuisance) {
      IMP_USAGE_CHECK(coordinates_[i].size() == 1,
                      "wrong size for coordinates_[" << i << "] !");
      IMP_USAGE_CHECK(velocities_[i].size() == 1, "wrong size for velocities_["
                                                      << i << "] !");
      Nuisance(ps[i]).set_nuisance(coordinates_[i][0]);
      ps[i]->set_value(FloatKey("vel"), velocities_[i][0]);
    }
    if (isxyz) {
      IMP_USAGE_CHECK(coordinates_[i].size() == 3,
                      "wrong size for coordinates_[" << i << "] !");
      IMP_USAGE_CHECK(velocities_[i].size() == 3, "wrong size for velocities_["
                                                      << i << "] !");
      core::XYZ(ps[i]).set_coordinate(0, coordinates_[i][0]);
      core::XYZ(ps[i]).set_coordinate(1, coordinates_[i][1]);
      core::XYZ(ps[i]).set_coordinate(2, coordinates_[i][2]);
      ps[i]->set_value(FloatKey("vx"), velocities_[i][0]);
      ps[i]->set_value(FloatKey("vy"), velocities_[i][1]);
      ps[i]->set_value(FloatKey("vz"), velocities_[i][2]);
    }
  }
}
Exemplo n.º 3
0
void MolecularDynamicsMover::save_coordinates() {
  IMP_OBJECT_LOG;
  ParticlesTemp ps = md_->get_simulation_particles();
  unsigned nparts = ps.size();
  coordinates_.clear();
  coordinates_.reserve(nparts);
  velocities_.clear();
  velocities_.reserve(nparts);
  for (unsigned i = 0; i < nparts; i++) {
    bool isnuisance = Nuisance::get_is_setup(ps[i]);
    bool isxyz = core::XYZ::get_is_setup(ps[i]);
    IMP_USAGE_CHECK(isnuisance || isxyz,
                    "Particle " << ps[i] << " is neither nuisance nor xyz!");
    if (isnuisance) {
      std::vector<double> x(1, Nuisance(ps[i]).get_nuisance());
      coordinates_.push_back(x);
      std::vector<double> v(1, ps[i]->get_value(FloatKey("vel")));
      velocities_.push_back(v);
    }
    if (isxyz) {
      std::vector<double> coords;
      core::XYZ d(ps[i]);
      coords.push_back(d.get_coordinate(0));
      coords.push_back(d.get_coordinate(1));
      coords.push_back(d.get_coordinate(2));
      coordinates_.push_back(coords);
      std::vector<double> v;
      v.push_back(ps[i]->get_value(FloatKey("vx")));
      v.push_back(ps[i]->get_value(FloatKey("vy")));
      v.push_back(ps[i]->get_value(FloatKey("vz")));
      velocities_.push_back(v);
    }
  }
}
Exemplo n.º 4
0
void MolecularDynamics::initialize() {
  set_maximum_time_step(4.0);
  degrees_of_freedom_=0;
  velocity_cap_=std::numeric_limits<Float>::max();
  vs_[0] = FloatKey("vx");
  vs_[1] = FloatKey("vy");
  vs_[2] = FloatKey("vz");
}
IMPATOM_BEGIN_NAMESPACE

BerendsenThermostatOptimizerState::BerendsenThermostatOptimizerState(
    const Particles &pis, double temperature, double tau) :
    pis_(pis), temperature_(temperature), tau_(tau)
{
  vs_[0] = FloatKey("vx");
  vs_[1] = FloatKey("vy");
  vs_[2] = FloatKey("vz");
}
IMPATOM_BEGIN_NAMESPACE

RemoveRigidMotionOptimizerState::RemoveRigidMotionOptimizerState(
    const ParticlesTemp &pis, unsigned skip_steps) :
  pis_(pis.begin(), pis.end()), skip_steps_(skip_steps),
    call_number_(0)
{
  vs_[0] = FloatKey("vx");
  vs_[1] = FloatKey("vy");
  vs_[2] = FloatKey("vz");
}
Exemplo n.º 7
0
// compute centroid from refined particles
void CentroidOfRefined::apply_index(Model *m,
                                    ParticleIndex pi) const {
  IMP_LOG_PROGRESS("BEGIN - updating centroid pi" << pi << " coords " <<
                   IMP::core::XYZ(m, pi).get_coordinates());
  // retrieving pis by ref if possible is cumbersome but is required for speed
  ParticleIndexes pis_if_not_byref;
  ParticleIndexes const* pPis;
  if(refiner_->get_is_by_ref_supported()){
    ParticleIndexes const& pis =
      refiner_->get_refined_indexes_by_ref(m, pi);
    pPis = &pis;
  } else{
    pis_if_not_byref = refiner_->get_refined_indexes(m, pi);
    pPis = &pis_if_not_byref;
  }
  ParticleIndexes const& pis = *pPis;
  unsigned int n = pis.size();
  double tw = 0;
  if (w_ != FloatKey()) {
    IMP_USAGE_CHECK( m->get_has_attribute(w_, pi),
                     "Centroid particle lacks non-trivial weight key" << w_ );
    for (unsigned int i = 0; i < n; ++i) {
      ParticleIndex cur_pi = pis[i];
      IMP_USAGE_CHECK( m->get_has_attribute(w_, cur_pi),
                       "CentroidOfRefined - Fine particle #" << i
                       << " lacks non-trivial weight key" << w_);
      tw += m->get_attribute(w_, cur_pi);
    }
    m->set_attribute(w_, pi, tw);
  } else {
    tw = 1;
  }
  for (unsigned int j = 0; j < ks_.size(); ++j) {
    double v = 0;
    for (unsigned int i = 0; i < n; ++i) {
      double w;
      ParticleIndex cur_pi = pis[i];
      if (w_ != FloatKey()) {
        w = m->get_attribute(w_, cur_pi) / tw;
      } else {
        w = Float(1.0) / n;
      }
      v += m->get_attribute(ks_[j], cur_pi) * w;
    }
    m->set_attribute(ks_[j], pi, v);
  }
  IMP_LOG_PROGRESS("DONE - updated centroid pi" << pi << " coords " <<
                   IMP::core::XYZ(m, pi).get_coordinates());
}
Exemplo n.º 8
0
void WeightedDerivativesToRefined::apply_index(Model *m,
                                       ParticleIndex pi) const {
  // retrieving pis by ref if possible is cumbersome but is required for speed
  ParticleIndexes pis_if_not_byref;
  ParticleIndexes const* pPis;
  if(refiner_->get_is_by_ref_supported()){
    ParticleIndexes const& pis =
      refiner_->get_refined_indexes_by_ref(m, pi);
    pPis = &pis;
  } else{
    pis_if_not_byref = refiner_->get_refined_indexes(m, pi);
    pPis = &pis_if_not_byref;
  }
  ParticleIndexes const& pis = *pPis;
  //  Prepare derivative accumulator to normalize by total weight
  Float total_weight;
  if(w_ != FloatKey()){
    total_weight = m->get_attribute(w_, pi);
  } else {
    total_weight = pis.size();
  }
  DerivativeAccumulator da( 1.0 / total_weight);
  // read K values for each key in keys_
  Floats Ks(keys_.size());
  for (unsigned int j = 0; j < Ks.size(); ++j){
    Ks[j] = m->get_derivative(keys_[j], pi);
  }
  // store K reweighted per each particle, normalized with da
  for (unsigned int i = 0; i < pis.size(); ++i) {
    Float w = m->get_attribute(w_, pis[i]);
    for (unsigned int j = 0; j < keys_.size(); ++j) {
      m->add_to_derivative(keys_[j], pis[i], w * Ks[j], da);
    }
  }
}
Exemplo n.º 9
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
float Settings::GetFloat(char *elem, char *name)
{
    float retValue = mapFloatChild[FloatKey(elem, name)];
    if (!GetFloatFromChild(elem, name, &retValue))
    {
        SetFloat(elem, name, retValue);
    }
    return retValue;
}
Exemplo n.º 10
0
FloatKey Weight::get_weight_key(int j) {
  static FloatKeys kk;
  if (kk.empty()) {
    for (int i = 0; i < nstates_max; ++i) {
      std::stringstream out;
      out << i;
      kk.push_back(FloatKey("weight" + out.str()));
    }
  }
  return kk[j];
}
Exemplo n.º 11
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
bool Settings::Load()
{
    nameFile = String("TVData/settings.xml");

    mapIntChild[IntKey(TV_SCREEN_WIDTH)] = SET::WINDOW::WIDTH;
    mapIntChild[IntKey(TV_SCREEN_HEIGHT)] = SET::WINDOW::HEIGHT;
    mapIntChild[IntKey(TV_LANGUAGE)] = 1;
    mapIntChild[IntKey(TV_TEXTURE_QUALITY)] = 2;
    mapIntChild[IntKey(TV_BRIGHTNESS)] = 50;
    mapIntChild[IntKey(TV_VOLUME)] = 50;
    mapIntChild[IntKey(TV_MAX_OCCLUDER_TRIANGLES)] = 5000;
    mapIntChild[IntKey(TV_TEXTURE_ANISOTROPY)] = 3;
    mapIntChild[IntKey(TV_MATERIAL_QUALITY)] = 3;
    mapIntChild[IntKey(TV_SHADOW_DRAW)] = 1;
    mapIntChild[IntKey(TV_SPECULAR_LIGHTING)] = 1;
    mapIntChild[IntKey(TV_SHADOW_MAP_SIZE)] = 4;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_WIDTH)] = SET::PANEL::BOTTOM::BUTTON::WIDTH;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_HEIGHT)] = SET::PANEL::BOTTOM::BUTTON::HEIGHT;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_HEIGHT)] = SET::PANEL::BOTTOM::HEIGHT;
    mapIntChild[IntKey(TV_PANEL_MAP_WIDTH)] = SET::PANEL::MAP::WIDTH;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_Y)] = 3;

    mapFloatChild[FloatKey(TV_PANEL_SPEED)] = SET::PANEL::SPEED;

    File inFile(gContext);
    if(inFile.Open(nameFile, Urho3D::FILE_READ))
    {
        file = new XMLFile(gContext);
        bool begined = file->BeginLoad(inFile);
        if(begined)
        {
            root = file->GetRoot();
            if(root != XMLElement::EMPTY)
            {
                return true;
            }
        }
    }
    if (file == nullptr)
    {
        file = new XMLFile(gContext);
    }
    root = file->CreateRoot("settings");
    return false;
}
Exemplo n.º 12
0
    }
    m->set_attribute(ks_[j], pi, v);
  }
  IMP_LOG_PROGRESS("DONE - updated centroid pi" << pi << " coords " <<
                   IMP::core::XYZ(m, pi).get_coordinates());
}

ModelObjectsTemp CentroidOfRefined::do_get_inputs(
    Model *m, const ParticleIndexes &pis) const {
  ModelObjectsTemp ret = refiner_->get_inputs(m, pis);
  ret += IMP::get_particles(m, pis);
  for (unsigned int i = 0; i < pis.size(); ++i) {
    ret +=
        IMP::get_particles(m, refiner_->get_refined_indexes(m, pis[i]));
  }
  return ret;
}
ModelObjectsTemp CentroidOfRefined::do_get_outputs(
    Model *m, const ParticleIndexes &pis) const {
  ModelObjectsTemp ret = IMP::get_particles(m, pis);
  return ret;
}

IMP_SUMMARIZE_DECORATOR_DEF(Centroid, XYZ, XYZs,
                            (new CentroidOfRefined(ref, FloatKey(), // pre
                                                   XYZ::get_xyz_keys())),
                            (new DerivativesToRefined(ref)) // post
                            );

IMPCORE_END_NAMESPACE
Exemplo n.º 13
0
const FloatKey Voxel::get_density_key() {
  static FloatKey density = FloatKey("density_val");
  return density;
}