Пример #1
0
/// Advance the simulation time to t+dt using a leap frog method
/// (equivalent to velocity verlet).
///
/// Forces must be computed before calling the integrator the first time.
///
///  - Advance velocities half time step using forces
///  - Advance positions full time step using velocities
///  - Update link cells and exchange remote particles
///  - Compute forces
///  - Update velocities half time step using forces
///
/// This leaves positions, velocities, and forces at t+dt, with the
/// forces ready to perform the half step velocity update at the top of
/// the next call.
///
/// After nSteps the kinetic energy is computed for diagnostic output.
double timestep(SimFlat* s, int nSteps, real_t dt)
{
   for (int ii=0; ii<nSteps; ++ii)
   {
      startTimer(velocityTimer);
      advanceVelocity(s, s->boxes->nLocalBoxes, 0.5*dt); 
      stopTimer(velocityTimer);

      startTimer(positionTimer);
      advancePosition(s, s->boxes->nLocalBoxes, dt);
      stopTimer(positionTimer);

      startTimer(redistributeTimer);
      redistributeAtoms(s);
      stopTimer(redistributeTimer);

      startTimer(computeForceTimer);
      computeForce(s);
      stopTimer(computeForceTimer);

      startTimer(velocityTimer);
      advanceVelocity(s, s->boxes->nLocalBoxes, 0.5*dt); 
      stopTimer(velocityTimer);
   }

   kineticEnergy(s);

   return s->ePotential;
}
Пример #2
0
double nTimeSteps(int n, simflat_t *s, real_t dt) {
    extern void printIt(simflat_t *sim,FILE *fp);
    int i;
    /**
     * Standard verlet algorithm:
     *   1: advance positions half a timestep using current velocities
     *   2: compute forces
     *   3: advance velocities (momenta) a full timestep
     *   4: advance positions half a timestep to bring in sync with velocities.
     **/

    /* convert dt to atomic units */
    dt = dt * bohr_per_atu_to_A_per_s;

    for(i=0; i<n; i++) {
        advancePositions(s,0,s->nboxes,(dt/2.0));
        computeForce(s);
        advanceVelocity(s,0,s->nboxes,dt);
        advancePositions(s,0,s->nboxes,(dt/2.0));
    }

    /* compute force to make consistent */
    computeForce(s);

    return s->e;

}
Пример #3
0
double nTimeSteps(int n, simulation_t *s, real_t dt) {
  extern void printIt(simulation_t *sim,FILE *fp);
  int i;
  /* for now no repositioning */
  /* half step forward for positions */
  //  advancePositions(s,0,s->boxes.nboxes,(dt/2.0));

  for(i=0; i<n; i++) {
    advancePositions(s,0,s->boxes.nboxes,(dt/2.0));
    reBox(s); /* reposition particles if needed */
    s->force(s); /* compute force */
    advanceVelocity(s,0,s->boxes.nboxes,dt); /* advance velocity */
    advancePositions(s,0,s->boxes.nboxes,(dt/2.0));
    //    advancePositions(s,0,s->boxes.nboxes,dt); /* advance positions */
  }
  reBox(s); /* reposition particles if needed */
  /* half step backward for positions */
  return s->e;
}