Alloy Phase Equilibrium

pycalphad: TDB equilibrium calculations

by K-Dense-AI · MIT license · ★ 45,977 on GitHub · updated Sep 21

pycalphad: TDB equilibrium calculations cover

Computes finite-temperature CALPHAD equilibria, phase fractions, and phase compositions from thermodynamic TDB databases using pycalphad. Use for alloy phase stability, equilibrium temperature sweeps, tie lines, lever-rule checks, or…

---
name: pycalphad
description: Computes finite-temperature CALPHAD equilibria, phase fractions, and phase compositions from thermodynamic TDB databases using pycalphad. Use for alloy phase stability, equilibrium temperature sweeps, tie lines, lever-rule checks, or reproducible phase-fraction calculations with explicit components and mole-fraction conditions.
license: MIT
compatibility: Requires Python 3.12+, pycalphad 0.11.2, and NumPy. Installation needs network access; calculations run locally without credentials. Real-material predictions require a suitable licensed thermodynamic database.
metadata:
  version: "1.1"
  skill-author: K-Dense Inc.
  tested-package-version: "0.11.2"
  last-reviewed: "2026-10-01"
---

# pycalphad: TDB equilibrium calculations

## When to use

Use for equilibrium phase fractions and compositions at a fixed bulk elemental mole
composition, specified pressure, and a list of finite temperatures. The bundled helper

Overview

Use for equilibrium phase fractions and compositions at a fixed bulk elemental mole composition, specified pressure, and a list of finite temperatures. The bundled helper executes real pycalphad equilibria, checks mass balance, repeats at greater sampling density, and exports each stable composition set separately.

What you get

  • report.json: settings and versions, TDB/settings SHA-256, excluded database phas
  • phase-equilibria.csv: one row per stable vertex per temperature and sampling run
Manual install (npx, ZIP)
Claude Codenpx skills add K-Dense-AI/scientific-agent-skills --skill pycalphad -g -a claude-code
Claude Code (degit)npx degit K-Dense-AI/scientific-agent-skills/skills/pycalphad#main ~/.claude/skills/pycalphad
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md8.0 KB
Read SKILL.md here
K-Dense-AI/main1 file shown
SKILL.md
Show the full text135 lines

pycalphad: TDB equilibrium calculations

When to use

Use for equilibrium phase fractions and compositions at a fixed bulk elemental mole composition, specified pressure, and a list of finite temperatures. The bundled helper executes real pycalphad equilibria, checks mass balance, repeats at greater sampling density, and exports each stable composition set separately.

Equilibrium is constrained by the selected database, components, phases, and conditions. It does not predict precipitation rates, retained metastable microstructures, or properties of phases missing from the database. Successful numerical checks do not establish the database's experimental accuracy.

Workflow

  1. Identify the TDB's source, license, assessment/publication, valid temperature/pressure and composition range, and required elements. Use the user's database for real alloys. The bundled assets/ideal-cu-ni.tdb is an original hypothetical teaching model, not an assessed Cu-Ni database.
  2. Inspect database elements and phases. Select the relevant phases deliberately; record exclusions because they can turn the calculation into a metastable constrained result. Include VA where required by sublattice models. Vacancies are not an independent bulk mole fraction. Keep coupled order/disorder definitions in the TDB, but do not select both partners as separate candidates when the ordered model already includes the disordered contribution; the helper rejects such filtered candidate lists.
  3. Copy assets/equilibrium.json. Specify exactly N-1 elemental mole fractions and one dependent non-vacancy element. The dependent fraction is 1 - sum(independent fractions); fractions are not silently normalized. Set K and Pa. Convert weight percentages or mass fractions before using this helper.
  4. Declare the database temperature interval from its assessment if known, or set database_temperature_range_k to null if unknown. This is user-supplied evidence, not a range automatically inferred from every TDB function. Requests outside a declared interval fail. Check pressure and composition validity separately.
  5. Run the calculation. Check finite Gibbs energies, phase fractions summing to one, reconstructed bulk composition, and stability to doubled pdens (phase-constitution sampling density). Near transitions, refine temperatures and sampling density further.
  6. Deliver phase fractions with their molar basis, phase compositions, database hash, conditions, excluded phases, and any numerical or assessment limitations.

Read references/model-and-validation.md for the analytic example, basis conversion, native Model/Workspace/property/plot contracts, miscibility-gap handling, and convergence limits.

