FeynKit · latest
On this page

Process

symbolica.community.hepkit Class

Process()

A scattering or decay process to pass to the diagram generator.

A process records its incoming and outgoing particles and model-sector restrictions. External states accept loaded Particle objects as well as names, signed PDG codes, and explicit ParticleSelector objects.

Examples

from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.standard_model()
process = model.process(["e-", "e+"], ["mu-", "mu+"])
result = process.generate_diagrams(loops=0)
assert result.report.completed

Member details

model

Property · read-only#
model: Model

The particle model supplying this process's Feynman rules.

Examples

Using the setup in the Process class example:

electron = process.model.particle("e-")

particle_veto

Property · read-only#
particle_veto: list[ParticleSelector]

The excluded particle selectors, shared by every generation operation.

Examples

Using the setup in the Process class example:

excluded_particles = process.particle_veto

particle_selection

Property · read-only#
particle_selection: Optional[list[ParticleSelector]]

Allowed species, including their antiparticles. None allows all; an empty list allows none. Shared by every generation operation.

Examples

Using the setup in the Process class example:

qed = model.process(["e-", "e+"], ["a", "a"], particle_selection=["e-", "a"])
allowed_particles = qed.particle_selection

vertex_allow

Property · read-only#
vertex_allow: Optional[list[VertexRule]]

Allowed model vertex rules; None permits every interaction.

Examples

Using the setup in the Process class example:

allowed_interactions = process.vertex_allow

vertex_veto

Property · read-only#
vertex_veto: list[VertexRule]

Excluded model vertex rules.

Examples

Using the setup in the Process class example:

excluded_interactions = process.vertex_veto

incoming

Property · read-only#
incoming: list[ParticleSelector]

Return the ordered incoming-particle selectors.

Examples

Using the setup in the Process class example:

assert [selector.name for selector in process.incoming] == ["e-", "e+"]

outgoing_alternatives

Property · read-only#
outgoing_alternatives: list[list[ParticleSelector]]

Return every allowed ordered final-state alternative.

Examples

Using the setup in the Process class example:

alternatives = process.outgoing_alternatives

__repr__

Method#
__repr__() -> str

Format the external states, model, and active particle/vertex restrictions.

Examples

Using the setup in the Process class example:

repr(process)

render

Method#
render(*, config: Optional[RenderSettings] = None, style: Optional[DiagramStyle] = None) -> DiagramView

Create a displayable blob with the process's physical incoming and outgoing particles. Alternative final states are displayed as separate schematics.

Examples

Using the setup in the Process class example:

drawing = process.render()
drawing
svg = drawing.measured(browser="chromium").to_svg()

Parameters

NameTypeDefaultDescription
configOptional[RenderSettings]None

Particle-label, layout and drawing overrides shared with Feynman diagrams.

styleOptional[DiagramStyle]None

Particle, momentum, and physical index presentation.

_repr_mimebundle_

Method#
_repr_mimebundle_(include: Optional[Sequence[str]] = None, exclude: Optional[Sequence[str]] = None) -> Any

Measure and display the process schematic in notebook frontends.

Examples

Using the setup in the Process class example:

from IPython.display import display
display(process)

Parameters

NameTypeDefaultDescription
includeOptional[Sequence[str]]None

MIME types requested by the frontend; None allows all available types.

excludeOptional[Sequence[str]]None

MIME types omitted from the frontend response.

_mime_

Method#
_mime_() -> Any

Return Marimo MIME data with static output and an optional live widget.

Examples

Using the setup in the Process class example:

view = process.render()
view  # static output is immediate; an optional widget refines label sizes
snapshot = view.measured(browser="chromium")

with_final_state_alternatives

Method#
with_final_state_alternatives(alternatives: Sequence[Sequence[Particle | ParticleSelector | str | int]]) -> Process

Return a process accepting any of the supplied final states. Generating amplitudes requires exactly one alternative; cross sections may include an empty alternative for a vacuum final state.

Examples

Using the setup in the Process class example:

process = model.process([11, -11], [22, 22])
inclusive = process.with_final_state_alternatives([[22, 22], [13, -13]])

Parameters

NameTypeDefaultDescription
alternativesSequence[Sequence[Particle | ParticleSelector | str | int]]—

Allowed outgoing particle lists.

with_filters

