[lammps-users] implementing pe/molecule, ke/molecule code

Dear All,

When implementing a new compute for pe/molecule, I've run into a snag.
I've attached ke/molecule for everyone should it be useful for you and
verified it against the tradition ke per group calculation.

pe/atom provides the per-atom potential energy, so a simple sum over
the molecules should be sufficient. it should look something like the
attached code below, where emol is the per-molecule energies, energy
is the final per-atom energies. how do i get this as the output to the
compute in global vector form? i need to spend more time with the code
(i am not a c++ programmer at all so much of this object orientation
is still foreign to me) but if anyone has any quick advice i would
greatly appreciate it.

thanks,
anthony

compute_ke_molecule.cpp (2.85 KB)

compute_ke_molecule.h (1.06 KB)

Several computes produce global vectors, type:
grep compute_vector compute*cpp

Is your definition of ke or pe/molecule, simply
the sum of ke or pe/atom over the atoms in
each molecule?

If so, I think this would be better cast as a
compute atom/molecule command which
allows any other computes/fixes/variables
that produce per-atom quantities to be
summed on a per-molecule basis.

Steve

I have finished pe/molecule and it is attached for anyone who'd like
to use it. The results have been verified with the standard
group-pe/atom-reduce approach, and I have also verified them for an
arbitrary number of processors. I agree Steve that a general compute
atom/molecule command would be wonderful but at the current time I
haven't done this. Perhaps in the future.

Previously I attached a ke/molecule routine. It is in this thread. It
does not function correctly when nproc > 3. It starts giving
completely incorrect results. When I compare output from ke/molecule
(left) and the traditional group/ke (right) approach for nproc < 4
processors, I get:

   2.3277478 2.3277478
  0.88430573 0.88430573
   1.1773675 1.1773675
   5.7744706 5.7744706
   6.0560864 6.0560864
  0.84987374 0.84987374
[.......]

When nproc > 3, then everything goes crazy:

           0 2.3277478
           0 0.88430577
           0 1.1763114
           0 6.1807095
           0 7.1122559
           0 0.56913804
           0 2.1099174
           0 4.2751924
   0.9184467 1.7285658
   1.1371243 5.0803918
   1.1759576 4.0432346
  0.44834868 1.1018384

If anyone very familiar with the parallel implementation in LAMMPS has
any ideas I would greatly appreciate it. My ke/molecule routine is
modeled exactly as my pe/molecule routine and the normal ke function.

Best,
Anthony

compute_pe_molecule.cpp (5.72 KB)

compute_pe_molecule.h (1.25 KB)

See the new compute atom/molecule command in the 21Oct10
patch, which can sum any per-atom value on a per-molecule basis.
Please check if this does what you want ...

Thanks,
Steve