Skip to content

Commit

Permalink
improve docs and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
houpc committed Feb 16, 2024
1 parent f607143 commit d4e952e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ julia> optimize!(sigmadf.diagram);
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
# Set the renormalization orders. The first 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, 3];
# Set the renormalization orders. The first element is the maximum order of the Green's function counterterms, and the second element is the maximum order of the interaction counterterms.
julia> renormalization_orders = [2, 1];

# Define functions that determine how the differentiation variables depend on the properties of the leaves in your graphs, identifying `BareGreenId` and `BareInteractionId` properties as the Green's function and interaction counterterms, respectively.
julia> leaf_dep_funcs = [pr -> pr isa FrontEnds.BareGreenId, pr -> pr isa FrontEnds.BareInteractionId];

# Generate the Dict of Graph for the renormalized self-energy diagrams with the Green's function counterterms and the interaction counterterms.
julia> dict_sigma = taylorAD(sigmadf.diagram, renormalization_orders, leaf_dep_funcs);
julia> dict_sigma = taylorAD(sigmadf.diagram, renormalization_orders, leaf_dep_funcs)
Dict{Vector{Int64}, Vector{Graph}} with 6 entries:
[0, 0] => [18822Ins, k[1.0, 0.0, 0.0], t(1, 1)=0.0=Ⓧ , 19019Dyn, k[1.0, 0.0, 0.0], t(1, 2)=0.0=⨁ ]
[2, 1] => [18823Ins, k[1.0, 0.0, 0.0], t(1, 1)[2, 1]=0.0=Ⓧ , 19020Dyn, k[1.0, 0.0, 0.0], t(1, 2)[2, 1]=0.0=⨁ ]
[2, 0] => [18824Ins, k[1.0, 0.0, 0.0], t(1, 1)[2]=0.0=Ⓧ , 19021Dyn, k[1.0, 0.0, 0.0], t(1, 2)[2]=0.0=⨁ ]
[1, 1] => [18825Ins, k[1.0, 0.0, 0.0], t(1, 1)[1, 1]=0.0=Ⓧ , 19022Dyn, k[1.0, 0.0, 0.0], t(1, 2)[1, 1]=0.0=⨁ ]
[1, 0] => [18826Ins, k[1.0, 0.0, 0.0], t(1, 1)[1]=0.0=Ⓧ , 19023Dyn, k[1.0, 0.0, 0.0], t(1, 2)[1]=0.0=⨁ ]
[0, 1] => [18827Ins, k[1.0, 0.0, 0.0], t(1, 1)[0, 1]=0.0=Ⓧ , 19024Dyn, k[1.0, 0.0, 0.0], t(1, 2)[0, 1]=0.0=⨁ ]
```
### Example: Compile Feynman diagrams to different programming languages
Expand All @@ -108,14 +115,14 @@ julia> Compilers.compile_Python(g_o21, :jax, "func_o21.py");
```
### Computational Graph visualization
#### Tree-type visualization using ETE
To visualize tree-type structures of the self-energy in the Parquet example, install the [ete3](http://etetoolkit.org/) Python package, a powerful toolkit for tree visualizations.
#### Tree-type visualization using ETE3
To visualize tree-type structures of the self-energy in the Parquet example, install the [ETE3](http://etetoolkit.org/) Python package, a powerful toolkit for tree visualizations.
Execute the following command in Julia for tree-type visualization of the self-energy generated in the above `Parquet` example:
```julia
julia> plot_tree(sigmadf.diagram, depth = 3)
```
For installation instructions on using ete3 with [PyCall.jl](https://github.com/JuliaPy/PyCall.jl), please refer to the PyCall.jl documentation on how to configure and use external Python packages within Julia.
For installation instructions on using ETE3 with [PyCall.jl](https://github.com/JuliaPy/PyCall.jl), please refer to the PyCall.jl documentation on how to configure and use external Python packages within Julia.
#### Graph visualization using DOT
The Back-End's `Compilers` module includes functionality to translate computational graphs into .dot files, which can be visualized using the `dot` command from Graphviz software. Below is an example code snippet that illustrates how to visualize the computational graph of the self-energy from the previously mentioned `Parquet` example.
Expand Down
10 changes: 5 additions & 5 deletions src/utility.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Utility
using ..ComputationalGraphs
#using ..ComputationalGraphs: Sum, Prod, Power, decrement_power
using ..ComputationalGraphs: decrement_power
using ..ComputationalGraphs: build_all_leaf_derivative, eval!, isfermionic
import ..ComputationalGraphs: count_operation, count_expanded_operation
Expand All @@ -18,12 +17,12 @@ export taylorAD
dict_graphs::Dict{Vector{Int},Vector{Graph}}=Dict{Vector{Int},Vector{Graph}}()
) where {G<:Graph}
Performs Taylor-mode automatic differentiation (AD) on a vector of graphs, with the differentiation process tailored based on specified derivative orders,
Performs Taylor-mode automatic differentiation (AD) on a vector of graphs, with the differentiation process tailored based on specified maximum orders of differentiation
and leaf dependency functions. It categorizes the differentiated graphs in a dictionary based on their derivative orders.
# Parameters
- `graphs`: A vector of graphs to be differentiated.
- `deriv_orders`: A vector of integers specifying the orders of differentiation to apply to the graphs.
- `deriv_orders`: A vector of integers specifying the maximum orders of differentiation to apply to the graphs.
- `leaf_dep_funcs`: A vector of functions determining the dependency of differentiation variables on the properties of leaves in the graphs.
- `dict_graphs`: Optional. A dictionary for storing the output graphs, keyed by vectors of integers representing the specific differentiation orders. Defaults to an empty dictionary.
Expand All @@ -32,16 +31,17 @@ export taylorAD
# Example Usage
```julia
# Define a vector of graphs and their corresponding derivative orders
# Define a vector of graphs
graphs = [g1, g2]
# Specify the maximum orders of differentiation
deriv_orders = [2, 3, 3]
# Define a vector of differentiation dependency functions for the properties of leaf.
# The first and second functions specify identify `BareGreenId` and `BareInteractionId` properties as the Green's function and interaction counterterms, respectively.
# The third function specifies the dependence of on the first external momentum of the leaf.
leaf_dep_funcs = [pr -> pr isa FrontEnds.BareGreenId, pr -> pr isa FrontEnds.BareInteractionId, pr -> pr.extK[1] != 0]
# Perform Taylor-mode AD and categorize the results
# Perform Taylor-mode AD and categorize the results. `result_dict` holds the AD results, organized by differentiation orders `[0:2, 0:3, 0:3]`.
result_dict = taylorAD(graphs, deriv_orders, leaf_dep_funcs)
```
"""
Expand Down

0 comments on commit d4e952e

Please sign in to comment.