Skip to content

Commit 1521afa

Browse files
authored
Merge pull request #8 from Ladme/v0.10
Version 0.10
2 parents c3d1d0d + d90cb7a commit 1521afa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+197421
-1558
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target
22
/Cargo.lock
3+
/.vscode
34

45
analyzer.rs
56
old.rs

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

Cargo.toml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,62 @@
11
[package]
22
name = "groan_rs"
33
description = "Gromacs Analysis Library for Rust"
4-
version = "0.9.0"
4+
version = "0.10.0"
55
license = "MIT"
66
edition = "2021"
77
authors = ["Ladislav Bartos"]
88
repository = "https://github.com/Ladme/groan_rs"
99
keywords = ["gromacs", "molecular-dynamics"]
1010
categories = ["command-line-utilities", "science"]
1111
build = "build.rs"
12-
exclude = ["test_files", ".vscode", "book", "validation"]
12+
exclude = [
13+
"test_files",
14+
".vscode",
15+
"book",
16+
"comparison",
17+
"run_check.sh",
18+
"run_check_tests.sh",
19+
"run_doc_tests.sh",
20+
"run_tests.sh",
21+
]
1322

1423
[dependencies]
15-
colored = "2.1"
24+
colored = "3.0.0"
1625
float-cmp = "0.10.0"
17-
indexmap = { version = "2.7", features = ["serde"] }
26+
indexmap = { version = "2.8.0", features = ["serde"] }
1827
regex = "1.11.1"
19-
thiserror = "2.0.4"
20-
serde = { version = "1.0.215", features = ["derive"] }
28+
thiserror = "2.0.12"
29+
serde = { version = "1.0.218", features = ["derive"] }
2130
serde_yaml = "0.9"
2231
fancy-regex = "0.14.0"
2332
nalgebra = "0.33.2"
24-
minitpr = "0.2.2"
33+
minitpr = "0.2.3"
2534
ndarray = "0.16.1"
2635
hashbrown = "0.15.2"
27-
getset = "0.1.3"
36+
getset = "0.1.5"
2837
parking_lot = { version = "0.12.3", optional = true }
38+
molly = { version = "0.3.3", optional = true }
39+
chemfiles = { version = "0.10.41", optional = true }
40+
itertools = "0.14.0"
41+
dyn-clone = "1.0.19"
2942

3043
[dev-dependencies]
3144
file_diff = "1.0.0"
32-
tempfile = "3.14.0"
33-
rand = "0.8.5"
45+
tempfile = "3.19.0"
46+
rand = "0.9.0"
3447
criterion = "0.5.1"
3548
paste = "1.0.15"
3649

3750
[build-dependencies]
38-
cc = { version = "1.2.1", features = ["parallel"] }
51+
cc = { version = "1.2.16", features = ["parallel"] }
3952

4053
[features]
54+
default = ["molly"]
55+
molly = ["dep:molly"]
56+
chemfiles = ["dep:chemfiles"]
4157
serde = ["ndarray/serde", "hashbrown/serde"]
42-
parallel = ["parking_lot"]
58+
parallel = ["dep:parking_lot"]
59+
no-xdrfile = []
4360

4461
[[bench]]
4562
name = "main"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Ladislav Bartos
3+
Copyright (c) 2023-2025 Ladislav Bartos
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

benches/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,24 @@ fn benchmark(c: &mut Criterion) {
5757
})
5858
});
5959

60+
c.bench_function("System::group_estimate_center (Protein)", |b| {
61+
b.iter(|| {
62+
std::hint::black_box(system.group_estimate_center("Protein").unwrap());
63+
})
64+
});
65+
6066
c.bench_function("System::group_get_center (Protein)", |b| {
6167
b.iter(|| {
6268
std::hint::black_box(system.group_get_center("Protein").unwrap());
6369
})
6470
});
6571

