Skip to content
Snippets Groups Projects
Commit 0ca6b16a authored by cmaffeo2's avatar cmaffeo2
Browse files

Fixed revert

parent 29535488
No related branches found
No related tags found
No related merge requests found
......@@ -180,80 +180,3 @@ int FullTabulatedPotential::countValueLines(const char* fileName) {
return count;
}
void TabulatedPotential::truncate(float cutoff) {
int home = int(floor((cutoff - r0)/dr));
if (home > n) return;
float v = v0[home];
for (int i = home; i < n; i++) v0[i] = v;
interpolate();
}
bool TabulatedPotential::truncate(float switchDist, float cutoff, float value) {
int indOff = int(floor((cutoff - r0)/dr));
int indSwitch = int(floor((switchDist - r0)/dr));
if (indSwitch > n) return false;
// Set everything after the cutoff to "value".
for (int i = indOff; i < n; i++) v0[i] = value;
// Apply a linear switch.
float v = v0[indSwitch];
float m = (value - v)/(indOff - indSwitch);
for (int i = indSwitch; i < indOff; i++) v0[i] = m*(i - indSwitch) + v;
interpolate();
return true;
}
Vector3 TabulatedPotential::computeForce(Vector3 r) {
float d = r.length();
Vector3 rUnit = -r/d;
int home = int(floor((d - r0)/dr));
if (home < 0) return Vector3(0.0f);
if (home >= n) return Vector3(0.0f);
float homeR = home*dr + r0;
float w = (d - homeR)/dr;
// Interpolate.
Vector3 force = -(3.0f*v3[home]*w*w + 2.0f*v2[home]*w + v1[home])*rUnit/dr;
return force;
}
void TabulatedPotential::init(const float* dist, const float* pot, int n0) {
n = abs(n0);
dr = dist[1]-dist[0];
r0 = dist[0];
r1 = r0 + n*dr;
v0 = new float[n];
for (int i = 0; i < n; i++) v0[i] = pot[i];
}
void TabulatedPotential::interpolate() {
v1 = new float[n];
v2 = new float[n];
v3 = new float[n];
for (int i = 0; i < n; i++) {
int i0 = i - 1;
int i1 = i;
int i2 = i + 1;
int i3 = i + 2;
if (i0 < 0) i0 = 0;
if (i2 >= n) i2 = n-1;
if (i3 >= n) i3 = n-1;
v3[i] = 0.5f*(-v0[i0] + 3.0f*v0[i1] - 3.0f*v0[i2] + v0[i3]);
v2[i] = 0.5f*(2.0f*v0[i0] - 5.0f*v0[i1] + 4.0f*v0[i2] - v0[i3]);
v1[i] = 0.5f*(-v0[i0] + v0[i2]);
}
e0 = v3[n-1] + v2[n-1] + v1[n-1] + v0[n-1];
}
>>>>>>> parent of 7b4247c... Merge branch 'feat/bondangle' into release
......@@ -14,6 +14,12 @@
#include "useful.h"
#include <cuda.h>
#ifndef gpuErrchk
#define delgpuErrchk
#define gpuErrchk(code) { if ((code) != cudaSuccess) { \
fprintf(stderr,"CUDA Error: %s %s %d\n", cudaGetErrorString(code), __FILE__, __LINE__); \
}}
#endif
class EnergyForce {
public:
......@@ -171,4 +177,8 @@ private:
float drInv; //TODO replace with drInv
float r0;
};
#ifndef delgpuErrchk
#undef delgpuErrchk
#undef gpuErrchk
#endif
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment