On multi/harmonic dihedrals

Dear all,

I noticed this long time ago, but, as far as I read, this still seems to be an issue with the latest LAMMPS distribution I checked (16Mar18).

Very briefly, if adopting the multi/harmonic dihedrals style, when the user wants to use the usual write_data functionality, the multi/harmonic coefficients seem to be left out.

A quick fix that seemed to work is adding (to dihedral_multi_harmonic.cpp) something along the lines of:

/* ----------------------------------------------------------------------
   proc 0 writes to data file
------------------------------------------------------------------------- */

void DihedralMultiHarmonic::write_data(FILE *fp)
{
  for (int i = 1; i <= atom->ndihedraltypes; i++)
    fprintf(fp,"%d %g %g %g %g %g\n",i,a1[i],a2[i],a3[i],a4[i],a5[i]);
}
------------------------------------------------------------------------- */

And, to dihedral_multi_harmonic.h:


void write_data(FILE *);

I hope this helps :slight_smile:

Best wishes,
Nicola

Dear all,

I noticed this long time ago, but, as far as I read, this still seems to be
an issue with the latest LAMMPS distribution I checked (16Mar18).

Very briefly, if adopting the multi/harmonic dihedrals style, when the user
wants to use the usual write_data functionality, the multi/harmonic
coefficients seem to be left out.

yes, there should be a comment in the write_data documentation, noting
that not all styles (pair and other) support this functionality.
the LAMMPS developers hope, that users like you then report when they
are missing this kind of functionality.

A quick fix that seemed to work is adding (to dihedral_multi_harmonic.cpp)
something along the lines of:

/* ----------------------------------------------------------------------
   proc 0 writes to data file
------------------------------------------------------------------------- */

void DihedralMultiHarmonic::write_data(FILE *fp)
{
  for (int i = 1; i <= atom->ndihedraltypes; i++)
    fprintf(fp,"%d %g %g %g %g %g\n",i,a1[i],a2[i],a3[i],a4[i],a5[i]);
}

------------------------------------------------------------------------- */

And, to dihedral_multi_harmonic.h:

void write_data(FILE *);

I hope this helps :slight_smile:

it would help more, if you just submit this as a pull request on
github and thus make it easy to add to the next LAMMPS patch release.

and while you are at it, it would help *even* more and make you a
"LAMMPS hero", if you would check, if there are other dihedral styles,
that are missing the write_data() method and add write_data support
for those as well, provided it makes sense (it doesn't for table or
hybrid styles).

axel.