What are the command lines used for the dumping forces in LAMMPS code?

The forces are the particular atoms/molecules forces due the effect of another atoms/molecules(Fij). These forces used for my spectral heat flux calculation please help me out.

Hi there,
Have you taken a look at the LAMMPS website? you can find detailed information here.

1 Like

I studied whatever you said and I tried also

Define computes for forces

compute force_BOR BOR group/group CH3

Ensure the compute command calculates per-atom information

compute_modify force_BOR dynamic yes

Define a dump file to store force data for Boron atoms

dump 1 all custom 100 forces_BOR.dat id c_force_BOR[1] c_force_BOR[2] c_force_BOR[3]

Actually I added above lines to my input code but I’m getting below error how to resolve this you have any idea sir

ERROR: Dump custom compute force_BOR does not compute per-atom info (src/dump_custom.cpp:1450)
Last command: dump 1 all custom 100 forces_BOR.dat id c_force_BOR[1] c_force_BOR[2] c_force_BOR[3]

“Ensure the compute command calculates per-atom information” is a bit optimistic. If you look in the documentation for compute group/group you will not see any instructions for how to make the compute do that (because the only way to do that is to modify the source code).

What about something like:

compute prop all property/atom fx fy fz
variable afx atom c_prop[1]
variable afy atom c_prop[2]
variable afz atom c_prop[3]
dump 1 all custom 100 forces.dump id xu yu zu v_afx v_afy v_afz
dump_modify 1 sort id colname v_afx Fx colname v_afy Fy colname v_afz Fz

Thank you for your reply sir. But I have some doubt whatever the force components in your command lines that forces are total force or force acting on one atom due to the effect of another atom(Fij)?

For example in my system I want to compute the force components of CH3 molecules due to the effect of Boron atoms(Fij).

I see. First of all, let me simplify the previous snippet:

compute prop all property/atom fx fy fz
dump 2 all custom $d forces2.dump id xu yu zu c_prop[1] c_prop[2] c_prop[3]
dump_modify 2 sort id colname c_prop[1] Fx colname c_prop[2] Fy colname c_prop[3] Fz

What you dump here is the total force acting on each atom.

If you want a subset, I would do it with a rerun where you define a group with the atoms you want to investigate and set to zero the pair coefficients or forces of the rest. Then you can restrict the compute and dump only to the group of interest.

You cannot have an output of all pairwise force contributions. There are far too many and that would require a massive use of extra storage or would cause a significant slowdown of the code (even if that output is not desired). Thus you can only have this if you modify the source code and accumulate and output it directly.

Please note, that when you are using long-range Coulomb by using a coul/long containing pair style and a kspace style, then you cannot even compute this properly, since the kspace contribution is not a pairwise computation and thus cannot be easily decomposed into pairwise subsets.

As @hothello was alluding to, the use of rerun in combination with a smart setting of pair coefficients, a switch to a cutoff coulomb (so you won’t need kspace) and a proper use of neigh_modify exclude can give you the total forces to individual atoms due to the atoms they are interacting with according to the settings. You will still not have the individual pairwise contributions. Those require source code modifications.

Please also note, that the compute group/group documentation clearly states that it computes the total force and total energy of the interaction between the two groups.

Can you please explain clearly Sir. I can’t understand clearly what you said.

Thank you for your reply sir. can you have idea about heat flux extraction from lammps input code? Can you provide the lines which are used to dump the heat flux in solid-liquid interaction case. Thank you in advance.

Please study the documentation. That is what it is for.

I written these lines to extract force

compute f1 poly force/tally

variable fx equal c_f1[1]

variable fy equal c_f1[2]

variable fz equal c_f1[3]

fix ff poly ave/correlate 1 100 100 c_f1[1] c_f1[2] c_f1[3] type auto file force.dat ave running

But im getting error

ERROR: Illegal compute force/tally command: missing argument(s) (src/TALLY/compute_force_tally.cpp:33)
Last command: compute f1 poly force/tally
where I did mistake Can you please help me out Sir.

Please study the documentation. That is what it is for.