Optimizing `vdw_energy()`
Closed this issue · 2 comments
SimonEnsemble commented
I think r_squared
follows from dx
as r_squared = sum(dx .* dx)
, no? i.e., no need to compute x_k
or do molecule.pos[:,i] - x_k
. Is that right?
SimonEnsemble commented
framework.box.c_to_f * molecule.pos
is computed multiple times inside the loop over atoms of the molecule.
So maybe this should be outside of the for loop over framework atoms.
xf_molecule_atom = framework.box.c_to_f * molecule.pos[:, i]
and then work with it later.
SimonEnsemble commented
dxf[j] += sign(dxf[j]) * repfactors[j]
is the sign right here? If dxf[j]
is less than negative repfactors[j] / 2
, it should be shifted to the right, so we should add repfactors[j]
, not make it further to the left?