Commit 09d17766 authored by peastman's avatar peastman
Browse files

Fixed an edge condition that could cause errors in CMAPTorsionForce

parent e703f76f
......@@ -61,8 +61,8 @@ angleB = fmod(angleB+2.0f*PI, 2.0f*PI);
int2 pos = MAP_POS[MAPS[index]];
int size = pos.y;
real delta = 2*PI/size;
int s = (int) (angleA/delta);
int t = (int) (angleB/delta);
int s = (int) fmin(angleA/delta, size-1);
int t = (int) fmin(angleB/delta, size-1);
float4 c[4];
int coeffIndex = pos.x+4*(s+size*t);
c[0] = COEFF[coeffIndex];
......
/* Portions copyright (c) 2010-2016 Stanford University and Simbios.
/* Portions copyright (c) 2010-2020 Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -133,8 +133,8 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord
int size = (int) sqrt(coeff[map].size());
double delta = 2*M_PI/size;
int s = (int) (angleA/delta);
int t = (int) (angleB/delta);
int s = (int) fmin(angleA/delta, size-1);
int t = (int) fmin(angleB/delta, size-1);
const vector<double>& c = coeff[map][s+size*t];
double da = angleA/delta-s;
double db = angleB/delta-t;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment