Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed May 28, 2024
1 parent 049c30d commit 9303693
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 631 deletions.
38 changes: 19 additions & 19 deletions debug/ee->AA.ipynb

Large diffs are not rendered by default.

590 changes: 0 additions & 590 deletions debug/ee->Ag.ipynb

This file was deleted.

4 changes: 4 additions & 0 deletions feynamp/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def compute_squared(
colorcorrelated=False,
spincorrelated=False,
tag=False,
drop_ms_prefix=False,
):
assert len(fds) > 0, "No FeynmanDiagrams to compute"
dims = fds[0].get_externals_size()
Expand Down Expand Up @@ -77,6 +78,9 @@ def compute_squared(
)
debug(f"{rr=}")

if drop_ms_prefix:
rr = rr.replace("ms_s", "s").replace("ms_u", "u").replace("ms_t", "t")

ret = form.sympyfy(
rr
# .replace("Mom_", "")
Expand Down
3 changes: 2 additions & 1 deletion feynamp/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def sympyfy(string_expr):
# .replace("ms_t", "t")
)
)
return simplify(ret.subs("Nc", "3").subs("Cf", "4/3"))
return ret
# return simplify(ret.subs("Nc", "3").subs("Cf", "4/3"))


def sympy_to_form_string(sympy_expr):
Expand Down
8 changes: 2 additions & 6 deletions feynamp/test/colorcorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ def assert_colorcorrelation(sympy_expr, fds, model):
momi = get_leg_momentum(legs[k])
momj = get_leg_momentum(legs[l])
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momi},{momj})".replace("Mom_", "")
),
sympy.parse_expr(f"colorcorrelation({momi},{momj})"),
0,
)
sum = sum.replace(
sympy.parse_expr(
f"colorcorrelation({momj},{momi})".replace("Mom_", "")
),
sympy.parse_expr(f"colorcorrelation({momj},{momi})"),
0,
)
# replace all remaining colorcorrelation(mom,mom) with 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
logger.setLevel(logging.DEBUG)


def test_colorcorrelation_ee_qq():
def test_colorcorrelation_ee_aa():
fm = load_ufo_model("ufo_sm")
qfm = feynmodel_to_qgraf(fm, True, False)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def test_colorcorrelation_ee_qq():
fds = [fml.diagrams[0]]
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 (
(cc / born)
.simplify()
.equals(sympy.parse_expr("Cf*colorcorrelation(Mom_p3,Mom_p4)"))
)

assert_colorcorrelation(cc / born, fds, fm)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def test_colorcorrelation_qq_photon_qq():
assert (
(cc / born)
.simplify()
.equals("Cf*(colorcorrelation(p1, p2) + colorcorrelation(p3, p4))")
.equals(
"Cf*(colorcorrelation(Mom_p1, Mom_p2) + colorcorrelation(Mom_p3, Mom_p4))"
)
)

