Skip to content

Commit

Permalink
add: PREFACTOR to force 0 return
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed May 28, 2024
1 parent ccfd848 commit d19e998
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 86 deletions.
244 changes: 164 additions & 80 deletions debug/ee->qq_.ipynb

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion feynamp/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def compute_squared(
fds: List[FeynmanDiagram],
fm: FeynModel,
colorcorrelated=False,
spincorrelated=False,
tag=False,
):
assert len(fds) > 0, "No FeynmanDiagrams to compute"
Expand All @@ -45,6 +46,8 @@ def compute_squared(
dims == fd.get_externals_size()
), "All FeynmanDiagrams must have the same external legs"
s2 = amplitude.square_parallel(fds, fm, tag=tag)
# PREFACTOR is used to cancel caluclation by setting it to 0
s2 = f"PREFACTOR*({s2})"
debug(f"{s2=}")

s2 = apply_color_parallel(
Expand All @@ -58,7 +61,7 @@ def compute_squared(
# fs += get_onshell(fds, fm)
# fs += get_mandelstamm(fds, fm)
# This is where it gets expensive
fs += get_polarisation_sums(fds, fm)
fs += get_polarisation_sums(fds, fm, spincorrelated=spincorrelated)
fs += get_kinematics()
fs += get_onshell(fds, fm)
fs += get_gammas(fds, fm)
Expand All @@ -79,6 +82,7 @@ def compute_squared(
ret = sympy.parse_expr(
rr.replace("Mom_", "")
.replace(".", "_")
.replace("PREFACTOR", "1")
.replace("^", "**")
.replace("mss", "s")
.replace("msu", "u")
Expand Down
5 changes: 4 additions & 1 deletion feynamp/form/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ 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]}+"
if left == "" or right == "":
# Nothing to color correlate => abort/return 0
return "id PREFACTOR = 0;"
# The minus sign below is from https://arxiv.org/pdf/1002.2581 Eq. 2.6
ret = f"""
id {left[:-1]} = -({right[:-1]});
"""
print(ret)
# print(ret)
return ret


Expand Down
2 changes: 1 addition & 1 deletion feynamp/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
dummy = 0
# TODO auto generate symbols
init = """
Symbols Pi,G,ZERO,Tr,Nc,Cf,CA,MC,ee,realpart;
Symbols Pi,G,ZERO,Tr,Nc,Cf,CA,MC,ee,realpart,PREFACTOR;
AutoDeclare Index Mu,Spin,Pol,Propagator;
AutoDeclare Symbol Mass,fd,mss,mst,msu;
AutoDeclare Vector Mom;
Expand Down
43 changes: 40 additions & 3 deletions feynamp/form/lorentz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from feynmodel.feyn_model import FeynModel

from feynamp.form.form import get_dummy_index, init, run, string_to_form
from feynamp.leg import find_leg_in_model
from feynamp.leg import find_leg_in_model, get_leg_momentum, is_vector
from feynamp.log import debug
from feynamp.momentum import insert_mass, insert_momentum
from feynamp.util import is_mass_zero
Expand Down Expand Up @@ -137,12 +137,49 @@ def get_orthogonal_polarisation_momentum(
raise ValueError("No orthogonal momentum found")


def get_polarisation_sums(fds: List[FeynmanDiagram], model: FeynModel):
pol_sums = """
def get_polarisation_sums(
fds: List[FeynmanDiagram], model: FeynModel, spincorrelated=False
):
pol_sums = ""
if spincorrelated:
legs = fds[0].legs
left = ""
right = ""
mom = []
ind1 = []
ind2 = []
isvec = []
for i, leg in enumerate(legs):
mom += [get_leg_momentum(leg)]
ind1 += [f"Pol{leg.id}"]
ind2 += [f"Pol{get_dummy_index(underscore=False, questionmark=False)}"]
isvec += [is_vector(fds[0], leg, model)]
for i, legi in enumerate(legs):
if isvec[i]:
mom = mom[i]
i1 = ind1[i]
i2 = ind2[i]
left += f"VPol({i1},{mom})*VPol({i2},{mom})*"
deltas = "*"
for k in range(len(legs)):
if isvec[k] and k != i and k != j:
deltas += f"d_({ind1[k]},{ind2[k]})*"
right += f"\nspincorrelation({mom[i]},MuMu,MuNu)*epsstar(MuMu,{i1},{mom})*eps(MuNu,{i2},{mom}){deltas[:-1]}+"
if right == "" or left == "":
# There is nothing to correlate => force the result to be 0
pol_sums += "id PREFACTOR = 0;"
else:
pol_sums += f"""
id {left} = ({right});
"""
print(f"{pol_sums=}")
else:
pol_sums += """
repeat;
id VPol(Polb?,Moma?) * VPol(Pold?,Moma?) = d_(Polb,Pold);
endrepeat;
"""

# TODO might want to loop over all fds?
for fd in [fds[0]]:
for l in fd.legs:
Expand Down
8 changes: 8 additions & 0 deletions feynamp/leg.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def get_color_vector(fd, leg, model):
return None


def is_vector(fd, leg, model):
"""
This is used to determine if a leg gets a spin correlation or not.
"""
p = find_leg_in_model(fd, leg, model)
return p.spin == 3


def get_leg_math(fd, leg, model): # epsilons or u/v optionally also barred
p = find_leg_in_model(fd, leg, model)
mom = get_leg_momentum(leg)
Expand Down

0 comments on commit d19e998

Please sign in to comment.