Ejemplo n.º 1
0
/* call hs_update periodically (i.e. once per frame) */
void hs_update (void)
{
	if (state.mem_range && !state.hiscores_have_been_loaded && safe_to_load()) {
		hs_load();
		state.hiscores_have_been_loaded = 1;
		option_hiscore = 0;
	}
}
Ejemplo n.º 2
0
/* call hs_update periodically (i.e. once per frame) */
void hs_update (void)
{
	if (state.mem_range)
	{
		if (!state.hiscores_have_been_loaded)
		{
			if (safe_to_load()) hs_load();
		}
	}
}
Ejemplo n.º 3
0
/* run simulation */
int run(void)
{
  gmx_mtop_t *mtop;
  int i, ndata, nat, rescnt = 0;
  char fxtc[FILENAME_MAX] = "";
  char *ftop;
  matrix box;
  rvec *xref = NULL, *xrefbb = NULL;
  zedata_t *ze = NULL;
  trj_t *trj = NULL;
  double dt, bref = 1.0/(BOLTZ*Tref), wtot = 0.0;
  hist_t *hsrms = NULL;
  bb_t *bb = NULL;
  FILE *fplog = NULL;

  memset(box, 0, sizeof(box));

  /* read topology and the reference structure */
  die_if ((ftop = nfexists(fntop, 7)) == NULL, "no topology file %s\n", fntop);
  mtop = read_tpx_conf(ftop, &xref, box, &nat, &dt);
  printf("using the structure in %s as the reference\n", ftop);

  bb = init_index(&rescnt, mtop); /* get indices for backbone dihedrals */
  xnew(xrefbb, rescnt * 3);
  xgetbb(xrefbb, xref, bb, rescnt);

  hsrms = hs_open(1, 0.0, xmax, xdel);

  if (fnlog) {
    xfopen(fplog, fnlog, "w", exit(1));
  }

  if (fndist2 != NULL) {
    /* if there's a second database, combine it with the first database */
    die_if (0 != hs_load(hsrms, fndist, HIST_VERBOSE),
        "cannot load master %s\n", fndist);
    die_if (0 != hs_load(hsrms, fndist2, HIST_VERBOSE|HIST_ADDITION),
        "cannot add the second %s\n", fndist2);

  } else  {
    /* if there's no second database, we accumulate trajectories */

    /* 1. initialize multiple histogram weights for tempering */
    if (!ctmd) {
      if ((ze = ze_load(fnze, 10)) == NULL) {
        fprintf(stderr, "cannot load %s\n", fnze);
        return -1;
      }
      /* we first load TRACE, compute weight of each frame */
      if ((trj = trj_loadseq(fntr, &ndata, dt, tequil,
              ze, bref, delbet)) == NULL) {
        fprintf(stderr, "failed to load trace\n");
        return -1;
      }
    } else {
      /* for regular MD, set ndata to a large number */
      ndata = 10000000;
    }

    /* 2. we now successively load xtc from each data dir,
     * try to match the TRACE frames */
    if (!ctmd) trj->pos = 0;

    for (i = 1; i <= ndata; i++) {
      sprintf(fxtc, "data%d/%s", i, fnxtc);
      if (!fexists(fxtc)) { /* test if the file exists */
        die_if(!ctmd, "cannot read %s\n", fnxtc);
        break;
      }
      if (0 != dotrj(hsrms, bb, rescnt, fplog,
            trj, fxtc, xrefbb, nat, box, &wtot)) {
        fprintf(stderr, "error doing %s\n", fnxtc);
        return -1;
      }
    }
  }
  hs_save(hsrms, fndist, HIST_ADDAHALF|HIST_VERBOSE);
  hs_close(hsrms);
  sfree(mtop);
  if (!ctmd) {
    if (trj) trj_free(trj);
    if (ze) ze_free(ze);
  }
  free(xrefbb);
  return 0;
}