Skip to main content

Post-processing toolkit for OCTP LAMMPS molecular-dynamics output

Project description

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()

# Conductivity
octp.cond_NE(mixture,  ion_names=["Na", "OH", "SCN"], ion_charges=[1, -1, -1])
octp.cond_Ons(mixture, ion_names=["Na", "OH", "SCN"], ion_charges=[1, -1, -1])

# 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_succesfull(T_min) Drop runs shorter than T_min ns
mandatory_properties() Volume, box size, temperature, particle counts
pressure(plotting, mov_ave) Pressure (Pa)
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, ...) Coordination number from RDF
bond_angles(start, stop, ...) Bond-angle distribution
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.

Module-level functions

Function Description
cond_NE(mixture, ion_names, ion_charges) Nernst–Einstein conductivity (S/m)
cond_Ons(mixture, ion_names, ion_charges) Onsager conductivity (S/m)
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

octp_pp-0.1.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

octp_pp-0.1.0-cp314-cp314-macosx_11_0_arm64.whl (289.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

octp_pp-0.1.0-cp312-cp312-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.12Windows x86-64

octp_pp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (324.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file octp_pp-0.1.0.tar.gz.

File metadata

  • Download URL: octp_pp-0.1.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for octp_pp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7aa9ae7588dc637711d24ce035fe47bd8a6e2eba84f2940622a19a8cf837604
MD5 022d0fd7d261ca70eb38cd527e920656
BLAKE2b-256 46a95f14d500a0441b69345e4eebbfcc259df4961799deea696bbd175035b541

See more details on using hashes here.

Provenance

The following attestation bundles were made for octp_pp-0.1.0.tar.gz:

Publisher: release.yml on JelleLagerweij/octp-pp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file octp_pp-0.1.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for octp_pp-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5c5051cdbb94abdab6004b65991021b07a7234ace0d35977476795d13f25410
MD5 334172845f2a9c738368a18668ae5ea2
BLAKE2b-256 e6ca44576b2d8bf91b78130a7a12bdc6534910996ab21b094c3fce79ae5de243

See more details on using hashes here.

Provenance

The following attestation bundles were made for octp_pp-0.1.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on JelleLagerweij/octp-pp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file octp_pp-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: octp_pp-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for octp_pp-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6d9e6b6cfeb49cd06b61b3b558aeb108a0003133081d58bb127f6e7007efd530
MD5 1ae78f8d41ba63570eeae3abf98a783c
BLAKE2b-256 9a6f4a12819c3f8cc5fe78b17ac3c6859381f26ddeb88bde56908279435f29f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for octp_pp-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on JelleLagerweij/octp-pp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file octp_pp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for octp_pp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 592747455f50b6d0cd1e5f1b2934fdf9b7512ecdc98e8ba99b7864a5a59ed0f0
MD5 e51e080351e4a823c414d52829a6634d
BLAKE2b-256 f87e65e576d65f739a9cc984737e349714a1ff98bf534c0a18a6429e4834ecc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for octp_pp-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on JelleLagerweij/octp-pp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page