Automatic index contraction
General
It is usually not necessary to define any index structure for terms appearing in the (Super)potential. This task is automatically performed by SARAH: it adds generation indices if necessary to all fields and parameters and contracts all charges using
 the Kronecker delta (
Delta
)  the antisymmetric tensor (
epsTensor
)  ClebschGordan Coefficients (
CGC
).
Simple contractions
The rules to contract indices corresponding to the fundamental (upper) and antifundamental (lower) representation of a gauge group are:
 an upper and a lower index is contracted via a Kronecker Delta
 N upper or lower indices of a SU(N) are contracted with the epsilon Tensor
Verifying Index Contractions
If one is unsure about how indices are contracted you can check the output of the function MakeIndexStructure
which is internally used. Example after loading the THDMII model:
In[1]: MakeIndexStructure[{H2, u, q}]
Out[1]: Delta[col2, col3] epsTensor[lef1, lef3]
In[2]: MakeIndexStructure[{conj[H1], d, q}]
Out[2]: Delta[col2, col3] Delta[lef1, lef3]
In case of a supersymmetric model one can view the contrations of all superfields in the superpotential using:
ShowSuperpotentialContractions;
after loading the model.
Example

3 \times \bar{3}
of SU(3):Delta[col1,col2] T[{col1}].Tc[{col2}]

2\times 2
of SU(2):epsTensor[lef1,lef2] Hu[{lef1}].Hd[{lef2}]

3\times 3 \times 3
of SU(3):epsTensor[col1,col2,col3] T[{col1}].T[{col2}].T[{col3}]

2\times 3\times 2
of SU(2):Delta[lef1,lef2] epsTensor[lef2b,lef3] Hu[{lef1}].T[{lef2,lef2b}].Hu[{lef3}]

3 \times \bar{3}
of SU(3) and2\times 2
of SU(2):Delta[col1,col2] epsTensor[lef1,lef3] Q[{lef1,col1}].u[{col2}].Hu[{lef3}]
ClebschGordan Coefficients
The CGCs which are used for interactions involving higher dimensional irreps are parametrized as follows:
CG[group,dnykin][indices]
First, the gauge group is given, afterwards the Dynkin labels of all involved irreps are stated and finally the indices are listed. For instance, the interaction between a scalar color sextet (Oc) and two fermionic triplets which appear in several generations (t
) is defined in the input by the user just as
Example
Ys Oc.t.t
and internally expanded by SARAH to
Ys[gen2,gen3]*CG[SU[3],{{0,2},{1,0},{1,0}}][col1,col2,co3]*Oc[{col1}]*t[{gen2,col2}]*t[{gen3,col3}]
The numerical values for all CGCs are calculated by Susyno.
Selfdefined contractions
Contractions for Lagrangian
In principle, it is also possible that the user can define a contraction of indices which is not the standard one. In particular for the S**U(2) it might be necessary to adjust the index contraction: there is some ambiguity because of the relation among the fundamental and antifundamental representation in this group. One can see that SARAH used contractions via

ShowSuperpotentialContractions
for SUSY models 
SA`LagrangianContractions
for nonSUSY models
Example

2 \times 3 \times 2
of SU(2): depending of the definition of the triplett
the demanded contraction might beepsTensor[lef1,lef2] epsTensor[lef2b,lef3] l[{lef1}].t[{lef2,lef2b}].l[{lef3}]
The default contraction of SARAH would have been instead
epsTensor[lef1,lef2] Delta[lef2b,lef3] l[{lef1}].t[{lef2,lef2b}].l[{lef3}]
Note, the indices for the fields are shown only for clarity here. When writing the contractions in the SARAH model file, it is not necessary to write the indices of the fields. These are generated automatically by SARAH. Thus, the correct syntax which shall be used in the model file is as follows
epsTensor[lef1,lef2] epsTensor[lef2b,lef3] l.t.l

H_u^\dagger \sigma_a H_u + H_d^\dagger \sigma_a H_d^2
can be written by using the completeness relation of the Pauli matrices as(2 Delta[lef1,lef4] Delta[lef2,lef3] Delta[lef1,lef2] Delta[lef3,lef4])* (conj[SHd].SHd.SHd.conj[SHd] + conj[SHu].SHu.SHu.conj[SHu]  2 conj[SHd].SHd.SHu.conj[SHu]) )
Contractions for RGEs
SARAH calculates the RGEs for the unbroken gauge groups. Therefore, it assumes that nonfundamental irreps not written as tensor product as this is the case for broken groups, but of vectors of appropriate length. Because of that, it has to recalculate the contractions internally, and makes use of routines of Susyno of that. However, Susyno returns the contractions with an arbitrary phase which can even change from Mathematica version to Mathematica version, i.e. this can sometimes by rather randomly. If you encounter such a problem, it's best to make use of the option to fix the contractions in the model. That's done via
ContractionRGE[COUPLING]=CONTRACTION
where COUPLING
is the name of the coupling for which you want to 'hardcode' the contraction and CONTRACTION
is the given contraction.
Example

Four triplet interaction: for 1/2 LT trip.trip.trip.trip
one can define as contraction used in the RGEs
ContractionRGE[LT]=Delta[lef1,lef2] Delta[lef3, lef4];

Tripletdoublet interaction: Writing the interaction between to scalar doublets
H
and a scalar tripletTs
asmuT conj[H].Ts.H
One can define an explicit contraction via
ContractionRGE[muT]=InvMat[99][lef1,lef2,lef3]; Off[Part::pspec]; InvMat[99][a___Integer]:={{{1/Sqrt[2], 0}, {0, 1/Sqrt[2]}, {0, (I/Sqrt[2])}}, {{0, (1/Sqrt[2])}, {1/Sqrt[2], 0}, {I/Sqrt[2], 0}}}[[/aa]]; On[Part::pspec];