Skip to content

Commit

Permalink
Add colorcorrelation sum test
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed May 28, 2024
1 parent 7da5310 commit 76a317a
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 158 deletions.
224 changes: 70 additions & 154 deletions debug/ee->qq_.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions feynamp/form/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_full_color_correlation_matrix(fds, legs, model, s2):
vec += [get_color_vector(fds[0], legs[i], model)]
ids += [color_vector_to_id(vec[i])]
mom += [get_leg_momentum(legs[i])]
ops += [color_vector_to_operator(vec[i])]
ops += [("(-1)*" if swap[i] else "") + str(color_vector_to_operator(vec[i]))]
ind += [color_vector_to_index(vec[i])]
ind1 += [str(ind[i]) + legs[i].id]
ind2 += [str(ind[i]) + get_dummy_index(underscore=False, questionmark=False)]
Expand All @@ -180,8 +180,9 @@ def get_full_color_correlation_matrix(fds, legs, model, s2):
right += f"\ncolorcorrelation({mom[i]},{mom[j]})*{ops[i]}({i1},{i2},{dummy})*{ops[j]}({j1},{j2},{dummy}){deltas[:-1]}+"
# right += f"\n{ops[i]}({i1},{i2},{dummy})*{ops[j]}({j1},{j2},{dummy}){deltas[:-1]}+"
# right += f"\ncolorcorrelation({mom[i]},{mom[j]})*d_({i1},{i2})*d_({j1},{j2}){deltas[:-1]}+"
# The minus sign below is from https://arxiv.org/pdf/1002.2581 Eq. 2.6
ret = f"""
id {left[:-1]} = {right[:-1]};
id {left[:-1]} = -({right[:-1]});
"""
print(ret)
return ret
Expand Down
10 changes: 9 additions & 1 deletion feynamp/leg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ def get_leg_momentum(leg):
return mom


def color_vector_to_casimir(color_vector: str) -> str:
if color_vector == "VA":
return "Ca"
if color_vector == "VC":
return "Cf"
return None


def color_vector_to_operator(color_vector):
if color_vector == "VA":
return "f"
return "complex(0,1)*f"
if color_vector == "VC":
return "T"
return None
Expand Down
Empty file added feynamp/test/__init__.py
Empty file.
52 changes: 52 additions & 0 deletions feynamp/test/colorcorrelation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from typing import List

from feynml.leg import Leg

from feynamp import sympy
from feynamp.leg import color_vector_to_casimir, get_color_vector, get_leg_momentum


def assert_colorcorrelation(sympy_expr, fd, legs: List[Leg], model):
"""
sympy_expr: sympy expression of cc/born
"""
for j in range(len(legs)):
vec = get_color_vector(fd, legs[j], model)
if vec is not None:
casimir = color_vector_to_casimir(vec)
sum = sympy_expr
for i in range(len(legs)):
momi = get_leg_momentum(legs[i])
momj = get_leg_momentum(legs[j])
# colorcorrelation is symmetric, and we only have sorted vertices
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momi},{momj})".replace("Mom_", "")
),
1,
)
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momj},{momi})".replace("Mom_", "")
),
1,
)
# TODO can be optimized
for k in range(len(legs)):
for l in range(len(legs)):
momi = get_leg_momentum(legs[k])
momj = get_leg_momentum(legs[l])
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momi},{momj})".replace("Mom_", "")
),
0,
)
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momj},{momi})".replace("Mom_", "")
),
0,
)
# replace all remaining colorcorrelation(mom,mom) with 0
assert sum.equals(sympy.parse_expr(casimir))
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from xsdata.formats.dataclass.parsers import XmlParser

from feynamp.form import compute_squared
from feynamp.test.colorcorrelation import assert_colorcorrelation