Method#
with_filters(*, particle_veto: Sequence[Particle | ParticleSelector | str | int] | types.EllipsisType | None = ..., particle_selection: Sequence[Particle | ParticleSelector | str | int] | types.EllipsisType | None = ..., vertex_allow: Sequence[VertexRule | str] | types.EllipsisType | None = ..., vertex_veto: Sequence[VertexRule | str] | types.EllipsisType | None = ...) -> Process

Return a process with updated particle and vertex restrictions. Omitted fields are preserved; None clears a field. An empty vertex_allow list permits no interactions, whereas None permits every interaction.

Examples

Using the setup in the Process class example:

qed = process.with_filters(vertex_allow=["V_98"])
unrestricted = qed.with_filters(vertex_allow=None)

Parameters

NameTypeDefaultDescription
particle_vetoSequence[Particle | ParticleSelector | str | int] | types.EllipsisType | Noneruntime default

Replace the excluded species, including their antiparticles.

particle_selectionSequence[Particle | ParticleSelector | str | int] | types.EllipsisType | Noneruntime default

Replace the allowed species, including their antiparticles. An empty list allows none. Clear particle_veto with None when switching modes.

vertex_allowSequence[VertexRule | str] | types.EllipsisType | Noneruntime default

Replace the allowed interaction rules.

vertex_vetoSequence[VertexRule | str] | types.EllipsisType | Noneruntime default

Replace the excluded interaction rules.

generate_diagrams

Method#
generate_diagrams(*, loops: int | tuple[int, int] = 0, symmetrize_initial: bool = False, symmetrize_final: Optional[bool] = None, symmetrize_left_right: bool = False, symmetrize_external_fermions: bool = False, threads: Optional[int] = None, max_vertices: Optional[int] = None, allow_self_loops: bool = True, allow_zero_flow_edges: bool = False, graph_prefix: Optional[str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, fermion_loop_count_range: Optional[tuple[int, int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: Optional[Mapping[str, int]] = None, sewn_tadpoles: Optional[bool] = None, cut_amplitude_coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, cut_amplitude_loop_count_range: Optional[tuple[int, int]] = None, select_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, veto_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, loop_momentum_bases: Optional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]] = None, numerator_prefactor: Optional[Expression] = None, projector: Optional[Expression] = None, numerator_grouping: Optional[NumeratorGrouping] = None, filter_zero_color: bool = False, cancellation_token: Optional[CancellationToken] = None, progress: Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> GenerationResult

Generate and optionally group all diagrams matching a process.

Model Feynman rules are instantiated into each returned diagram: inspect vertex.numerator_expression() and edge.numerator_expression() for individual factors, or diagram.numerator_expression() for their combined numerator.

Examples

Using the setup in the Process class example:

result = process.generate_diagrams(max_vertices=6)
combined_numerator = result.diagrams[0].numerator_expression()

Parameters

NameTypeDefaultDescription
loopsint | tuple[int, int]0

Exact order or inclusive range for this call, default zero. Cross sections count loops in the sewn forward graph; two-particle tree cuts need loops=1.

symmetrize_initialboolFalse

Identify graphs related by initial-state permutations; default False.

symmetrize_finalOptional[bool]None

Identify final-state permutations; None uses True for cross sections and False for amplitudes.

symmetrize_left_rightboolFalse

Identify cross-section graphs related by exchanging amplitude sides.

symmetrize_external_fermionsboolFalse

Include amplitude fermions in enabled external-state symmetry classes.

threadsOptional[int]None

Number of worker threads; None uses the generator default.

max_verticesOptional[int]None

Maximum interaction vertices; None applies no override.

allow_self_loopsboolTrue

Permit propagators that start and end on the same vertex; defaults to True.

allow_zero_flow_edgesboolFalse

Permit internal edges with identically zero momentum flow.

graph_prefixOptional[str]None

Prefix assigned to generated diagram names; None uses "D" (diagram).

maximum_bridgesint | None | types.EllipsisTyperuntime default

Omission or Ellipsis requires one-particle irreducibility only for diagrams with loops; tree exchanges are allowed, including in mixed loop ranges. An integer limits internal bridges at every loop order; None disables it.

self_energySelfEnergyFilterOptions | types.EllipsisType | Noneruntime default

Reject self-energy subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

tadpolesTadpoleFilterOptions | types.EllipsisType | Noneruntime default

Reject tadpole subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

zero_snailsSnailFilterOptions | types.EllipsisType | Noneruntime default

Reject zero-snail subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Exact coupling powers or inclusive ranges; an upper None is unbounded.

fermion_loop_count_rangeOptional[tuple[int, int]]None

Inclusive range of closed fermion loops.

factorized_loop_topologies_count_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of factorized loop-topology components. Defaults to (1, 1) for vacuum processes; None disables the restriction.

blob_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive cross-section blob-count range. Defaults to (1, 1) for cross sections; None omits the filter, which also selects (1, 1).

spectator_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of spectators, initial-state legs crossed by a cut, on each cut side. Defaults to (0, 0) for cross sections; None omits the filter, which also selects (0, 0). A graph selected only through a spectator cut is a selection-only diagram (is_selection_only): it is listed and exported, but not turned into an amplitude or integrand.

perturbative_ordersOptional[Mapping[str, int]]None

Exact perturbative powers required for cross-section graphs.

sewn_tadpolesOptional[bool]None

Reject tadpoles revealed by sewing cross-section sides; None applies no filter.

cut_amplitude_coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Coupling-order bounds applied independently within every cut amplitude.

cut_amplitude_loop_count_rangeOptional[tuple[int, int]]None

Inclusive combined loop count across both sides of every cut.

select_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Retain only these diagram objects, content-derived IDs, or finalized names.

veto_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Remove these diagram objects, content-derived IDs, or finalized names.

loop_momentum_basesOptional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]]None

