Package aloha :: Module aloha_fct
[hide private]
[frames] | no frames]

Source Code for Module aloha.aloha_fct

  1  ################################################################################ 
  2  # 
  3  # Copyright (c) 2012 The ALOHA Development team and Contributors 
  4  # 
  5  # This file is a part of the ALOHA project, an application which  
  6  # automatically generates HELAS ROUTINES 
  7  # 
  8  # It is subject to the ALOHA license which should accompany this  
  9  # distribution. 
 10  # 
 11  # 
 12  ################################################################################ 
 13  from aloha.aloha_object import * 
 14  import cmath 
 15   
16 -class WrongFermionFlow(Exception):
17 pass
18 19 ################################################################################ 20 ## CHECK FLOW VALIDITY OF A LORENTZ STRUCTURE 21 ################################################################################
22 -def check_flow_validity(expression, nb_fermion):
23 """Check that the fermion flow follows the UFO convention 24 1) Only one flow is defined and is 1 -> 2, 3 -> 4, ... 25 2) that 1/3/... are on the left side of any Gamma matrices 26 """ 27 28 assert nb_fermion != 0 and (nb_fermion % 2) == 0 29 30 # Need to expand the expression in order to have a simple sum of expression 31 expr = eval(expression) 32 expr = expr.simplify() 33 #expr is now a valid AddVariable object if they are a sum or 34 if expr.vartype != 1: # not AddVariable 35 expr = [expr] # put in a list to allow comparison 36 37 for term in expr: 38 if term.vartype == 0: # Single object 39 if not term.spin_ind in [[1,2], [2,1]]: 40 raise WrongFermionFlow, 'Fermion should be the first particles of any interactions' 41 if isinstance(term, (Gamma, Gamma5, Sigma)): 42 if not term.spin_ind == [2,1]: 43 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow' 44 45 elif term.vartype == 2: # product of object 46 link, rlink = {}, {} 47 for obj in term: 48 if not obj.spin_ind: 49 continue 50 ind1, ind2 = obj.spin_ind 51 if isinstance(obj, (Gamma, Sigma)): 52 if (ind1 in range(1, nb_fermion+1) and ind1 % 2 == 1) or \ 53 (ind2 in range(2, nb_fermion+1) and ind2 % 2 == 0 ): 54 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow' 55 if ind1 not in link.keys(): 56 link[ind1] = ind2 57 else: 58 rlink[ind1] = ind2 59 if ind2 not in link.keys(): 60 link[ind2] = ind1 61 else: 62 rlink[ind2] = ind1 63 for i in range(1, nb_fermion,2): 64 old = [] 65 pos = i 66 while 1: 67 old.append(pos) 68 if pos in link.keys() and link[pos] not in old: 69 pos = link[pos] 70 elif pos in rlink.keys() and rlink[pos] not in old: 71 pos = rlink[pos] 72 elif pos != i+1: 73 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow' 74 elif pos == i+1: 75 break
76
77 -def guess_routine_from_name(names):
78 """ return (UFO name, tag , offshell) from a given name """ 79 80 output =[] 81 for name in names: 82 data = name.split('_') 83 if len(data) == 2: 84 main, offshell = data 85 multiple = [] 86 else: 87 main, multiple, offshell = data[0], data[1:-1],data[-1] 88 89 # search for tag allow tag [L, C$] 90 allow_tag = ['C1','C2','C3','C4','C5','C6','C7'] 91 tags = [] 92 len_tag = -1 93 while len(tags) != len_tag: 94 len_tag = len(tags) 95 for tag in allow_tag: 96 if main.endswith(tag): 97 main = main[:-len(tag)] 98 tags.append(int(tag[1:])) 99 break 100 101 # create the correct lorentz 102 lorentz = [main] 103 if multiple: 104 base = main 105 while base[-1].isdigit(): 106 base = base[:-1] 107 for nb in multiple: 108 lorentz.append('%s%s' % (base, nb)) 109 110 # add in the results 111 output.append((tuple(lorentz), tuple(tags), int(offshell))) 112 return output
113