Add capability to generate diagram: Goldstone diagrams from SeQuant term strings - #582
Add capability to generate diagram: Goldstone diagrams from SeQuant term strings#582zhihao-deng wants to merge 1 commit into
Conversation
Python renderer that turns a SeQuant CC term string into a Goldstone diagram PNG, with the CSV/PNO-DF overlay (C / CsC boxes, domain superscripts, DF auxiliary label) toggleable down to the canonical CC skeleton. Includes a batch driver and examples
| ``` | ||
|
|
||
| Everything is driven by the **term string** that SeQuant prints — you paste it in, you | ||
| get a diagram out. The renderer understands the CSV/PNO–DF flavour of those strings |
There was a problem hiding this comment.
Pull request overview
Adds a new standalone Python utility under utilities/diagram_gen/ to parse SeQuant coupled-cluster term strings and render publication-style Goldstone diagrams (PNG), with optional CSV/DF overlay annotations (domains, C/CsC bridges, DF auxiliary K) and a canonical “skeleton-only” mode.
Changes:
- Introduces
csv_diagram.pyrenderer with CLI + reusable parsing/graph/layout APIs. - Adds batch rendering (
render_all.py) and automated cleanliness checks (audit_diagrams.py) for large equation files. - Documents the term-string format, rendering options, and diagram conventions (plus sample inputs).
Reviewed changes
Copilot reviewed 6 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| utilities/diagram_gen/sample_terms.txt | Sample SeQuant terms for quick manual testing. |
| utilities/diagram_gen/render_all.py | Batch driver to render full equation markdown sections into PNG sets + index. |
| utilities/diagram_gen/README.md | Usage, options, input format description, and Python API examples. |
| utilities/diagram_gen/csv-cc-diagram-rules.md | Formalized diagram conventions and the “overlay invariance” rule set. |
| utilities/diagram_gen/csv_diagram.py | Core parser/graph builder/layout engine + matplotlib renderer and CLI. |
| utilities/diagram_gen/audit_diagrams.py | Automated audit to detect overlaps/collisions in rendered output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import matplotlib | ||
| matplotlib.use("Agg") | ||
| import matplotlib.pyplot as plt | ||
| from matplotlib.lines import Line2D |
| hv_pair = None | ||
| if len(hvs) == 2: | ||
| hv_pair = (hvs[0], hvs[1]) | ||
| elif len(hvs) > 2: | ||
| raise ValueError(">2 interaction half-vertices not supported") |
|
I found the following with the help of Claude. (Removed the slop.) Blocking 1: an ordinary 4-index
|
|
@bimalgaudel does this work for unitary CC? |
Adds
utilities/diagram_gen/, a standalone Python tool that turns a SeQuantcoupled-cluster term string into a Goldstone diagram PNG.
The term string SeQuant prints is the only input — paste it in, get a diagram out:
python3 csv_diagram.py '2 (f{i_1;μ̃_1} * C{μ̃_1;a_1<i_1>}) * t{a_1<i_1>;i_1}' bubble.png The renderer understands the CSV/PNO–DF flavour of those strings (PAO→PNO transforms C, PAO overlaps s, density-fitting auxiliary index Κ) and draws them as overlay annotations. --no-csv drops every annotation, leaving the textbook CC Goldstone skeleton.