Skip to content

Releases: sinagilassi/PyThermoEst

🚀 Release v0.2.0 — Antoine Examples

Choose a tag to compare

@sinagilassi sinagilassi released this 17 Dec 06:53

✨ Summary

Scope: Added example scripts and a small utility to demonstrate Antoine parameter estimation and result visualization.

🧪 Examples

Files: examples/antoine/antoine-1.py, examples/antoine/antoine-2.py.

Data: Included example datasets examples/antoine/data.csv and examples/antoine/data-2.csv to reproduce the demos.

🔍 Highlights

  • Quick-start: antoine-1.py — minimal end-to-end example fitting Antoine constants from CSV.
  • Advanced: antoine-2.py — demonstrates enhanced input handling and richer output/visualization using the helper utilities.
  • Reusable utilities: antoine_utils.py — helpers for data loading, preprocessing, fitting, and formatting results for reuse.

💡 Why it matters

Benefits: Makes it easy to reproduce Antoine parameter estimation workflows, validate fits on sample datasets, and adapt utilities for other thermodynamic parameter estimation tasks.

▶️ Usage

Run: From examples/antoine, execute:

python antoine-1.py
python antoine-2.py

🛠️ Notes for maintainers

Recommendation: Add a short README to examples/antoine with the expected Python version and dependencies, and consider adding an automated example runner in CI.

🧾 Key code snippets from examples

🧩 antoine-1.py (end-to-end fit)

# estimate coefficients from CSV
from pyThermoEst.docs.antoine import (
    estimate_coefficients_from_experimental_data,
    AntoineFitResult,
)

result: AntoineFitResult | None = estimate_coefficients_from_experimental_data(
    experimental_data=DATA_FILE_PATH,
)
if result is None:
    print("Failed to estimate Antoine coefficients from experimental data.")
else:
    print(result)

🔧 antoine-2.py (programmatic fit)

# build Temperature/Pressure objects and estimate coefficients
from pythermodb_settings.models import Temperature, Pressure
from pyThermoEst.docs.antoine import estimate_coefficients, AntoineFitResult
import numpy as np

Ts = [Temperature(value=T, unit="K") for T in temperatures]
Ps = [Pressure(value=P, unit="Pa") for P in Pressures]

result: AntoineFitResult | None = estimate_coefficients(temperatures=Ts, pressures=Ps)
if result is not None:
    plot_antoine_fit(
        T_data=np.array(temperatures),
        P_data=np.array(Pressures),
        fit_report=result.model_dump(),
        T_unit="K",
        p_unit="Pa",
    )