72+
c.bench_function("System::group_estimate_center (Membrane)", |b| {
73+
b.iter(|| {
74+
std::hint::black_box(system.group_estimate_center("Membrane").unwrap());
75+
})
76+
});
77+
6678
c.bench_function("System::group_get_center (Membrane)", |b| {
6779
b.iter(|| {
6880
std::hint::black_box(system.group_get_center("Membrane").unwrap());

build.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1+
// Released under MIT License.
2+
// Copyright (c) 2023-2025 Ladislav Bartos
3+
14
extern crate cc;
25

36
fn main() {
4-
// compile the xdrfile library
5-
let source_files = vec![
6-
"external/xdrfile/xdrfile.c",
7-
"external/xdrfile/xdrfile_xtc.c",
8-
"external/xdrfile/xdrfile_trr.c",
9-
"external/xdrfile/xdrfile_jump.c",
10-
];
11-
cc::Build::new()
12-
.files(source_files)
13-
.include("external/xdrfile")
14-
.warnings(false)
15-
.flag("-O3")
16-
.compile("libxdrfile.a");
7+
if std::env::var("CARGO_FEATURE_NO_XDRFILE").is_ok() {
8+
// do nothing if `no-xdrfile` feature is enabled
9+
} else {
10+
// compile the xdrfile library
11+
let source_files = vec![
12+
"external/xdrfile/xdrfile.c",
13+
"external/xdrfile/xdrfile_xtc.c",
14+
"external/xdrfile/xdrfile_trr.c",
15+
"external/xdrfile/xdrfile_jump.c",
16+
];
17+
cc::Build::new()
18+
.files(source_files)
19+
.include("external/xdrfile")
20+
.warnings(false)
21+
.flag("-O3")
22+
.compile("libxdrfile.a");
1723

18-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile.c");
19-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile.h");
20-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_xtc.c");
21-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_xtc.h");
22-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_trr.c");
23-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_trr.h");
24-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_jump.c");
25-
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_jump.h");
24+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile.c");
25+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile.h");
26+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_xtc.c");
27+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_xtc.h");
28+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_trr.c");
29+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_trr.h");
30+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_jump.c");
31+
println!("cargo:rerun-if-changed=external/xdrfile/xdrfile_jump.h");
32+
}
2633
}

changelog.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
11

22
## Changelog for the `groan_rs` library
33

4+
### Version 0.10.0
5+
6+
#### New XTC Parser
7+
- Now using [`molly`](https://crates.io/crates/molly) for faster reading of XTC files. Requires the `molly` feature to be active, otherwise the standard `xdrfile` library is used. With `molly` iterating through XTC files is ~50% faster compared to `xdrfile`.
8+
- Implemented an efficient "partial-frame" XTC reader using `molly`. It attempts to only read atoms of a specified group while ignoring the rest of the atoms. See `GroupXtcReader` and `System::group_xtc_iter` for more information.
9+
- `GroupXtcReader` implements a new trait `TrajGroupReadOpen`.
10+
11+
#### Integration with the `chemfiles` Library
12+
- All trajectory file formats supported by `chemfiles` can be now read using `System::traj_iter<ChemfilesReader>`. However, only XTC, TRR, TNG, DCD, Amber NetCDF, and LAMMPSTRJ are independently tested by `groan_rs`. Be careful when working with other file formats since these may not work properly.
13+
- To enable integration with `chemfiles`, you have to enable the `chemfiles` feature. If you do this, you need to have `cmake` version LOWER than 4.0.
14+
15+
#### More Precise Center of Geometry/Mass Calculations
16+
- **IMPORTANT Breaking changes:**
17+
- Implemented the Refined Bai-Breen algorithm similar to the pseudo-center of mass recentering algorithm described in https://arxiv.org/abs/2501.14578.
18+
- Methods `AtomIteratorWithBox::get_center` and `AtomIteratorWithBox::get_com` using the original Bai-Breen algorithm have been RENAMED to `AtomIteratorWithBox::estimate_center` and `AtomIteratorWithBox::estimate_com`, respectively.
19+
- Similarly, `System::group_get_center` and `System::group_get_com` have been renamed to `System::group_estimate_center` and `System::group_estimate_com`.
20+
- New functions called `AtomIteratorWithBox::get_center`, `AtomIteratorWithBox::get_com`, `System::group_get_center`, `System::group_get_com` use the **Refined Bai-Breen algorithm** which consists of 1) calculating the pseudo-center of geometry of the selected atoms, 2) making the group whole in the simulation box, 3) naive calculation of center of geometry or mass in the simulation box.
21+
- The refined Bai-Breen algorithm is much more precise than the original Bai-Breen algorithm but only works for groups that are smaller than half the simulation box. It is also ~50% slower than the original Bai-Breen algorithm.
22+
- All internal `groan_rs` methods now use the Refined Bai-Breen algorithm, with the exception of `System::atoms_center` and `System::atoms_center_mass` which continue to use the original Bai-Breen algorithm but are recommended to only be used for visual centering.
23+
24+
#### CellGrid
25+
- Implemented a `CellGrid` (also known as cell lists) structure for efficient pairwise distance calculations within a cutoff.
26+
- New atom iterator, `UnorderedAtomIterator`, has been implemented.
27+
- `System::guess_bonds` has been reimplemented using a `CellGrid` making it **much** more efficient, especially for large systems.
28+
- **Breaking change:** `System::guess_bonds_parallel` has been removed. (But the new `System::guess_bonds` is now much faster than `System::guess_bonds_parallel` has been.)
29+
30+
#### Hydrogen Bond Analysis
31+
- Implemented a way to identify hydrogen bonds (`HBondAnalysis`) in a trajectory. The analysis can be performed with any trajectory reader (`HBondTrajRead::hbonds_analyze`).
32+
33+
#### Changes to Trajectory Iteration
34+
- **Breaking change:** `TrajReadOpen` trait has been renamed to `TrajFullReadOpen`. The original `TrajReadOpen` trait now requires implementing the `initialize` method which can be used to construct either `TrajFullReadOpen` structure
35+
36+
#### Changes to `System::traj_iter_map_reduce` (as is tradition)
37+
- **Breaking changes:**
38+
- The `Data` structure in `System::traj_iter_map_reduce` no longer needs to implement `Add`. Instead, it needs to implement `ParallelTrajData` which requires the user to specify how the data structures should be reduced (merged). `ParallelTrajData` also allows the user to provide a custom `initialize` function which accepts thread ID and is automatically called after spawning a thread. This allows the user to implement thread-specific behavior or to properly sort the final results.
39+
- `System::traj_iter_map_reduce` can be now provided a group name in case a "partial-frame" iteration should be performed. In such case, the provided `Reader` structure must be `GroupXtcReader`.
40+
- The `Reader` structure in `System::traj_iter_map_reduce` still needs to implement `TrajReadOpen` but it's the new trait (see 'Changes to Trajectory Iteration`).
41+
- Made error propagation better. If a single thread encounters an error, all other threads will abort within 10 trajectory frames.
42+
43+
#### Expansion of Utilities for Ignoring PBC
44+
- Introduced `NaiveShape` trait for geometry filtering ignoring PBC and implemented this trait for `Sphere`, `Rectangular`, and `Cylinder`.
45+
- Implemented `ImmutableAtomIterable::filter_geometry_naive` and `MutableAtomIterable::filter_geometry_naive` for geometry filtering of atoms from iterators ignoring PBC and box dimensions.
46+
47+
#### Other Changes
48+
- Introduced `Atom::reset_bonded` and `System::clear_bonds` for simpler removal of bonding information.
49+
- Sodium atoms should be less often misclassified as sulfur when guessing elements.
50+
- Reworked how groups are stored inside a system. Introduced a new `Groups` structure for storing groups.
51+
- **Bug fix:** Fixed undefined behavior in xdrfile jumping which lead to TRR files being read incorrectly when using clang.
52+
- **Bug fix:** Fixed incorrect parsing of some TPR files generated with Gromacs 2025.
53+
54+
***
55+
456
### Version 0.9.0
557

658
#### Atom Index
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)