Execute the tested example

From the collection root:

uv run --no-project --python 3.12 --with pycalphad==0.11.2 --with numpy==2.5.3 \
  python skills/pycalphad/scripts/equilibrate.py \
  skills/pycalphad/assets/ideal-cu-ni.tdb \
  skills/pycalphad/assets/equilibrium.json equilibrium-result

Tested on Python 3.12, pycalphad 0.11.2, and NumPy 2.5.3. Use a new output directory. All thermodynamic calculations are local; the script does not upload a TDB.

For the supplied hypothetical model at X(Ni)=0.5 and 101325 Pa:

Temperature Equilibrium result
900 K FCC_A1 only
1100 K 0.5 FCC_A1 + 0.5 LIQUID; X(Ni) approximately 0.527307 and 0.472693 respectively
1300 K LIQUID only

The suite verifies analytic common-tangent compositions, a noncentral lever-rule case, Gibbs energy, mass balance, both single-phase limits, and actual same-phase miscibility gap vertices. These validate the computational workflow, not real Cu-Ni metallurgy.

Outputs and acceptance

  • report.json: settings and versions, TDB/settings SHA-256, excluded database phases, requested, solver-imposed, and reconstructed bulk compositions, per-temperature baseline/refined results, and checks. Experimental validity is not evaluated by the helper.
  • phase-equilibria.csv: one row per stable vertex per temperature and sampling run, including phase name, molar phase fraction, and elemental mole fractions. Its Gibbs energy column is the whole-system molar Gibbs energy, repeated for each vertex; it is not the individual phase energy.

Unused pycalphad vertices have blank names and NaN values; those are omitted. Named vertices with invalid values cause failure. Multiple vertices with the same phase name are retained because a miscibility gap can contain two composition sets of one phase. Vertex indices do not track the same physical phase continuously across temperatures.

In stable 0.11.2, pycalphad clips independent mole fractions to [1e-10, 1-1e-10]. Each result records solver_bulk_mole_fractions and the largest absolute difference from the requested bulk in composition_condition_adjustment_absolute_error. Mass-balance checks still compare against the requested composition; a tighter tolerance can therefore fail at an endpoint. Do not claim exact pure-component or ultratrace results from a clipped multicomponent calculation.

all_checks_passed requires each run's phase-sum and bulk-composition residuals within mass_balance_tolerance, phase totals stable within phase_fraction_tolerance, and system Gibbs energy stable within gibbs_energy_tolerance_j_per_mol when pdens doubles. This comparison does not certify the global minimum or track individual composition-set movement within a same-phase miscibility gap; inspect their exported compositions too. Failed checks remain visible in the report rather than being relabeled as convergence.

Boundaries and upstream contracts

The helper handles elemental mole fractions, one composition, one pressure, and up to 1000 explicit positive temperatures. It validates selected phases through pycalphad's phase-compatibility rules; incompatible or automatically filtered order/disorder phase sets produce an explicit error. It does not silently remove requested phases.

Charged-species constraints, externally imposed chemical potentials, custom models, activity reference-state changes, and database optimization require additional modeling and are outside this helper's tested scope. Do not extrapolate the pedagogical asset to real material selection or heat-treatment decisions.

Upstream latest documentation currently describes 0.11.3 development builds. The bundled helper and the reference's native examples were exercised against stable 0.11.2 on 2026-10-01; the release's source was checked against the installed wheel. No remote thermodynamic calculation or database-fetch API is used. Database loads a local path, file-like object, or TDB text; a URL is not a supported download shortcut.

