Dear all, I need 2nd derivative of Coul potential energy, and I need the Ewald sum in the calculation, can you give me some tips? Regards, yunai

Second derivative with respect to what?

And when and what do you need it for?

Thanks for reply. I used ewald sum in the calculation of coulomb energy, i was stuck in the second derivative with respect to the Coulomb energy U(r) in the formula [ U’’(r) - U’(r)/r ] . This is related with the calculation of elastic constant in

J.R. Ray, M.C. Moody, A. Rahman, Phys. Rev. B 32 (1985) 733.

I need to do it in my compute style cpp, and using fix to output it.

The problem is that I can’t fully understand the Coulomb force and energy algorithm in the KSPACE/pair_coul_long.cpp, which uses ftable and etable, what should I to do with it?

yunai

Well, first of all, the Coulomb force and energy is computed in two parts. You have the short-range part (essentially a regular coulomb with an `erfc()`

damping) in the pair style and the long-range part is done in the kspace style.

Second, the ftable/etable code is just one branch of the code that speeds things up by approximating it with a 12bit-lookup table and linear interpolation, you can ignore it and just look at the alternate branch which uses a fast polynomial approximation for the `erfc()`

function. Or you just look up the explicit analytical functional form and implement it (slower) with using the `erfc()`

function from the math library directly. For the long-range part, you have to then look up the corresponding part in the ewald.cpp file.

To do this correctly and properly with a code as flexible as LAMMPS can be quite complex. An alternative, more general approach is to use finite differences and a harmonic approximation like in

fix numdiff command — LAMMPS documentation or dynamical_matrix command — LAMMPS documentation.

Very detailed reply, i’ll have a try. Thank you very much. Mr. akohlmey!

Best Regards,

yunai