Diagram selectors paired with ordered stable edge IDs for independent loop momenta.

numerator_prefactorOptional[Expression]None

Scalar multiplier retained on every finalized diagram numerator.

projectorOptional[Expression]None

Override all automatic external-state contractions; S("1") disables them. The default cross-section projector also sums paired initial colors without averaging; unsewn amplitude colors remain open.

numerator_groupingOptional[NumeratorGrouping]None

Defaults to None: no numerator comparison or grouping. Diagrams still contain numerators. Pass NumeratorGrouping to compare and group them.

filter_zero_colorboolFalse

Discard diagrams whose color algebra proves the numerator is zero, before numerator grouping. Defaults to False, independently of grouping.

cancellation_tokenOptional[CancellationToken]None

Shared token for cancelling a running generation task. Token cancellation returns an incomplete result; Python signal-handler exceptions, including KeyboardInterrupt, stop generation and propagate to the caller.

progressLiteral['auto'] | collections.abc.Callable[[GenerationProgress], None] | None'auto'

Defaults to "auto": show progress when marimo.running_in_notebook() is true, with stage, counts, and elapsed time. None disables progress. Known totals use a progress bar; unknown totals use a spinner. The display closes on completion, cancellation, or error. Observe stage changes and coalesced counts on the calling Python thread. Callback exceptions propagate and stop generation.

filtercollections.abc.Callable[[symbolica.core.Graph, int], bool] | NoneNone

Prune partial topologies during enumeration. The first N vertices are complete. False rejects only this search branch. Edge data is the base particle PDG code; node data is 0 internally, -(index+1) for incoming legs and +(index+1) for outgoing legs. Mutating the snapshot does not change enumeration. Keep callbacks cheap: each snapshot is constructed using Symbolica's core Python Graph API.

generate_amplitude

