sft_wick.diagrams — Feynman Diagram Representation¶
Feynman diagram representation using networkx.
Each diagram is a MultiGraph where: - Nodes are either external points (observable fields) or interaction vertices - Edges are propagators (C or R)
- class sft_wick.diagrams.FeynmanDiagram(graph=<factory>, _node_counter=0)[source]¶
Bases:
objectGraph-based representation of a single Feynman diagram.
- Parameters:
graph (MultiGraph)
_node_counter (int)
- graph: MultiGraph¶
- add_external_point(label, field_type, component=None, spatial='', full_label=None)[source]¶
Add an external point (observable field) to the diagram.
- Parameters:
label (str) – Default display label for the node (typically a compact form like
"$\phi_a$").field_type (str) –
"physical"or"response".component (str | None) – Component index (
Nonefor scalar fields).spatial (str) – Spatial argument string.
full_label (str | None) – Optional richer label that includes the spatial argument (e.g.
"$\phi_a(x_1)$"). Stashed under thefull_labelnode attribute so renderers can opt into it via theLABEL_FULLformat flag. WhenNonenofull_labelkey is set (renderers fall back tolabel).
- Returns:
The unique node ID assigned to this external point.
- Return type:
- add_propagator(node1, node2, kind, index_left=None, index_right=None, spatial_left='', spatial_right='', phi_end=None, psi_end=None)[source]¶
Add a propagator edge between two nodes.
- Parameters:
node1 (str) – Source node ID.
node2 (str) – Target node ID.
kind (str) –
"C"for correlation or"R"for response.index_left (str | None) – Left component index (
Nonefor scalars).index_right (str | None) – Right component index (
Nonefor scalars).spatial_left (str) – Left spatial argument.
spatial_right (str) – Right spatial argument.
phi_end (str | None) – For R propagators, the node ID on the physical (φ) side.
Nonefor C propagators.psi_end (str | None) – For R propagators, the node ID on the response (ψ) side.
Nonefor C propagators.
- Return type:
None
Note
Arrow-direction convention for R propagators. An R edge
R = ⟨φ ψ⟩is directed: when rendered, the arrowhead points from the response (ψ) end to the physical (φ) end — i.e. the arrow lands onphi_end. This encodes the causal/retarded flow (a perturbation entering at the ψ leg produces the response at the φ leg). Both renderers honour this:DiagramRenderer(matplotlib) andTikzRenderer(TikZ). C propagators are undirected and carry no arrow.
- classmethod from_pairing(observable_ops, vertex_instances, pairing)[source]¶
Construct a diagram from a Wick contraction pairing.
- Parameters:
observable_ops (list[FieldOperator]) – External field operators.
vertex_instances (list[VertexInstance]) – Instantiated interaction vertices.
pairing (tuple[tuple[int, int], ...]) – Tuple of
(i, j)index pairs from Wick contraction.
- Returns:
A fully-constructed
FeynmanDiagramwith external nodes, vertex nodes, and propagator edges.- Return type:
- canonical_form()[source]¶
Return a hashable canonical form for this diagram’s topology.
Two diagrams have the same canonical form if and only if they are isomorphic under relabeling of vertex nodes that share the same coupling type. External nodes are distinguished by their position in the observable. Edge kind (C/R) and R-direction are structural; component indices and spatial arguments on edges are ignored.
- Returns:
A hashable tuple
(ext_meta, vert_meta, edges)that is identical for topologically equivalent diagrams.- Return type: