Duello
Virial Coefficient and Dissociation Constant Estimation for Rigid Macromolecules
Duello is a tool to calculate the potential of mean force (PMF) between two rigid bodies, performing a
statistical mechanical average over inter-molecular orientations using subdivided icosahedrons.
For each mass center separation, R, the static contribution to the partition function,
where
The osmotic second virial coefficient, which has dimensions of volume, reports on exactly two-body interactions:
where
Binary packages are available through PyPI.org:
pip install duelloIf you have a Rust toolchain installed, you may alternatively build and install from source:
cargo install --git https://github.com/mlund/duelloThe command-line tool duello does the 6D scanning and calculates
the angularly averaged potential of mean force, w(R), which
is used to derive the 2nd virial coefficient and two-body dissociation constant, .xyz format and all particle names must
be defined in the topology file under atoms.
The topology also defines the particular pair-potential to use, see below.
Note that a Coulomb/Yukawa potential is automatically added and should
hence not be specified in the topology.
Coulomb is evaluated analytically (no cutoff) in all backends, while
short-range potentials (e.g. AshbaughHatch, WCA) are splined for GPU/SIMD backends.
duello scan \
--mol1 cppm-p18.xyz \
--mol2 cppm-p18.xyz \
--rmin 37 --rmax 50 --dr 0.5 \
--top topology.yaml \
--resolution 0.8 \
--cutoff 50 \
--molarity 0.05 \
--temperature 298.15 \
--backend auto \
--grid "type=powerlaw2,size=500,shift=true"The --grid option controls interpolation of short-range pair potentials (GPU/SIMD backends).
The --cutoff sets the spline range in angstroms; it should cover the SR potential
(e.g. AshbaughHatch cutoff) but does not affect the analytical Coulomb/Yukawa evaluation.
| Key | Values | Default | Description |
|---|---|---|---|
type |
powerlaw2, invr2 |
powerlaw2 |
Grid spacing (invr2 avoids sqrt in eval) |
size |
integer | 500 |
Number of grid points |
shift |
true, false |
true |
Shift energy to zero at cutoff |
energy_cap |
float or none |
none |
Cap repulsive wall (kJ/mol) for f32 precision |
Example: --grid "type=invr2,size=1000,shift=false,energy_cap=50"
The program is written in Rust and attempts to use either GPU or all available CPU cores. The following backends are available, with performance measured on the Calvados3 lysozyme example (2.4M poses, 128 atoms per molecule, Apple M4):
| Backend | Description | Poses/ms | Speedup |
|---|---|---|---|
reference |
Exact potentials (validation) | 48 | 1.0x |
simd |
NEON (aarch64) / AVX2 (x86) | 131 | 2.7x |
gpu |
wgpu compute shaders | 1065 | 22x |
The auto backend (default) selects GPU if available, otherwise SIMD.
GPU and SIMD backends use cubic Hermite splines for short-range potentials
and evaluate Coulomb/Yukawa analytically without cutoff.
For simulations involving a rigid body and mobile atoms (e.g. ions), the full 6D scan is unnecessary.
The atom-scan subcommand computes a 3D table (R, theta, phi) of interaction energies between a
rigid body and a single test atom type, using Yukawa electrostatics and short-range pair potentials
from the topology:
duello atom-scan \
--mol1 4lzt.xyz \
--atom Na \
--rmin 2.0 --rmax 60 --dr 0.5 \
--top topology.yaml \
--resolution 0.5 \
--cutoff 150 \
--molarity 0.02 \
--output atom_table.bin.gzThe output is a flat binary table (Table3DFlat) that can be loaded for fast lookup
with barycentric interpolation on the icosphere mesh.
The following uses pdb2xyz to create a coarse grained XYZ file and Calvados topology for Duello:
pip install pdb2xyz
pdb2xyz -i 4lzt.pdb -o 4lzt.xyz --pH 7.0 --sidechains
duello scan \
-1 4lzt.xyz -2 4lzt.xyz \
--rmin 24 --rmax 80 --dr 0.5 \
--resolution 0.6 \
--top topology.yaml \
--molarity 0.05If pdb2xyz gives errors, you may be able to correct your PDB file with
pdbfixer.
Ready-to-run script examples are provided in the scripts/ directory:
| Command | Description |
|---|---|
scripts/cppm.sh |
Spherical, multipolar particles using the CPPM model |
scripts/calvados3.sh |
Two coarse grained lysozyme molecules w. Calvados3 interactions |
Each macromolecule is represented by a rigid constellation of beads with
properties defined under atoms in the topology file.
The inter-molecular energy,
The provided examples illustrate the following schemes:
- Screened
Coulomb+AshbaughHatch, for the Calvados model. - Screened
Coulomb+WeeksChandlerAndersenfor the CPPM model.
Many more pair-potentials are available through the
interatomic library,
e.g. LennardJones, HardSphere etc.
Warning: The electrostatic term (Coulomb/Yukawa) is always automatically added and should therefore not be specified in the topology.
This is for development purposes only and details how to create and publish a binary package on pypi.org.
Run this on MacOS, linux (x86 and arm) to get all architectures:
docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin:v1.11.5 publish -u __token__ -p PYPI_TOKENFor local Maturin installs, follow the steps below.
pip install ziglang pipx
pipx install maturin # on ubuntu; then restart shell
maturin publish -u __token__ -p PYPI_TOKEN --target=x86_64-unknown-linux-gnu --zigMacOS targets can be generated without --zig using the targets
x86_64-apple-darwin and aarch64-apple-darwin.
rustup target list
rustup target add x86_64-apple-darwin