logger = logging.getLogger("feynamp")
logger.setLevel(logging.DEBUG)
Expand All @@ -35,3 +36,5 @@ def test_colorcorrelation_ee_qq():
born = compute_squared(fds, fm, colorcorrelated=False)
cc = compute_squared(fds, fm, colorcorrelated=True)
assert (cc / born).simplify().equals(sympy.parse_expr("Cf*colorcorrelation(p3,p4)"))

assert_colorcorrelation(cc / born, fds[0], fds[0].legs, fm)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from xsdata.formats.dataclass.parsers import XmlParser

from feynamp.form import compute_squared
from feynamp.test.colorcorrelation import assert_colorcorrelation

logger = logging.getLogger("feynamp")
logger.setLevel(logging.DEBUG)
Expand Down Expand Up @@ -40,6 +41,8 @@ def test_colorcorrelation_qq_photon_qq():
.equals("Cf*(colorcorrelation(p1, p2) + colorcorrelation(p3, p4))")
)

assert_colorcorrelation(cc / born, fds[0], fds[0].legs, fm)


def test_colorcorrelation_qq_gluon_qq():
fm = load_ufo_model("ufo_sm")
Expand All @@ -65,7 +68,9 @@ def test_colorcorrelation_qq_gluon_qq():
.simplify()
.equals(
sympy.parse_expr(
"Cf*colorcorrelation(p1, p2) + Cf*colorcorrelation(p3, p4) - Nc*colorcorrelation(p1, p2)/2 + Nc*colorcorrelation(p1, p3)/4 - Nc*colorcorrelation(p1, p4)/4 - Nc*colorcorrelation(p2, p3)/4 + Nc*colorcorrelation(p2, p4)/4 - Nc*colorcorrelation(p3, p4)/2 + Nc**2*colorcorrelation(p1, p3)/(8*Cf) + Nc**2*colorcorrelation(p1, p4)/(8*Cf) + Nc**2*colorcorrelation(p2, p3)/(8*Cf) + Nc**2*colorcorrelation(p2, p4)/(8*Cf) - 5*colorcorrelation(p1, p3)/(8*Cf) - 5*colorcorrelation(p1, p4)/(8*Cf) - 5*colorcorrelation(p2, p3)/(8*Cf) - 5*colorcorrelation(p2, p4)/(8*Cf) + colorcorrelation(p1, p3)/(2*Cf*Nc**2) + colorcorrelation(p1, p4)/(2*Cf*Nc**2) + colorcorrelation(p2, p3)/(2*Cf*Nc**2) + colorcorrelation(p2, p4)/(2*Cf*Nc**2)"
"Cf*colorcorrelation(p1, p2) + Cf*colorcorrelation(p3, p4) - Nc*colorcorrelation(p1, p2)/2 + Nc*colorcorrelation(p1, p3)/4 + Nc*colorcorrelation(p1, p4)/4 + Nc*colorcorrelation(p2, p3)/4 + Nc*colorcorrelation(p2, p4)/4 - Nc*colorcorrelation(p3, p4)/2 + Nc**2*colorcorrelation(p1, p3)/(8*Cf) - Nc**2*colorcorrelation(p1, p4)/(8*Cf) - Nc**2*colorcorrelation(p2, p3)/(8*Cf) + Nc**2*colorcorrelation(p2, p4)/(8*Cf) - 5*colorcorrelation(p1, p3)/(8*Cf) + 5*colorcorrelation(p1, p4)/(8*Cf) + 5*colorcorrelation(p2, p3)/(8*Cf) - 5*colorcorrelation(p2, p4)/(8*Cf) + colorcorrelation(p1, p3)/(2*Cf*Nc**2) - colorcorrelation(p1, p4)/(2*Cf*Nc**2) - colorcorrelation(p2, p3)/(2*Cf*Nc**2) + colorcorrelation(p2, p4)/(2*Cf*Nc**2)"
)
)
)

assert_colorcorrelation(cc / born, fds[0], fds[0].legs, fm)

0 comments on commit 76a317a

Please sign in to comment.