usr/kevin/code/develop/direct.c
int direct_initial_ensemble(Ensemble * current, double *runtime,
			    sim_state_t * s_init, ffs_param_t * ffs) {
  int bb;
  int nstates;
  double lambda, old_lambda;
  double lambda_a;
  double lambda_b;

  sim_state_t * snew;

  nstates = ffs->interface[1].nstates;
  current->N = 0;
  ffs_param_lambda_a(ffs, &lambda_a);
  ffs_param_lambda_b(ffs, &lambda_b);

  /* MAKE TRIAL BASED ON HEAD OF TREE s_init assign rnd seed */
  snew = simulation_state_allocate();
  simulation_state_copy(s_init, snew);

  simulation_run_to_time(snew, ffs->teq, ffs->nstepmax);
  simulation_state_time_set(snew, 0.0);
  lambda = simulation_lambda(snew);

  /* THE RESULTS OF THE TRIAL ARE NOT INSERTED IN TREE HERE. */

  *runtime = 0.0;
  bb = 0;
  ffs->ncross = 0;
 
  while ((*runtime) < ffs->trun) {
  
    old_lambda = lambda;

    /* SLIGHTLY OBSCURE 0 gives one step */
    simulation_run_to_time(snew, DBL_MAX, 0);

    lambda = simulation_lambda(snew);
    (*runtime) = simulation_state_time(snew);

    if (lambda >= lambda_b) {
      /* TRIAL HAS 'failed' */
      /* MAKE NEW TRIAL BASED ON HEAD OF TREE */
      simulation_state_copy(s_init, snew);
      simulation_run_to_time(snew, ffs->teq, ffs->nstepmax);
      simulation_state_time_set(snew, (*runtime));
      lambda = simulation_lambda(snew);
      old_lambda = lambda;
    }

    /* CHECKING FOR CROSSINGS of A state boundary */
    
    if ((old_lambda < lambda_a) && (lambda >= lambda_a)) {

      ++ffs->ncross;

      if ((bb < nstates) && (ffs->ncross % ffs->nskip == 0)) {

	/* INSERT CURRENT STATE INTO NEW NODE IN TREE CHILD OF HEAD */
	/* RECORD STATE and continue current trial */

	current->pstates[bb] = simulation_state_allocate();
	simulation_state_copy(snew, current->pstates[bb]);

	current->wt[bb] = 1.0;
	current->N++;
	bb++;
      }
    }

    ffs->runsteps++;
  }

  if (bb < nstates - 1) {
    printf(" collection run was not long enough! %d %d\n", bb, nstates);
    /* UNCONTROLLED EXIT */
    abort();
  }

  simulation_state_free(snew);

  return 0;
}
/*****************************************************************************
 *
 *  direct_initial_ensemble
 *
 *  Equilibrate and generate an initial ensemble at the first
 *  interface.
 *
 *****************************************************************************/
