Repository navigation
Conversation
…checks Material data from another framework (for example elastic constants from Quantum ESPRESSO) is passed to a continuum model only when every calculation a check requires has run. The required calculations are derived from the producer's own settings, so a missing one counts as failed instead of being skipped; a check that only compares the calculations it finds cannot see one that never ran. - src/scale_bridge: handoff card (values plus every calculation behind them), obligation ledger (accept / reject / incomplete, plan of the missing calculations with their settings and estimated cost), rule for cubic elastic constants from plane-wave DFT stress-strain calculations (cutoff x1.25 and k-mesh x1.3; half smearing and k-mesh x1.5 when smearing is used; C' and C44 within 2 %, pressure within 0.1 GPa; reported values within 1 % of the stresses), continuum stiffness (rotated about z, plane stress), provider interface (entry point group openpaso.material_providers; GENIUS is the intended first provider, its adapter lives with GENIUS) - tool material_handoff: schema, check, plan, continuum (refused unless the check accepts), providers, produce, complete - docs: how-it-works/scale-bridging.md, tools/material_handoff.md, tools index, menu, _gen_reference TOOL_GROUPS Checked: tests/test_scale_bridge.py, 12 cases (complete evidence accepted; missing and stopped calculations incomplete and planned; failed calculation, missing opposite strain pair, non-finite stress, limit exceeded and unsupported reported values rejected; looser or different settings do not count; rotation; tool flow with a fake provider). pytest tests: 102 passed, 20 skipped (test_web_search_reports_a_block.py needs langchain, not installed here).
The rule read the normal pair from e_xx and the shear pair from e_yz only, so a card whose producer sheared in xy (as the GENIUS copper calculations do) was reported as lacking a shear pair. In a cubic crystal every axis and every shear plane give the same constants, so the rule now finds the pair in whichever single component it is applied. Two tests relabel the cube axes of a complete card and expect the same decision and constants.
Answers to Copilot's review of the material handoff. - Every entry of a strain or stress tensor must be a finite number; a NaN in an entry no rule reads went through. - A strain counts as normal or shear only if it is pure and symmetric; mixed and asymmetric strains passed as one component. - The reference must be unstrained, and must state a positive plane-wave cutoff, a valid ecutrho and a three-number k-mesh; without a cutoff the cutoff comparison silently became a k-mesh comparison. - Values must be in GPa: the rule compares them with stresses in GPa. - A repeat counts only with the same role and strain as the calculation it repeats, no smearing when the reference has none, and every other setting identical in both directions. - A completed retry counts over an earlier stopped attempt; a failed one still rejects. - A stopped base calculation leaves the card incomplete instead of rejecting it on NaN differences; derived values are empty for a structurally invalid card instead of raising. - A provider's material or kind label can no longer place the saved card outside its folder. Each case has a test that fails on the previous code (16 cases). A copper card built from real Quantum ESPRESSO outputs written by GENIUS is accepted (tests/data/cu_elastic_card.json).
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues can hide failed calculations and combine repeats with inconsistent settings, allowing invalid or unconverged elastic constants to pass.
5 open issues
Failed attempts must take precedence over completed attempts · New Require common settings across convergence repeats · New Include completed retries when selecting base calculation evidence · New Budget the recorded cost of stopped base reruns · New Handle exact zero matches without producing NaN · New
What changed in this PR
Adds a material-data handoff layer between upstream frameworks and openPASO’s continuum solvers, requiring complete convergence evidence before exporting stiffness data.
Changes:
- Introduces material cards, an obligation ledger, and cubic elastic-constant validation rules.
- Adds provider integration and the
material_handofftool for checking, completing, and converting material data. - Adds regression tests, a GENIUS-produced copper fixture, and user documentation.
| File | Description |
|---|---|
tests/test_scale_bridge.py |
Tests validation, provider completion, stiffness conversion, and safe filenames. |
tests/data/cu_elastic_card.json |
Supplies copper evidence from Quantum ESPRESSO calculations. |
src/tools/scale_bridge.py |
Exposes the material handoff workflow as an MCP tool. |
src/server.py |
Registers the new tool. |
src/scale_bridge/rules/pw_dft_elastic.py |
Defines cubic elasticity evidence and convergence checks. |
src/scale_bridge/rules/__init__.py |
Dispatches checks and plans to registered rules. |
src/scale_bridge/providers.py |
Defines and discovers upstream material providers. |
src/scale_bridge/obligations.py |
Tracks required calculations, decisions, and estimated costs. |
src/scale_bridge/continuum.py |
Produces rotated stiffness and plane-stress matrices. |
src/scale_bridge/card.py |
Defines material cards and structural validation. |
src/scale_bridge/__init__.py |
Documents and exports the handoff API. |
mkdocs.yml |
Adds navigation for the new documentation. |
docs/tools/material_handoff.md |
Documents tool parameters and actions. |
docs/tools/index.md |
Adds the tool and updates the tool count. |
docs/how-it-works/scale-bridging.md |
Explains evidence checks, providers, and limitations. |
docs/_gen_reference.py |
Adds the tool to generated reference documentation. |
Review effort: Balanced
| same = [c for c in hits if c.role == base.role and _same_strain(c, base)] | ||
| fit = [c for c in same if satisfies(c.settings, need)] | ||
| # a completed retry counts over an earlier stopped attempt; a failed one still rejects | ||
| fit.sort(key=lambda c: {"complete": 0, "failed": 1, "stopped": 2}[c.status]) |
Comment on lines
+224
to
+225
| if base_done and all(o.status == COMPLETE for o in cmp.obligations): | ||
| qb, qv = quantities(*chosen), quantities(*repeats) |
| """(reference, normal+, normal-, shear+, shear-) at the reference settings, or (None, reason).""" | ||
| if card.units != "GPa": | ||
| return None, f"the values are in '{card.units}'; this rule compares them with stresses in GPa" | ||
| own = [c for c in card.evidence if not c.variant_of] |
| {k: REPORTED_LIMIT for k in ("C11", "C12", "C44")}, []) | ||
| for c in chosen: | ||
| st, reason = _status(c) | ||
| reported.obligations.append(Obligation(c.name, c.settings, 0.0, st, reason, c.name if st == COMPLETE else "")) |
Comment on lines
+199
to
+200
| reported.differences = {k: abs(card.values[k] / q[k] - 1) if k in card.values and q[k] else float("nan") | ||
| for k in reported.limits} |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


