Unverified Commit edc7237f authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

more thorough checking if the reaxff force field is consistent.

parent 586f2c00
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -337,6 +337,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,

    j = atoi(tmp[0]) - 1;
    k = atoi(tmp[1]) - 1;
    if ((c < 10) || (j < 0) || (k < 0))
      control->error_ptr->all(FLERR, "Inconsistent force field file");

    if (j < reax->num_atom_types && k < reax->num_atom_types) {

@@ -361,6 +363,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
      /* line 2 */
      fgets(s,MAX_LINE,fp);
      c=Tokenize(s,&tmp);
      if (c < 8)
        control->error_ptr->all(FLERR, "Inconsistent force field file");

      val = atof(tmp[0]); reax->tbp[j][k].p_be2     = val;
      reax->tbp[k][j].p_be2     = val;
@@ -491,6 +495,9 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
    j = atoi(tmp[0]) - 1;
    k = atoi(tmp[1]) - 1;

    if ((c < (lgflag ? 9 : 8)) || (j < 0) || (k < 0))
      control->error_ptr->all(FLERR, "Inconsistent force field file");

    if (j < reax->num_atom_types && k < reax->num_atom_types)        {
      val = atof(tmp[2]);
      if (val > 0.0) {
@@ -528,6 +535,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
        reax->tbp[k][j].r_pp = val;
      }

      if (lgflag) {
        val = atof(tmp[8]);
        if (val >= 0.0) {
          reax->tbp[j][k].lgcij = val;
@@ -535,6 +543,7 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
        }
      }
    }
  }

  for( i = 0; i < reax->num_atom_types; ++i )
    for( j = 0; j < reax->num_atom_types; ++j )
@@ -552,6 +561,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
    j = atoi(tmp[0]) - 1;
    k = atoi(tmp[1]) - 1;
    m = atoi(tmp[2]) - 1;
    if ((c < 10) || (j < 0) || (k < 0) || (m < 0))
      control->error_ptr->all(FLERR, "Inconsistent force field file");

    if (j < reax->num_atom_types && k < reax->num_atom_types &&
        m < reax->num_atom_types) {
@@ -611,6 +622,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
    k = atoi(tmp[1]) - 1;
    m = atoi(tmp[2]) - 1;
    n = atoi(tmp[3]) - 1;
    if ((c < 9) || (k < 0) || (m < 0))
      control->error_ptr->all(FLERR, "Inconsistent force field file");

    if (j >= 0 && n >= 0) { // this means the entry is not in compact form
      if (j < reax->num_atom_types && k < reax->num_atom_types &&
@@ -667,8 +680,6 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
    }
  }



  /* next line is number of hydrogen bond params and some comments */
  fgets( s, MAX_LINE, fp );
  c = Tokenize( s, &tmp );
@@ -686,7 +697,8 @@ char Read_Force_Field( FILE *fp, reax_interaction *reax,
    j = atoi(tmp[0]) - 1;
    k = atoi(tmp[1]) - 1;
    m = atoi(tmp[2]) - 1;

    if ((c < 7) || (j < 0) || (k < 0) || (m < 0))
      control->error_ptr->all(FLERR, "Inconsistent force field file");

    if (j < reax->num_atom_types && m < reax->num_atom_types) {
      val = atof(tmp[3]);