Method#
generate_amplitude(*, dimension: Optional[Expression | int | Float | int | float | str | decimal.Decimal | ComplexFloat | Float | int | float | str | decimal.Decimal | complex | tuple[Float | int | float | str | decimal.Decimal, Float | int | float | str | decimal.Decimal]] = None, real: Optional[Sequence[Expression]] = None, loops: int | tuple[int, int] = 0, symmetrize_initial: bool = False, symmetrize_final: Optional[bool] = None, symmetrize_left_right: bool = False, symmetrize_external_fermions: bool = False, threads: Optional[int] = None, max_vertices: Optional[int] = None, allow_self_loops: bool = True, allow_zero_flow_edges: bool = False, graph_prefix: Optional[str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, fermion_loop_count_range: Optional[tuple[int, int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: Optional[Mapping[str, int]] = None, sewn_tadpoles: Optional[bool] = None, cut_amplitude_coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, cut_amplitude_loop_count_range: Optional[tuple[int, int]] = None, select_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, veto_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, loop_momentum_bases: Optional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]] = None, numerator_prefactor: Optional[Expression] = None, projector: Optional[Expression] = None, numerator_grouping: Optional[NumeratorGrouping] = None, filter_zero_color: bool = False, cancellation_token: Optional[CancellationToken] = None, progress: Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> Amplitude

Generate a coherent symbolic amplitude for this process. Cancelled or empty generation cannot produce an amplitude.

Model Feynman rules are instantiated into each returned diagram: inspect vertex.numerator_expression() and edge.numerator_expression() for individual factors, or diagram.numerator_expression() for their combined numerator.

Examples

Using the setup in the Process class example:

result = process.generate_amplitude(max_vertices=6)
operator = result.expression()

Parameters

NameTypeDefaultDescription
dimensionOptional[Expression | int | Float | int | float | str | decimal.Decimal | ComplexFloat | Float | int | float | str | decimal.Decimal | complex | tuple[Float | int | float | str | decimal.Decimal, Float | int | float | str | decimal.Decimal]]None

Lorentz dimension of the amplitude; default four.

realOptional[Sequence[Expression]]None

Additional scalars assumed real under conjugation.

loopsint | tuple[int, int]0

Exact order or inclusive range for this call, default zero. Cross sections count loops in the sewn forward graph; two-particle tree cuts need loops=1.

symmetrize_initialboolFalse

Identify graphs related by initial-state permutations; default False.

symmetrize_finalOptional[bool]None

Identify final-state permutations; None uses True for cross sections and False for amplitudes.

symmetrize_left_rightboolFalse

Identify cross-section graphs related by exchanging amplitude sides.

symmetrize_external_fermionsboolFalse

Include amplitude fermions in enabled external-state symmetry classes.

threadsOptional[int]None

Number of worker threads; None uses the generator default.

max_verticesOptional[int]None

Maximum interaction vertices; None applies no override.

allow_self_loopsboolTrue

Permit propagators that start and end on the same vertex; defaults to True.

allow_zero_flow_edgesboolFalse

Permit internal edges with identically zero momentum flow.

graph_prefixOptional[str]None

Prefix assigned to generated diagram names; None uses "D" (diagram).

maximum_bridgesint | None | types.EllipsisTyperuntime default

Omission or Ellipsis requires one-particle irreducibility only for diagrams with loops; tree exchanges are allowed, including in mixed loop ranges. An integer limits internal bridges at every loop order; None disables it.

self_energySelfEnergyFilterOptions | types.EllipsisType | Noneruntime default

Reject self-energy subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

tadpolesTadpoleFilterOptions | types.EllipsisType | Noneruntime default

Reject tadpole subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

zero_snailsSnailFilterOptions | types.EllipsisType | Noneruntime default

Reject zero-snail subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Exact coupling powers or inclusive ranges; an upper None is unbounded.

fermion_loop_count_rangeOptional[tuple[int, int]]None

Inclusive range of closed fermion loops.

factorized_loop_topologies_count_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of factorized loop-topology components. Defaults to (1, 1) for vacuum processes; None disables the restriction.

blob_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive cross-section blob-count range. Defaults to (1, 1) for cross sections; None omits the filter, which also selects (1, 1).

spectator_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of spectators, initial-state legs crossed by a cut, on each cut side. Defaults to (0, 0) for cross sections; None omits the filter, which also selects (0, 0). A graph selected only through a spectator cut is a selection-only diagram (is_selection_only): it is listed and exported, but not turned into an amplitude or integrand.

perturbative_ordersOptional[Mapping[str, int]]None

Exact perturbative powers required for cross-section graphs.

sewn_tadpolesOptional[bool]None

Reject tadpoles revealed by sewing cross-section sides; None applies no filter.

cut_amplitude_coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Coupling-order bounds applied independently within every cut amplitude.

cut_amplitude_loop_count_rangeOptional[tuple[int, int]]None

Inclusive combined loop count across both sides of every cut.

select_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Retain only these diagram objects, content-derived IDs, or finalized names.

veto_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Remove these diagram objects, content-derived IDs, or finalized names.

loop_momentum_basesOptional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]]None

Diagram selectors paired with ordered stable edge IDs for independent loop momenta.

numerator_prefactorOptional[Expression]None

Scalar multiplier retained on every finalized diagram numerator.

projectorOptional[Expression]None

Override all automatic external-state contractions; S("1") disables them. The default cross-section projector also sums paired initial colors without averaging; unsewn amplitude colors remain open.

numerator_groupingOptional[NumeratorGrouping]None

Defaults to None: no numerator comparison or grouping. Diagrams still contain numerators. Pass NumeratorGrouping to compare and group them.

filter_zero_colorboolFalse

Discard diagrams whose color algebra proves the numerator is zero, before numerator grouping. Defaults to False, independently of grouping.

