Beispiel #1
0
int tclcommand_integrate(ClientData data, Tcl_Interp *interp, int argc, char **argv) 
{
  int  n_steps;
  
  INTEG_TRACE(fprintf(stderr,"%d: integrate:\n",this_node));

  if (argc < 1) {
    Tcl_AppendResult(interp, "wrong # args: \n\"", (char *) NULL);
    return tclcommand_integrate_print_usage(interp);  }
  else if (argc < 2) {                    return tclcommand_integrate_print_status(interp); }

  if (ARG1_IS_S("set")) {
    if      (argc < 3)                    return tclcommand_integrate_print_status(interp);
    if      (ARG_IS_S(2,"nvt"))           return tclcommand_integrate_set_nvt(interp, argc, argv);
#ifdef NPT
    else if (ARG_IS_S(2,"npt_isotropic")) return tclcommand_integrate_set_npt_isotropic(interp, argc, argv);
#endif
    else {
      Tcl_AppendResult(interp, "unknown integrator method:\n", (char *)NULL);
      return tclcommand_integrate_print_usage(interp);
    }
  } else if ( !ARG_IS_I(1,n_steps) ) return tclcommand_integrate_print_usage(interp);

  /* go on with integrate <n_steps> */
  if(n_steps < 0) {
    Tcl_AppendResult(interp, "illegal number of steps (must be >0) \n", (char *) NULL);
    return tclcommand_integrate_print_usage(interp);;
  }
  /* perform integration */
  if (mpi_integrate(n_steps))
    return mpi_gather_runtime_errors(interp, TCL_OK);
  return TCL_OK;
}
Beispiel #2
0
int tclcommand_integrate(ClientData data, Tcl_Interp *interp, int argc,
                         char **argv) {
  int n_steps, reuse_forces = 0;

  INTEG_TRACE(fprintf(stderr, "%d: integrate:\n", this_node));

  if (argc < 1) {
    Tcl_AppendResult(interp, "wrong # args: \n\"", (char *)NULL);
    return tclcommand_integrate_print_usage(interp);
  } else if (argc < 2) {
    return tclcommand_integrate_print_status(interp);
  }

  if (ARG1_IS_S("set")) {
    if (argc < 3)
      return tclcommand_integrate_print_status(interp);
    if (ARG_IS_S(2, "nvt"))
      return tclcommand_integrate_set_nvt(interp, argc, argv);
#ifdef NPT
    else if (ARG_IS_S(2, "npt_isotropic"))
      return tclcommand_integrate_set_npt_isotropic(interp, argc, argv);
#endif
    else {
      Tcl_AppendResult(interp, "unknown integrator method:\n", (char *)NULL);
      return tclcommand_integrate_print_usage(interp);
    }
  } else {
    if (!ARG_IS_I(1, n_steps))
      return tclcommand_integrate_print_usage(interp);

    // actual integration
    if ((argc == 3) && ARG_IS_S(2, "reuse_forces")) {
      reuse_forces = 1;
    } else if ((argc == 3) && ARG_IS_S(2, "recalc_forces")) {
      reuse_forces = -1;
    } else if (argc != 2)
      return tclcommand_integrate_print_usage(interp);
  }
  /* go on with integrate <n_steps> */
  if (n_steps < 0) {
    Tcl_AppendResult(interp, "illegal number of steps (must be >0) \n",
                     (char *)NULL);
    return tclcommand_integrate_print_usage(interp);
    ;
  }

  /* if skin wasn't set, do an educated guess now */
  if (!skin_set) {
    if (max_cut == 0.0) {
      Tcl_AppendResult(interp, "cannot automatically determine skin, please "
                               "set it manually via \"setmd skin\"\n",
                       (char *)NULL);
      return TCL_ERROR;
    }
    skin = 0.4 * max_cut;
    mpi_bcast_parameter(FIELD_SKIN);
  }

  /* perform integration */
  if (!correlations_autoupdate && !observables_autoupdate) {
    if (mpi_integrate(n_steps, reuse_forces))
      return gather_runtime_errors(interp, TCL_OK);
  } else {
    for (int i = 0; i < n_steps; i++) {
      if (mpi_integrate(1, reuse_forces))
        return gather_runtime_errors(interp, TCL_OK);
      reuse_forces = 1;
      autoupdate_observables();
      autoupdate_correlations();
    }
    if (n_steps == 0) {
      if (mpi_integrate(0, reuse_forces))
        return gather_runtime_errors(interp, TCL_OK);
    }
  }
  return TCL_OK;
}