Пример #1
0
  /** integrate Newton's equation by one step, velocity Verlet */
  void vv() {
    double dth = dt * .5, dtl = dt / L;

    for (int id = 0; id < N; id++) // velocity-verlet, first half
    for (int d = 0; d < D; d++) {
        v[id][d] += f[id][d] * dth;
        x[id][d] += v[id][d] * dtl;
      }

    force(); // compute force

    for (int id = 0; id < N; id++) // velocity-verlet, second half
    for (int d = 0; d < D; d++) v[id][d] += f[id][d] * dth;

    rmcom(); // rm angular momentum however isn't good idea due to
    // pbc and minimal image convension
    K = vrescale(0.02); // compute kinetic energy and adjust velocity
    E = K + Us;
    step++;
    avU.add(U);
    avK.add(K);
    avp.add(p);
  }
Пример #2
0
 void clearData() {
   step = 0;
   avU.clear();
   avK.clear();
   avp.clear();
 }