1---
2name: pycalphad
3description: Computes finite-temperature CALPHAD equilibria, phase fractions, and phase compositions from thermodynamic TDB databases using pycalphad. Use for alloy phase stability, equilibrium temperature sweeps, tie lines, lever-rule checks, or reproducible phase-fraction calculations with explicit components and mole-fraction conditions.
4license: MIT
5compatibility: Requires Python 3.12+, pycalphad 0.11.2, and NumPy. Installation needs network access; calculations run locally without credentials. Real-material predictions require a suitable licensed thermodynamic database.
6metadata:
7 version: "1.1"
8 skill-author: K-Dense Inc.
9 tested-package-version: "0.11.2"
10 last-reviewed: "2026-10-01"
11---
12 
13# pycalphad: TDB equilibrium calculations
14 
15## When to use
16 
17Use for equilibrium phase fractions and compositions at a fixed bulk elemental mole
18composition, specified pressure, and a list of finite temperatures. The bundled helper
19executes real pycalphad equilibria, checks mass balance, repeats at greater sampling
20density, and exports each stable composition set separately.
21 
22Equilibrium is constrained by the selected database, components, phases, and conditions.
23It does not predict precipitation rates, retained metastable microstructures, or properties
24of phases missing from the database. Successful numerical checks do not establish the
25database's experimental accuracy.
26 
27## Workflow
28 
291. Identify the TDB's source, license, assessment/publication, valid temperature/pressure
30 and composition range, and required elements. Use the user's database for real alloys.
31 The bundled [assets/ideal-cu-ni.tdb](assets/ideal-cu-ni.tdb) is an original hypothetical
32 teaching model, **not an assessed Cu-Ni database**.
332. Inspect database elements and phases. Select the relevant phases deliberately; record
34 exclusions because they can turn the calculation into a metastable constrained result.
35 Include `VA` where required by sublattice models. Vacancies are not an independent bulk
36 mole fraction. Keep coupled order/disorder definitions in the TDB, but do not select
37 both partners as separate candidates when the ordered model already includes the
38 disordered contribution; the helper rejects such filtered candidate lists.
393. Copy [assets/equilibrium.json](assets/equilibrium.json). Specify exactly N-1 elemental
40 mole fractions and one dependent non-vacancy element. The dependent fraction is
41 `1 - sum(independent fractions)`; fractions are not silently normalized. Set K and Pa.
42 Convert weight percentages or mass fractions before using this helper.
434. Declare the database temperature interval from its assessment if known, or set
44 `database_temperature_range_k` to null if unknown. This is user-supplied evidence,
45 not a range automatically inferred from every TDB function. Requests outside a declared
46 interval fail. Check pressure and composition validity separately.
475. Run the calculation. Check finite Gibbs energies, phase fractions summing to one,
48 reconstructed bulk composition, and stability to doubled `pdens` (phase-constitution
49 sampling density). Near transitions, refine temperatures and sampling density further.
506. Deliver phase fractions with their **molar** basis, phase compositions, database hash,
51 conditions, excluded phases, and any numerical or assessment limitations.
52 
53Read [references/model-and-validation.md](references/model-and-validation.md) for the
54analytic example, basis conversion, native Model/Workspace/property/plot contracts,
55miscibility-gap handling, and convergence limits.
56 
57## Execute the tested example
58 
59From the collection root:
60 
61```bash
62uv run --no-project --python 3.12 --with pycalphad==0.11.2 --with numpy==2.5.3 \
63 python skills/pycalphad/scripts/equilibrate.py \
64 skills/pycalphad/assets/ideal-cu-ni.tdb \
65 skills/pycalphad/assets/equilibrium.json equilibrium-result
66```
67 
68Tested on Python 3.12, pycalphad 0.11.2, and NumPy 2.5.3. Use a new output directory.
69All thermodynamic calculations are local; the script does not upload a TDB.
70 
71For the supplied hypothetical model at X(Ni)=0.5 and 101325 Pa:
72 
73| Temperature | Equilibrium result |
74| --- | --- |
75| 900 K | FCC_A1 only |
76| 1100 K | 0.5 FCC_A1 + 0.5 LIQUID; X(Ni) approximately 0.527307 and 0.472693 respectively |
77| 1300 K | LIQUID only |
78 
79The suite verifies analytic common-tangent compositions, a noncentral lever-rule case,
80Gibbs energy, mass balance, both single-phase limits, and actual same-phase miscibility
81gap vertices. These validate the computational workflow, not real Cu-Ni metallurgy.
82 
83## Outputs and acceptance
84 
85- `report.json`: settings and versions, TDB/settings SHA-256, excluded database phases,
86 requested, solver-imposed, and reconstructed bulk compositions, per-temperature
87 baseline/refined results, and checks. Experimental validity is not evaluated by the helper.
88- `phase-equilibria.csv`: one row per stable vertex per temperature and sampling run,
89 including phase name, molar phase fraction, and elemental mole fractions. Its Gibbs
90 energy column is the **whole-system molar Gibbs energy**, repeated for each vertex;
91 it is not the individual phase energy.
92 
93Unused pycalphad vertices have blank names and NaN values; those are omitted. Named
94vertices with invalid values cause failure. Multiple vertices with the same phase name
95are retained because a miscibility gap can contain two composition sets of one phase.
96Vertex indices do not track the same physical phase continuously across temperatures.
97 
98In stable 0.11.2, pycalphad clips independent mole fractions to `[1e-10, 1-1e-10]`.
99Each result records `solver_bulk_mole_fractions` and the largest absolute difference
100from the requested bulk in `composition_condition_adjustment_absolute_error`.
101Mass-balance checks still compare against the **requested** composition; a tighter
102tolerance can therefore fail at an endpoint. Do not claim exact pure-component or
103ultratrace results from a clipped multicomponent calculation.
104 
105`all_checks_passed` requires each run's phase-sum and bulk-composition residuals within
106`mass_balance_tolerance`, phase totals stable within `phase_fraction_tolerance`, and
107system Gibbs energy stable within `gibbs_energy_tolerance_j_per_mol` when `pdens` doubles.
108This comparison does not certify the global minimum or track individual composition-set
109movement within a same-phase miscibility gap; inspect their exported compositions too.
110Failed checks remain visible in the report rather than being relabeled as convergence.
111 
112## Boundaries and upstream contracts
113 
114The helper handles elemental mole fractions, one composition, one pressure, and up to
1151000 explicit positive temperatures. It validates selected phases through pycalphad's
116phase-compatibility rules; incompatible or automatically filtered order/disorder phase
117sets produce an explicit error. It does not silently remove requested phases.
118 
119Charged-species constraints, externally imposed chemical potentials, custom models,
120activity reference-state changes, and database optimization require additional modeling
121and are outside this helper's tested scope. Do not extrapolate the pedagogical asset to
122real material selection or heat-treatment decisions.
123 
124- [Equilibrium dataset semantics](https://pycalphad.org/docs/latest/examples/3_High_Throughput_Analysis/2_UsingCalculationResults.html)
125- [Phase fractions and composition basis](https://pycalphad.org/docs/latest/examples/2_Computing_Properties/1_PhaseCompositions.html)
126- [Equilibrium and sampling API](https://pycalphad.org/docs/latest/api/pycalphad.core.html)
127- [Ordering examples](https://pycalphad.org/docs/latest/examples/2_Computing_Properties/4_EquilibriumWithOrdering.html)
128- [Stable 0.11.2 source](https://github.com/pycalphad/pycalphad/tree/0.11.2/pycalphad)
129 
130Upstream `latest` documentation currently describes 0.11.3 development builds. The
131bundled helper and the reference's native examples were exercised against stable
1320.11.2 on 2026-10-01; the release's source was checked against the installed wheel.
133No remote thermodynamic calculation or database-fetch API is used. `Database` loads a
134local path, file-like object, or TDB text; a URL is not a supported download shortcut.
135 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 45,977
Checked
Source
K-Dense-AI/scientific-agent-skills ↗
Creator
K-Dense-AI · 168 listings
View creator

Similar skills

See all →

More from K-Dense-AI

SkillAdaptyv Bio Foundry APIK-Dense-AI/scientific-agent-skills · by K-Dense-AIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.★ 46k GitHub starsSkillTime Series MLK-Dense-AI/scientific-agent-skills · by K-Dense-AIThis skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.★ 46k GitHub starsSkillAnalytical Method ValidatorK-Dense-AI/scientific-agent-skills · by K-Dense-AIPlan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.★ 46k GitHub starsSkillSingle-Cell Data StructureK-Dense-AI/scientific-agent-skills · by K-Dense-AIData structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.★ 46k GitHub starsSkillAutonomous Artifact OptimizerK-Dense-AI/scientific-agent-skills · by K-Dense-AIAutonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g. "get my model's eval score up", "improve this agent/harness", "tune this pipeline", "beat the baseline on this benchmark", "run a search over approaches and keep the best", "do an MLE-bench / Kaggle-style optimization", or any long-horizon "make this artifact better and don't just memorize the dev set" task. Trigger it even when the user doesn't say "Arbor" or "hypothesis tree" but describes repeated experiment-and-evaluate loops, branching exploration of competing ideas, or worries about a dev/test gap. Runs Claude itself as the coordinator with subagent executors in isolated git worktrees; for the standalone `arbor` CLI tool see references/arbor-upstream.md.★ 46k GitHub starsSkillGene Regulatory Network InferrerK-Dense-AI/scientific-agent-skills · by K-Dense-AIInfer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.★ 46k GitHub stars