Skip to main content

octp-pp

Post-processing toolkit for OCTP (Order-n Transport Properties) output files from LAMMPS molecular dynamics simulations.

The computationally intensive work — file parsing, MSD fitting, and all physical-property models — is compiled to native code via a PyO3/maturin Rust extension. Interactive visualisations use Plotly.

Features

  • Rust core — parsing, diffusivity fitting, Laliberte density/viscosity, Dewane and Gilliam conductivity models, and concentration conversions all run natively; the Brent–Dekker molarity→molality inversion is ~570× faster than an equivalent scipy.fsolve loop
  • Automatic run averaging — pass a list of parallel-run folders; means and standard deviations are computed automatically
  • Biased Random Walk (BRW) correction — built-in correction for proton-hopping contributions (OH⁻ / H₃O⁺) matched against experimental conductivity
  • Configurable constants — ion charges, molecular weights, hop distance, etc. live in a JSONL file and can be overridden at runtime without touching code

Installation

pip install octp-pp

From source

git clone https://github.com/JelleLagerweij/octp-pp
cd octp-pp
pip install maturin
maturin develop            # debug build  (fast compile, slower runtime)
maturin develop --release  # release build (slow compile, fast runtime)

maturin build (and pip install .) always use the release profile. maturin develop defaults to debug — ideal during active development.

Quick start

import octp_pp as octp
import octp_pp.helpers as hf

# Five parallel NVT runs stored under data/run_1 … data/run_5
mixture = octp.PP_OCTP(
    "data",
    [f"run_{i}" for i in range(1, 6)],
    groups=["wat", "Na", "OH", "SCN"],
    dt=2,           # timestep in fs
    plotting=True,  # interactive Plotly figures
)

# Configure non-default file names (if needed)
mixture.filenames(Diff_Onsag="diffonsag.dat", Diff_self="diffself.dat")
mixture.changefit(Minc=7, Mmax=45, er_max=0.05)

# State properties
mixture.density()
mixture.molality("OH",  "wat", hf.MOLECULAR_WEIGHTS["WAT"])
mixture.molality("SCN", "wat", hf.MOLECULAR_WEIGHTS["WAT"])

# Transport properties
mixture.viscosity()
mixture.self_diffusivity(YH_correction=True)
mixture.onsager_coeff()

# Structural properties with new features
mixture.coord_number(solvent="wat", interpolate_spline=3)  # RDF with interpolation
mixture.bond_angles(smoothing_width=5.0)  # Angular smoothing in degrees

# Conductivity
mixture.electrical_conductivity(ion_names=["Na", "OH", "SCN"], ion_charges=[1, -1, -1], method="nernst-einstein")
mixture.electrical_conductivity(ion_names=["Na", "OH", "SCN"], ion_charges=[1, -1, -1], method="direct")

# BRW correction (requires experimental Excel file)
octp.biassed_random_walk(mixture, "Experiments_total.xlsx")

mixture.store()   # writes postprocessed.csv next to the data folder

Physical-property helpers (octp_pp.helpers)

All functions are vectorised and delegate to the Rust core.

Function Model Output
statepoint_Laliberte(T, m, salt, fits) Laliberte (2004) density (kg/m³), molarity (mol/L)
viscosity_Laliberte(T, m, salt, fits) Laliberte (2007) dynamic viscosity (Pa·s)
dewane_conductivity(T, m, salt, ...) Dewane and Hammer conductivity (S/m)
KOH_conductivity_Gilliam_combined(T, m, salt, fits) Gilliam conductivity (S/m)
molarity_to_molality(c, T, salt, fits) Brent–Dekker root finder molality (mol/kg)
molality_to_mass_fraction(m, salt) exact mass fraction
mass_fraction_to_molality(w, salt) exact molality (mol/kg)
molality_to_mol_fraction(m, solvent) exact mole fraction
mol_fraction_to_molality(x, solvent) exact molality (mol/kg)
tau_calculator(sig_exp, sig_MD, T, L, N, δ) Lagerweij lifetime τ (s)
diffusion_adjustment(tau) Lagerweij D_hop (m²/s)

Fit parameters are stored in a user-provided JSON file (see test/fits_laliberte.json for the expected structure).

Global constants

Loaded from octp_pp/constants.jsonl at import time. Override at runtime without editing any file:

# Add a custom salt for this session
hf.load_constants(updates={"MOLECULAR_WEIGHTS": {"MYMAT": 123.45}})

# Inspect what is loaded
print(hf.MOLECULAR_WEIGHTS)
print(hf.DELTA_HOP)

API reference

PP_OCTP class

