git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1414 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -10,6 +10,7 @@ if ($1 == 1) then
|
||||
cp angle.cpp ..
|
||||
cp angle_charmm.cpp ..
|
||||
cp angle_cosine.cpp ..
|
||||
cp angle_cosine_delta.cpp ..
|
||||
cp angle_cosine_squared.cpp ..
|
||||
cp angle_harmonic.cpp ..
|
||||
cp angle_hybrid.cpp ..
|
||||
@ -43,6 +44,7 @@ if ($1 == 1) then
|
||||
# cp angle.h ..
|
||||
cp angle_charmm.h ..
|
||||
cp angle_cosine.h ..
|
||||
cp angle_cosine_delta.h ..
|
||||
cp angle_cosine_squared.h ..
|
||||
cp angle_harmonic.h ..
|
||||
cp angle_hybrid.h ..
|
||||
@ -81,6 +83,7 @@ else if ($1 == 0) then
|
||||
rm ../angle.cpp
|
||||
rm ../angle_charmm.cpp
|
||||
rm ../angle_cosine.cpp
|
||||
rm ../angle_cosine_delta.cpp
|
||||
rm ../angle_cosine_squared.cpp
|
||||
rm ../angle_harmonic.cpp
|
||||
rm ../angle_hybrid.cpp
|
||||
@ -114,6 +117,7 @@ else if ($1 == 0) then
|
||||
# rm ../angle.h
|
||||
rm ../angle_charmm.h
|
||||
rm ../angle_cosine.h
|
||||
rm ../angle_cosine_delta.h
|
||||
rm ../angle_cosine_squared.h
|
||||
rm ../angle_harmonic.h
|
||||
rm ../angle_hybrid.h
|
||||
|
||||
179
src/MOLECULE/angle_cosine_delta.cpp
Normal file
179
src/MOLECULE/angle_cosine_delta.cpp
Normal file
@ -0,0 +1,179 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
This software is distributed under the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Axel Kohlmeyer (U Penn), akohlmey at cmm.chem.upenn.edu
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "math.h"
|
||||
#include "stdlib.h"
|
||||
#include "angle_cosine_delta.h"
|
||||
#include "atom.h"
|
||||
#include "neighbor.h"
|
||||
#include "domain.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define SMALL 0.001
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AngleCosineDelta::AngleCosineDelta(LAMMPS *lmp) : AngleCosineSquared(lmp) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AngleCosineDelta::compute(int eflag, int vflag)
|
||||
{
|
||||
int i1,i2,i3,n,type;
|
||||
double delx1,dely1,delz1,delx2,dely2,delz2,theta,dtheta,dcostheta,tk;
|
||||
double eangle,f1[3],f3[3];
|
||||
double rsq1,rsq2,r1,r2,c,a,cot,a11,a12,a22,b11,b12,b22,c0,s0,s;
|
||||
|
||||
eangle = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = 0;
|
||||
|
||||
double **x = atom->x;
|
||||
double **f = atom->f;
|
||||
int **anglelist = neighbor->anglelist;
|
||||
int nanglelist = neighbor->nanglelist;
|
||||
int nlocal = atom->nlocal;
|
||||
int newton_bond = force->newton_bond;
|
||||
|
||||
for (n = 0; n < nanglelist; n++) {
|
||||
i1 = anglelist[n][0];
|
||||
i2 = anglelist[n][1];
|
||||
i3 = anglelist[n][2];
|
||||
type = anglelist[n][3];
|
||||
|
||||
// 1st bond
|
||||
|
||||
delx1 = x[i1][0] - x[i2][0];
|
||||
dely1 = x[i1][1] - x[i2][1];
|
||||
delz1 = x[i1][2] - x[i2][2];
|
||||
domain->minimum_image(delx1,dely1,delz1);
|
||||
|
||||
rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1;
|
||||
r1 = sqrt(rsq1);
|
||||
|
||||
// 2nd bond
|
||||
|
||||
delx2 = x[i3][0] - x[i2][0];
|
||||
dely2 = x[i3][1] - x[i2][1];
|
||||
delz2 = x[i3][2] - x[i2][2];
|
||||
domain->minimum_image(delx2,dely2,delz2);
|
||||
|
||||
rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2;
|
||||
r2 = sqrt(rsq2);
|
||||
|
||||
// angle (cos and sin)
|
||||
|
||||
c = delx1*delx2 + dely1*dely2 + delz1*delz2;
|
||||
c /= r1*r2;
|
||||
|
||||
if (c > 1.0) c = 1.0;
|
||||
if (c < -1.0) c = -1.0;
|
||||
|
||||
theta = acos(c);
|
||||
|
||||
s = sqrt(1.0 - c*c);
|
||||
if (s < SMALL) s = SMALL;
|
||||
s = 1.0/s;
|
||||
|
||||
cot = c/s;
|
||||
|
||||
// force & energy
|
||||
|
||||
dtheta = theta - theta0[type];
|
||||
dcostheta = cos(dtheta);
|
||||
tk = k[type] * (1.0-dcostheta);
|
||||
|
||||
if (eflag) eangle = tk;
|
||||
|
||||
a = -k[type];
|
||||
|
||||
// expand dtheta for cos and sin contribution to force
|
||||
|
||||
a11 = a*c / rsq1;
|
||||
a12 = -a / (r1*r2);
|
||||
a22 = a*c / rsq2;
|
||||
|
||||
b11 = -a*c*cot / rsq1;
|
||||
b12 = a*cot / (r1*r2);
|
||||
b22 = -a*c*cot / rsq2;
|
||||
|
||||
c0 = cos(theta0[type]);
|
||||
s0 = sin(theta0[type]);
|
||||
|
||||
f1[0] = (a11*delx1 + a12*delx2)*c0 + (b11*delx1 + b12*delx2)*s0;
|
||||
f1[1] = (a11*dely1 + a12*dely2)*c0 + (b11*dely1 + b12*dely2)*s0;
|
||||
f1[2] = (a11*delz1 + a12*delz2)*c0 + (b11*delz1 + b12*delz2)*s0;
|
||||
f3[0] = (a22*delx2 + a12*delx1)*c0 + (b22*delx2 + b12*delx1)*s0;
|
||||
f3[1] = (a22*dely2 + a12*dely1)*c0 + (b22*dely2 + b12*dely1)*s0;
|
||||
f3[2] = (a22*delz2 + a12*delz1)*c0 + (b22*delz2 + b12*delz1)*s0;
|
||||
|
||||
// apply force to each of 3 atoms
|
||||
|
||||
if (newton_bond || i1 < nlocal) {
|
||||
f[i1][0] += f1[0];
|
||||
f[i1][1] += f1[1];
|
||||
f[i1][2] += f1[2];
|
||||
}
|
||||
|
||||
if (newton_bond || i2 < nlocal) {
|
||||
f[i2][0] -= f1[0] + f3[0];
|
||||
f[i2][1] -= f1[1] + f3[1];
|
||||
f[i2][2] -= f1[2] + f3[2];
|
||||
}
|
||||
|
||||
if (newton_bond || i3 < nlocal) {
|
||||
f[i3][0] += f3[0];
|
||||
f[i3][1] += f3[1];
|
||||
f[i3][2] += f3[2];
|
||||
}
|
||||
|
||||
if (evflag) ev_tally(i1,i2,i3,nlocal,newton_bond,eangle,f1,f3,
|
||||
delx1,dely1,delz1,delx2,dely2,delz2);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double AngleCosineDelta::single(int type, int i1, int i2, int i3)
|
||||
{
|
||||
double **x = atom->x;
|
||||
|
||||
double delx1 = x[i1][0] - x[i2][0];
|
||||
double dely1 = x[i1][1] - x[i2][1];
|
||||
double delz1 = x[i1][2] - x[i2][2];
|
||||
domain->minimum_image(delx1,dely1,delz1);
|
||||
double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1);
|
||||
|
||||
double delx2 = x[i3][0] - x[i2][0];
|
||||
double dely2 = x[i3][1] - x[i2][1];
|
||||
double delz2 = x[i3][2] - x[i2][2];
|
||||
domain->minimum_image(delx2,dely2,delz2);
|
||||
double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2);
|
||||
|
||||
double c = delx1*delx2 + dely1*dely2 + delz1*delz2;
|
||||
c /= r1*r2;
|
||||
if (c > 1.0) c = 1.0;
|
||||
if (c < -1.0) c = -1.0;
|
||||
|
||||
double theta = acos(c);
|
||||
double dtheta = theta - theta0[type];
|
||||
double dcostheta = cos(dtheta);
|
||||
double tk = k[type] * (1.0-dcostheta);
|
||||
return tk;
|
||||
}
|
||||
28
src/MOLECULE/angle_cosine_delta.h
Normal file
28
src/MOLECULE/angle_cosine_delta.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
This software is distributed under the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ANGLE_COSINE_DELTA_H
|
||||
#define ANGLE_COSINE_DELTA_H
|
||||
|
||||
#include "stdio.h"
|
||||
#include "angle_cosine_squared.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AngleCosineDelta : public AngleCosineSquared {
|
||||
public:
|
||||
AngleCosineDelta(class LAMMPS *);
|
||||
void compute(int, int);
|
||||
double single(int, int, int, int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -22,15 +22,15 @@ namespace LAMMPS_NS {
|
||||
class AngleCosineSquared : public Angle {
|
||||
public:
|
||||
AngleCosineSquared(class LAMMPS *);
|
||||
~AngleCosineSquared();
|
||||
void compute(int, int);
|
||||
virtual ~AngleCosineSquared();
|
||||
virtual void compute(int, int);
|
||||
void coeff(int, int, char **);
|
||||
double equilibrium_angle(int);
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
double single(int, int, int, int);
|
||||
virtual double single(int, int, int, int);
|
||||
|
||||
private:
|
||||
protected:
|
||||
double *k,*theta0;
|
||||
|
||||
void allocate();
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#ifdef AngleInclude
|
||||
#include "angle_charmm.h"
|
||||
#include "angle_cosine.h"
|
||||
#include "angle_cosine_delta.h"
|
||||
#include "angle_cosine_squared.h"
|
||||
#include "angle_harmonic.h"
|
||||
#include "angle_hybrid.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#ifdef AngleClass
|
||||
AngleStyle(charmm,AngleCharmm)
|
||||
AngleStyle(cosine,AngleCosine)
|
||||
AngleStyle(cosine/delta,AngleCosineDelta)
|
||||
AngleStyle(cosine/squared,AngleCosineSquared)
|
||||
AngleStyle(harmonic,AngleHarmonic)
|
||||
AngleStyle(hybrid,AngleHybrid)
|
||||
|
||||
Reference in New Issue
Block a user