[lammps-users] energy keyword in fix addforce

Dear all,

I have no clue on defining the energy keyword for the way that I am using fix addforce below for fixes 3 & 4. Any help is greatly appreciated.

fix 1 UpperFixed store/force
fix 2 LowerFixed store/force

compute ufzc UpperFixed reduce ave f_1[3]
compute lfzc LowerFixed reduce ave f_2[3]

variable avg_velocityZ_up equal vcm(UpperFixed,z)
variable avg_velocityZ_low equal vcm(LowerFixed,z)

variable vz_init_upper equal -v_avg_velocityZ_up
variable vz_init_lower equal -v_avg_velocityZ_low

velocity UpperFixed set 0 0 v_vz_init_upper sum yes units box
velocity LowerFixed set 0 0 v_vz_init_lower sum yes units box

variable appforceZ1 equal -c_ufzc
variable appforceZ2 equal -c_lfzc

fix 3 UpperFixed addforce 0 0 v_appforceZ1 energy ???

fix_modify 3 virial yes energy yes

fix 4 LowerFixed addforce 0 0 v_appforceZ2 energy ???

fix_modify 4 virial yes energy yes

fix 5 all npt/cauchy temp {TempHi} {TempHi} (100.0 * dt) & x 0.0 0.0 (1000.0 * dt) y 0.0 0.0 $(1000.0 * dt) couple none tchain 5 tloop 100 pchain 5 ploop 100 nreset 1000 alpha 0.001

fix_modify 5 temp TempNVT press Press

fix 7 all dt/reset 1 NULL NULL ${MaxDist} units box

fix 8 all balance 2500 1.0 shift xyz 10 1.0 weight time 0.8

fix 9 all momentum 1000 linear 1 1 1 #angular

run 100000 post no

It looks like you are computing an average force and applying that as a variable with fix addforce.
There is no way I see to specify the energy variable for that needed for minimization.

Why not just use fix aveforce instead? It can work with minimization as-is. No need for a variable.

Steve

Steve,

One last question on this fix.

Do you think it is necessary to modify fixes 3 and 4 like below?

fix 1 UpperFixed store/force
fix 2 LowerFixed store/force

compute ufzc UpperFixed reduce ave f_1[3]
compute lfzc LowerFixed reduce ave f_2[3]

variable avg_velocityZ_up equal vcm(UpperFixed,z)
variable avg_velocityZ_low equal vcm(LowerFixed,z)

variable vz_init_upper equal -v_avg_velocityZ_up
variable vz_init_lower equal -v_avg_velocityZ_low

velocity UpperFixed set 0 0 v_vz_init_upper sum yes units box
velocity LowerFixed set 0 0 v_vz_init_lower sum yes units box

variable appforceZ1 equal -c_ufzc
variable appforceZ2 equal -c_lfzc

fix 3 UpperFixed addforce 0 0 v_appforceZ1

fix_modify 3 virial yes energy yes

fix 4 LowerFixed addforce 0 0 v_appforceZ2

fix_modify 4 virial yes energy yes

fix 5 all npt/cauchy temp 300 300 (100.0 * dt) & x 0.0 0.0 (1000.0 * dt) y 0.0 0.0 $(1000.0 * dt) couple none tchain 5 tloop 100 pchain 5 ploop 100 nreset 1000 alpha 0.001

fix_modify 5 temp TempNVT press Press

fix 7 all dt/reset 1 NULL NULL 0.02 units box

fix 8 all balance 2500 1.0 shift xyz 10 1.0 weight time 0.8

fix 9 all momentum 1000 linear 1 1 1

run 100000 post no

The fix addforce doc page explains what those 2 modify options do. It’s up to you.
Try a modify option both ways to see the difference.

Steve