cancellation_tokenOptional[CancellationToken]None

Shared token for cancelling a running generation task. Token cancellation returns an incomplete result; Python signal-handler exceptions, including KeyboardInterrupt, stop generation and propagate to the caller.

progressLiteral['auto'] | collections.abc.Callable[[GenerationProgress], None] | None'auto'

Defaults to "auto": show progress when marimo.running_in_notebook() is true, with stage, counts, and elapsed time. None disables progress. Known totals use a progress bar; unknown totals use a spinner. The display closes on completion, cancellation, or error. Observe stage changes and coalesced counts on the calling Python thread. Callback exceptions propagate and stop generation.

filtercollections.abc.Callable[[symbolica.core.Graph, int], bool] | NoneNone

Prune partial topologies during enumeration. The first N vertices are complete. False rejects only this search branch. Edge data is the base particle PDG code; node data is 0 internally, -(index+1) for incoming legs and +(index+1) for outgoing legs. Mutating the snapshot does not change enumeration. Keep callbacks cheap: each snapshot is constructed using Symbolica's core Python Graph API.

generate_cross_section

Method#
generate_cross_section(*, loops: int | tuple[int, int] = 0, symmetrize_initial: bool = False, symmetrize_final: Optional[bool] = None, symmetrize_left_right: bool = False, symmetrize_external_fermions: bool = False, threads: Optional[int] = None, max_vertices: Optional[int] = None, allow_self_loops: bool = True, allow_zero_flow_edges: bool = False, graph_prefix: Optional[str] = None, maximum_bridges: int | None | types.EllipsisType = ..., self_energy: SelfEnergyFilterOptions | types.EllipsisType | None = ..., tadpoles: TadpoleFilterOptions | types.EllipsisType | None = ..., zero_snails: SnailFilterOptions | types.EllipsisType | None = ..., coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, fermion_loop_count_range: Optional[tuple[int, int]] = None, factorized_loop_topologies_count_range: tuple[int, int] | types.EllipsisType | None = ..., blob_range: tuple[int, int] | types.EllipsisType | None = ..., spectator_range: tuple[int, int] | types.EllipsisType | None = ..., perturbative_orders: Optional[Mapping[str, int]] = None, sewn_tadpoles: Optional[bool] = None, cut_amplitude_coupling_orders: Optional[Mapping[str, int | tuple[int, Optional[int]]]] = None, cut_amplitude_loop_count_range: Optional[tuple[int, int]] = None, select_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, veto_diagrams: Optional[Sequence[FeynmanDiagram | str]] = None, loop_momentum_bases: Optional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]] = None, numerator_prefactor: Optional[Expression] = None, projector: Optional[Expression] = None, numerator_grouping: Optional[NumeratorGrouping] = None, filter_zero_color: bool = False, cancellation_token: Optional[CancellationToken] = None, progress: Literal['auto'] | collections.abc.Callable[[GenerationProgress], None] | None = 'auto', filter: collections.abc.Callable[[symbolica.core.Graph, int], bool] | None = None) -> GenerationResult

Generate sewn forward diagrams and their physical final-state cuts. The result contains diagrams and cut metadata, before phase-space integration.

Model Feynman rules are instantiated into each returned diagram: inspect vertex.numerator_expression() and edge.numerator_expression() for individual factors, or diagram.numerator_expression() for their combined numerator.

Examples

A two-particle tree cut has one loop after the amplitude sides are sewn:

from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
process = model.process(["phi", "phi"], ["phi", "phi"])
result = process.generate_cross_section(loops=1)
assert result.diagrams[0].cuts
combined_numerator = result.diagrams[0].numerator_expression()

Parameters

NameTypeDefaultDescription
loopsint | tuple[int, int]0

Exact order or inclusive range for this call, default zero. Cross sections count loops in the sewn forward graph; two-particle tree cuts need loops=1.

symmetrize_initialboolFalse

Identify graphs related by initial-state permutations; default False.

symmetrize_finalOptional[bool]None

Identify final-state permutations; None uses True for cross sections and False for amplitudes.

symmetrize_left_rightboolFalse

Identify cross-section graphs related by exchanging amplitude sides.

symmetrize_external_fermionsboolFalse

Include amplitude fermions in enabled external-state symmetry classes.

threadsOptional[int]None

Number of worker threads; None uses the generator default.

max_verticesOptional[int]None

Maximum interaction vertices; None applies no override.

allow_self_loopsboolTrue

