FeynKit · latest
On this page

Amplitude

symbolica.community.hepkit Class

Amplitude(diagrams: Sequence[FeynmanDiagram], *, 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)

A coherent sum of amputated, unintegrated Feynman-diagram operators.

Diagrams must describe the same external states in the same model. Named couplings are expanded; model-declared real parameters and physical momenta are real under conjugation. Complex parameters remain complex. Quadratic denominators use the graph convention without widths or an i0 prescription. Already-sewn forward diagrams are rejected.

Examples

from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
process = model.process(["phi", "phi"], ["phi", "phi"])
generated = process.generate_diagrams()
diagram = generated.diagrams[0]
amplitude = hep.Amplitude(generated.diagrams)
operator = amplitude.expression()
adjoint = amplitude.conjugate().expression()
squared = amplitude.squared().sum_spins(average_initial=True).sum_colors()
scalar = squared.expression()
scalar = scalar.contract(collect_chains=False, collect_traces=False)

Constructor

#

Sum weighted diagram operators with matching graph external indices.

Examples

Using the setup in the Amplitude class example:

amplitude = hep.Amplitude(generated.diagrams)

Parameters

NameTypeDefaultDescription
diagramsSequence[FeynmanDiagram]—

Nonempty collection of complete, unsewn diagrams.

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, default four. Bispinor spaces retain dimension four.

realOptional[Sequence[Expression]]None

Additional scalar expressions assumed real under conjugation.

Member details

diagrams

Property · read-only#
diagrams: list[FeynmanDiagram]

Source diagrams, retaining weights, routing, and graph provenance.

Examples

Using the setup in the Amplitude class example:

assert len(amplitude.diagrams) == len(generated.diagrams)

legs

Property · read-only#
legs: list[AmplitudeLeg]

Physical external states in increasing external-label order.

Examples

Using the setup in the Amplitude class example:

external_states = [(leg.index, leg.particle.name) for leg in amplitude.legs]

terms

Property · read-only#
terms: list[TensorExpression]

Individual weighted operators, with aligned external tensor ports.

Examples

Using the setup in the Amplitude class example:

operators = amplitude.terms
assert len(operators) == len(amplitude.diagrams)

is_conjugated

Property · read-only#
is_conjugated: bool

Whether this amplitude is the physical adjoint of its source diagrams.

Examples

Using the setup in the Amplitude class example:

assert not amplitude.is_conjugated
assert amplitude.conjugate().is_conjugated

from_diagram

Static method#
from_diagram(diagram: FeynmanDiagram, *, 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) -> Amplitude

Construct an amplitude from one complete diagram.

Examples

Using the setup in the Amplitude class example:

amplitude = hep.Amplitude.from_diagram(diagram)

Parameters

NameTypeDefaultDescription
diagramFeynmanDiagram—

Complete, unsewn source diagram.

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, default four.

realOptional[Sequence[Expression]]None

Additional scalar reality assumptions.

expression

Method#
expression() -> TensorExpression

Return the complete operator as a Spenso tensor expression.

Examples

Using the setup in the Amplitude class example:

operator = amplitude.expression()

conjugate

Method#
conjugate() -> Amplitude

Conjugate scalar coefficients, color tensors, and Dirac chains.

Physical external-leg labels are preserved across different fermion pairings.

Examples

Using the setup in the Amplitude class example:

adjoint = amplitude.conjugate()

squared

Method#
squared() -> SquaredAmplitude

Form the coherent square, including all interferences, with distinct ports.

Spin/color sums and initial-state averages remain explicit operations.

Examples

Using the setup in the Amplitude class example:

squared = amplitude.squared().sum_spins().sum_colors()

__repr__

Method#
__repr__() -> str

Describe the retained diagrams, external states, and conjugation state.

Examples

Using the setup in the Amplitude class example:

print(amplitude)

render

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

Prepare a browser-measured view of the amplitude's diagrams and weighted terms.

Examples

Using the setup in the Amplitude class example:

from symbolica.community.graph import RenderSettings, DrawOptions
drawing = amplitude.render(config=RenderSettings(drawing=DrawOptions(node_radius=5)), max_diagrams=2)
snapshot = drawing.measured(browser="chromium")
html = snapshot.to_html()

Parameters

NameTypeDefaultDescription
configOptional[RenderSettings]None

Layout, labels, and stroke settings shared by all diagrams.

styleOptional[DiagramStyle]None

Particle, momentum, and physical index presentation.

max_diagramsOptional[int]6

Maximum displayed contributions (default 6); None includes all, 0 none.

term_settingsOptional[DisplaySettings]None

Tensor notation settings for each weighted contribution.

_repr_mimebundle_

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

Render compact diagram rows with weighted operators and expandable graphs.

Examples

Using the setup in the Amplitude class example:

from IPython.display import display
display(amplitude)

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 Amplitude class example:

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