Commit be2d155c authored by Giacomo Fiorin's avatar Giacomo Fiorin
Browse files

Minor changes and fixes not relevant to LAMMPS

parent c2430939
Loading
Loading
Loading
Loading
+39 −6
Original line number Diff line number Diff line
@@ -367,6 +367,7 @@ int cvm::atom_group::parse(std::string const &conf)
        cvm::error("Error: atomsColValue, if provided, must be non-zero.\n", INPUT_ERROR);
      }

      // NOTE: calls to add_atom() and/or add_atom_id() are in the proxy-implemented function
      cvm::load_atoms(atoms_file_name.c_str(), *this, atoms_col, atoms_col_value);
    }
  }
@@ -403,11 +404,21 @@ int cvm::atom_group::parse(std::string const &conf)
    }
  }

  // We need to know the fitting options to decide whether the group is scalable
  parse_error |= parse_fitting_options(group_conf);

  if (is_available(f_ag_scalable_com) && !b_rotate) {
    enable(f_ag_scalable_com);
    enable(f_ag_scalable);
  }

  if (is_enabled(f_ag_scalable) && !b_dummy) {
    cvm::log("Enabling scalable calculation for group \""+this->key+"\".\n");
    index = (cvm::proxy)->init_atom_group(atoms_ids);
  }

  parse_error |= parse_fitting_options(group_conf);
  bool b_print_atom_ids = false;
  get_keyval(group_conf, "printAtomIDs", b_print_atom_ids, false, colvarparse::parse_silent);

  // TODO move this to colvarparse object
  check_keywords(group_conf, key.c_str());
@@ -427,6 +438,10 @@ int cvm::atom_group::parse(std::string const &conf)
	    cvm::to_str(total_mass)+", total charge = "+
            cvm::to_str(total_charge)+".\n");

  if (b_print_atom_ids) {
    cvm::log("Internal definition of the atom group:\n");
  }

  cvm::decrease_depth();

  return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
@@ -583,6 +598,21 @@ int cvm::atom_group::add_atom_name_residue_range(std::string const &psf_segid,
}


std::string const cvm::atom_group::print_atom_ids() const
{
  size_t line_count = 0;
  std::ostringstream os("");
  for (size_t i = 0; i < atoms_ids.size(); i++) {
    os << " " << std::setw(9) << atoms_ids[i];
    if (++line_count == 7) {
      os << "\n";
      line_count = 0;
    }
  }
  return os.str();
}


