Time-dependent external force

Dear All,

I would like to add a time-dependent external force to particles of my system simulated by using the DPD-SMOOTH. To this end, I look at the code:

pair_sdpd_taitwater_isothermal.cpp

and in principle the external force should be added to here:

f[i][0] += delx * fpair + (velx + delx * delVdotDelR / rsq) * fvisc + f_random[0] + fbx;
f[i][1] += dely * fpair + (vely + dely * delVdotDelR / rsq) * fvisc + f_random[1] + F_EXTERNAL(t)

However, how can I get the variable t of F_EXTERNAL(t)? It is not defined in

void PairSDPDTaitwaterIsothermal::compute (int eflag, int vflag)

Thank you very much for any help.

The proper mechanism to add an external force is to use fix external fix external command — LAMMPS documentation

The proper mechanism to add a time dependent force than can be computed from per-atom properties would be to use fix addforce with an atom style variable (that variable can depend on the time/timestep): fix addforce command — LAMMPS documentation

If you want to modify the source code, then you are free to do it, but then you have to read, learn and understand how LAMMPS works internally. You will not likely find people willing to help you with the rather blunt and very hackish approach that you seem to be looking at.

Thank you very much. In fact, I want to add a time-dependent force F_ij(t) acting on a particle i from its neighbour particle j. That is:

F(i) = F(i)_original + F_ij(t).

Where F(i)_original is the original force acting on i from MD force field. My question is whether fix addforce can do that? If not where can I get time t?

How is F_ij determined?

The code change you are quoting is not adding a pairwise force, but a per-atom force.

Thank you very much. The time-dependent force per atom is determined as:

F_ij(t) = k*[ r_ij(t) - r_ij_eq ]

where r_ij_eq is an equilibrium value, and r_ij(t) is time-dependent.

I would like to add this force to atoms in the code: pair_sdpd_taitwater_isothermal.cpp

This doesn’t say anything about how they are computed and what kind of time dependency you are after.

Please keep in mind, that advice given here can only be as good as the information you provide. At the moment, this is (still) extremely limited.

And - as I previously stated - the example code you have given does not apply a pairwise force, yet you claim that you have successfully done with a constant term. That means that either your assessment of success is not good or the information you have provided is incomplete.

Of course you are free to withhold more detailed information, but then it is not possible to give further advice than what was already given and what is available in the Programmer Guide section of the LAMMPS manual.