예제 #1
0
int tclcommand_nemd(ClientData data, Tcl_Interp *interp, int argc,
                    char **argv) {
#ifdef NEMD
    int status = TCL_OK;

    INTEG_TRACE(fprintf(stderr, "%d: nemd:\n", this_node));
    Tcl_ResetResult(interp);

    /* print nemd status */
    if (argc == 1) {
        status = tclcommand_nemd_print_status(interp);
    } else if (ARG1_IS_S("off")) {
        nemd_method = NEMD_METHOD_OFF;
        status = nemd_free();
    } else if (ARG1_IS_S("exchange")) {
        status = tclcommand_nemd_parse_exchange(interp, argc, argv);
    } else if (ARG1_IS_S("shearrate")) {
        status = tclcommand_nemd_parse_shearrate(interp, argc, argv);
    } else if (ARG1_IS_S("profile")) {
        status = tclcommand_nemd_parse_and_print_profile(interp);
    } else if (ARG1_IS_S("viscosity")) {
        status = tclcommand_nemd_parse_and_print_viscosity(interp);
    } else {
        Tcl_AppendResult(interp, "Unkwnown keyword: \n", (char *)NULL);
        return tclcommand_nemd_print_usage(interp);
    }

    return gather_runtime_errors(interp, status);

#endif
    INTEG_TRACE(
        fprintf(stderr, "%d: call to nemd but not compiled in!\n", this_node));
    return tclcommand_nemd_print_usage(interp);
}
예제 #2
0
파일: nemd.cpp 프로젝트: sehrhardt/espresso
/** Initialize all data structures for nemd. */
void nemd_init(int n_slabs, int n_exchange, double shear_rate) 
{
  int i;
  
  INTEG_TRACE(fprintf(stderr,"%d: nemd_init: n_slabs=%d n_exchange=%d\n",this_node, n_slabs, n_exchange));

  /* check node grid */
  if( n_nodes > 1 ) {
      runtimeErrorMsg() <<"NEMD is a single node feature";
    return;
  }

  /* first free old structures befor initializing new ones */
  if(nemddata.n_slabs > -1) nemd_free();
  /* exit nemd integration */
  if(n_slabs == 0) return;

  /* fill nemd structure */
  nemddata.n_slabs          = n_slabs;
  nemddata.top_slab         = 0;
  nemddata.mid_slab         = n_slabs/2;

  nemddata.thickness        = box_l[2]/(double)nemddata.n_slabs;
  nemddata.invthickness     = 1.0 / nemddata.thickness;

  nemddata.shear_rate       = shear_rate;
  nemddata.slab_vel         = time_step*shear_rate*box_l[2]/4.0;

  nemddata.n_exchange       = n_exchange;
 
  nemddata.slab             = (Slab *)Utils::malloc(nemddata.n_slabs*sizeof(Slab));
  nemddata.velocity_profile = (double *)Utils::malloc(nemddata.n_slabs*sizeof(double));

  nemddata.momentum = 0.0;
  nemddata.momentum_norm = 0;

  /* initialize slabs and velocity profile */
  for(i=0;i<nemddata.n_slabs;i++) {
    nemddata.velocity_profile[i]     = 0.0;

    nemddata.slab[i].v_mean          = 0.0;
    nemddata.slab[i].n_parts_in_slab = 0;
    nemddata.slab[i].v_min           = 0.0;
    nemddata.slab[i].ind_min         = 0;
    nemddata.slab[i].fastest         = NULL;
    nemddata.slab[i].n_fastest       = 0;
    nemddata.slab[i].vel_diff        = 0.0;
  }
  /* allocate arrays for indices of fastest particles in slab */
  if(nemddata.n_exchange > 0) {
    nemddata.slab[nemddata.top_slab].fastest = (int *)Utils::malloc(nemddata.n_exchange*sizeof(int));
    nemddata.slab[nemddata.mid_slab].fastest = (int *)Utils::malloc(nemddata.n_exchange*sizeof(int));
  }
  for(i=0;i<nemddata.n_exchange;i++) {
    nemddata.slab[nemddata.top_slab].fastest[i] = -1;
    nemddata.slab[nemddata.mid_slab].fastest[i] = -1;
  }
  nemddata.slab[nemddata.top_slab].v_min   = -1e10;
  nemddata.slab[nemddata.mid_slab].v_min   = +1e10;
}