git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9089 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2012-11-21 16:36:52 +00:00
parent de40c5ec0a
commit e6a0e1ee51
5 changed files with 72 additions and 75 deletions

View File

@ -13,7 +13,7 @@
/* ----------------------------------------------------------------------
Contributing author: Loukas D. Peristeras (Scienomics SARL)
[ based on angle_cosine_quared.cpp Naveen Michaud-Agrawal (Johns Hopkins U)]
[ based on angle_cosine_squared.cpp Naveen Michaud-Agrawal (Johns Hopkins U)]
------------------------------------------------------------------------- */
#include "math.h"

View File

@ -104,26 +104,22 @@ void DihedralFourier::compute(int eflag, int vflag)
vb1x = x[i1][0] - x[i2][0];
vb1y = x[i1][1] - x[i2][1];
vb1z = x[i1][2] - x[i2][2];
domain->minimum_image(vb1x,vb1y,vb1z);
// 2nd bond
vb2x = x[i3][0] - x[i2][0];
vb2y = x[i3][1] - x[i2][1];
vb2z = x[i3][2] - x[i2][2];
domain->minimum_image(vb2x,vb2y,vb2z);
vb2xm = -vb2x;
vb2ym = -vb2y;
vb2zm = -vb2z;
domain->minimum_image(vb2xm,vb2ym,vb2zm);
// 3rd bond
vb3x = x[i4][0] - x[i3][0];
vb3y = x[i4][1] - x[i3][1];
vb3z = x[i4][2] - x[i3][2];
domain->minimum_image(vb3x,vb3y,vb3z);
ax = vb1y*vb2zm - vb1z*vb2ym;
ay = vb1z*vb2xm - vb1x*vb2zm;
@ -283,12 +279,12 @@ void DihedralFourier::allocate()
memory->create(nterms,n+1,"dihedral:nterms");
k = new double * [n+1];
multiplicity = new int * [n+1];
shift = new int * [n+1];
shift = new double * [n+1];
cos_shift = new double * [n+1];
sin_shift = new double * [n+1];
for (int i = 1; i <= n; i++) {
k[i] = cos_shift[i] = sin_shift[i] = 0;
multiplicity[i] = shift[i] = 0;
k[i] = shift[i] = cos_shift[i] = sin_shift[i] = 0;
multiplicity[i] = 0;
}
memory->create(setflag,n+1,"dihedral:setflag");
@ -313,7 +309,7 @@ void DihedralFourier::coeff(int narg, char **arg)
double k_one;
int multiplicity_one;
int shift_one;
double shift_one;
int nterms_one = force->inumeric(arg[1]);
if (nterms_one < 1)
@ -327,14 +323,14 @@ void DihedralFourier::coeff(int narg, char **arg)
nterms[i] = nterms_one;
k[i] = new double [nterms_one];
multiplicity[i] = new int [nterms_one];
shift[i] = new int [nterms_one];
shift[i] = new double [nterms_one];
cos_shift[i] = new double [nterms_one];
sin_shift[i] = new double [nterms_one];
for (int j = 0; j<nterms_one; j++) {
int offset = 1+3*j;
k_one = force->numeric(arg[offset+1]);
multiplicity_one = force->inumeric(arg[offset+2]);
shift_one = force->inumeric(arg[offset+3]);
shift_one = force->numeric(arg[offset+3]);
k[i][j] = k_one;
multiplicity[i][j] = multiplicity_one;
shift[i][j] = shift_one;
@ -359,7 +355,7 @@ void DihedralFourier::write_restart(FILE *fp)
for(int i = 1; i <= atom->ndihedraltypes; i++) {
fwrite(k[i],sizeof(double),nterms[i],fp);
fwrite(multiplicity[i],sizeof(int),nterms[i],fp);
fwrite(shift[i],sizeof(int),nterms[i],fp);
fwrite(shift[i],sizeof(double),nterms[i],fp);
}
}
@ -381,7 +377,7 @@ void DihedralFourier::read_restart(FILE *fp)
for (int i=1; i<=atom->ndihedraltypes; i++) {
k[i] = new double [nterms[i]];
multiplicity[i] = new int [nterms[i]];
shift[i] = new int [nterms[i]];
shift[i] = new double [nterms[i]];
cos_shift[i] = new double [nterms[i]];
sin_shift[i] = new double [nterms[i]];
}
@ -390,14 +386,14 @@ void DihedralFourier::read_restart(FILE *fp)
for (int i=1; i<=atom->ndihedraltypes; i++) {
fread(k[i],sizeof(double),nterms[i],fp);
fread(multiplicity[i],sizeof(int),nterms[i],fp);
fread(shift[i],sizeof(int),nterms[i],fp);
fread(shift[i],sizeof(double),nterms[i],fp);
}
}
for (int i=1; i<=atom->ndihedraltypes; i++) {
MPI_Bcast(k[i],nterms[i],MPI_DOUBLE,0,world);
MPI_Bcast(multiplicity[i],nterms[i],MPI_INT,0,world);
MPI_Bcast(shift[i],nterms[i],MPI_INT,0,world);
MPI_Bcast(shift[i],nterms[i],MPI_DOUBLE,0,world);
}
for (int i=1; i <= atom->ndihedraltypes; i++) {

View File

@ -35,8 +35,8 @@ class DihedralFourier : public Dihedral {
void read_restart(FILE *);
protected:
double **k,**cos_shift,**sin_shift;
int **multiplicity,**shift;
double **k,**cos_shift,**sin_shift,**shift;
int **multiplicity;
int *nterms;
int implicit,weightflag;

View File

@ -159,7 +159,7 @@ void DihedralNHarmonic::compute(int eflag, int vflag)
sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " %d %d %d %d",
me,update->ntimestep,
atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]);
error->warning(FLERR,str);
error->warning(FLERR,str,0);
fprintf(screen," 1st atom: %d %g %g %g\n",
me,x[i1][0],x[i1][1],x[i1][2]);
fprintf(screen," 2nd atom: %d %g %g %g\n",

View File

@ -78,21 +78,18 @@ void ImproperFourier::compute(int eflag, int vflag)
vb1x = x[i2][0] - x[i1][0];
vb1y = x[i2][1] - x[i1][1];
vb1z = x[i2][2] - x[i1][2];
domain->minimum_image(vb1x,vb1y,vb1z);
// 2nd bond
vb2x = x[i3][0] - x[i1][0];
vb2y = x[i3][1] - x[i1][1];
vb2z = x[i3][2] - x[i1][2];
domain->minimum_image(vb2x,vb2y,vb2z);
// 3rd bond
vb3x = x[i4][0] - x[i1][0];
vb3y = x[i4][1] - x[i1][1];
vb3z = x[i4][2] - x[i1][2];
domain->minimum_image(vb3x,vb3y,vb3z);
addone(i1,i2,i3,i4, type,evflag,eflag,
vb1x, vb1y, vb1z,
@ -165,10 +162,14 @@ void ImproperFourier::addone(const int &i1,const int &i2,const int &i3,const int
me,update->ntimestep,
atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]);
error->warning(FLERR,str,0);
fprintf(screen," 1st atom: %d %g %g %g\n", me,x[i1][0],x[i1][1],x[i1][2]);
fprintf(screen," 2nd atom: %d %g %g %g\n", me,x[i2][0],x[i2][1],x[i2][2]);
fprintf(screen," 3rd atom: %d %g %g %g\n", me,x[i3][0],x[i3][1],x[i3][2]);
fprintf(screen," 4th atom: %d %g %g %g\n", me,x[i4][0],x[i4][1],x[i4][2]);
fprintf(screen," 1st atom: %d %g %g %g\n",
me,x[i1][0],x[i1][1],x[i1][2]);
fprintf(screen," 2nd atom: %d %g %g %g\n",
me,x[i2][0],x[i2][1],x[i2][2]);
fprintf(screen," 3rd atom: %d %g %g %g\n",
me,x[i3][0],x[i3][1],x[i3][2]);
fprintf(screen," 4th atom: %d %g %g %g\n",
me,x[i4][0],x[i4][1],x[i4][2]);
}
}