diff -Naur lammps-1Dec08/doc/fix_modify.html lammps-2Dec08/doc/fix_modify.html --- lammps-1Dec08/doc/fix_modify.html 2008-02-29 18:13:20.000000000 -0700 +++ lammps-2Dec08/doc/fix_modify.html 2008-12-03 13:54:17.000000000 -0700 @@ -61,7 +61,10 @@ thermo_style command for info on how potential energy is output. The contribution by itself can be printed by using the keyword f_ID in the thermo_style custom command, where ID is the -fix-ID of the appropriate fix. +fix-ID of the appropriate fix. Note that you must use this setting +for a fix if you are using it when performing an energy +minimization and if you want the energy and forces it +produces to be part of the optimization criteria.
Restrictions: none
diff -Naur lammps-1Dec08/doc/fix_modify.txt lammps-2Dec08/doc/fix_modify.txt --- lammps-1Dec08/doc/fix_modify.txt 2008-02-29 18:13:20.000000000 -0700 +++ lammps-2Dec08/doc/fix_modify.txt 2008-12-03 13:54:17.000000000 -0700 @@ -54,7 +54,10 @@ "thermo_style"_thermo_style.html command for info on how potential energy is output. The contribution by itself can be printed by using the keyword f_ID in the thermo_style custom command, where ID is the -fix-ID of the appropriate fix. +fix-ID of the appropriate fix. Note that you must use this setting +for a fix if you are using it when performing an "energy +minimization"_minimize.html and if you want the energy and forces it +produces to be part of the optimization criteria. [Restrictions:] none diff -Naur lammps-1Dec08/doc/fix_spring.html lammps-2Dec08/doc/fix_spring.html --- lammps-1Dec08/doc/fix_spring.html 2008-05-15 16:05:51.000000000 -0600 +++ lammps-2Dec08/doc/fix_spring.html 2008-12-03 14:44:31.000000000 -0700 @@ -101,9 +101,7 @@ various output commands. This is the total force on the group of atoms by the spring. In the case of the couple style, it is the force on the fix group (group-ID) or the -negative of the force on the 2nd group (group-ID2). The vector values -calculated by this fix are "extensive", meaning they scale with the -number of atoms in the simulation. +negative of the force on the 2nd group (group-ID2).No parameter of this fix can be used with the start/stop keywords of the run command. This fix is not invoked during energy diff -Naur lammps-1Dec08/doc/fix_spring.txt lammps-2Dec08/doc/fix_spring.txt --- lammps-1Dec08/doc/fix_spring.txt 2008-05-15 16:05:51.000000000 -0600 +++ lammps-2Dec08/doc/fix_spring.txt 2008-12-03 14:44:31.000000000 -0700 @@ -94,9 +94,7 @@ various "output commands"_Section_howto.html#4_15. This is the total force on the group of atoms by the spring. In the case of the {couple} style, it is the force on the fix group (group-ID) or the -negative of the force on the 2nd group (group-ID2). The vector values -calculated by this fix are "extensive", meaning they scale with the -number of atoms in the simulation. +negative of the force on the 2nd group (group-ID2). No parameter of this fix can be used with the {start/stop} keywords of the "run"_run.html command. This fix is not invoked during "energy diff -Naur lammps-1Dec08/doc/fix_spring_self.html lammps-2Dec08/doc/fix_spring_self.html --- lammps-1Dec08/doc/fix_spring_self.html 2008-06-06 17:21:53.000000000 -0600 +++ lammps-2Dec08/doc/fix_spring_self.html 2008-12-03 14:44:31.000000000 -0700 @@ -46,9 +46,9 @@ potential energy as part of thermodynamic output.
This fix computes a scalar energy which can be accessed by various -output commands. The scalar value -calculated by this fix is "extensive", meaning it scales with the -number of atoms in the simulation. +output commands. This energy is the sum of +the spring energy for each atom, where the per-atom energy is 0.5 * K +* r^2.
No parameter of this fix can be used with the start/stop keywords of the run command. diff -Naur lammps-1Dec08/doc/fix_spring_self.txt lammps-2Dec08/doc/fix_spring_self.txt --- lammps-1Dec08/doc/fix_spring_self.txt 2008-06-06 17:21:53.000000000 -0600 +++ lammps-2Dec08/doc/fix_spring_self.txt 2008-12-03 14:44:31.000000000 -0700 @@ -43,9 +43,9 @@ potential energy as part of "thermodynamic output"_thermo_style.html. This fix computes a scalar energy which can be accessed by various -"output commands"_Section_howto.html#4_15. The scalar value -calculated by this fix is "extensive", meaning it scales with the -number of atoms in the simulation. +"output commands"_Section_howto.html#4_15. This energy is the sum of +the spring energy for each atom, where the per-atom energy is 0.5 * K +* r^2. No parameter of this fix can be used with the {start/stop} keywords of the "run"_run.html command. diff -Naur lammps-1Dec08/src/fix_spring.cpp lammps-2Dec08/src/fix_spring.cpp --- lammps-1Dec08/src/fix_spring.cpp 2008-08-01 10:09:17.000000000 -0600 +++ lammps-2Dec08/src/fix_spring.cpp 2008-12-03 14:26:29.000000000 -0700 @@ -28,8 +28,7 @@ using namespace LAMMPS_NS; -#define TETHER 0 -#define COUPLE 1 +enum{TETHER,COUPLE}; /* ---------------------------------------------------------------------- */ @@ -157,9 +156,6 @@ double *mass = atom->mass; int nlocal = atom->nlocal; - ftotal[0] = ftotal[1] = ftotal[2] = 0.0; - force_flag = 0; - double massfrac; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -167,10 +163,12 @@ f[i][0] -= fx*massfrac; f[i][1] -= fy*massfrac; f[i][2] -= fz*massfrac; - ftotal[0] -= fx*massfrac; - ftotal[1] -= fy*massfrac; - ftotal[2] -= fz*massfrac; } + + ftotal[0] = -fx; + ftotal[1] = -fy; + ftotal[2] = -fz; + force_flag = 0; } /* ---------------------------------------------------------------------- */ @@ -207,9 +205,6 @@ double *mass = atom->mass; int nlocal = atom->nlocal; - ftotal[0] = ftotal[1] = ftotal[2] = 0.0; - force_flag = 0; - double massfrac; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -217,9 +212,6 @@ f[i][0] += fx*massfrac; f[i][1] += fy*massfrac; f[i][2] += fz*massfrac; - ftotal[0] += fx*massfrac; - ftotal[1] += fy*massfrac; - ftotal[2] += fz*massfrac; } if (mask[i] & group2bit) { massfrac = mass[type[i]]/masstotal2; @@ -228,6 +220,11 @@ f[i][2] -= fz*massfrac; } } + + ftotal[0] = -fx; + ftotal[1] = -fy; + ftotal[2] = -fz; + force_flag = 0; } /* ---------------------------------------------------------------------- */