assert_colorcorrelation(cc / born, fds, fm)
Expand Down Expand Up @@ -68,7 +70,7 @@ 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(Mom_p1, Mom_p2) + Cf*colorcorrelation(Mom_p3, Mom_p4) - Nc*colorcorrelation(Mom_p1, Mom_p2)/2 + Nc*colorcorrelation(Mom_p1, Mom_p3)/4 + Nc*colorcorrelation(Mom_p1, Mom_p4)/4 + Nc*colorcorrelation(Mom_p2, Mom_p3)/4 + Nc*colorcorrelation(Mom_p2, Mom_p4)/4 - Nc*colorcorrelation(Mom_p3, Mom_p4)/2 + Nc**2*colorcorrelation(Mom_p1, Mom_p3)/(8*Cf) - Nc**2*colorcorrelation(Mom_p1, Mom_p4)/(8*Cf) - Nc**2*colorcorrelation(Mom_p2, Mom_p3)/(8*Cf) + Nc**2*colorcorrelation(Mom_p2, Mom_p4)/(8*Cf) - 5*colorcorrelation(Mom_p1, Mom_p3)/(8*Cf) + 5*colorcorrelation(Mom_p1, Mom_p4)/(8*Cf) + 5*colorcorrelation(Mom_p2, Mom_p3)/(8*Cf) - 5*colorcorrelation(Mom_p2, Mom_p4)/(8*Cf) + colorcorrelation(Mom_p1, Mom_p3)/(2*Cf*Nc**2) - colorcorrelation(Mom_p1, Mom_p4)/(2*Cf*Nc**2) - colorcorrelation(Mom_p2, Mom_p3)/(2*Cf*Nc**2) + colorcorrelation(Mom_p2, Mom_p4)/(2*Cf*Nc**2)"
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/form/qcd/2_to_2/tree/test_tree_gg_gg.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_gg_gg():
# for fd in fds:
# fd.render(render="ascii")

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(
ret.subs(
{
Expand Down
4 changes: 2 additions & 2 deletions tests/form/qcd/2_to_2/tree/test_tree_prompt_photon.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_prompt_photon():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret.subs({"s": "-u-t", "Nc": 3, "Cf": "4/3", "ee": 1, "G": 1}))

assert res.equals(
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_crossed_prompt_photon():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret.subs({"s": "-u-t", "Nc": 3, "Cf": "4/3"}))

# We have to multiply by two here since
Expand Down
4 changes: 3 additions & 1 deletion tests/form/qcd/2_to_2/tree/test_tree_qcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def test_compton():
# for fd in fds:
# fd.render(render="ascii")

ret = compute_squared(fds, fm, tag=True)
ret = compute_squared(fds, fm, tag=True).subs(
{"ms_s": "s", "ms_t": "t", "ms_u": "u"}
)
res = sympy.simplify(
ret.subs(
{
Expand Down
7 changes: 6 additions & 1 deletion tests/form/qcd/2_to_2/tree/test_tree_qqb_gg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def test_qqb_gg():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm).subs("Nc", "3").subs("Cf", "4/3")
ret = (
compute_squared(fds, fm)
.subs("Nc", "3")
.subs("Cf", "4/3")
.subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
)

g = sympy.Symbol("G")

Expand Down
1 change: 1 addition & 0 deletions tests/form/qcd/2_to_2/tree/test_tree_qqb_qqb.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_form_qqb_qqb_automatic():

ret = (
feynamp.form.compute_squared(fds, fm)
.subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
.subs("Nc", "3")
.subs("Cf", "4/3")
.subs("cA", "3")
Expand Down
2 changes: 1 addition & 1 deletion tests/form/qcd/2_to_3/tree/test_tree_ee_qqg.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_ee_qqg():
fd1, fd2 = np.array(fml.diagrams)[[f.has_pdgid(22) for f in fml.diagrams]]
fds = [fd1, fd2]

ret = compute_squared(fds, fm, tag=False)
ret = compute_squared(fds, fm, tag=False, drop_ms_prefix=True)

# ret.subs("Nc","3").subs("Cf","4/3").subs("s34","-t13-t23-s35").subs("Mass_Me" , 0).simplify()

Expand Down
2 changes: 1 addition & 1 deletion tests/form/qed/2_to_2/test_tree_ee_aa.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_eminus_eminus_to_eminus_eminus():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret.subs({"s": "-t-u+2*Mass_Me**2"}))

Mass_Me, ee, t, u = sympy.symbols("Mass_Me ee t u")
Expand Down
4 changes: 2 additions & 2 deletions tests/form/qed/2_to_2/test_tree_ee_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_eminus_eminus_to_eminus_eminus():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret)

Mass_Me, ee, s, t, u = sympy.symbols("Mass_Me ee s t u")
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_eminus_eplus_to_eminus_eplus():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret)

Mass_Me, ee, s, t, u = sympy.symbols("Mass_Me ee s t u")
Expand Down
4 changes: 2 additions & 2 deletions tests/form/qed/2_to_2/test_tree_qed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_compton():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret.subs({"Mass_Me": 0, "t": "-u-s", "ee": "e"}))

assert res.equals(ref.equation_6_113)
Expand All @@ -54,7 +54,7 @@ def test_emu_emu():
fml = parser.from_string(xml_string, FeynML)
fds = fml.diagrams

ret = compute_squared(fds, fm)
ret = compute_squared(fds, fm).subs({"ms_s": "s", "ms_t": "t", "ms_u": "u"})
res = sympy.simplify(ret.subs({"Mass_Me": 0, "Mass_MM": 0, "ee": "e"}))

assert res.equals(ref.equation_6_30)

0 comments on commit 9303693

Please sign in to comment.