Fix invalid result when dihedral quadratic angle is > pi or < -pi
This commit is contained in:
@ -195,6 +195,8 @@ void DihedralQuadratic::compute(int eflag, int vflag)
|
|||||||
siinv = 1.0/si;
|
siinv = 1.0/si;
|
||||||
|
|
||||||
double dphi = phi-phi0[type];
|
double dphi = phi-phi0[type];
|
||||||
|
if (dphi > MY_PI) dphi -= 2*MY_PI;
|
||||||
|
else if (dphi < -MY_PI) dphi += 2*MY_PI;
|
||||||
p = k[type]*dphi;
|
p = k[type]*dphi;
|
||||||
pd = - 2.0 * p * siinv;
|
pd = - 2.0 * p * siinv;
|
||||||
p = p * dphi;
|
p = p * dphi;
|
||||||
|
|||||||
@ -23,11 +23,13 @@
|
|||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
#include "math_const.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
|
||||||
#include "suffix.h"
|
#include "suffix.h"
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
using namespace MathConst;
|
||||||
|
|
||||||
#define TOLERANCE 0.05
|
#define TOLERANCE 0.05
|
||||||
#define SMALL 0.001
|
#define SMALL 0.001
|
||||||
@ -218,6 +220,8 @@ void DihedralQuadraticOMP::eval(int nfrom, int nto, ThrData * const thr)
|
|||||||
siinv = 1.0/si;
|
siinv = 1.0/si;
|
||||||
|
|
||||||
double dphi = phi-phi0[type];
|
double dphi = phi-phi0[type];
|
||||||
|
if (dphi > MY_PI) dphi -= 2*MY_PI;
|
||||||
|
else if (dphi < -MY_PI) dphi += 2*MY_PI;
|
||||||
p = k[type]*dphi;
|
p = k[type]*dphi;
|
||||||
pd = - 2.0 * p * siinv;
|
pd = - 2.0 * p * siinv;
|
||||||
p = p * dphi;
|
p = p * dphi;
|
||||||
|
|||||||
Reference in New Issue
Block a user