Skip to main content

Electrochemical thermodynamics toolkit for VASP workflows

Project description

EC Toolkit

Electrochemical thermodynamics toolkit for VASP workflows:
– Parse OUTCAR & POSCAR
– Build reaction mechanisms from DFT energies, ZPE, and entropy
– Compute ΔG profiles, overpotentials, & Gmax – Plot free‐energy diagrams


Features

  • I/O parsers
    • OutcarParser.read_edft, OutcarParser.read_zpe_tds, OutcarParser.read_converged, OutcarParser.auto_read
    • PoscarParser backed by ASE, full support for selective dynamics
  • Data models
    • Compound, ElementaryStep, Mechanism, mechanism_constructor
  • Thermo analysis
    • compute_eta_td, compute_g_max
  • Visualization
    • plot_free_energy with optional ηTD and Gmax annotations

Installation

pip install ec-toolkit

Quickstart

from pathlib import Path
import matplotlib.pyplot as plt

from ec_toolkit.io.outcar import OutcarParser
from ec_toolkit.models.classes import Compound, ElementaryStep, Mechanism
from ec_toolkit.models.constructor import mechanism_constructor
from ec_toolkit.analysis.thermodynamics import compute_g_max, compute_eta_td
from ec_toolkit.visualization.plotting import plot_free_energy

# 1) Read energies from VASP runs
workdir = Path("my_vasp_runs").expanduser()
steps   = ["M", "M-OH", "M-O", "M-OOH"]

# Request TΔS computation and structure check (checks that EDFT run converged AND
# that the ZPE OUTCAR contained no imaginary frequencies). When check_structure=True
# auto_read returns (edfts, zpes, tdss, check_list).
edfts, zpes, tdss, conv_list = OutcarParser.auto_read(
    workdir, steps, calc_tds=True, check_structure=True
)

# 2) Wrap as Compounds
compounds = {
    name: Compound(name, {"dft": e, "zpe": z, "tds": t}, converged=conv)
    for name, e, z, t, conv in zip(steps, edfts, zpes, tdss, conv_list)
}

# 3) Stoichiometry / mechanism construction (example for OER mononuclear)
oer_mononuc_steps = [
    {"M-OH": +1.0, "H2": +0.5, "M": -1.0, "H2O": -1.0},
    {"M-O": +1.0, "H2": +0.5, "M-OH": -1.0},
    {"M-OOH": +1.0, "H2": +0.5, "M-O": -1.0, "H2O": -1.0},
    {"M": +1.0, "H2": +0.5, "O2": +1, "M-OOH": -1.0},
]
oer_mononuc_labels = ["M→M-OH", "M-OH→M-O", "M-O→M-OOH", "M-OOH→M"]
oer_mononuc_elmask = [True, True, True, True]

# Build a mechanism-constructor / factory (constructor returns
# a callable that you then call with Compound objects - returns a Mechanism directly).
oer_mononuc_mechanism = mechanism_constructor(
    "oer_mononuc",
    step_stoich=oer_mononuc_steps,
    step_labels=oer_mononuc_labels,
    el_steps=oer_mononuc_elmask,
    eq_pot=1.23,
    is_oxidation_reaction=True,
    sym_fac=1,
    ref_el="RHE",
    correction_step=4,
)

h2o = Compound("h2o", {"dft": -14.321257, "zpe": 0, "tds": 0}, converged=True)
h2 = Compound("h2", {"dft": -6.900225, "zpe": 0, "tds": 0}, converged=True)

# instantiate the Mechanism using the constructor returned above
oer_mono = oer_mononuc_mechanism(
    M=compounds["M"],
    M_OH=compounds["M-OH"],
    M_O=compounds["M-O"],
    M_OOH=compounds["M-OOH"],
    H2=h2,
    H2O=h2o,
)

# 4) Plot (plotting uses the biased profile produced by compute_g_max under the hood)
plot_free_energy(mech=oer_mono, op=0, annotate_eta=False, labels=["M", "M-OH", "M-O", "M-OOH", "M + H2O"])
plt.show()

Custom ZPE locator

By default ZPE/TdS is looked for under s1/zpe/OUTCAR, but you can customize. If your ZPE runs live elsewhere (e.g. in step1_zpe), pass your own locator:

def my_zpe_locator(wd: Path, step: str) -> Path:
    return wd / f"{step}_zpe" / "OUTCAR"

edfts, zpes, tdss = OutcarParser.auto_read(
    workdir, steps, calc_tds=True,
    zpe_locator=my_zpe_locator
)

License

This project is released under the MIT License. See License for details.


Contributors

  • Noel Marks
  • Maksim Sokolov

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

ec_toolkit-0.3.2.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

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

ec_toolkit-0.3.2-cp314-cp314-macosx_11_0_arm64.whl (853.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file ec_toolkit-0.3.2.tar.gz.

File metadata

  • Download URL: ec_toolkit-0.3.2.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ec_toolkit-0.3.2.tar.gz
Algorithm Hash digest
SHA256 da365b46d1e2480f233e7d5f0197394175d8e8d0a1c7195415841362faac5524
MD5 997dd94182e58903a2d349ae155d4e6a
BLAKE2b-256 94c320db01a07bf0064836d902e6b2f320496370176fdc9e2ab1f7cc97404121

See more details on using hashes here.

File details

Details for the file ec_toolkit-0.3.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ec_toolkit-0.3.2-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 853.6 kB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ec_toolkit-0.3.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e9209a5be6e85128bd117797a6bcfb15c607c91ada854e4dcede33bfeee2760
MD5 1635fda0e2c6d4e43ac5958e3072f6d7
BLAKE2b-256 edea43677464a2ae580f0f9bbe55277f8fadf1048ffe4839b18d25bae7bd6b65

See more details on using hashes here.

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