Skip to content

Usage Overview

Convenience Functions

For convenience when generating diagrams in the 'standard' setup, FeynGraph provides the generate_diagrams function. For example, the 2-loop diagrams for the process \(u\bar{u} \rightarrow ggg\) with the standard settings can be generated with

import feyngraph as fg
diags = fg.generate_diagrams(["u", "u~"], ["g"]*3, 2)
use feyngraph::generate_diagrams;
let diags = generate_diagrams(&["u", "u~"], &["g"; 3], 2, Default::default(), Default::default());

By default, the used model is the Standard Model in Feynman gauge imported from the default FeynRules Standard Model and no diagram selection is performed.

Lower-level Interface

If more control is needed over the generation process than the convenience functions allow, the underlying generator objects can be used manually. The diagram generation process in FeynGraph is split into two steps,

  1. Generate all topologies possibly contributing to the process (handled by a TopologyGenerator)
  2. Assign all combinations of particles and vertices to the topologies (handled by a DiagramGenerator)

Details on the respective steps are given on the following pages.

Global Library Configuration

FeynGraph has some global options to control the library's general environment.

Multithreading

FeynGraph uses the rayon Rust crate to parallelize the diagram generation. By default, all available logical cores of the host system are used. If this is undesired, the number of used threads can be chosen manually:

import feyngraph as fg
fg.set_threads(16)

FeynGraph uses rayon's default global thread pool, which can be initialized to a specific number of threads with

use rayon::ThreadPoolBuilder;
ThreadPoolBuilder::new().num_threads(16).build_global().unwrap();
See the rayon documentation for more details.

Logging

FeynGraph uses Pythons standard logging interface. To see the logging messages, the logger has to be configured, e.g. with a RichHandler for nice formatting:

import logging
from rich.logging import RichHandler
logging.basicConfig(
  format="%(message)s",
  datefmt="[%X]",
  handlers=[RichHandler(show_path=False, rich_tracebacks=True)],
)

FeynGraph uses the log crate for logging. If FeynGraph is used in an executable, it should include a logger to consume and show the logs produced by FeynGraph.