Project

General

Profile

Bug #2362

tng_*_of_particle_nr_get() functions return wrong result for structures with multiple molecule types

Added by Alexey Anikeenko 4 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Affected version - extra info:
1.8.1
Affected version:
Close

Description

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.

conf.gro (401 Bytes) conf.gro configuration with 1 Na + 2 water molecules Alexey Anikeenko, 12/21/2017 11:01 AM
topol.top (169 Bytes) topol.top Alexey Anikeenko, 12/21/2017 11:04 AM
conf.tng (1.23 KB) conf.tng trjconv result Alexey Anikeenko, 12/21/2017 11:04 AM
funcX_of_particle_nr.patch (2.1 KB) funcX_of_particle_nr.patch suggested fix Alexey Anikeenko, 12/21/2017 11:06 AM

Also available in: Atom PDF