tng_*_of_particle_nr_get() functions return wrong result for structures with multiple molecule types
Most of the fuctions getting properties of real particle nr return wrong values if structure contains several molecules with different number of atoms.
Steps to reproduce using tng_io_read_pos example program and sample structure with 1*Na+ and 2*H2O molecules:
$ ./tng/build/bin/examples/tng_io_read_pos conf.tng 1 Result: 1 frames in file Particle: HW1 (: SOL) 0 0.230000 0.628000 0.113000 Expected result: 1 frames in file Particle: OW (: SOL) 0 0.230000 0.628000 0.113000
I believe, it happens due to logical error of using [nr % mol->n_atoms] instead of [(nr - cnt) % mol->n_atoms], which was later copy/pasted. Suggested fix is attached below.
This bug affects VMD's molfile/tngpulugin.C (not yet binary distributed), because they use these functions to read topological structure from .tng file.