openPASO accepts material constants from another framework and hands them to a continuum model only when every calculation a check requires has actually run. The first producer is GENIUS, which writes and test-runs Quantum ESPRESSO inputs. A missing calculation counts as a failed check, not a skipped one: a check that only compares the calculations it finds cannot see one that never ran.
What is added.
src/scale_bridge:openpaso.material_providers; the GENIUS adapter lives with GENIUS).material_handoff, with the actions schema, check, plan, continuum (refused unless the check accepts), providers, produce and complete.how-it-works/scale-bridging.md,tools/material_handoff.md, the tools index and the menu.Which failures it catches. The rule rejects or holds back a card when:
The normal pair may lie along any cube axis and the shear pair in any plane; in a cubic crystal they are equivalent. A provider's labels cannot place a saved card outside its folder.
How it was checked.
tests/test_scale_bridge.py: 31 cases. They include:The cases added after Copilot's review on the fork fail on the code before them.
A copper card built from real Quantum ESPRESSO outputs written by GENIUS is accepted (
tests/data/cu_elastic_card.json; C11 177.25, C12 123.42, C44 79.17 GPa). An agent then used these constants in the web interface for a perforated copper sheet in NGSolve, and openPASO verified that result.pytest tests: 130 passed, 15 skipped (Windows, before the last round of rule tests;test_scale_bridge.pypasses after it).Not run: the suite on Linux.