11 #define MIN_DEBUG_LEVEL 3 19 #define GF_OVERLAPCHECK_FREQ 1000 43 int numGridForcedAtoms=0;
48 for (
int gridnum = 0; gridnum < numGrids; gridnum++) {
54 return numGridForcedAtoms;
77 for (
int gridnum = 0; gridnum < numGrids; gridnum++) {
78 std::vector <int> thisGrid;
79 thisGrid.reserve(numGridForcedAtoms);
82 thisGrid.push_back(i);
96 Vector gfScale = grid->get_scale();
99 int gridForcedCount=0;
106 for (
int idx = 0; idx < thisGrid.size(); idx++)
112 DebugM(1,
"Atom " << p[i].
id <<
" is gridforced\n" <<
endi);
121 int err = grid->compute_VdV(pos, V, dV);
130 Force force = -charge * scale *
Vector(gfScale.
x * dV.
x, gfScale.
y * dV.
y, gfScale.
z * dV.
z);
133 DebugM(2,
"scale = " << scale <<
" gfScale = " << gfScale <<
" charge = " << charge <<
"\n" <<
endi);
137 DebugM(2,
"grid = " << gridnum <<
" force = " << force <<
" pos = " << pos <<
" V = " << V <<
" dV = " << dV <<
" step = " <<
homePatch->
flags.
step <<
" index = " << p[i].
id <<
"\n" <<
endi);
139 DebugM(1,
"transform = " << (
int)p[i].transform.i <<
" " 143 iout <<
iWARN <<
"V is NaN!\natomid = " << p[i].
id <<
" loc = " << p[i].
position <<
" V = " << V <<
"\n" <<
endi;
152 if (gfScale.
x == gfScale.
y && gfScale.
x == gfScale.
z)
155 energy += scale * gfScale.
x * (charge * V);
159 extVirial +=
outer(force,vpos);
165 for (
int i = 0; i <
numAtoms; i++) {
168 DebugM(1,
"Atom " << p[i].
id <<
" is gridforced\n" <<
endi);
179 int err = grid->compute_VdV(pos, V, dV);
188 Force force = -charge * scale *
Vector(gfScale.
x * dV.
x, gfScale.
y * dV.
y, gfScale.
z * dV.
z);
191 DebugM(2,
"scale = " << scale <<
" gfScale = " << gfScale <<
" charge = " << charge <<
"\n" <<
endi);
195 DebugM(2,
"grid = " << gridnum <<
" force = " << force <<
" pos = " << pos <<
" V = " << V <<
" dV = " << dV <<
" step = " <<
homePatch->
flags.
step <<
" index = " << p[i].
id <<
"\n" <<
endi);
197 DebugM(1,
"transform = " << (
int)p[i].transform.i <<
" " 201 iout <<
iWARN <<
"V is NaN!\natomid = " << p[i].
id <<
" loc = " << p[i].
position <<
" V = " << V <<
"\n" <<
endi;
210 if (gfScale.
x == gfScale.
y && gfScale.
x == gfScale.
z)
213 energy += scale * gfScale.
x * (charge * V);
217 extVirial +=
outer(force,vpos);
256 if ((gfScale.
x == 0.0) && (gfScale.
y == 0.0) && (gfScale.
z == 0.0)) {
257 DebugM(3,
"Skipping grid index " << gridnum <<
"\n" <<
endi);
269 sprintf(errmsg,
"Warning: Periodic cell basis too small for Gridforce grid %d. Set gridforcechecksize off in configuration file to ignore.\n", gridnum);
278 DebugM(3,
"center = " << center <<
"\n" <<
endi);
284 do_calc(g, gridnum, p,
numAtoms, mol, forces, energy, extForce, extVirial);
287 do_calc(g, gridnum, p,
numAtoms, mol, forces, energy, extForce, extVirial);
GridforceGrid * get_gridfrc_grid(int gridnum) const
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
NAMD_HOST_DEVICE Tensor outer(const Vector &v1, const Vector &v2)
#define ADD_TENSOR_OBJECT(R, RL, D)
SimParameters * simParameters
ComputeGridForce(ComputeID c, PatchID pid)
std::ostream & endi(std::ostream &s)
#define GF_OVERLAPCHECK_FREQ
std::ostream & iWARN(std::ostream &s)
SubmitReduction * willSubmit(int setID, int size=-1)
void createGridForcedIdxList(int numGridForcedAtoms)
void doForce(FullAtom *p, Results *r)
static ReductionMgr * Object(void)
Molecule stores the structural information for the system.
FullAtomList & getAtomList()
bool fits_lattice(const Lattice &lattice)
void NAMD_bug(const char *err_msg)
virtual Position get_center(void) const =0
virtual ~ComputeGridForce()
SubmitReduction * reduction
PatchID getPatchID() const
void get_gridfrc_params(Real &k, Charge &q, int atomnum, int gridnum) const
int checkGridForceRatio()
if fewer than half the atoms in the patch need grid forces, use a list
void NAMD_die(const char *err_msg)
virtual Bool get_checksize(void) const =0
virtual Vector get_scale(void) const =0
virtual Tensor get_e(void) const =0
#define ADD_VECTOR_OBJECT(R, RL, D)
void do_calc(T *grid, int gridnum, FullAtom *p, int numAtoms, Molecule *mol, Force *forces, BigReal &energy, Force &extForce, Tensor &extVirial)
Bool is_atom_gridforced(int atomnum, int gridnum) const
GridforceGridType get_grid_type(void)
std::vector< std::vector< int > > gridForcedAtomIdxList