direct_initial_ensemble
Equilibrate and generate an initial ensemble at the first
interface.
direct_initial_ensemble Equilibrate and generate an initial ensemble at the first interface .
int direct_initial_ensemble(Ensemble * current, double *runtime,
			    sim_state_t * s_init, ffs_param_t * ffs) {
  int bb;
  int nstates;
  double lambda, old_lambda;
  double lambda_a;
  double lambda_b;
  sim_state_t * snew;
  nstates = ffs->interface[1].nstates;
  current->N = 0;
  ffs_param_lambda_a(ffs, &lambda_a);
  ffs_param_lambda_b(ffs, &lambda_b);
  snew = simulation_state_allocate();
  simulation_state_copy(s_init, snew);
  simulation_run_to_time(snew, ffs->teq, ffs->nstepmax);
  simulation_state_time_set(snew, 0.0);
  lambda = simulation_lambda(snew);
  *runtime = 0.0;
  bb = 0;
  ffs->ncross = 0;
  while ((*runtime) < ffs->trun) {
    old_lambda = lambda;
    simulation_run_to_time(snew, DBL_MAX, 0);
    lambda = simulation_lambda(snew);
    (*runtime) = simulation_state_time(snew);
    if (lambda >= lambda_b) {
      simulation_state_copy(s_init, snew);
      simulation_run_to_time(snew, ffs->teq, ffs->nstepmax);
      simulation_state_time_set(snew, (*runtime));
      lambda = simulation_lambda(snew);
      old_lambda = lambda;
    }
    if ((old_lambda < lambda_a) && (lambda >= lambda_a)) {
      ++ffs->ncross;
      if ((bb < nstates) && (ffs->ncross % ffs->nskip == 0)) {
	current->pstates[bb] = simulation_state_allocate();
	simulation_state_copy(snew, current->pstates[bb]);
	current->wt[bb] = 1.0;
	current->N++;
	bb++;
      }
    }
    ffs->runsteps++;
  }
  if (bb < nstates - 1) {
    printf(" collection run was not long enough! %d %d\n", bb, nstates);
    abort();
  }
  simulation_state_free(snew);
  return 0;
}
int direct_initial_ensemble ( Ensemble * current , double * runtime , sim_state_t * s_init , ffs_param_t * ffs ) { int bb ; int nstates ; double lambda , old_lambda ; double lambda_a ; double lambda_b ; sim_state_t * snew ; nstates = ffs -> interface [ 1 ] . nstates ; current -> N = 0 ; ffs_param_lambda_a ( ffs , & lambda_a ) ; ffs_param_lambda_b ( ffs , & lambda_b ) ; snew = simulation_state_allocate ( ) ; simulation_state_copy ( s_init , snew ) ; simulation_run_to_time ( snew , ffs -> teq , ffs -> nstepmax ) ; simulation_state_time_set ( snew , 0.0 ) ; lambda = simulation_lambda ( snew ) ; * runtime = 0.0 ; bb = 0 ; ffs -> ncross = 0 ; while ( ( * runtime ) < ffs -> trun ) { old_lambda = lambda ; simulation_run_to_time ( snew , DBL_MAX , 0 ) ; lambda = simulation_lambda ( snew ) ; ( * runtime ) = simulation_state_time ( snew ) ; if ( lambda >= lambda_b ) { simulation_state_copy ( s_init , snew ) ; simulation_run_to_time ( snew , ffs -> teq , ffs -> nstepmax ) ; simulation_state_time_set ( snew , ( * runtime ) ) ; lambda = simulation_lambda ( snew ) ; old_lambda = lambda ; } if ( ( old_lambda < lambda_a ) && ( lambda >= lambda_a ) ) { ++ ffs -> ncross ; if ( ( bb < nstates ) && ( ffs -> ncross % ffs -> nskip == 0 ) ) { current -> pstates [ bb ] = simulation_state_allocate ( ) ; simulation_state_copy ( snew , current -> pstates [ bb ] ) ; current -> wt [ bb ] = 1.0 ; current -> N ++ ; bb ++ ; } } ffs -> runsteps ++ ; } if ( bb < nstates - 1 ) { printf ( " \n " , bb , nstates ) ; abort ( ) ; } simulation_state_free ( snew ) ; return 0 ; }
direct_initial_ensemble
  Equilibrate and generate an initial ensemble at the first
  interface.
direct_initial_ensemble Equilibrate and generate an initial ensemble at the first interface .
/* MAKE TRIAL BASED ON HEAD OF TREE s_init assign rnd seed */ /* THE RESULTS OF THE TRIAL ARE NOT INSERTED IN TREE HERE. */ /* SLIGHTLY OBSCURE 0 gives one step */ /* TRIAL HAS 'failed' */ /* MAKE NEW TRIAL BASED ON HEAD OF TREE */ /* CHECKING FOR CROSSINGS of A state boundary */ /* INSERT CURRENT STATE INTO NEW NODE IN TREE CHILD OF HEAD */ /* RECORD STATE and continue current trial */ /* UNCONTROLLED EXIT */