int cvm::atom_group::parse_fitting_options(std::string const &group_conf)
{
  bool b_defined_center = get_keyval(group_conf, "centerReference", b_center, false);
@@ -1118,8 +1148,7 @@ void cvm::atom_group::apply_colvar_force(cvm::real const &force)
    log("Communicating a colvar force from atom group to the MD engine.\n");
  }

  if (b_dummy)
    return;
  if (b_dummy) return;

  if (noforce) {
    cvm::error("Error: sending a force to a group that has "
@@ -1161,17 +1190,21 @@ void cvm::atom_group::apply_colvar_force(cvm::real const &force)

void cvm::atom_group::apply_force(cvm::rvector const &force)
{
  if (b_dummy)
    return;
  if (cvm::debug()) {
    log("Communicating a colvar force from atom group to the MD engine.\n");
  }

  if (b_dummy) return;

  if (noforce) {
    cvm::error("Error: sending a force to a group that has "
               "\"disableForces\" defined.\n");
               "\"enableForces\" set to off.\n");
    return;
  }

  if (is_enabled(f_ag_scalable)) {
    (cvm::proxy)->apply_atom_group_force(index, force);
    return;
  }

  if (b_rotate) {
+2 −0
Original line number Diff line number Diff line
@@ -253,6 +253,8 @@ public:
    return atoms.size();
  }

  std::string const print_atom_ids() const;

  /// \brief If this option is on, this group merely acts as a wrapper
  /// for a fixed position; any calls to atoms within or to
  /// functions that return disaggregated data will fail
+3 −6
Original line number Diff line number Diff line
@@ -84,15 +84,12 @@ cvm::atom_group *colvar::cvc::parse_group(std::string const &conf,
      if (is_available(f_cvc_scalable_com) && is_available(f_cvc_com_based)) {
        enable(f_cvc_scalable_com);
        enable(f_cvc_scalable);
        group->enable(f_ag_scalable_com);
        group->enable(f_ag_scalable);
        // The CVC makes the feature available;
        // the atom group will enable it unless it needs to compute a rotational fit
        group->provide(f_ag_scalable_com);
      }

      // TODO check for other types of parallelism here

      if (is_enabled(f_cvc_scalable)) {
        cvm::log("Will enable scalable calculation for group \""+group->key+"\".\n");
      }
    }

    if (group->parse(conf) == COLVARS_OK) {
+4 −2
Original line number Diff line number Diff line
@@ -449,8 +449,10 @@ void colvardeps::init_ag_requires() {

  // Features that are implemented (or not) by all atom groups
  feature_states[f_ag_active]->available = true;
  feature_states[f_ag_scalable_com]->available = (cvm::proxy->scalable_group_coms() == COLVARS_OK);
  feature_states[f_ag_scalable]->available = feature_states[f_ag_scalable_com]->available;
  // f_ag_scalable_com is provided by the CVC iff it is COM-based
  feature_states[f_ag_scalable_com]->available = false;
  // TODO make f_ag_scalable depend on f_ag_scalable_com (or something else)
  feature_states[f_ag_scalable]->available = true;
}


+20 −11
Original line number Diff line number Diff line
@@ -810,6 +810,7 @@ int colvarmodule::analyze()

int colvarmodule::setup()
{
  if (this->size() == 0) return cvm::get_error();
  // loop over all components of all colvars to reset masses of all groups
  for (std::vector<colvar *>::iterator cvi = colvars.begin();
       cvi != colvars.end();  cvi++) {
@@ -867,25 +868,35 @@ int colvarmodule::reset()

int colvarmodule::setup_input()
{
  // name of input state file
  restart_in_name = proxy->input_prefix().size() ?
    std::string(proxy->input_prefix()+".colvars.state") :
    std::string("") ;
  if (this->size() == 0) return cvm::get_error();

  std::string restart_in_name("");

  // read the restart configuration, if available
  if (restart_in_name.size()) {
  if (proxy->input_prefix().size()) {
    // read the restart file
    restart_in_name = proxy->input_prefix();
    std::ifstream input_is(restart_in_name.c_str());
    if (!input_is.good()) {
      cvm::error("Error: in opening restart file \""+
      // try by adding the suffix
      input_is.clear();
      restart_in_name = restart_in_name+std::string(".colvars.state");
      input_is.open(restart_in_name.c_str());
    }

    if (!input_is.good()) {
      cvm::error("Error: in opening input file \""+
                 std::string(restart_in_name)+"\".\n",
                 FILE_ERROR);
      return COLVARS_ERROR;
    } else {
      cvm::log(cvm::line_marker);
      cvm::log("Restarting from file \""+restart_in_name+"\".\n");
      read_restart(input_is);
      if (cvm::get_error() != COLVARS_OK) {
        return COLVARS_ERROR;
      } else {
        proxy->input_prefix().clear();
      }
      cvm::log(cvm::line_marker);
    }
@@ -897,7 +908,9 @@ int colvarmodule::setup_input()

int colvarmodule::setup_output()
{
  int error_code = 0;
  if (this->size() == 0) return cvm::get_error();

  int error_code = COLVARS_OK;

  // output state file (restart)
  restart_out_name = proxy->restart_output_prefix().size() ?
@@ -1545,11 +1558,7 @@ std::list<std::string> colvarmodule::index_group_names;
std::list<std::vector<int> > colvarmodule::index_groups;
bool     colvarmodule::use_scripted_forces = false;
bool     colvarmodule::scripting_after_biases = true;

// file name prefixes
std::string colvarmodule::output_prefix = "";
std::string colvarmodule::restart_in_name = "";


// i/o constants
size_t const colvarmodule::it_width = 12;
Loading