Skip to content

Commit c1e7433

Browse files
committed
Fixed a panic when writing groups of atoms not starting with index 0 into XTC/TRR files
1 parent 4d5da93 commit c1e7433

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "groan_rs"
33
description = "Gromacs Analysis Library for Rust"
4-
version = "0.11.0"
4+
version = "0.11.1"
55
license = "MIT"
66
edition = "2021"
77
authors = ["Ladislav Bartos"]

src/io/trr_io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,17 @@ impl PrivateTrajWrite for TrrWriter {
491491
let iterator =
492492
AtomIterator::new(system.get_atoms(), self.group.get_atoms(), system.get_box());
493493

494-
for atom in iterator {
494+
for (i, atom) in iterator.enumerate() {
495495
if let Some(pos) = atom.get_position() {
496-
coordinates[atom.get_index()] = [pos.x, pos.y, pos.z];
496+
coordinates[i] = [pos.x, pos.y, pos.z];
497497
}
498498

499499
if let Some(vel) = atom.get_velocity() {
500-
velocities[atom.get_index()] = [vel.x, vel.y, vel.z];
500+
velocities[i] = [vel.x, vel.y, vel.z];
501501
}
502502

503503
if let Some(force) = atom.get_force() {
504-
forces[atom.get_index()] = [force.x, force.y, force.z]
504+
forces[i] = [force.x, force.y, force.z]
505505
}
506506
}
507507

src/io/xtc_io/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ mod xtc_write {
304304
let iterator =
305305
AtomIterator::new(system.get_atoms(), self.group.get_atoms(), system.get_box());
306306
let mut coordinates = vec![[0.0, 0.0, 0.0]; n_atoms];
307-
for atom in iterator {
307+
for (i, atom) in iterator.enumerate() {
308308
if let Some(pos) = atom.get_position() {
309-
coordinates[atom.get_index()] = [pos.x, pos.y, pos.z];
309+
coordinates[i] = [pos.x, pos.y, pos.z];
310310
}
311311
}
312312

0 commit comments

Comments
 (0)