Skip to content

Commit

Permalink
simplify readme
Browse files Browse the repository at this point in the history
  • Loading branch information
houpc committed Feb 10, 2024
1 parent 9432b96 commit 8d5f9b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3,602 deletions.
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
In general, Feynman diagrams represents high-order integral. The integrand are propagators/interactions composed by the basis arithmetic operations (multiplication, addition, power, etc). The sequence of calculating the integrand by combining the propagators/interactions with the arithmetic operatos can be represented as an algebraic computational graph. In this sense, the computational graph serves as an intermediate representation that standardizes the treatment of various diagram types, ensuring a consistent approach across different QFT calculations.

![infrastructure](assets/diagram_compiler.svg?raw=true "Compiler Infrastructure")

Drawing from these insights, the architecture of our compiler is intentionally crafted to process Feynman diagrams via a strategic, three-stage process that reflects the advanced design principles of the LLVM compiler architecture. This approach enhances the compiler's flexibility for a wide array of QFT computations and significantly improves its computational efficiency. The workflow is organized into three critical stages:

- **Front End**: In this initial phase, Feynman diagrams are generated and transformed into a standardized intermediate representation, taking the form of static computational graphs. This stage features two key algorithms for generating generic Feynman diagrams for weak-coupling expansions:
Expand All @@ -41,16 +42,19 @@ To install the package, you can simply use the following command in the Julia pa
julia> using Pkg
julia> Pkg.add("FeynmanDiagram.jl")
```

### Example: Self-energy in FrontEnds

The algorithms in `FrontEnds` generates Feynman diagrams for weak coupling expansions, supporting various diagram types, such as self-energy, polarization, 3-point vertex function, and 4-point vertex function. The internal degrees of freedom can be either the loop variables (e.g., momentum or frequency) or the site variables (e.g., imaginary-time or lattice site).

The example below demonstrates generating two-loop self-energy diagrams by `Parquet`, and optimizing and visualizing their computational graphs.
The example below demonstrates generating two-loop self-energy diagrams by `Parquet` and optimizing their computational graphs.

#### Diagram generation by `Parquet` and optimization

#### Generated by `Parquet`:
```julia
julia> using FeynmanDiagram
julia> import FeynmanDiagram.FrontEnds: NoHartree

# Define a parameter structure for two-loop self-energy diagrams in the momentum and the imaginary-time representation. Require the diagrams to be green's function irreducible.
julia> para = Parquet.DiagPara(type = Parquet.SigmaDiag, innerLoopNum = 2 hasTau = true, filter=[NoHartree,]);

Expand All @@ -65,33 +69,20 @@ julia> sigmadf = Parquet.build(para)

# Optimize the Graph for the given Feynman diagrams.
julia> optimize!(sigmadf.diagram);

# Visualize the computational graph as a tree using ETE.
julia> plot_tree(sigmadf.diagram)
```
The generated computational graphs are shown in the following figures as trees, in which the first one is the instant self-energy diagram, and the second one is the dynamic self-energy diagram. The leaves of the tree are the propagators (labeled with `G`) and the charge-charge interactions (labeled with `ccIns`).
![tree](assets/sigmaIns_ete.svg?raw=true "Diagram Tree")
![tree](assets/sigma_ete.svg?raw=true "Diagram Tree")
#### Construct renormalized Feynman diagrams by Taylor-mode AD
The example code below demonstrates how to build the renormalized Feynman diagrams for the self-energy with the Green's function counterterms and the interaction counterterms using Taylor-mode AD.
```julia
julia> using FeynmanDiagram

# Set the renormalization orders. The first element is the order of Feynman diagrams, the second element is the order of the Green's function counterterms, and the second element is the order of the interaction counterterms.
julia> renormalization_orders = [(2,0,0), (2,1,0), (2,0,1), (2,2,0), (2,1,1), (2,0,2)];

# Generate the Dict of Graph for the renormalized self-energy diagrams with the Green's function counterterms and the interaction counterterms.
julia> dict_sigma = Parquet.diagdict_parquet(Parquet.SigmaDiag, renormalization_orders, filter=[FrontEnds.NoHartree])
Dict{Tuple{Int64, Int64, Int64}, Tuple{Vector{Graph}, Vector{Vector{Int64}}}} with 6 entries:
(2, 0, 1) => ([19215[0, 1]=0.0=⨁ , 19581[0, 1]=0.0=⨁ ], [[1, 1], [1, 2]])
(2, 0, 0) => ([19207=0.0=⨁ , 19573=0.0=⨁ ], [[1, 1], [1, 2]])
(2, 0, 2) => ([19209[0, 2]=0.0=⨁ , 19576[0, 2]=0.0=⨁ ], [[1, 1], [1, 2]])
(2, 2, 0) => ([19210[2]=0.0=⨁ , 19575[2]=0.0=⨁ ], [[1, 1], [1, 2]])
(2, 1, 0) => ([19211[1]=0.0=⨁ , 19577[1]=0.0=⨁ ], [[1, 1], [1, 2]])
(2, 1, 1) => ([19212[1, 1]=0.0=⨁ , 19578[1, 1]=0.0=⨁ ], [[1, 1], [1, 2]])
julia> dict_sigma = Parquet.diagdict_parquet(Parquet.SigmaDiag, renormalization_orders, filter=[FrontEnds.NoHartree]);
```
### Example: BackEnds's `Compilers` for self-energy
Expand Down Expand Up @@ -119,6 +110,11 @@ Install the [ete3](http://etetoolkit.org/) Python package for tree-type visualiz
Note that we rely on [PyCall.jl](https://github.com/JuliaPy/PyCall.jl) to call the ete3 python functions from julia. Therefore, you have to install ete3 python package use the python distribution associated with PyCall. According to the tutorial of PyCall, "by default on Mac and Windows systems, Pkg.add("PyCall") or Pkg.build("PyCall") will use the Conda.jl package to install a minimal Python distribution (via Miniconda) that is private to Julia (not in your PATH). You can use the Conda Julia package to install more Python packages, and import Conda to print the Conda.PYTHONDIR directory where python was installed. On GNU/Linux systems, PyCall will default to using the python3 program (if any, otherwise python) in your PATH."
You can simply use the following command for the tree-type visualization of the self-energy in the above `Parquet` example.
```julia
julia> plot_tree(sigmadf.diagram)
```
#### Graph visualization using DOT
Back End's `Compilers` support compile the computataional graphs to the `dot` file, which can be visualized using the `dot` command in Graphviz programs. The example code below demonstrates how to visualize the computational graph of the self-energy in the above `Parquet` example.
Expand Down
File renamed without changes
Loading

0 comments on commit 8d5f9b3

Please sign in to comment.