Permit propagators that start and end on the same vertex; defaults to True.

allow_zero_flow_edgesboolFalse

Permit internal edges with identically zero momentum flow.

graph_prefixOptional[str]None

Prefix assigned to generated diagram names; None uses "D" (diagram).

maximum_bridgesint | None | types.EllipsisTyperuntime default

Omission or Ellipsis requires one-particle irreducibility only for diagrams with loops; tree exchanges are allowed, including in mixed loop ranges. An integer limits internal bridges at every loop order; None disables it.

self_energySelfEnergyFilterOptions | types.EllipsisType | Noneruntime default

Reject self-energy subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

tadpolesTadpoleFilterOptions | types.EllipsisType | Noneruntime default

Reject tadpole subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

zero_snailsSnailFilterOptions | types.EllipsisType | Noneruntime default

Reject zero-snail subgraphs. Omission enables the default filter for non-vacuum processes; explicit None disables it. Ellipsis selects automatic defaults.

coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Exact coupling powers or inclusive ranges; an upper None is unbounded.

fermion_loop_count_rangeOptional[tuple[int, int]]None

Inclusive range of closed fermion loops.

factorized_loop_topologies_count_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of factorized loop-topology components. Defaults to (1, 1) for vacuum processes; None disables the restriction.

blob_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive cross-section blob-count range. Defaults to (1, 1) for cross sections; None omits the filter, which also selects (1, 1).

spectator_rangetuple[int, int] | types.EllipsisType | Noneruntime default

Inclusive range of spectators, initial-state legs crossed by a cut, on each cut side. Defaults to (0, 0) for cross sections; None omits the filter, which also selects (0, 0). A graph selected only through a spectator cut is a selection-only diagram (is_selection_only): it is listed and exported, but not turned into an amplitude or integrand.

perturbative_ordersOptional[Mapping[str, int]]None

Exact perturbative powers required for cross-section graphs.

sewn_tadpolesOptional[bool]None

Reject tadpoles revealed by sewing cross-section sides; None applies no filter.

cut_amplitude_coupling_ordersOptional[Mapping[str, int | tuple[int, Optional[int]]]]None

Coupling-order bounds applied independently within every cut amplitude.

cut_amplitude_loop_count_rangeOptional[tuple[int, int]]None

Inclusive combined loop count across both sides of every cut.

select_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Retain only these diagram objects, content-derived IDs, or finalized names.

veto_diagramsOptional[Sequence[FeynmanDiagram | str]]None

Remove these diagram objects, content-derived IDs, or finalized names.

loop_momentum_basesOptional[Sequence[tuple[FeynmanDiagram | str, Sequence[int]]]]None

Diagram selectors paired with ordered stable edge IDs for independent loop momenta.

numerator_prefactorOptional[Expression]None

Scalar multiplier retained on every finalized diagram numerator.

projectorOptional[Expression]None

Override all automatic external-state contractions; S("1") disables them. The default cross-section projector also sums paired initial colors without averaging; unsewn amplitude colors remain open.

numerator_groupingOptional[NumeratorGrouping]None

Defaults to None: no numerator comparison or grouping. Diagrams still contain numerators. Pass NumeratorGrouping to compare and group them.

filter_zero_colorboolFalse

Discard diagrams whose color algebra proves the numerator is zero, before numerator grouping. Defaults to False, independently of grouping.

cancellation_tokenOptional[CancellationToken]None

Shared token for cancelling a running generation task. Token cancellation returns an incomplete result; Python signal-handler exceptions, including KeyboardInterrupt, stop generation and propagate to the caller.

progressLiteral['auto'] | collections.abc.Callable[[GenerationProgress], None] | None'auto'

Defaults to "auto": show progress when marimo.running_in_notebook() is true, with stage, counts, and elapsed time. None disables progress. Known totals use a progress bar; unknown totals use a spinner. The display closes on completion, cancellation, or error. Observe stage changes and coalesced counts on the calling Python thread. Callback exceptions propagate and stop generation.

filtercollections.abc.Callable[[symbolica.core.Graph, int], bool] | NoneNone

Prune partial topologies during enumeration. The first N vertices are complete. False rejects only this search branch. Edge data is the base particle PDG code; node data is 0 internally, -(index+1) for incoming legs and +(index+1) for outgoing legs. Mutating the snapshot does not change enumeration. Keep callbacks cheap: each snapshot is constructed using Symbolica's core Python Graph API.