I am new to lammps, I am simulating a membrane and gas molecules in the surroundings, I want to know what is the necessary force to maintain a position in z, for which I am fixing a group of molecules that I call c and calculating what is the force necessary to maintain in that position for which I am using addforce, but when I add addforce at the time of printing the force in z it appears zero, does anyone know how I can solve this?
compute cforcex group-c property/atom fx
compute cforcey group-c property/atom fy
compute cforcez group-c property/atom fz
variable forcex equal -fx[2080]
variable forcey equal -fy[2080]
variable forcez equal -fz[2080]
dump 4 group-c custom 100 final.dump id type x y z c_cforcex c_cforcey c_cforcez
variable posx equal x[2080]
variable posy equal y[2080]
variable posz equal z[2080]
# Thermodynamic properties
thermo_style custom step temp pe ke etotal press density v_forcex v_forcey v_forcez v_posx v_posy v_posz
thermo 100
# Apply forces
fix 1 all nvt temp 0.1 0.1 0.01
fix c-group group-c addforce 0 0 v_forcez every 1
I have try to put the dump command before add force or thermostyle command before add force but I got zero for the force in the z direcction, which is no true
To have the atoms in group group-c
immobilized in z-direction, you would only need to do:
velocity group-c set NULL NULL 0.0
fix zzero group-c setforce NULL NULL 0.0
If an atom has no velocity and there is no force to change its velocity, then it will not move.
right but the true it is I don’t want the force in z to be zero, I want to know what it is the force that it should be applied to nullify the force on z but when I do it the way I am doing it, the force in z seems to be zero
That force is - of course - the negative of the z-force on the individual atoms in that group. You can actually retrieve that force from fix setforce (check out the part of its documentation describing output obtions).
If you want the net force of the entire group, you need to use compute reduce with the sum option.
What your code does and what you are looking at are the force components of one specific atom, but it is not at all clear from the information you provide, how you selected that specific atom and what its force represents.
ok many thanks, the atom was selected randomly, and my intention is to run a lot of simulations to observe the necessary force to keep that atom in differents positions in z (each simulation at the same z), for that I need to allow to move in the plane x-y but not in z
Please have a look at fix aveforce.
it works same way as addforce I guess my problem is the output forces, I don’t want lammps just to nullify the force in z but to show me how much is need to keep it in the position but whenever I applied add force or aveforce in thermo style output show the force is zero in z same for dump output…
If you use fix addforce and add the negative force acting on the atoms in the fix group, the force in the dump file should be zero. However, if you are using fix setforce in the way is suggested, you can get the output of the forces before they were set to zero from the fix. As I have already pointed out, how to do this can be inferred from the documentation (and the output howto).
Please note that we are beginning to go in circles now, and mostly because the information your are providing is very limited and in parts contradictory. If you still want something else, you need to provide a better and more detailed explanation of what it is that you want to do and also explain why and it would be a massive improvement, if you could demonstrate what you want using one of the example input decks bundled with LAMMPS.
ok what I want is to apply a restraining force in z direction (i.e. atoms would be allowed to move in z-direction, but pull back by the force) but as I do or intending to do that I get zero in the force in z, and in the dump file I am still getting the same so I guess I don’t get how to do it properly 