pycalphad
它能做什么
这个程序可以计算不同材料(合金)在各种温度和压力下的表现。它会显示合金中会形成哪些部分(相),以及每种相的数量。
适用场景
- ✓了解金属合金中的相稳定性。
- ✓检查相会如何随温度变化。
- ✓精确计算合金中每种相的含量。
技能链接
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pycalphad/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请使用 Cu-Ni 数据库,计算一种铜镍合金在 1000 开尔文、1 个大气压下的相及其含量。”
每周 5 个新技能,1 分钟读完。
工作原理
你需要提供一个包含材料信息的数据库,以及实验条件(温度、压力、成分)。程序会利用这些信息预测哪些相是稳定的,以及它们以什么比例出现。
技术内容(原始 SKILL.md)
作者在 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
- 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.
- Inspect database elements and phases. Select the relevant phases deliberately; record
exclusions because they can turn the calculation into a metastable constrained result.
Include
VAwhere 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. - 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. - Declare the database temperature interval from its assessment if known, or set
database_temperature_range_kto 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. - 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. - 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.
…
常见问题
什么是 TDB 数据库?
它是一个文件,里面包含元素的热力学信息,以及这些元素在不同温度和压力下相互作用、形成不同相的方式。
合金中的“相”是什么?
相是材料混合后可能形成的不同结构或化合物。例如在铜镍合金中,可能同时存在固相或液相。
程序会预测相形成的速度吗?
不会。它只计算平衡状态,也就是最终稳定的状态,而不计算达到这个状态的过程或速度。
详情
作者的原始描述
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.
热度
- GitHub 星标
- 51k
- 排名
- #3537
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …