some questions about the source code of lammps

Dear sir,

My name is Jiawei Xu.I am a student from Zhejiang University in China, now, I face some problem when I modify the source code of bond_harmonic of lammps.

I can’t understand these part of the source code of bond_harmonic.

Number 1

r = sqrt(rsq);

dr = r - r0[type];

rk = k[type] * dr;

As we know, the potential formula of bond harmonic is E=K(r-r0)^2, the coefficient of the style is K and r0, through the source code I list, I can’t understand the meaning of ‘[type]’, I also see ‘[type]’ in the other style of bond, so I want you could tell me the meaning of the ‘[type]’.

Number 2

This statement if (r > 0.0) fbond = -2.0*rk/r calculates the force magnitude scaled by distance r, my question is that I only the potential formula, I don’t know the formula that calculated the force, how can I transform the formula of potential to the formula of force, I can’t find it in the code, I wish you can help me.

Above all are two questions of myself, I am looking forward to getting your suggestion. Thank you very much.

Best regards

Jiawei

The bond coeff command defines K and r0 for each

bond type. Thus r0[type] refers to that value.

Force = -dE/dr.

Steve