Skip to content
Skillpedia
Misc51k · #1945

pycalphad

Helps your agent calculate how different materials behave at various temperatures. It's useful for scientists creating new alloys or materials.

What it does

This program calculates how different materials (alloys) behave at various temperatures and pressures. It shows which parts (phases) of an alloy form and in what quantity.

When to use it

  • ✓To understand phase stability in metal alloys.
  • ✓To check how phases change with temperature.
  • ✓To calculate the exact amount of each phase in an alloy.

Example of what to ask your AI

“Calculate the phases and their amounts for a Copper-Nickel alloy at 1000 Kelvin and 1 atmosphere of pressure, using the Cu-Ni database.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pycalphad/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pycalphad/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

You provide a database with information about the materials and the conditions (temperature, pressure, composition). The program uses this information to predict which phases are stable and in what proportion they appear.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add K-Dense-AI/scientific-agent-skills --skill pycalphad

Or download just the file:

curl -L https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/main/skills/pycalphad/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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.

…

FAQ

What is a TDB database?

It's a file containing thermodynamic information about elements and how they interact to form different phases at various temperatures and pressures.

What are 'phases' in an alloy?

Phases are the different structures or compounds that can form when materials are mixed. For example, in a Copper-Nickel alloy, solid or liquid phases might exist.

Does the program predict the formation speed of phases?

No, it only calculates the equilibrium, meaning the stable final state, not the process or speed at which it is reached.

Details

Original description by the author

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.

repo: K-Dense-AI/scientific-agent-skills

Popularity

GitHub stars
51k
Ranking position
#1945
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills