Commit 6d84bd61 authored by Aidan Thompson's avatar Aidan Thompson
Browse files

Added compute_beta()

parent a243be2d
Loading
Loading
Loading
Loading
+22 −21
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ PairSNAP::~PairSNAP()
    memory->destroy(radelem);
    memory->destroy(wjelem);
    memory->destroy(coeffelem);
    memory->destroy(beta);
  }

  // Need to set this because restart not handled by PairHybrid
@@ -246,14 +247,15 @@ void PairSNAP::compute_regular(int eflag, int vflag)
    }

    // for neighbors of I within cutoff:
    // compute dUi/drj and dBi/drj
    // Fij = dEi/dRj = -dEi/dRi => add to Fi, subtract from Fj
    // compute Fij = dEi/dRj = -dEi/dRi 
    // add to Fi, subtract from Fj

    double* coeffi = coeffelem[ielem];
    // compute dE_i/dB_i = beta_i

    // omit beta0 from beta vector
    compute_betai(ielem);

    // compute beta_i*Z_i = Y_i

    double* beta = coeffi+1; 
    snaptr->compute_yi(beta);

    for (int jj = 0; jj < ninside; jj++) {
@@ -261,22 +263,6 @@ void PairSNAP::compute_regular(int eflag, int vflag)
      snaptr->compute_duidrj(snaptr->rij[jj],
                             snaptr->wj[jj],snaptr->rcutij[jj]);

//       snaptr->compute_dbidrj();
//       snaptr->copy_dbi2dbvec();

//       fij[0] = 0.0;
//       fij[1] = 0.0;
//       fij[2] = 0.0;

//       // linear contributions

//       for (int k = 1; k <= ncoeff; k++) {
//         double bgb = coeffi[k];
//         fij[0] += bgb*snaptr->dbvec[k-1][0];
//         fij[1] += bgb*snaptr->dbvec[k-1][1];
//         fij[2] += bgb*snaptr->dbvec[k-1][2];
//       }

//       // quadratic contributions

//       if (quadraticflag) {
@@ -326,6 +312,7 @@ void PairSNAP::compute_regular(int eflag, int vflag)

      // evdwl = energy of atom I, sum over coeffs_k * Bi_k

      double* coeffi = coeffelem[ielem];
      evdwl = coeffi[0];
      if (!quadraticflag) {
        snaptr->compute_bi();
@@ -1306,6 +1293,18 @@ void PairSNAP::build_per_atom_arrays()
#endif
}

/* ----------------------------------------------------------------------
   compute beta_i 
------------------------------------------------------------------------- */

void PairSNAP::compute_betai(int ielem)
{
  double* coeffi = coeffelem[ielem];

  for (int k = 1; k <= ncoeff; k++)
    beta[k-1] = coeffi[k];
}

/* ----------------------------------------------------------------------
   allocate all arrays
------------------------------------------------------------------------- */
@@ -1434,6 +1433,7 @@ void PairSNAP::coeff(int narg, char **arg)
    memory->destroy(radelem);
    memory->destroy(wjelem);
    memory->destroy(coeffelem);
    memory->destroy(beta);
  }

  char* type1 = arg[0];
@@ -1631,6 +1631,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename)
  memory->create(radelem,nelements,"pair:radelem");
  memory->create(wjelem,nelements,"pair:wjelem");
  memory->create(coeffelem,nelements,ncoeffall,"pair:coeffelem");
  memory->create(beta,ncoeffall,"pair:beta");

  // Loop over nelements blocks in the SNAP coefficient file

+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ protected:
  void set_sna_to_shared(int snaid,int i);
  void build_per_atom_arrays();

  void compute_betai(int);

  int schedule_user;
  double schedule_time_guided;
  double schedule_time_dynamic;
@@ -99,6 +101,7 @@ protected:
  double *radelem;              // element radii
  double *wjelem;               // elements weights
  double **coeffelem;           // element bispectrum coefficients
  double* beta;                 // beta for current atom
  int *map;                     // mapping from atom types to elements
  int twojmax, diagonalstyle, switchflag, bzeroflag;
  double rfac0, rmin0, wj1, wj2;
+4 −4

File changed.

Contains only whitespace changes.