Method Description
filenames(**kwargs) Set LAMMPS output file names
changefit(margin, Minc, Mmax, er_max) Tune MSD log-log fitting
check_successful(T_min) Drop runs shorter than T_min ns
mandatory_properties() Volume, box size, temperature, particle counts
pressure(plotting, filter_time) Pressure (Pa) with time-based filtering
density() Density (kg/m³) from NPT run
molarity(group) Molarity (mol/L)
molality(group, solvent, MW_solvent) Molality (mol/kg)
viscosity(plotting) Shear + bulk viscosity (Pa·s)
thermal_conductivity(plotting) Thermal conductivity (W/m/K)
self_diffusivity(YH_correction, ...) Self-diffusion coefficients (m²/s)
onsager_coeff(box_size_check, ...) Onsager cross-coefficients (m²/s)
coord_number(solvent, interpolate_spline, ...) Coordination number from RDF with interpolation
bond_angles(start, stop, smoothing_width) Bond-angle distribution with angular smoothing
read_thermoprop(property, ensemble, plotting, filter_time) Read thermo properties with time-based filtering
electrical_conductivity(ion_names, ion_charges, method, ...) Electrical conductivity (S/m) with Nernst-Einstein or direct methods
store(location, name, for_excel) Save results DataFrame to CSV / Excel

All optional methods call mandatory_properties() automatically if it has not yet been run.

Time-based Filtering

Several methods support filter_time parameter for exponential weighted moving average filtering of time-series data. The filter window is specified in femtoseconds (fs) and is automatically converted to the appropriate number of data points based on the actual time spacing in the data:

# Apply 500 fs moving average filter to pressure data
mixture.pressure(filter_time=500)

# Filter thermodynamic property data
mixture.read_thermoprop('v_TotEn', 'nvt', filter_time=5000)

# Filter energy data
mixture.tot_energy(filter_time=1000)
mixture.pot_energy(filter_time=1000)

Filtering is applied only to plotted data, not to the computed averages stored in results.

RDF Interpolation

The coord_number method supports Akima1DInterpolator-based interpolation for smoother RDF analysis:

# No interpolation (default)
mixture.coord_number(solvent="wat")

# Interpolate with 3 subdivisions per interval (4x denser grid)
mixture.coord_number(solvent="wat", interpolate_spline=3)

# High-density interpolation (50x denser grid)
mixture.coord_number(solvent="wat", interpolate_spline=50)
  • interpolate_spline=None, 0, or 1: No interpolation
  • interpolate_spline>1: Interpolate with that many subdivisions per original interval

Module-level functions

Function Description
biassed_random_walk(mixture, exp_file) BRW correction; writes back to mixture.results
read(datafile, export) Read OCTP MSD file → DataFrame
local_maximum_finder(data, start, n) First local maximum in g(r)

License

MIT

Metadata

Release files for octp-pp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for octp-pp 0.2.0
File Size Uploaded
octp_pp-0.2.0.tar.gz 24.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for octp-pp 0.2.0
File Interpreter ABI Platform
octp_pp-0.2.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
octp_pp-0.2.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
octp_pp-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details

Total release size: 25.0 MB

Release files / octp_pp-0.2.0.tar.gz

Download URL octp_pp-0.2.0.tar.gz
Size 24.2 MB
Tags Source
SHA-256 checksum
How to use checksums
86ba28314d0d5341938e4b69f4768f0898e58f71e2603ac4e97111c48a986879
BLAKE2b-256 checksum
How to use checksums
7226708ae01d63c80f91ff902321b7d6397fc48a2dab6cfa7709bd39de1fc066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / octp_pp-0.2.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL octp_pp-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Size 291.1 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8069aa61a2fbe589aee7e1a1a40c4d64e5bffc2445b33982a98ff30b6f5e58c6
BLAKE2b-256 checksum
How to use checksums
2bbcbe7f82eb276a158c7ba3f627e135f3e43ea58bdc969f7a34f0ab972f9d84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / octp_pp-0.2.0-cp312-cp312-win_amd64.whl

Download URL octp_pp-0.2.0-cp312-cp312-win_amd64.whl
Size 196.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
02e8a9a273aa9da786c2fddadfe08f5b948b2ca2d870fa1a42e3fafb377b2c28
BLAKE2b-256 checksum
How to use checksums
68e063c25fda61a7976aa79e0578a2189336278cd6e5d5e4a9a5c3b133dfef83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / octp_pp-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL octp_pp-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 331.5 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5a976ba80bafbf56fcfb25861135eb3da11186085ecdae265594a3d8b2a29245
BLAKE2b-256 checksum
How to use checksums
c4ae5af6a44d2dd4e698067d2091950a8462365453a434cd669696b0bd14e7f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.6

19 release files

0.2.5

19 release files

0.2.2

4 release files

This release

0.2.0 This release

4 release files

0.1.7

4 release files

0.1.6

4 release files

0.1.5

4 release files

0.1.4

4 release files

0.1.3

4 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page