(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* The package `REAP' is written for Mathematica 7 and is distributed under the
terms of GNU Public License http://www.gnu.org/copyleft/gpl.html *)


BeginPackage[
  "REAP`RGEMSSMsoftbrokenProton`",
  {
    "REAP`RGESymbol`", "REAP`RGESolver`","REAP`RGEUtilities`", "REAP`RGEParameters`","REAP`RGEInitial`",
    "MixingParameterTools`MPT3x3`","REAP`SusyTCProton`",
    (* transitions to these models are possible: *)
    "REAP`RGESM`", "REAP`RGESM0N`",
    "REAP`RGE2HDM`", "REAP`RGE2HDM0N`"
  }
];

ClearAll[STCversion]; STCversion="1.2"; Protect[STCversion];

Print["\n Loading RGEMSSMsoftbrokenProton version ",STCversion];

(* First reserve some additional symbols used in this model *) 
BeginPackage["REAP`RGESymbol`"];

ClearAll[STCsign\[Mu]]; STCsign\[Mu]; Protect[STCsign\[Mu]];

ClearAll[STCcMSSM]; STCcMSSM; Protect[STCcMSSM];

ClearAll[STCSusyScale]; STCSusyScale; Protect[STCSusyScale];
ClearAll[STCSusyScaleFromStops]; STCSusyScaleFromStops; Protect[STCSusyScaleFromStops];

ClearAll[STCCCBConstraints]; STCCCBConstraints; Protect[STCCCBConstraints];
ClearAll[STCUFBConstraints]; STCUFBConstraints; Protect[STCUFBConstraints];
ClearAll[STCTachyonConstraints]; STCTachyonConstraints; Protect[STCTachyonConstraints];

ClearAll[STCOnlyTan\[Beta]TC]; STCOnlyTan\[Beta]TC; Protect[STCOnlyTan\[Beta]TC];

ClearAll[RGEA0]; RGEA0; Protect[RGEA0];
ClearAll[RGEM12]; RGEM12; Protect[RGEM12];
ClearAll[RGEm0]; RGEm0; Protect[RGEm0];

ClearAll[RGEM1]; RGEM1; Protect[RGEM1];
ClearAll[RGEM2]; RGEM2; Protect[RGEM2];
ClearAll[RGEM3]; RGEM3; Protect[RGEM3];

ClearAll[RGETd]; RGETd; Protect[RGETd];
ClearAll[RGETe]; RGETe; Protect[RGETe];
ClearAll[RGETu]; RGETu; Protect[RGETu];
ClearAll[RGET\[Nu]]; RGET\[Nu]; Protect[RGET\[Nu]];

ClearAll[RGEm2Q]; RGEm2Q; Protect[RGEm2Q];
ClearAll[RGEm2L]; RGEm2L; Protect[RGEm2L];
ClearAll[RGEm2u]; RGEm2u; Protect[RGEm2u];
ClearAll[RGEm2d]; RGEm2d; Protect[RGEm2d];
ClearAll[RGEm2e]; RGEm2e; Protect[RGEm2e];
ClearAll[RGEm2\[Nu]]; RGEm2\[Nu]; Protect[RGEm2\[Nu]];
ClearAll[RGEm2Hd]; RGEm2Hd; Protect[RGEm2Hd];
ClearAll[RGEm2Hu]; RGEm2Hu; Protect[RGEm2Hu];
ClearAll[RGECL5qlqq]; RGECL5qlqq; Protect[RGECL5qlqq];
ClearAll[RGECR5udeu]; RGECR5udeu; Protect[RGECR5udeu];


ClearAll[STCGetSusyScale];
STCGetSusyScale::usage="STCGetSUSYScale[] returns the SUSY breaking scale Q.";

ClearAll[STCGetSusySpectrum]; STCGetSusySpectrum::usage="STCGetSUSYSpectrum[] returns a list of replacement rules for the SUSY breaking scale Q, the tree-level \!\(\*OverscriptBox[\(DR\), \(_\)]\) value of \[Mu], and the \!\(\*OverscriptBox[\(DR\), \(_\)]\) soft-breaking masses m3, M1, M2, M3, Mh, MH, MA, MHp, m\[Chi]0, m\[Chi]p, \!\(ms\_(u,d,e)\), \!\(ms\_\[Nu]\), \[Theta]W, tan\[Alpha], the neutralino mixing matrix N, the chargino mixing matrices U, V and the sfermion mixing matrices \!\(W\_(u,d,e)\), \!\(W\_\[Nu]\). The mixing matrices are defined by:

     \!\(M\_\[Chi]0\) = \!\(N\^T\) \!\(M\^\(diag\)\) N		\!\(M\_\[Chi]p\) = \!\(U\^T\) \!\(M\^\(diag\)\) V		\!\(M\_f\) = \!\(W\_f\) \!\(M\^\(diag\)\) \!\(W\_f\^\[Dagger]\)
";

ClearAll[STCGetOneLoopValues]; STCGetOneLoopValues::usage="STCGetOneLoopValues[] returns the one-loop \!\(\*OverscriptBox[\(DR\), \(_\)]\) parameter \[Mu], the one-loop \!\(\*OverscriptBox[\(DR\), \(_\)]\) soft-breaking mass m3, and the one-loop \!\(\*OverscriptBox[\(DR\), \(_\)]\) vev at the SUSY breaking scale Q, as well as the pole-mass MHp (MA) of the charged (CP-odd) Higgs boson for STCcMSSM == True (False).";

ClearAll[STCGetSCKMValues]; STCGetSCKMValues::usage="STCGetSCKMValues[] returns the sfermion soft-breaking mass squared matrices, the trilinear coupling matrices, Yukawa couplings in the SCKM basis with SLHA2 conventions!";

ClearAll[STCGetInternalValues]; STCGetInternalValues::usage="STCGetInternalValues[] returns everything used internally for the Threshold calculation, i.e. \!\(\*OverscriptBox[\(DR\), \(_\)]\) soft-breaking mass matrices, Yukawa, trilinear and gauge couplings, tree-level SUSY Spectrum except charged (CP-odd) Higgs mass, pole masses of charged (CP-odd) Higgs mass, mixing matrices, and the one-loop \!\(\*OverscriptBox[\(DR\), \(_\)]\) parameter \[Mu] with STCcMSSM == True (False).\n Users should utilize STCGetSUSYSpectrum[] and STCGetOneLoopValues[] instead!";

ClearAll[STCGetCKMMatrix];
STCGetCKMMatrix::usage="STCGetCKMMxtrix[] returns the CKM Matrix.";

ClearAll[STCGetPMNSMatrix];
STCGetPMNSMatrix::usage="STCGetPMNSMxtrix[] returns the PMNS Matrix.";

ClearAll[STCWriteSLHA2Output];
STCWriteSLHA2Output::usage="STCWriteSLHA2Output[\"Path\"] writes an SLHA2 output file at \"Path\".";

ClearAll[STCSLHA2Import];
STCSLHA2Import::usage="STCSLHA2Import[\"Path\"] loads a Les Houches input file from \"Path\" and executes SusyTCProton.";

ClearAll[STCGetProtonDecayOperators];
STCGetProtonDecayOperators::usage="Get the proton decay operators as replacement rules";

ClearAll[STCTest];
STCTest::usage="Testing function";

ClearAll[STCSearchSMTransition]; STCSearchSMTransition; Protect[STCSearchSMTransition];

ClearAll[RGEForce1Loop]; RGEForce1Loop; Protect[RGEForce1Loop];

EndPackage[];

(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! package depends on RGESM.m !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
(* dependencies are marked by !!! in the file *)


(* register MSSMsoftbroken *)
(* Note that model name has to match file name! *)
RGERegisterModel["MSSMsoftbrokenProton","REAP`RGEMSSMsoftbrokenProton`",
    `Private`GetParameters,
    `Private`SolveModel,
    {
    RGEg1->`Private`Getg1,
    RGEg2->`Private`Getg2,
    RGEg3->`Private`Getg3,
    RGE\[Epsilon]1Max->`Private`Get\[Epsilon]1Max,
    RGERawM\[Nu]r->`Private`GetRawM\[Nu]r,
    RGEYd->`Private`GetYd,
    RGEM\[Nu]->`Private`GetM\[Nu],
    RGE\[Epsilon]1->`Private`Get\[Epsilon]1,
    RGEMu->`Private`GetMu,
    RGECoupling->`Private`GetCoupling,
    RGEMixingParameters->`Private`GetMixingParameters,
    RGERawY\[Nu]->`Private`GetRawY\[Nu],
    RGEM\[Nu]r->`Private`GetM\[Nu]r,
    RGEMd->`Private`GetMd,
    RGEYu->`Private`GetYu,
    RGE\[Kappa]->`Private`Get\[Kappa],
    RGE\[Alpha]->`Private`Get\[Alpha],
    RGEPoleMTop->`Private`GetPoleMTop,
    RGEM1Tilde->`Private`GetM1Tilde,
    RGEAll->`Private`GetSolution,
    RGEMe->`Private`GetMe,
    RGETwistingParameters->`Private`GetTwistingParameters,
    RGERaw->`Private`GetRawSolution,
    RGEY\[Nu]->`Private`GetY\[Nu],
    RGEYe->`Private`GetYe,
    (* Softbreaking parameters, 21.5.2015 *)
    RGETd->`Private`GetTd,
    RGETu->`Private`GetTu,
    RGETe->`Private`GetTe,
    RGET\[Nu]->`Private`GetT\[Nu],
    RGERawT\[Nu]->`Private`GetRawT\[Nu],
    RGEM1->`Private`GetM1,
    RGEM2->`Private`GetM2,
    RGEM3->`Private`GetM3,
    RGEm2Q->`Private`Getm2Q,
    RGEm2L->`Private`Getm2L,
    RGEm2u->`Private`Getm2u,
    RGEm2d->`Private`Getm2d,
    RGEm2e->`Private`Getm2e,
    RGEm2\[Nu]->`Private`Getm2\[Nu],
    RGEm2Hd->`Private`Getm2Hd,
    RGEm2Hu->`Private`Getm2Hu,
    RGECL5qlqq->`Private`GetCL5qlqq,
    RGECR5udeu->`Private`GetCR5udeu
    },
    {
      (*{"SM",`Private`TransSM},*)
      {"SM0N",`Private`TransSM0N},
      {"2HDM0N",`Private`Trans2HDM0N},
      (*{"2HDM",`Private`Trans2HDM},*)
      {"MSSMsoftbrokenProton",`Private`TransMSSMsoftbroken}
    },
    `Private`GetInitial,
    `Private`ModelSetOptions,
    `Private`ModelGetOptions
];


Begin["`Private`"];
Map[Needs,{
    "REAP`RGESymbol`","REAP`RGESolver`","REAP`RGEUtilities`", "REAP`RGEParameters`","REAP`RGEInitial`",
    "MixingParameterTools`MPT3x3`", "REAP`SusyTCProton`",
    "REAP`RGESM`","REAP`RGESM0N`","REAP`RGE2HDM`","REAP`RGE2HDM0N`"}
];

(* definitions for the Minimal Supersymmetric Standard Model (MSSM) *)

ClearAll[RGEOptions];
RGEOptions;
Options[RGEOptions]={
    RGEModelVariant->"1Loop", (* loop level of the used RGE equations *)
    RGEForce1Loop -> {},
    RGEAutoGenerated->False, (* used to find automatically generated entries *)
    RGEPrecision->6, (* precision to find transitions *)
    RGEMaxNumberIterations->20, (* maximum number of iterations in the loops to search transitions *)
    RGEvEW->246, (* vev of the SM Higgs *)
    RGEtan\[Beta]->50, (* tan \[Beta]=vu/vd *)  
    STCsign\[Mu]->1, (* sign of \[Mu] *)
    STCcMSSM->True,
    STCSusyScale->"Automatic",
    STCSusyScaleFromStops->True,
    STCCCBConstraints->True,
    STCUFBConstraints->True,
    STCTachyonConstraints->False,
    STCOnlyTan\[Beta]TC->False,
    RGEIntegratedOut->0, (* number of the integrated out neutrinos *)
    Method->StiffnessSwitching, (* option of NDSolve *)
    RGESearchTransition->True, (* enables/disables the automatic search for transitions *)
    STCSearchSMTransition->True, (* enables/disables the automatic search for transitions *)
    RGEThresholdFactor->1 (* neutrinos are integrated out at RGEThresholdFactor*Mass *)
}; (* options of the model *)

ModelName="MSSMsoftbrokenProton";
ModelVariants={"1Loop", "1Loop0N", "2Loop", "2Loop0N"};
gSUSYScale = None;
gSUSYSpectrum = None;
gSCKMvalues = None;
gOneLoopValues = None;
ginternalValues = None;
gVCKM = None;
gVPMNS = None;
gProtonDecayOperators = None;

MakeList[f_List] := f
MakeList[f_] := {f}
RGE[Force1Loop_, idx_] := RGE[Force1Loop, idx] = Switch[
  (* Use switch instead of list to not evaluate 2-loop stuff unnecessarily *)
  idx,
  1, RGE1LoopProton  [MakeList@ Force1Loop],
  2, RGE1Loop0NProton[MakeList@ Force1Loop],
  3, RGE2LoopProton  [MakeList@ Force1Loop],
  4, RGE2Loop0NProton[MakeList@ Force1Loop]
];




STCGetSusyScale[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
      Return[None];
    ];
    Return[gSUSYScale];
];

STCGetSusySpectrum[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
      Return[None];
    ];
    Return[gSUSYSpectrum];
];

STCGetSCKMValues[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
      Return[None];
    ];
    Return[gSCKMValues];
];

STCGetOneLoopValues[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
      Return[None];
    ];
    Return[gOneLoopValues];
];

STCGetInternalValues[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
      Return[None];
    ];
    Return[ginternalValues];
];

STCGetCKMMatrix[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
	Return[None];
    ];
    Return[gVCKM];
];

STCGetPMNSMatrix[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
	Return[None];
    ];
    Return[gPMNS];
];

STCGetProtonDecayOperators[]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
	Return[None];
    ];
    Return[gProtonDecayOperators];
];

(*
STCTest[]:=Block[{defaultOptions,newOptions,variant},
	Return[1];
];
*)



(*SLHA input*)

GetBlock[outputfile_, $Blockname_] := Block[{stringstart, stringend, tempstring, blockout, 
   Blockname = ToUpperCase[$Blockname]},
   If[DeleteDuplicates[StringPosition[outputfile, Blockname]] == {}, Return[{}]];
   stringstart = StringPosition[outputfile, Blockname][[1, 1]];
   tempstring = StringPosition[outputfile, "BLOCK"];
   If[tempstring[[-1, 1]] != stringstart,
    stringend = tempstring[[
      Position[tempstring, Select[tempstring, #[[1]] == stringstart &][[1]]][[1,1]] + 1, 1
      ]] - 2,
    stringend = StringLength[outputfile] - 1
   ];
   blockout = StringTake[outputfile, {stringstart, stringend}]
];

RemoveComments[outputfile_, Blockname_] := Block[{block = StringTrim[GetBlock[outputfile, Blockname]], 
   blockout = "", stringstart, stringend, L, ni = 1},
   If[block == {}, Return[{}]];
   stringstart = StringPosition[block, "#"]//Flatten//DeleteDuplicates;
   stringend = Join[StringPosition[block, "\n"]//Flatten//DeleteDuplicates, {StringLength[block] + 1}];
   L = Length[stringend];
   While[L > 0,
     If[stringstart == {}, Break[]];
     While[stringstart[[-1]] < If[Length[stringend] > 1, stringend[[-2]], 1], 
       stringend = Drop[stringend, -1]
     ];
     block = StringDrop[block, {stringstart[[-1]], stringend[[-1]] - 1}];
     stringstart = Drop[stringstart, -1];
     stringend = Drop[stringend, -1];
     L--;
     ni++
     (*If[ni == 1000, Break[]]*)
   ];
   block
];

ToNumber[string_] := Block[{Epos, mantissa, exponent, stringtemp = StringTrim[string]},
   If[StringFreeQ[string, "E"],
     If[StringFreeQ[string, "NaN"],
       Return[ToExpression[string]],
       (*else*)
       Return[Indeterminate]
     ],
     (*else*)
     Epos = StringPosition[stringtemp, "E"][[1, 1]];
     mantissa = ToExpression[StringTake[stringtemp, Epos - 1]];
     exponent = ToExpression[StringTake[stringtemp, -(StringLength[stringtemp] - Epos)]];
     If[mantissa != 0, 
       Return[SetPrecision[mantissa*10^exponent, Epos - 2]], 
       Return[0.]
     ]
   ]
];

GetValues[outputfile_, Blockname_] := Block[{block = RemoveComments[outputfile, Blockname], values, 
   stringstart, stringend, ni = 2, tempstring},
   If[block == {}, Return[{}]];
   stringend = Join[StringPosition[block, "\n"]//Flatten//DeleteDuplicates, {StringLength[block] + 1}];
   values = Reap[
     While[ni <= Length[stringend],
       tempstring = StringTrim[StringTake[block, {stringend[[ni - 1]] + 1, stringend[[ni]] - 1}]];
       Sow[Rule[
         ToNumber[StringTake[tempstring, 3]], 
         ToNumber[StringTake[tempstring, -StringLength[tempstring] + 3]]+0.0
       ]]; 
       ni++
     ]
   ][[2, 1]];
   Return[values]
];

GetSwitches[outputfile_, Blockname_] := Block[{block = RemoveComments[outputfile, Blockname], switch, 
   stringstart, stringend, ni = 1},
   If[block == {}, Return[{}]];
   stringend = Join[StringPosition[block, "\n"]//Flatten//DeleteDuplicates, {StringLength[block] + 1}];
   stringstart = Complement[
     Range[StringLength[block]],
     Join[StringPosition[block, " "]//Flatten//DeleteDuplicates,stringend]
   ];
   switch = Reap[
     While[ni <= Length[stringend] - 1,
       While[stringend[[ni]] > stringstart[[1]], 
         stringstart = Drop[stringstart, 1]
       ];
       Sow[Rule[
         ToExpression[StringTake[block, {stringstart[[1]]}]], 
         ToExpression[StringTake[block, {stringstart[[2]]}]]
       ]];
       stringstart = Drop[stringstart, 2];
       ni++
     ]
   ][[2, 1]];
   Return[switch]
];

GetMatrix[outputfile_, Blockname_] := Block[{block = RemoveComments[outputfile, Blockname], matrix, 
   stringstart, stringend, ni = 1},
   If[block == {}, Return[{}]];
   stringend = Join[StringPosition[block, "\n"]//Flatten//DeleteDuplicates, {StringLength[block] + 1}];
   stringstart = Complement[
     Range[StringLength[block]], 
     Join[StringPosition[block, " "]//Flatten//DeleteDuplicates, stringend]
   ];
   matrix = Reap[
     While[ni <= Length[stringend] - 1,
       While[stringend[[ni]] > stringstart[[1]], 
         stringstart = Drop[stringstart, 1]
       ];
       Sow[{
         ToExpression[StringTake[block, {stringstart[[1]]}]], 
         ToExpression[StringTake[block, {stringstart[[2]]}]], 
         ToNumber[StringTake[block, {stringstart[[3]], stringend[[ni + 1]] - 1}]]
       }];
       stringstart = Drop[stringstart, 2];
       ni++
     ]
   ][[2, 1]];
   Return[matrix]
];

CreateMatrix[input_, blockname_] := Block[{values = GetMatrix[input, blockname], mentry, ni = 1, L, 
   dim = {0, 0}},
   If[values == {}, Return[0]];
   L = Length[values];
   dim[[1]] = Max[values[[All, 1]]];
   dim[[2]] = Max[values[[All, 2]]];
   mentry = ConstantArray[0, dim];
   Do[
     mentry[[values[[ni, 1]], values[[ni, 2]]]] = values[[ni, 3]],
   {ni, L}];
   Return[mentry]
];

CreateHRMatrix[input_, blockname_] := Block[{values = GetMatrix[input, blockname], mentry, ni = 1, L, 
   dim = {0, 0}},
   If[values == {}, Return[0]];
   L = Length[values];
   dim = Max[Max[values[[All, 1]]], Max[values[[All, 2]]]];
   mentry = ConstantArray[0., {dim, dim}];
   Do[
     If[values[[ni, 1]] <= values[[ni, 2]],
       mentry[[values[[ni, 1]], values[[ni, 2]]]] = values[[ni, 3]];
       mentry[[values[[ni, 2]], values[[ni, 1]]]] = values[[ni, 3]]
     ],
   {ni, L}];
   Return[mentry]
];

CreateHIMatrix[input_, blockname_] := Block[{values = GetMatrix[input, blockname], mentry, ni = 1, L, 
   dim},
   If[values == {}, Return[0]];
   L = Length[values];
   dim = Max[Max[values[[All, 1]]], Max[values[[All, 2]]]];
   mentry = ConstantArray[0., {dim, dim}];
   Do[
     If[values[[ni, 1]] < values[[ni, 2]],
       mentry[[values[[ni, 1]], values[[ni, 2]]]] = values[[ni, 3]];
       mentry[[values[[ni, 2]], values[[ni, 1]]]] = (-1)*values[[ni, 3]]
     ],
   {ni, L}];
   Return[mentry]
];


SLHAInput[input_] := Block[{
   modsel = GetSwitches[input, "Block MODSEL"],
   minpar = GetValues[input, "Block Minpar"],
   imminpar = GetValues[input, "Block IMMinpar"],
   stc = GetSwitches[input, "Block SusyTC"],
   extpar = GetValues[input, "Block EXTPAR"],
   imextpar = GetValues[input, "Block IMEXTPAR"],
   qextpar = GetValues[input, "Block QEXTPAR"],
   gaugeSMnormalized = GetValues[input, "Block GAUGE"], (* SLHA has SM normalization of hypercharge, REAP/SUSYTC uses GUT normalization, which has a coupling bigger b a factor Sqrt[5/3] *)
   gauge,
   GUT, MZ, initialrule, caught, \[Phi],
   Yd = CreateMatrix[input, "Block YD"] + I CreateMatrix[input, "Block IMYD"],
   Yu = CreateMatrix[input, "Block YU"] + I CreateMatrix[input, "Block IMYU"],
   Ye = CreateMatrix[input, "Block YE"] + I CreateMatrix[input, "Block IMYE"],
   Yn = CreateMatrix[input, "Block YN"] + I CreateMatrix[input, "Block IMYN"],
   Mn = CreateHRMatrix[input, "Block MN"] + I CreateHRMatrix[input, "Block IMMN"],
   Td = CreateMatrix[input, "Block TD"] + I CreateMatrix[input, "Block IMTD"],
   Tu = CreateMatrix[input, "Block TU"] + I CreateMatrix[input, "Block IMTU"],
   Te = CreateMatrix[input, "Block TE"] + I CreateMatrix[input, "Block IMTE"],
   Tn = CreateMatrix[input, "Block TN"] + I CreateMatrix[input, "Block IMTN"],
   msq2 = CreateHRMatrix[input, "Block MSQ2"] + I CreateHIMatrix[input, "Block IMMSQ2"],
   msu2 = CreateHRMatrix[input, "Block MSU2"] + I CreateHIMatrix[input, "Block IMMSU2"],
   msd2 = CreateHRMatrix[input, "Block MSD2"] + I CreateHIMatrix[input, "Block IMMSD2"],
   msl2 = CreateHRMatrix[input, "Block MSL2"] + I CreateHIMatrix[input, "Block IMMSL2"],
   mse2 = CreateHRMatrix[input, "Block MSE2"] + I CreateHIMatrix[input, "Block IMMSE2"],
   msn2 = CreateHRMatrix[input, "Block MSN2"] + I CreateHIMatrix[input, "Block IMMSN2"],
   m1, m2, m3 },
   gauge={1->Sqrt[5/3]*(1/.gaugeSMnormalized),2->(2/.gaugeSMnormalized),3->(3/.gaugeSMnormalized)}; (* gauge couplings now with GUT normalization for hypercharge *)
   GUT = If[Not[IntegerQ[(0 /. extpar)]], (0 /. extpar), 2*10^16];
   MZ = If[Not[IntegerQ[(0 /. qextpar)]], (0 /. qextpar), 91.1876];
   m1 = If[Not[IntegerQ[(1 /. extpar)]], (1 /. extpar), 0] + 
        If[Not[IntegerQ[(1 /. imextpar)]], I (1 /. imextpar), 0];
   m2 = If[Not[IntegerQ[(2 /. extpar)]], (2 /. extpar), 0] + 
        If[Not[IntegerQ[(2 /. imextpar)]], I (2 /. imextpar), 0];
   m3 = If[Not[IntegerQ[(3 /. extpar)]], (3 /. extpar), 0] + 
        If[Not[IntegerQ[(3 /. imextpar)]], I (3 /. imextpar), 0];
  RGEReset[];
  RGEAdd["MSSMsoftbrokenProton"];
  initialrule = Reap[
     If[Not[IntegerQ[(1 /. minpar)]], Sow[RGEm0 -> (1 /. minpar)]];
     If[Not[IntegerQ[(2 /. minpar)]], Sow[RGEM12 -> (2 /. minpar)]];
     If[Not[IntegerQ[(5 /. minpar)]], Sow[RGEA0 -> (5 /. minpar)]];
     If[Not[IntegerQ[m1]], Sow[RGEM1 -> m1]];
     If[Not[IntegerQ[m2]], Sow[RGEM2 -> m2]];
     If[Not[IntegerQ[m3]], Sow[RGEM3 -> m3]];
     If[Not[IntegerQ[(21 /. extpar)]], Sow[RGEm2Hd -> (21 /. extpar)]];
     If[Not[IntegerQ[(22 /. extpar)]], Sow[RGEm2Hu -> (22 /. extpar)]];
     If[Not[IntegerQ[(1 /. gauge)]] && Not[(1/.gauge)==Sqrt[5/3]], Sow[RGEg1 -> (1 /. gauge)]];
     If[Not[IntegerQ[(2 /. gauge)]], Sow[RGEg2 -> (2 /. gauge)]];
     If[Not[IntegerQ[(3 /. gauge)]], Sow[RGEg3 -> (3 /. gauge)]];
     If[ArrayQ[Yd], Sow[RGEYd -> -Transpose[Yd]]];
     If[ArrayQ[Yu], Sow[RGEYu -> Transpose[Yu]]];
     If[ArrayQ[Ye], Sow[RGEYe -> -Transpose[Ye]]];
     If[ArrayQ[Yn], Sow[RGEY\[Nu] -> Transpose[Yn]]];
     If[ArrayQ[Mn], Sow[RGEM\[Nu]r -> Mn]];
     If[ArrayQ[Td], Sow[RGETd -> -Transpose[Td]]];
     If[ArrayQ[Tu], Sow[RGETu -> Transpose[Tu]]];
     If[ArrayQ[Te], Sow[RGETe -> -Transpose[Te]]];
     If[ArrayQ[Tn], Sow[RGET\[Nu] -> Transpose[Tn]]];
     If[ArrayQ[msq2], Sow[RGEm2Q -> msq2]];
     If[ArrayQ[msu2], Sow[RGEm2u -> msu2]];
     If[ArrayQ[msd2], Sow[RGEm2d -> msd2]];
     If[ArrayQ[msl2], Sow[RGEm2L -> msl2]];
     If[ArrayQ[mse2], Sow[RGEm2e -> mse2]];
     If[ArrayQ[msn2], Sow[RGEm2\[Nu] -> msn2]];
     Sow[RGESuggestion -> "GUT"]
  ][[2, 1]];
  \[Phi] = If[IntegerQ[4 /. minpar] && IntegerQ[4 /. imminpar], 0, 
    ArcTan[
     If[Not[IntegerQ[(4 /. minpar)]], (4 /. minpar), 0], 
     If[Not[IntegerQ[(4 /. imminpar)]], (4 /. imminpar), 0]
    ]
  ];
  RGESetOptions["MSSMsoftbrokenProton", STCsign\[Mu] -> E^(I \[Phi]) // Chop];
  If[Not[IntegerQ[3 /. minpar]], RGESetOptions["MSSMsoftbrokenProton", RGEtan\[Beta] -> (3 /. minpar)]];
  If[(5 /. modsel) != 2, RGESetOptions["MSSMsoftbrokenProton", STCcMSSM -> False]];
  If[(1 /. stc) != 1, RGESetOptions["MSSMsoftbrokenProton", STCSusyScaleFromStops -> False]];
  If[(2 /. stc) != 1 && (2 /. stc) != 2, 
    RGESetOptions["MSSMsoftbrokenProton", STCSearchSMTransition -> False]
  ];
  If[(3 /. stc) != 1 && (3 /. stc) != 3, 
    RGESetOptions["MSSMsoftbrokenProton", STCCCBConstraints -> False]
  ];
  If[(4 /. stc) != 1 && (4 /. stc) != 4, 
    RGESetOptions["MSSMsoftbrokenProton", STCUFBConstraints -> False]
  ];
  If[(6 /. stc) != 1 && (6 /. stc) != 6, 
    RGESetOptions["MSSMsoftbrokenProton", RGEModelVariant -> "2Loop"]
  ];
  If[Not[IntegerQ[(23 /. qextpar)]], 
    RGESetOptions["MSSMsoftbrokenProton", STCSusyScale -> (23 /. qextpar)]
  ];
  RGESetInitial[GUT, #] &@initialrule;
	Return[{MZ,GUT,(5/.stc)}]
];


STCSLHA2Import[file_] := Block[{input = ToUpperCase[Import[file, "String"]],MZ,GUT,message},
  {MZ,GUT,message} = SLHAInput[input];
  caught=Catch[RGESolve[MZ, GUT], TachyonicMass];
  If[ListQ[caught] && (message == 1 || message == 5), 
    Print["Warning... Tachyonic masses encountered:\n", caught]
  ];
];

STCSLHA2Import[] := STCSLHA2Import[NotebookDirectory[]<>"SusyTC.in"];


(*SLHA Output*)

PDGcodes={25,35,36,37,1000021,1000022,1000023,1000025,1000035,1000024,1000037,1000002,1000004,1000006,2000002,2000004,2000006,1000001,1000003,1000005,2000001,2000003,2000005,1000011,1000013,1000015,2000011,2000013,2000015,1000012,1000014,1000016};
ToSLHAString[numin_]:=Block[{abs=Abs[numin],sign=Sign[numin],out,expo=0},
out=If[sign>=0," ","-"];
If[abs!=0&&abs!=1.,
expo=Floor[Log[10,abs]];
abs=abs/(10^expo)];
If[abs==0,Return[" 0.00000000E+00"]];
out=StringJoin[out,ToString[SetPrecision[abs,9]],"E",
If[expo>=0,"+","-"],If[StringLength[ToString[Abs[expo]]]==1,"0",""],
ToString[Abs[expo]]]
]
ToSLHAPDGCode[numin_]:=Block[{out=ToString[numin]},
While[StringLength[out]<9,out=StringJoin[" ",out]];
out
]

WriteSLHA2Output[fileout_,xloop_,initial_]:=Block[{text=""},
text=StringJoin[
"# SUSY Les Houches Accord 2 - REAP MSSMsoftbrokenProton + SusyTC\n",
"#-------------------------------------------------------------------\n",
"# REAP 1.11.2 or higher...\n",
"#   S. Antusch, J. Kersten, M. Lindner, M. Ratz, M.A. Schmidt, JHEP 0503 (2005) 024, hep-ph/0501272\n",
"# RGEMSSMsoftbroken + SusyTC\n",
"#   S. Antusch, C. Sluka, ..., ...\n",
"# RGEMSSMsoftbrokenProton + SusyTCProton\n",
"#   S. Antusch, C. Hohl, V. Susic\n",
"#-------------------------------------------------------------------\n",
"# Created: ",DateString[],"\n",
"BLOCK SPINFO # Program information\n",
"     1  SusyTCProton\n",
"     2  ",STCversion,"\n",
"BLOCK MODSEL  # Select Model\n",
"     1  1   # High scale input\n",
"     5  ",If[Not[("cMSSM"/.xloop)],"1   # only CKM phase","2   # CP violation"],"\n",
"     6  3   # Flavour violation\n",
"BLOCK MINPAR  # Constrained MSSM Input parameters\n",
"     1  ",ToSLHAString[RGEm0/.initial],"  # m0\n",
"     2  ",ToSLHAString[RGEM12/.initial],"  # m12\n",
"     3  ",ToSLHAString["tan\[Beta]"/.xloop],"  # TanBeta input at SUSY scale\n",
"     4  ",If[Not[("cMSSM"/.xloop)],ToSLHAString[("sign\[Mu]"/.xloop)],ToSLHAString[Re[("\[Mu]"/.xloop)]/Abs[("\[Mu]"/.xloop)]]],If[Not[("cMSSM"/.xloop)],"  # Sign\[Mu]\n","  # Cos \[Phi] Mu\n"],
"     5  ",ToSLHAString[RGEA0/.initial],"  # Azero\n",
If[("cMSSM"/.xloop),StringJoin[
"BLOCK IMMINPAR\n",
"     4  ",ToSLHAString[Im[("\[Mu]"/.xloop)]/Abs[("\[Mu]"/.xloop)]],"  # Sin \[Phi] Mu\n"],""
],
"BLOCK MASS Q = ",ToSLHAString["Q"/.xloop],"  # tree-level DRbar masses (SUSY scale)\n",
" ",ToSLHAPDGCode[PDGcodes[[1]]],"   ",ToSLHAString["Mh"/.xloop],"   # h0\n",
" ",ToSLHAPDGCode[PDGcodes[[2]]],"   ",ToSLHAString["MH"/.xloop],"   # H0\n",
" ",ToSLHAPDGCode[PDGcodes[[3]]],"   ",ToSLHAString["MA"/.xloop],"   # A0",If[Not[("cMSSM"/.xloop)]," (one loop pole mass)\n","\n"],
" ",ToSLHAPDGCode[PDGcodes[[4]]],"   ",ToSLHAString["MHp"/.xloop],"   # H+",If[("cMSSM"/.xloop)," (one loop pole mass)\n","\n"],
" ",ToSLHAPDGCode[PDGcodes[[5]]],"   ",ToSLHAString["M3"/.xloop],"   # ~g\n",
" ",ToSLHAPDGCode[PDGcodes[[6]]],"   ",ToSLHAString[("m\[Chi]0"/.xloop)[[1]]],"   # ~\[Chi]0_1\n",
" ",ToSLHAPDGCode[PDGcodes[[7]]],"   ",ToSLHAString[("m\[Chi]0"/.xloop)[[2]]],"   # ~\[Chi]0_2\n",
" ",ToSLHAPDGCode[PDGcodes[[8]]],"   ",ToSLHAString[("m\[Chi]0"/.xloop)[[3]]],"   # ~\[Chi]0_3\n",
" ",ToSLHAPDGCode[PDGcodes[[9]]],"   ",ToSLHAString[("m\[Chi]0"/.xloop)[[4]]],"   # ~\[Chi]0_4\n",
" ",ToSLHAPDGCode[PDGcodes[[10]]],"   ",ToSLHAString[("m\[Chi]p"/.xloop)[[1]]],"   # ~\[Chi]+_1\n",
" ",ToSLHAPDGCode[PDGcodes[[11]]],"   ",ToSLHAString[("m\[Chi]p"/.xloop)[[2]]],"   # ~\[Chi]+_2\n",
" ",ToSLHAPDGCode[PDGcodes[[12]]],"   ",ToSLHAString[("msude"/.xloop)[[1,1]]],"   # ~u_1\n",
" ",ToSLHAPDGCode[PDGcodes[[13]]],"   ",ToSLHAString[("msude"/.xloop)[[1,2]]],"   # ~u_2\n",
" ",ToSLHAPDGCode[PDGcodes[[14]]],"   ",ToSLHAString[("msude"/.xloop)[[1,3]]],"   # ~u_3\n",
" ",ToSLHAPDGCode[PDGcodes[[15]]],"   ",ToSLHAString[("msude"/.xloop)[[1,4]]],"   # ~u_4\n",
" ",ToSLHAPDGCode[PDGcodes[[16]]],"   ",ToSLHAString[("msude"/.xloop)[[1,5]]],"   # ~u_5\n",
" ",ToSLHAPDGCode[PDGcodes[[17]]],"   ",ToSLHAString[("msude"/.xloop)[[1,6]]],"   # ~u_6\n",
" ",ToSLHAPDGCode[PDGcodes[[18]]],"   ",ToSLHAString[("msude"/.xloop)[[2,1]]],"   # ~d_1\n",
" ",ToSLHAPDGCode[PDGcodes[[19]]],"   ",ToSLHAString[("msude"/.xloop)[[2,2]]],"   # ~d_2\n",
" ",ToSLHAPDGCode[PDGcodes[[20]]],"   ",ToSLHAString[("msude"/.xloop)[[2,3]]],"   # ~d_3\n",
" ",ToSLHAPDGCode[PDGcodes[[21]]],"   ",ToSLHAString[("msude"/.xloop)[[2,4]]],"   # ~d_4\n",
" ",ToSLHAPDGCode[PDGcodes[[22]]],"   ",ToSLHAString[("msude"/.xloop)[[2,5]]],"   # ~d_5\n",
" ",ToSLHAPDGCode[PDGcodes[[23]]],"   ",ToSLHAString[("msude"/.xloop)[[2,6]]],"   # ~d_6\n",
" ",ToSLHAPDGCode[PDGcodes[[24]]],"   ",ToSLHAString[("msude"/.xloop)[[3,1]]],"   # ~e_1\n",
" ",ToSLHAPDGCode[PDGcodes[[25]]],"   ",ToSLHAString[("msude"/.xloop)[[3,2]]],"   # ~e_2\n",
" ",ToSLHAPDGCode[PDGcodes[[26]]],"   ",ToSLHAString[("msude"/.xloop)[[3,3]]],"   # ~e_3\n",
" ",ToSLHAPDGCode[PDGcodes[[27]]],"   ",ToSLHAString[("msude"/.xloop)[[3,4]]],"   # ~e_4\n",
" ",ToSLHAPDGCode[PDGcodes[[28]]],"   ",ToSLHAString[("msude"/.xloop)[[3,5]]],"   # ~e_5\n",
" ",ToSLHAPDGCode[PDGcodes[[29]]],"   ",ToSLHAString[("msude"/.xloop)[[3,6]]],"   # ~e_6\n",
" ",ToSLHAPDGCode[PDGcodes[[30]]],"   ",ToSLHAString[("ms\[Nu]"/.xloop)[[1]]],"   # ~\[Nu]_1\n",
" ",ToSLHAPDGCode[PDGcodes[[31]]],"   ",ToSLHAString[("ms\[Nu]"/.xloop)[[2]]],"   # ~\[Nu]_2\n",
" ",ToSLHAPDGCode[PDGcodes[[32]]],"   ",ToSLHAString[("ms\[Nu]"/.xloop)[[3]]],"   # ~\[Nu]_3\n",
"BLOCK NMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[("N"/.xloop)[[1,1]]]//Chop],"   # Re(N[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[("N"/.xloop)[[1,2]]]//Chop],"   # Re(N[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[("N"/.xloop)[[1,3]]]//Chop],"   # Re(N[[1,3]])\n",
"  1  4   ",ToSLHAString[Re[("N"/.xloop)[[1,4]]]//Chop],"   # Re(N[[1,4]])\n",
"  2  1   ",ToSLHAString[Re[("N"/.xloop)[[2,1]]]//Chop],"   # Re(N[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[("N"/.xloop)[[2,2]]]//Chop],"   # Re(N[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[("N"/.xloop)[[2,3]]]//Chop],"   # Re(N[[2,3]])\n",
"  2  4   ",ToSLHAString[Re[("N"/.xloop)[[2,4]]]//Chop],"   # Re(N[[2,4]])\n",
"  3  1   ",ToSLHAString[Re[("N"/.xloop)[[3,1]]]//Chop],"   # Re(N[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[("N"/.xloop)[[3,2]]]//Chop],"   # Re(N[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[("N"/.xloop)[[3,3]]]//Chop],"   # Re(N[[3,3]])\n",
"  3  4   ",ToSLHAString[Re[("N"/.xloop)[[3,4]]]//Chop],"   # Re(N[[3,4]])\n",
"  4  1   ",ToSLHAString[Re[("N"/.xloop)[[4,1]]]//Chop],"   # Re(N[[4,1]])\n",
"  4  2   ",ToSLHAString[Re[("N"/.xloop)[[4,2]]]//Chop],"   # Re(N[[4,2]])\n",
"  4  3   ",ToSLHAString[Re[("N"/.xloop)[[4,3]]]//Chop],"   # Re(N[[4,3]])\n",
"  4  4   ",ToSLHAString[Re[("N"/.xloop)[[4,4]]]//Chop],"   # Re(N[[4,4]])\n",
"BLOCK IMNMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[("N"/.xloop)[[1,1]]]//Chop],"   # Im(N[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[("N"/.xloop)[[1,2]]]//Chop],"   # Im(N[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[("N"/.xloop)[[1,3]]]//Chop],"   # Im(N[[1,3]])\n",
"  1  4   ",ToSLHAString[Im[("N"/.xloop)[[1,4]]]//Chop],"   # Im(N[[1,4]])\n",
"  2  1   ",ToSLHAString[Im[("N"/.xloop)[[2,1]]]//Chop],"   # Im(N[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[("N"/.xloop)[[2,2]]]//Chop],"   # Im(N[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[("N"/.xloop)[[2,3]]]//Chop],"   # Im(N[[2,3]])\n",
"  2  4   ",ToSLHAString[Im[("N"/.xloop)[[2,4]]]//Chop],"   # Im(N[[2,4]])\n",
"  3  1   ",ToSLHAString[Im[("N"/.xloop)[[3,1]]]//Chop],"   # Im(N[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[("N"/.xloop)[[3,2]]]//Chop],"   # Im(N[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[("N"/.xloop)[[3,3]]]//Chop],"   # Im(N[[3,3]])\n",
"  3  4   ",ToSLHAString[Im[("N"/.xloop)[[3,4]]]//Chop],"   # Im(N[[3,4]])\n",
"  4  1   ",ToSLHAString[Im[("N"/.xloop)[[4,1]]]//Chop],"   # Im(N[[4,1]])\n",
"  4  2   ",ToSLHAString[Im[("N"/.xloop)[[4,2]]]//Chop],"   # Im(N[[4,2]])\n",
"  4  3   ",ToSLHAString[Im[("N"/.xloop)[[4,3]]]//Chop],"   # Im(N[[4,3]])\n",
"  4  4   ",ToSLHAString[Im[("N"/.xloop)[[4,4]]]//Chop],"   # Im(N[[4,4]])\n",
"BLOCK UMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[("U"/.xloop)[[1,1]]]//Chop],"   # Re(U[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[("U"/.xloop)[[1,2]]]//Chop],"   # Re(U[[1,2]])\n",
"  2  1   ",ToSLHAString[Re[("U"/.xloop)[[2,1]]]//Chop],"   # Re(U[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[("U"/.xloop)[[2,2]]]//Chop],"   # Re(U[[2,2]])\n",
"BLOCK IMUMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[("U"/.xloop)[[1,1]]]//Chop],"   # Im(U[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[("U"/.xloop)[[1,2]]]//Chop],"   # Im(U[[1,2]])\n",
"  2  1   ",ToSLHAString[Im[("U"/.xloop)[[2,1]]]//Chop],"   # Im(U[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[("U"/.xloop)[[2,2]]]//Chop],"   # Im(U[[2,2]])\n",
"BLOCK VMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[("V"/.xloop)[[1,1]]]//Chop],"   # Re(V[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[("V"/.xloop)[[1,2]]]//Chop],"   # Re(V[[1,2]])\n",
"  2  1   ",ToSLHAString[Re[("V"/.xloop)[[2,1]]]//Chop],"   # Re(V[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[("V"/.xloop)[[2,2]]]//Chop],"   # Re(V[[2,2]])\n",
"BLOCK IMVMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[("V"/.xloop)[[1,1]]]//Chop],"   # Im(V[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[("V"/.xloop)[[1,2]]]//Chop],"   # Im(V[[1,2]])\n",
"  2  1   ",ToSLHAString[Im[("V"/.xloop)[[2,1]]]//Chop],"   # Im(V[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[("V"/.xloop)[[2,2]]]//Chop],"   # Im(V[[2,2]])\n",
"BLOCK USQMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,1]]]//Chop],"   # Re(Ru[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,2]]]//Chop],"   # Re(Ru[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,3]]]//Chop],"   # Re(Ru[[1,3]])\n",
"  1  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,4]]]//Chop],"   # Re(Ru[[1,4]])\n",
"  1  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,5]]]//Chop],"   # Re(Ru[[1,5]])\n",
"  1  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,6]]]//Chop],"   # Re(Ru[[1,6]])\n",
"  2  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,1]]]//Chop],"   # Re(Ru[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,2]]]//Chop],"   # Re(Ru[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,3]]]//Chop],"   # Re(Ru[[2,3]])\n",
"  2  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,4]]]//Chop],"   # Re(Ru[[2,4]])\n",
"  2  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,5]]]//Chop],"   # Re(Ru[[2,5]])\n",
"  2  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,6]]]//Chop],"   # Re(Ru[[2,6]])\n",
"  3  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,1]]]//Chop],"   # Re(Ru[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,2]]]//Chop],"   # Re(Ru[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,3]]]//Chop],"   # Re(Ru[[3,3]])\n",
"  3  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,4]]]//Chop],"   # Re(Ru[[3,4]])\n",
"  3  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,5]]]//Chop],"   # Re(Ru[[3,5]])\n",
"  3  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,6]]]//Chop],"   # Re(Ru[[3,6]])\n",
"  4  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,1]]]//Chop],"   # Re(Ru[[4,1]])\n",
"  4  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,2]]]//Chop],"   # Re(Ru[[4,2]])\n",
"  4  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,3]]]//Chop],"   # Re(Ru[[4,3]])\n",
"  4  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,4]]]//Chop],"   # Re(Ru[[4,4]])\n",
"  4  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,5]]]//Chop],"   # Re(Ru[[4,5]])\n",
"  4  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,6]]]//Chop],"   # Re(Ru[[4,6]])\n",
"  5  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,1]]]//Chop],"   # Re(Ru[[5,1]])\n",
"  5  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,2]]]//Chop],"   # Re(Ru[[5,2]])\n",
"  5  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,3]]]//Chop],"   # Re(Ru[[5,3]])\n",
"  5  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,4]]]//Chop],"   # Re(Ru[[5,4]])\n",
"  5  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,5]]]//Chop],"   # Re(Ru[[5,5]])\n",
"  5  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,6]]]//Chop],"   # Re(Ru[[5,6]])\n",
"  6  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,1]]]//Chop],"   # Re(Ru[[6,1]])\n",
"  6  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,2]]]//Chop],"   # Re(Ru[[6,2]])\n",
"  6  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,3]]]//Chop],"   # Re(Ru[[6,3]])\n",
"  6  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,4]]]//Chop],"   # Re(Ru[[6,4]])\n",
"  6  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,5]]]//Chop],"   # Re(Ru[[6,5]])\n",
"  6  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,6]]]//Chop],"   # Re(Ru[[6,6]])\n",
"BLOCK IMUSQMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,1]]]//Chop],"   # Im(Ru[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,2]]]//Chop],"   # Im(Ru[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,3]]]//Chop],"   # Im(Ru[[1,3]])\n",
"  1  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,4]]]//Chop],"   # Im(Ru[[1,4]])\n",
"  1  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,5]]]//Chop],"   # Im(Ru[[1,5]])\n",
"  1  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[1,6]]]//Chop],"   # Im(Ru[[1,6]])\n",
"  2  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,1]]]//Chop],"   # Im(Ru[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,2]]]//Chop],"   # Im(Ru[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,3]]]//Chop],"   # Im(Ru[[2,3]])\n",
"  2  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,4]]]//Chop],"   # Im(Ru[[2,4]])\n",
"  2  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,5]]]//Chop],"   # Im(Ru[[2,5]])\n",
"  2  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[2,6]]]//Chop],"   # Im(Ru[[2,6]])\n",
"  3  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,1]]]//Chop],"   # Im(Ru[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,2]]]//Chop],"   # Im(Ru[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,3]]]//Chop],"   # Im(Ru[[3,3]])\n",
"  3  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,4]]]//Chop],"   # Im(Ru[[3,4]])\n",
"  3  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,5]]]//Chop],"   # Im(Ru[[3,5]])\n",
"  3  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[3,6]]]//Chop],"   # Im(Ru[[3,6]])\n",
"  4  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,1]]]//Chop],"   # Im(Ru[[4,1]])\n",
"  4  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,2]]]//Chop],"   # Im(Ru[[4,2]])\n",
"  4  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,3]]]//Chop],"   # Im(Ru[[4,3]])\n",
"  4  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,4]]]//Chop],"   # Im(Ru[[4,4]])\n",
"  4  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,5]]]//Chop],"   # Im(Ru[[4,5]])\n",
"  4  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[4,6]]]//Chop],"   # Im(Ru[[4,6]])\n",
"  5  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,1]]]//Chop],"   # Im(Ru[[5,1]])\n",
"  5  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,2]]]//Chop],"   # Im(Ru[[5,2]])\n",
"  5  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,3]]]//Chop],"   # Im(Ru[[5,3]])\n",
"  5  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,4]]]//Chop],"   # Im(Ru[[5,4]])\n",
"  5  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,5]]]//Chop],"   # Im(Ru[[5,5]])\n",
"  5  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[5,6]]]//Chop],"   # Im(Ru[[5,6]])\n",
"  6  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,1]]]//Chop],"   # Im(Ru[[6,1]])\n",
"  6  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,2]]]//Chop],"   # Im(Ru[[6,2]])\n",
"  6  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,3]]]//Chop],"   # Im(Ru[[6,3]])\n",
"  6  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,4]]]//Chop],"   # Im(Ru[[6,4]])\n",
"  6  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,5]]]//Chop],"   # Im(Ru[[6,5]])\n",
"  6  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[1]]][[6,6]]]//Chop],"   # Im(Ru[[6,6]])\n",
"BLOCK DSQMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,1]]]//Chop],"   # Re(Rd[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,2]]]//Chop],"   # Re(Rd[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,3]]]//Chop],"   # Re(Rd[[1,3]])\n",
"  1  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,4]]]//Chop],"   # Re(Rd[[1,4]])\n",
"  1  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,5]]]//Chop],"   # Re(Rd[[1,5]])\n",
"  1  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,6]]]//Chop],"   # Re(Rd[[1,6]])\n",
"  2  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,1]]]//Chop],"   # Re(Rd[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,2]]]//Chop],"   # Re(Rd[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,3]]]//Chop],"   # Re(Rd[[2,3]])\n",
"  2  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,4]]]//Chop],"   # Re(Rd[[2,4]])\n",
"  2  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,5]]]//Chop],"   # Re(Rd[[2,5]])\n",
"  2  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,6]]]//Chop],"   # Re(Rd[[2,6]])\n",
"  3  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,1]]]//Chop],"   # Re(Rd[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,2]]]//Chop],"   # Re(Rd[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,3]]]//Chop],"   # Re(Rd[[3,3]])\n",
"  3  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,4]]]//Chop],"   # Re(Rd[[3,4]])\n",
"  3  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,5]]]//Chop],"   # Re(Rd[[3,5]])\n",
"  3  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,6]]]//Chop],"   # Re(Rd[[3,6]])\n",
"  4  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,1]]]//Chop],"   # Re(Rd[[4,1]])\n",
"  4  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,2]]]//Chop],"   # Re(Rd[[4,2]])\n",
"  4  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,3]]]//Chop],"   # Re(Rd[[4,3]])\n",
"  4  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,4]]]//Chop],"   # Re(Rd[[4,4]])\n",
"  4  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,5]]]//Chop],"   # Re(Rd[[4,5]])\n",
"  4  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,6]]]//Chop],"   # Re(Rd[[4,6]])\n",
"  5  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,1]]]//Chop],"   # Re(Rd[[5,1]])\n",
"  5  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,2]]]//Chop],"   # Re(Rd[[5,2]])\n",
"  5  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,3]]]//Chop],"   # Re(Rd[[5,3]])\n",
"  5  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,4]]]//Chop],"   # Re(Rd[[5,4]])\n",
"  5  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,5]]]//Chop],"   # Re(Rd[[5,5]])\n",
"  5  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,6]]]//Chop],"   # Re(Rd[[5,6]])\n",
"  6  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,1]]]//Chop],"   # Re(Rd[[6,1]])\n",
"  6  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,2]]]//Chop],"   # Re(Rd[[6,2]])\n",
"  6  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,3]]]//Chop],"   # Re(Rd[[6,3]])\n",
"  6  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,4]]]//Chop],"   # Re(Rd[[6,4]])\n",
"  6  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,5]]]//Chop],"   # Re(Rd[[6,5]])\n",
"  6  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,6]]]//Chop],"   # Re(Rd[[6,6]])\n",
"BLOCK IMDSQMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,1]]]//Chop],"   # Im(Rd[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,2]]]//Chop],"   # Im(Rd[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,3]]]//Chop],"   # Im(Rd[[1,3]])\n",
"  1  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,4]]]//Chop],"   # Im(Rd[[1,4]])\n",
"  1  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,5]]]//Chop],"   # Im(Rd[[1,5]])\n",
"  1  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[1,6]]]//Chop],"   # Im(Rd[[1,6]])\n",
"  2  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,1]]]//Chop],"   # Im(Rd[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,2]]]//Chop],"   # Im(Rd[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,3]]]//Chop],"   # Im(Rd[[2,3]])\n",
"  2  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,4]]]//Chop],"   # Im(Rd[[2,4]])\n",
"  2  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,5]]]//Chop],"   # Im(Rd[[2,5]])\n",
"  2  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[2,6]]]//Chop],"   # Im(Rd[[2,6]])\n",
"  3  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,1]]]//Chop],"   # Im(Rd[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,2]]]//Chop],"   # Im(Rd[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,3]]]//Chop],"   # Im(Rd[[3,3]])\n",
"  3  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,4]]]//Chop],"   # Im(Rd[[3,4]])\n",
"  3  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,5]]]//Chop],"   # Im(Rd[[3,5]])\n",
"  3  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[3,6]]]//Chop],"   # Im(Rd[[3,6]])\n",
"  4  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,1]]]//Chop],"   # Im(Rd[[4,1]])\n",
"  4  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,2]]]//Chop],"   # Im(Rd[[4,2]])\n",
"  4  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,3]]]//Chop],"   # Im(Rd[[4,3]])\n",
"  4  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,4]]]//Chop],"   # Im(Rd[[4,4]])\n",
"  4  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,5]]]//Chop],"   # Im(Rd[[4,5]])\n",
"  4  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[4,6]]]//Chop],"   # Im(Rd[[4,6]])\n",
"  5  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,1]]]//Chop],"   # Im(Rd[[5,1]])\n",
"  5  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,2]]]//Chop],"   # Im(Rd[[5,2]])\n",
"  5  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,3]]]//Chop],"   # Im(Rd[[5,3]])\n",
"  5  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,4]]]//Chop],"   # Im(Rd[[5,4]])\n",
"  5  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,5]]]//Chop],"   # Im(Rd[[5,5]])\n",
"  5  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[5,6]]]//Chop],"   # Im(Rd[[5,6]])\n",
"  6  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,1]]]//Chop],"   # Im(Rd[[6,1]])\n",
"  6  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,2]]]//Chop],"   # Im(Rd[[6,2]])\n",
"  6  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,3]]]//Chop],"   # Im(Rd[[6,3]])\n",
"  6  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,4]]]//Chop],"   # Im(Rd[[6,4]])\n",
"  6  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,5]]]//Chop],"   # Im(Rd[[6,5]])\n",
"  6  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[2]]][[6,6]]]//Chop],"   # Im(Rd[[6,6]])\n",
"BLOCK SELMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,1]]]//Chop],"   # Re(Re[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,2]]]//Chop],"   # Re(Re[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,3]]]//Chop],"   # Re(Re[[1,3]])\n",
"  1  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,4]]]//Chop],"   # Re(Re[[1,4]])\n",
"  1  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,5]]]//Chop],"   # Re(Re[[1,5]])\n",
"  1  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,6]]]//Chop],"   # Re(Re[[1,6]])\n",
"  2  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,1]]]//Chop],"   # Re(Re[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,2]]]//Chop],"   # Re(Re[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,3]]]//Chop],"   # Re(Re[[2,3]])\n",
"  2  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,4]]]//Chop],"   # Re(Re[[2,4]])\n",
"  2  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,5]]]//Chop],"   # Re(Re[[2,5]])\n",
"  2  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,6]]]//Chop],"   # Re(Re[[2,6]])\n",
"  3  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,1]]]//Chop],"   # Re(Re[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,2]]]//Chop],"   # Re(Re[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,3]]]//Chop],"   # Re(Re[[3,3]])\n",
"  3  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,4]]]//Chop],"   # Re(Re[[3,4]])\n",
"  3  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,5]]]//Chop],"   # Re(Re[[3,5]])\n",
"  3  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,6]]]//Chop],"   # Re(Re[[3,6]])\n",
"  4  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,1]]]//Chop],"   # Re(Re[[4,1]])\n",
"  4  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,2]]]//Chop],"   # Re(Re[[4,2]])\n",
"  4  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,3]]]//Chop],"   # Re(Re[[4,3]])\n",
"  4  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,4]]]//Chop],"   # Re(Re[[4,4]])\n",
"  4  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,5]]]//Chop],"   # Re(Re[[4,5]])\n",
"  4  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,6]]]//Chop],"   # Re(Re[[4,6]])\n",
"  5  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,1]]]//Chop],"   # Re(Re[[5,1]])\n",
"  5  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,2]]]//Chop],"   # Re(Re[[5,2]])\n",
"  5  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,3]]]//Chop],"   # Re(Re[[5,3]])\n",
"  5  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,4]]]//Chop],"   # Re(Re[[5,4]])\n",
"  5  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,5]]]//Chop],"   # Re(Re[[5,5]])\n",
"  5  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,6]]]//Chop],"   # Re(Re[[5,6]])\n",
"  6  1   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,1]]]//Chop],"   # Re(Re[[6,1]])\n",
"  6  2   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,2]]]//Chop],"   # Re(Re[[6,2]])\n",
"  6  3   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,3]]]//Chop],"   # Re(Re[[6,3]])\n",
"  6  4   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,4]]]//Chop],"   # Re(Re[[6,4]])\n",
"  6  5   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,5]]]//Chop],"   # Re(Re[[6,5]])\n",
"  6  6   ",ToSLHAString[Re[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,6]]]//Chop],"   # Re(Re[[6,6]])\n",
"BLOCK IMSELMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,1]]]//Chop],"   # Im(Re[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,2]]]//Chop],"   # Im(Re[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,3]]]//Chop],"   # Im(Re[[1,3]])\n",
"  1  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,4]]]//Chop],"   # Im(Re[[1,4]])\n",
"  1  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,5]]]//Chop],"   # Im(Re[[1,5]])\n",
"  1  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[1,6]]]//Chop],"   # Im(Re[[1,6]])\n",
"  2  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,1]]]//Chop],"   # Im(Re[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,2]]]//Chop],"   # Im(Re[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,3]]]//Chop],"   # Im(Re[[2,3]])\n",
"  2  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,4]]]//Chop],"   # Im(Re[[2,4]])\n",
"  2  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,5]]]//Chop],"   # Im(Re[[2,5]])\n",
"  2  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[2,6]]]//Chop],"   # Im(Re[[2,6]])\n",
"  3  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,1]]]//Chop],"   # Im(Re[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,2]]]//Chop],"   # Im(Re[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,3]]]//Chop],"   # Im(Re[[3,3]])\n",
"  3  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,4]]]//Chop],"   # Im(Re[[3,4]])\n",
"  3  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,5]]]//Chop],"   # Im(Re[[3,5]])\n",
"  3  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[3,6]]]//Chop],"   # Im(Re[[3,6]])\n",
"  4  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,1]]]//Chop],"   # Im(Re[[4,1]])\n",
"  4  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,2]]]//Chop],"   # Im(Re[[4,2]])\n",
"  4  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,3]]]//Chop],"   # Im(Re[[4,3]])\n",
"  4  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,4]]]//Chop],"   # Im(Re[[4,4]])\n",
"  4  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,5]]]//Chop],"   # Im(Re[[4,5]])\n",
"  4  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[4,6]]]//Chop],"   # Im(Re[[4,6]])\n",
"  5  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,1]]]//Chop],"   # Im(Re[[5,1]])\n",
"  5  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,2]]]//Chop],"   # Im(Re[[5,2]])\n",
"  5  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,3]]]//Chop],"   # Im(Re[[5,3]])\n",
"  5  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,4]]]//Chop],"   # Im(Re[[5,4]])\n",
"  5  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,5]]]//Chop],"   # Im(Re[[5,5]])\n",
"  5  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[5,6]]]//Chop],"   # Im(Re[[5,6]])\n",
"  6  1   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,1]]]//Chop],"   # Im(Re[[6,1]])\n",
"  6  2   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,2]]]//Chop],"   # Im(Re[[6,2]])\n",
"  6  3   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,3]]]//Chop],"   # Im(Re[[6,3]])\n",
"  6  4   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,4]]]//Chop],"   # Im(Re[[6,4]])\n",
"  6  5   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,5]]]//Chop],"   # Im(Re[[6,5]])\n",
"  6  6   ",ToSLHAString[Im[ConjugateTranspose[("Wude"/.xloop)[[3]]][[6,6]]]//Chop],"   # Im(Re[[6,6]])\n",
"BLOCK SNUMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,1]]]//Chop],"   # Re(R\[Nu][[1,1]])\n",
"  1  2   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,2]]]//Chop],"   # Re(R\[Nu][[1,2]])\n",
"  1  3   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,3]]]//Chop],"   # Re(R\[Nu][[1,3]])\n",
"  2  1   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,1]]]//Chop],"   # Re(R\[Nu][[2,1]])\n",
"  2  2   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,2]]]//Chop],"   # Re(R\[Nu][[2,2]])\n",
"  2  3   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,3]]]//Chop],"   # Re(R\[Nu][[2,3]])\n",
"  3  1   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,1]]]//Chop],"   # Re(R\[Nu][[3,1]])\n",
"  3  2   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,2]]]//Chop],"   # Re(R\[Nu][[3,2]])\n",
"  3  3   ",ToSLHAString[Re[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,3]]]//Chop],"   # Re(R\[Nu][[3,3]])\n",
"BLOCK IMSNUMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,1]]]//Chop],"   # Im(R\[Nu][[1,1]])\n",
"  1  2   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,2]]]//Chop],"   # Im(R\[Nu][[1,2]])\n",
"  1  3   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[1,3]]]//Chop],"   # Im(R\[Nu][[1,3]])\n",
"  2  1   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,1]]]//Chop],"   # Im(R\[Nu][[2,1]])\n",
"  2  2   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,2]]]//Chop],"   # Im(R\[Nu][[2,2]])\n",
"  2  3   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[2,3]]]//Chop],"   # Im(R\[Nu][[2,3]])\n",
"  3  1   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,1]]]//Chop],"   # Im(R\[Nu][[3,1]])\n",
"  3  2   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,2]]]//Chop],"   # Im(R\[Nu][[3,2]])\n",
"  3  3   ",ToSLHAString[Im[ConjugateTranspose[("W\[Nu]"/.xloop)][[3,3]]]//Chop],"   # Im(R\[Nu][[3,3]])\n",
"BLOCK ALPHA Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"         ",ToSLHAString[ArcTan["tan\[Alpha]"/.xloop]],"   # tree-level \[Alpha]H\n",
"BLOCK HMIX Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"    1   ",ToSLHAString[Re["\[Mu]"/.xloop]],If[Not[("cMSSM"/.xloop)],"  # \[Mu]\n","   # Re(\[Mu])\n"],
"    2   ",ToSLHAString["tan\[Beta]"/.xloop],"  # tan\[Beta]\n",
"    3   ",ToSLHAString["vev"/.xloop],"  # vev\n",
If[Not[("cMSSM"/.xloop)],StringJoin[
"    4   ",ToSLHAString[("MA"/.xloop)^2],"  # MA^2\n"
],""
],
"  101   ",ToSLHAString["m3"/.xloop],"  # m3\n",
If[("cMSSM"/.xloop),StringJoin[
"BLOCK IMHMIX\n",
"    1   ",ToSLHAString[Im["\[Mu]"/.xloop]],"   # Im(\[Mu])\n"],""
],
"BLOCK GAUGE Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"     1  ", ToSLHAString[Sqrt[3/5]*("g1"/.xloop)],"  # g1\n",(* Hypercharge normalization changed from GUT to SM*)
"     2  ", ToSLHAString["g2"/.xloop],"  # g2\n",
"     3  ", ToSLHAString["g3"/.xloop],"  # g3\n",
"BLOCK MSQ2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[1,1]]]//Chop],"   # Re(m2Q[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[1,2]]]//Chop],"   # Re(m2Q[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[1,3]]]//Chop],"   # Re(m2Q[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[2,1]]]//Chop],"   # Re(m2Q[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[2,2]]]//Chop],"   # Re(m2Q[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[2,3]]]//Chop],"   # Re(m2Q[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[3,1]]]//Chop],"   # Re(m2Q[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[3,2]]]//Chop],"   # Re(m2Q[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["m2Q"]/.xloop)[[3,3]]]//Chop],"   # Re(m2Q[[3,3]])\n",
"BLOCK IMMSQ2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[1,1]]]//Chop],"   # Im(m2Q[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[1,2]]]//Chop],"   # Im(m2Q[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[1,3]]]//Chop],"   # Im(m2Q[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[2,1]]]//Chop],"   # Im(m2Q[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[2,2]]]//Chop],"   # Im(m2Q[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[2,3]]]//Chop],"   # Im(m2Q[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[3,1]]]//Chop],"   # Im(m2Q[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[3,2]]]//Chop],"   # Im(m2Q[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["m2Q"]/.xloop)[[3,3]]]//Chop],"   # Im(m2Q[[3,3]])\n",
"BLOCK MSU2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[1,1]]]//Chop],"   # Re(m2u[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[1,2]]]//Chop],"   # Re(m2u[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[1,3]]]//Chop],"   # Re(m2u[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[2,1]]]//Chop],"   # Re(m2u[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[2,2]]]//Chop],"   # Re(m2u[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[2,3]]]//Chop],"   # Re(m2u[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[3,1]]]//Chop],"   # Re(m2u[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[3,2]]]//Chop],"   # Re(m2u[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["m2u"]/.xloop)[[3,3]]]//Chop],"   # Re(m2u[[3,3]])\n",
"BLOCK IMMSU2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[1,1]]]//Chop],"   # Im(m2u[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[1,2]]]//Chop],"   # Im(m2u[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[1,3]]]//Chop],"   # Im(m2u[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[2,1]]]//Chop],"   # Im(m2u[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[2,2]]]//Chop],"   # Im(m2u[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[2,3]]]//Chop],"   # Im(m2u[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[3,1]]]//Chop],"   # Im(m2u[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[3,2]]]//Chop],"   # Im(m2u[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["m2u"]/.xloop)[[3,3]]]//Chop],"   # Im(m2u[[3,3]])\n",
"BLOCK MSD2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[1,1]]]//Chop],"   # Re(m2d[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[1,2]]]//Chop],"   # Re(m2d[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[1,3]]]//Chop],"   # Re(m2d[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[2,1]]]//Chop],"   # Re(m2d[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[2,2]]]//Chop],"   # Re(m2d[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[2,3]]]//Chop],"   # Re(m2d[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[3,1]]]//Chop],"   # Re(m2d[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[3,2]]]//Chop],"   # Re(m2d[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["m2d"]/.xloop)[[3,3]]]//Chop],"   # Re(m2d[[3,3]])\n",
"BLOCK IMMSD2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[1,1]]]//Chop],"   # Im(m2d[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[1,2]]]//Chop],"   # Im(m2d[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[1,3]]]//Chop],"   # Im(m2d[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[2,1]]]//Chop],"   # Im(m2d[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[2,2]]]//Chop],"   # Im(m2d[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[2,3]]]//Chop],"   # Im(m2d[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[3,1]]]//Chop],"   # Im(m2d[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[3,2]]]//Chop],"   # Im(m2d[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["m2d"]/.xloop)[[3,3]]]//Chop],"   # Im(m2d[[3,3]])\n",
"BLOCK MSL2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[1,1]]]//Chop],"   # Re(m2Le[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[1,2]]]//Chop],"   # Re(m2Le[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[1,3]]]//Chop],"   # Re(m2Le[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[2,1]]]//Chop],"   # Re(m2Le[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[2,2]]]//Chop],"   # Re(m2Le[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[2,3]]]//Chop],"   # Re(m2Le[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[3,1]]]//Chop],"   # Re(m2Le[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[3,2]]]//Chop],"   # Re(m2Le[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["m2L"]/.xloop)[[3,3]]]//Chop],"   # Re(m2Le[[3,3]])\n",
"BLOCK IMMSL2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[1,1]]]//Chop],"   # Im(m2Le[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[1,2]]]//Chop],"   # Im(m2Le[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[1,3]]]//Chop],"   # Im(m2Le[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[2,1]]]//Chop],"   # Im(m2Le[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[2,2]]]//Chop],"   # Im(m2Le[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[2,3]]]//Chop],"   # Im(m2Le[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[3,1]]]//Chop],"   # Im(m2Le[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[3,2]]]//Chop],"   # Im(m2Le[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["m2L"]/.xloop)[[3,3]]]//Chop],"   # Im(m2Le[[3,3]])\n",
"BLOCK MSE2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[1,1]]]//Chop],"   # Re(m2e[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[1,2]]]//Chop],"   # Re(m2e[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[1,3]]]//Chop],"   # Re(m2e[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[2,1]]]//Chop],"   # Re(m2e[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[2,2]]]//Chop],"   # Re(m2e[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[2,3]]]//Chop],"   # Re(m2e[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[3,1]]]//Chop],"   # Re(m2e[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[3,2]]]//Chop],"   # Re(m2e[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["m2e"]/.xloop)[[3,3]]]//Chop],"   # Re(m2e[[3,3]])\n",
"BLOCK IMMSE2 Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[1,1]]]//Chop],"   # Im(m2e[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[1,2]]]//Chop],"   # Im(m2e[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[1,3]]]//Chop],"   # Im(m2e[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[2,1]]]//Chop],"   # Im(m2e[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[2,2]]]//Chop],"   # Im(m2e[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[2,3]]]//Chop],"   # Im(m2e[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[3,1]]]//Chop],"   # Im(m2e[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[3,2]]]//Chop],"   # Im(m2e[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["m2e"]/.xloop)[[3,3]]]//Chop],"   # Im(m2e[[3,3]])\n",
"BLOCK TU Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[1,1]]]//Chop],"   # Re(Tu[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[1,2]]]//Chop],"   # Re(Tu[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[1,3]]]//Chop],"   # Re(Tu[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[2,1]]]//Chop],"   # Re(Tu[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[2,2]]]//Chop],"   # Re(Tu[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[2,3]]]//Chop],"   # Re(Tu[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[3,1]]]//Chop],"   # Re(Tu[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[3,2]]]//Chop],"   # Re(Tu[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[1]][[3,3]]]//Chop],"   # Re(Tu[[3,3]])\n",
"BLOCK IMTU Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[1,1]]]//Chop],"   # Im(Tu[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[1,2]]]//Chop],"   # Im(Tu[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[1,3]]]//Chop],"   # Im(Tu[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[2,1]]]//Chop],"   # Im(Tu[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[2,2]]]//Chop],"   # Im(Tu[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[2,3]]]//Chop],"   # Im(Tu[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[3,1]]]//Chop],"   # Im(Tu[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[3,2]]]//Chop],"   # Im(Tu[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[1]][[3,3]]]//Chop],"   # Im(Tu[[3,3]])\n",
"BLOCK TD Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[1,1]]]//Chop],"   # Re(Td[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[1,2]]]//Chop],"   # Re(Td[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[1,3]]]//Chop],"   # Re(Td[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[2,1]]]//Chop],"   # Re(Td[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[2,2]]]//Chop],"   # Re(Td[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[2,3]]]//Chop],"   # Re(Td[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[3,1]]]//Chop],"   # Re(Td[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[3,2]]]//Chop],"   # Re(Td[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[2]][[3,3]]]//Chop],"   # Re(Td[[3,3]])\n",
"BLOCK IMTD Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[1,1]]]//Chop],"   # Im(Td[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[1,2]]]//Chop],"   # Im(Td[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[1,3]]]//Chop],"   # Im(Td[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[2,1]]]//Chop],"   # Im(Td[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[2,2]]]//Chop],"   # Im(Td[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[2,3]]]//Chop],"   # Im(Td[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[3,1]]]//Chop],"   # Im(Td[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[3,2]]]//Chop],"   # Im(Td[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[2]][[3,3]]]//Chop],"   # Im(Td[[3,3]])\n",
"BLOCK TE Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[1,1]]]//Chop],"   # Re(Te[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[1,2]]]//Chop],"   # Re(Te[[1,2]])\n",
"  1  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[1,3]]]//Chop],"   # Re(Te[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[2,1]]]//Chop],"   # Re(Te[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[2,2]]]//Chop],"   # Re(Te[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[2,3]]]//Chop],"   # Re(Te[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[3,1]]]//Chop],"   # Re(Te[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[3,2]]]//Chop],"   # Re(Te[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[(SCKMBasis["T"]/.xloop)[[3]][[3,3]]]//Chop],"   # Re(Te[[3,3]])\n",
"BLOCK IMTE Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[1,1]]]//Chop],"   # Im(Te[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[1,2]]]//Chop],"   # Im(Te[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[1,3]]]//Chop],"   # Im(Te[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[2,1]]]//Chop],"   # Im(Te[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[2,2]]]//Chop],"   # Im(Te[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[2,3]]]//Chop],"   # Im(Te[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[3,1]]]//Chop],"   # Im(Te[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[3,2]]]//Chop],"   # Im(Te[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[(SCKMBasis["T"]/.xloop)[[3]][[3,3]]]//Chop],"   # Im(Te[[3,3]])\n",
"BLOCK YU Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[1]][[1]]]//Chop,"   # Yu[[1,1]]\n",
"  2  2   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[1]][[2]]]//Chop,"   # Yu[[2,2]]\n",
"  3  3   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[1]][[3]]]//Chop,"   # Yu[[3,3]]\n",
"BLOCK YD Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[2]][[1]]]//Chop,"   # Yd[[1,1]]\n",
"  2  2   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[2]][[2]]]//Chop,"   # Yd[[2,2]]\n",
"  3  3   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[2]][[3]]]//Chop,"   # Yd[[3,3]]\n",
"BLOCK YE Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[3]][[1]]]//Chop,"   # Ye[[1,1]]\n",
"  2  2   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[3]][[2]]]//Chop,"   # Ye[[2,2]]\n",
"  3  3   ",ToSLHAString[(SCKMBasis["Y"]/.xloop)[[3]][[3]]]//Chop,"   # Ye[[3,3]]\n",
"BLOCK VCKM Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[("VCKM"/.xloop)[[1,1]]]//Chop],"   # Re(VCKM[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[("VCKM"/.xloop)[[1,2]]]//Chop],"   # Re(VCKM[[1,1]])\n",
"  1  3   ",ToSLHAString[Re[("VCKM"/.xloop)[[1,3]]]//Chop],"   # Re(VCKM[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[("VCKM"/.xloop)[[2,1]]]//Chop],"   # Re(VCKM[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[("VCKM"/.xloop)[[2,2]]]//Chop],"   # Re(VCKM[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[("VCKM"/.xloop)[[2,3]]]//Chop],"   # Re(VCKM[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[("VCKM"/.xloop)[[3,1]]]//Chop],"   # Re(VCKM[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[("VCKM"/.xloop)[[3,2]]]//Chop],"   # Re(VCKM[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[("VCKM"/.xloop)[[3,3]]]//Chop],"   # Re(VCKM[[3,3]])\n",
"BLOCK IMVCKM Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[("VCKM"/.xloop)[[1,1]]]//Chop],"   # Im(VCKM[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[("VCKM"/.xloop)[[1,2]]]//Chop],"   # Im(VCKM[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[("VCKM"/.xloop)[[1,3]]]//Chop],"   # Im(VCKM[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[("VCKM"/.xloop)[[2,1]]]//Chop],"   # Im(VCKM[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[("VCKM"/.xloop)[[2,2]]]//Chop],"   # Im(VCKM[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[("VCKM"/.xloop)[[2,3]]]//Chop],"   # Im(VCKM[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[("VCKM"/.xloop)[[3,1]]]//Chop],"   # Im(VCKM[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[("VCKM"/.xloop)[[3,2]]]//Chop],"   # Im(VCKM[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[("VCKM"/.xloop)[[3,3]]]//Chop],"   # Im(VCKM[[3,3]])\n",
"BLOCK UPMNS Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Re[("VPMNS"/.xloop)[[1,1]]]//Chop],"   # Re(VPMNS[[1,1]])\n",
"  1  2   ",ToSLHAString[Re[("VPMNS"/.xloop)[[1,2]]]//Chop],"   # Re(VPMNS[[1,1]])\n",
"  1  3   ",ToSLHAString[Re[("VPMNS"/.xloop)[[1,3]]]//Chop],"   # Re(VPMNS[[1,3]])\n",
"  2  1   ",ToSLHAString[Re[("VPMNS"/.xloop)[[2,1]]]//Chop],"   # Re(VPMNS[[2,1]])\n",
"  2  2   ",ToSLHAString[Re[("VPMNS"/.xloop)[[2,2]]]//Chop],"   # Re(VPMNS[[2,2]])\n",
"  2  3   ",ToSLHAString[Re[("VPMNS"/.xloop)[[2,3]]]//Chop],"   # Re(VPMNS[[2,3]])\n",
"  3  1   ",ToSLHAString[Re[("VPMNS"/.xloop)[[3,1]]]//Chop],"   # Re(VPMNS[[3,1]])\n",
"  3  2   ",ToSLHAString[Re[("VPMNS"/.xloop)[[3,2]]]//Chop],"   # Re(VPMNS[[3,2]])\n",
"  3  3   ",ToSLHAString[Re[("VPMNS"/.xloop)[[3,3]]]//Chop],"   # Re(VPMNS[[3,3]])\n",
"BLOCK IMUPMNS Q= ",ToSLHAString["Q"/.xloop],"  # (SUSY scale)\n",
"  1  1   ",ToSLHAString[Im[("VPMNS"/.xloop)[[1,1]]]//Chop],"   # Im(VPMNS[[1,1]])\n",
"  1  2   ",ToSLHAString[Im[("VPMNS"/.xloop)[[1,2]]]//Chop],"   # Im(VPMNS[[1,2]])\n",
"  1  3   ",ToSLHAString[Im[("VPMNS"/.xloop)[[1,3]]]//Chop],"   # Im(VPMNS[[1,3]])\n",
"  2  1   ",ToSLHAString[Im[("VPMNS"/.xloop)[[2,1]]]//Chop],"   # Im(VPMNS[[2,1]])\n",
"  2  2   ",ToSLHAString[Im[("VPMNS"/.xloop)[[2,2]]]//Chop],"   # Im(VPMNS[[2,2]])\n",
"  2  3   ",ToSLHAString[Im[("VPMNS"/.xloop)[[2,3]]]//Chop],"   # Im(VPMNS[[2,3]])\n",
"  3  1   ",ToSLHAString[Im[("VPMNS"/.xloop)[[3,1]]]//Chop],"   # Im(VPMNS[[3,1]])\n",
"  3  2   ",ToSLHAString[Im[("VPMNS"/.xloop)[[3,2]]]//Chop],"   # Im(VPMNS[[3,2]])\n",
"  3  3   ",ToSLHAString[Im[("VPMNS"/.xloop)[[3,3]]]//Chop],"   # Im(VPMNS[[3,3]])\n"
];
Export[fileout,text,"String"];
];

STCWriteSLHA2Output[Path_?StringQ]:=Block[{},
    If[Not[REAP`RGESolver`Private`gRGESolutionValid],
	Return[None];
    ];
    If[ginternalValues==None,
	Print["No SUSY spectrum available... Return None."];
	Return[None];
    ];
    WriteSLHA2Output[Path,ginternalValues,RGEGetInitial[][[2]]]
];

STCWriteSLHA2Output[]:=STCWriteSLHA2Output[NotebookDirectory[]<>"SusyTC.out"];


ClearAll[GetRawSolution];
GetRawSolution[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns all parameters of the SM *)
    Return[(ParametersFunc[pScale]/.pSolution)[[1]]];
];

ClearAll[GetRawM\[Nu]r];
GetRawM\[Nu]r[pScale_,pSolution_,pOpts___]:=Block[{lM},
(* returns the mass matrix of the heavy neutrinos *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lM=(M\[Nu]r[pScale]/.pSolution)[[1]];
    Return[lM];
];

ClearAll[GetRawY\[Nu]];
GetRawY\[Nu][pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the Yukawa coupling matrix of the neutrinos *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    Return[(Y\[Nu][pScale]/.pSolution)[[1]]];
];

ClearAll[GetRawT\[Nu]];
GetRawT\[Nu][pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking trilinear coupling matrix of the neutrinos *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    Return[(T\[Nu][pScale]/.pSolution)[[1]]];
];

ClearAll[GetCoupling];
GetCoupling[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the coupling constants *)
   Return[({g1[pScale],g2[pScale],g3[pScale]}/.pSolution)[[1]]];
];

ClearAll[Getg1];
Getg1[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the coupling constants *)
   Return[(g1[pScale]/.pSolution)[[1]]];
];

ClearAll[Getg2];
Getg2[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the coupling constants *)
   Return[(g2[pScale]/.pSolution)[[1]]];
];

ClearAll[Getg3];
Getg3[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the coupling constants *)
   Return[(g3[pScale]/.pSolution)[[1]]];
];

ClearAll[Get\[Alpha]];
Get\[Alpha][pScale_,pSolution_,pOpts___]:=Block[{lg},
(* returns the fine structure constants *)
    lg=({g1[pScale],g2[pScale],g3[pScale]}/.pSolution)[[1]];
    Return[lg^2/(4*Pi)];
];

ClearAll[GetYe];
GetYe[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the Yukawa coupling matrix of the charged leptons *)
    Return[(Ye[pScale]/.pSolution)[[1]]];
];

ClearAll[GetYu];
GetYu[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the Yukawa coupling matrix of the up-type quarks *)
    Return[(Yu[pScale]/.pSolution)[[1]]];
];

ClearAll[GetYd];
GetYd[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the Yukawa coupling matrix of the down-type quarks *)
    Return[(Yd[pScale]/.pSolution)[[1]]];
];

ClearAll[GetTe];
GetTe[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking trilinear coupling matrix of the charged leptons *)
    Return[(Te[pScale]/.pSolution)[[1]]];
];

ClearAll[GetTu];
GetTu[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking trilinear coupling matrix of the up-type quarks *)
    Return[(Tu[pScale]/.pSolution)[[1]]];
];

ClearAll[GetTd];
GetTd[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking trilinear coupling matrix of the down-type quarks *)
    Return[(Td[pScale]/.pSolution)[[1]]];
];

ClearAll[GetY\[Nu]];
GetY\[Nu][pScale_,pSolution_,pOpts___]:=Block[{lY\[Nu],lY\[Nu]Rotated,lM,lIntegratedOut,lLenM,lMhigh,lf,lg,lMEval,lCutoff,lUp},
(* returns the Yukawa couplings of the neutrinos *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lIntegratedOut=(RGEIntegratedOut/.Options[lOpts]);

    lY\[Nu]=(Y\[Nu][pScale]/.pSolution)[[1]];

    Catch[
      If[lIntegratedOut>0,
        lCutoff=RGEGetCutoff[Exp[pScale],1];
        lUp=RGEGetRange[][[2]];
        If[lCutoff>Exp[lUp],
            {lMInitial,lY\[Nu]Rotated}=({RGEM\[Nu]r,RGEY\[Nu]}/.RGEGetInitial[][[2]]);
            lLenM=Length[lMInitial];
            If[lLenM>Length[lM],
                {lMInitial,lY\[Nu]Rotated}=RGERotateM[lMInitial,lY\[Nu]Rotated];
                lY\[Nu]=Table[If[lf<=lLenM-lIntegratedOut,lY\[Nu][[lf,lg]],lY\[Nu]Rotated[[lf,lg]]],{lf,lLenM},{lg,lLenM}];
            ];

            Throw[lCutoff,RGEScaleTooBig]
        ];
        lY\[Nu]Rotated=RGEGetSolution[lCutoff,RGEY\[Nu],1];
        lM=RGEGetSolution[lCutoff,RGEM\[Nu]r,1];
        lLenM=Length[lM];
        {lM,lY\[Nu]Rotated}=RGERotateM[lM,lY\[Nu]Rotated];
        lY\[Nu]=Table[If[lf<=lLenM-lIntegratedOut,lY\[Nu][[lf,lg]],lY\[Nu]Rotated[[lf,lg]]],{lf,lLenM},{lg,lLenM}];
      ];
    ,RGEScaleTooBig];
    Return[lY\[Nu]];
];

ClearAll[GetT\[Nu]];
GetT\[Nu][pScale_,pSolution_,pOpts___]:=Block[{lT\[Nu],lT\[Nu]Rotated,lM,lIntegratedOut,lLenM,lMhigh,lf,lg,lMEval,lCutoff,lUp},
(* returns the softbreaking trilinear couplings of the neutrinos *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lIntegratedOut=(RGEIntegratedOut/.Options[lOpts]);

    lT\[Nu]=(T\[Nu][pScale]/.pSolution)[[1]];

    Catch[
      If[lIntegratedOut>0,
        lCutoff=RGEGetCutoff[Exp[pScale],1];
        lUp=RGEGetRange[][[2]];
        If[lCutoff>Exp[lUp],
            {lMInitial,lT\[Nu]Rotated}=({RGEM\[Nu]r,RGET\[Nu]}/.RGEGetInitial[][[2]]);
            lLenM=Length[lMInitial];
            If[lLenM>Length[lM],
                {lMInitial,lT\[Nu]Rotated}=RGERotateM[lMInitial,lT\[Nu]Rotated];
                lT\[Nu]=Table[If[lf<=lLenM-lIntegratedOut,lT\[Nu][[lf,lg]],lT\[Nu]Rotated[[lf,lg]]],{lf,lLenM},{lg,lLenM}];
            ];

            Throw[lCutoff,RGEScaleTooBig]
        ];
        lT\[Nu]Rotated=RGEGetSolution[lCutoff,RGET\[Nu],1];
        lM=RGEGetSolution[lCutoff,RGEM\[Nu]r,1];
        lLenM=Length[lM];
        {lM,lT\[Nu]Rotated}=RGERotateM[lM,lT\[Nu]Rotated];
        lT\[Nu]=Table[If[lf<=lLenM-lIntegratedOut,lT\[Nu][[lf,lg]],lT\[Nu]Rotated[[lf,lg]]],{lf,lLenM},{lg,lLenM}];
      ];
    ,RGEScaleTooBig];
    Return[lT\[Nu]];
];

ClearAll[GetM1];
GetM1[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking gaugino mass M1 *)
    Return[(M1[pScale]/.pSolution)[[1]]];
];

ClearAll[GetM2];
GetM2[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking gaugino mass M2 *)
    Return[(M2[pScale]/.pSolution)[[1]]];
];

ClearAll[GetM3];
GetM3[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking gaugino mass M3 *)
    Return[(M3[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2Q];
Getm2Q[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2Q *)
    Return[(m2Q[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2L];
Getm2L[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2L *)
    Return[(m2L[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2u];
Getm2u[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2u *)
    Return[(m2u[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2d];
Getm2d[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2d *)
    Return[(m2d[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2e];
Getm2e[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2e *)
    Return[(m2e[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2\[Nu]];
Getm2\[Nu][pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2\[Nu] *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    Return[(m2\[Nu][pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2Hd];
Getm2Hd[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2Hd *)
    Return[(m2Hd[pScale]/.pSolution)[[1]]];
];

ClearAll[Getm2Hu];
Getm2Hu[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the softbreaking mass-squared m2Hu *)
    Return[(m2Hu[pScale]/.pSolution)[[1]]];
];

ClearAll[Get\[Kappa]];
Get\[Kappa][pScale_,pSolution_,pOpts___]:=Block[{l\[Kappa]},
(* returns \[Kappa] *)
	l\[Kappa]=(\[Kappa][pScale]/.pSolution)[[1]];
        Return[l\[Kappa]];
];

ClearAll[GetM\[Nu]r];
GetM\[Nu]r[pScale_,pSolution_,pOpts___]:=Block[{lM,lIntegratedOut,lLenM,lMhigh,lf,lg,lMEval,lCutoff,lUp},
(* returns the mass matrix of the heavy neutrinos *)
        If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
        lOpts;
        Options[lOpts]=Options[RGEOptions];
        SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
        lIntegratedOut=(RGEIntegratedOut/.Options[lOpts]);
        lM=(M\[Nu]r[pScale]/.pSolution)[[1]];
        Catch[
          If[lIntegratedOut>0,
            lCutoff=RGEGetCutoff[Exp[pScale],1];
            lUp=RGEGetRange[][[2]];
            If[lCutoff>Exp[lUp],
                lMInitial=(RGEM\[Nu]r/.RGEGetInitial[][[2]]);
                lLenM=Length[lMInitial];
                If[lLenM>Length[lM],
                    lMEval=Sqrt[Sort[Abs[RGEEigenvalues[Dagger[lMInitial].lMInitial]],Greater]];
                    lM=Table[
                        If[lf==lg, If[lf<=lLenM-lIntegratedOut,lM[[lf,lg]],lMEval[[lLenM-lf+1]] ],
                            If[(lf<=lLenM-lIntegratedOut)&&(lg<=lLenM-lIntegratedOut),lM[[lf,lg]],0]
                        ],
                        {lf,lLenM},{lg,lLenM}
                    ];
                ];
                Throw[lCutoff,RGEScaleTooBig]
            ];
            lMhigh=RGEGetSolution[lCutoff,RGEM\[Nu]r,1];
            lLenM=Length[lMhigh];
            lMEval=Sqrt[Sort[Abs[RGEEigenvalues[Dagger[lMhigh].lMhigh]],Greater]];
            lM=Table[
              If[lf==lg,If[lf<=lLenM-lIntegratedOut,lM[[lf,lg]],lMEval[[lLenM-lf+1]] ],
                        If[(lf<=lLenM-lIntegratedOut)&&(lg<=lLenM-lIntegratedOut),lM[[lf,lg]],0]
              ],
              {lf,lLenM},{lg,lLenM}];
            ];
            ,RGEScaleTooBig
        ];
        Return[lM];
];

ClearAll[GetM\[Nu]];
GetM\[Nu][pScale_,pSolution_,pOpts___]:=Block[{l\[Kappa],lY\[Nu],lM,lvu},
(* returns the mass matrix of the neutrinos *)
    
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lvu=RGEv\[Nu]/.Options[lOpts];
    
    l\[Kappa] = (\[Kappa][pScale]/.pSolution)[[1]];
    If[!FreeQ[pSolution, Y\[Nu]],
      {lY\[Nu],lM}=({Y\[Nu][pScale],M\[Nu]r[pScale]}/.pSolution)[[1]];
      If[ MatrixConditionNumber[lM] > 2*Precision[lM],
        Print["GetM\[Nu]: The matrix M=", MatrixForm[lM], 
          " is ill-conditioned and the condition number is ", 
          MatrixConditionNumber[lM]]
        ];
      l\[Kappa] += 2*Transpose[lY\[Nu]].Inverse[lM].lY\[Nu];
    ];
    
    Return[-lvu^2 * (1/2)^2 * 10^9 * l\[Kappa]];
];

ClearAll[GetMu];
GetMu[pScale_,pSolution_,pOpts___]:=Block[{lMu,lvu},
(* returns the mass matrix of the up-type quarks *)
   lOpts;
   Options[lOpts]=Options[RGEOptions];
   SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
   lvu=RGEvu/.Options[lOpts];
   lMu=lvu/Sqrt[2]*(Yu[pScale]/.pSolution)[[1]];
   Return[lMu];
];

ClearAll[GetPoleMTop];
GetPoleMTop[pScale_,pSolution_,pOpts___]:=Block[{lMtop,lg3,lScale,lPrecision,lCount},
(* returns the mass matrix of the up-type quarks *)
   lPrecision=RGEPrecision/.pOpts/.RGETransition->6;
   lCountMax=RGEMaxNumberIterations/.pOpts/.RGEMaxNumberIterations->20;
   lScale=Exp[pScale];
   lg3=RGEGetSolution[lScale,RGECoupling][[3]];
   lMu=RGEGetSolution[lScale,RGEMu];
   lMtop=Re[Sqrt[Max[RGEEigenvalues[Dagger[lMu].lMu]]*(1+lg3^2/3/Pi)]];
   lCount=0;
   While[RGEFloor[Abs[lMtop-lScale],RGEPrecision->lPrecision]>0,
	lScale=lMtop;
	lg3=RGEGetSolution[lScale,RGECoupling][[3]];
	lMu=RGEGetSolution[lScale,RGEMu];
	lMtop=Re[Sqrt[Max[RGEEigenvalues[Dagger[lMu].lMu]]*(1+lg3^2/3/Pi)]];
	lCount++;
	If[lCount>lCountMax,
		Print["RGEGetsolution[pScale,RGEPoleMTop]: algorithm to search transitions does not converge. There have been ",lCount," iterations so far. Returning: ",N[Sort[lTransitions,Greater],lPrecision]];
		Return[lMtop];
            ];
	];
   Return[lMtop];
];

ClearAll[GetMd];
GetMd[pScale_,pSolution_,pOpts___]:=Block[{lMd,lvd},
(* returns the mass matrix of the down-type quarks *)
   lOpts;
   Options[lOpts]=Options[RGEOptions];
   SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
   lvd=RGEvd/.Options[lOpts];
   lMd=lvd/Sqrt[2]*(Yd[pScale]/.pSolution)[[1]];
   Return[lMd];
];

ClearAll[GetMe];
GetMe[pScale_,pSolution_,pOpts___]:=Block[{lMe,lvd},
(* returns the mass matrix of the charged leptons *)
   lOpts;
   Options[lOpts]=Options[RGEOptions];
   SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
   lvd=RGEve/.Options[lOpts];
   lMe=lvd/Sqrt[2]*(Ye[pScale]/.pSolution)[[1]];
   Return[lMe];
];

ClearAll[GetSolution];
GetSolution[pScale_,pSolution_,pOpts___]:=Block[{lPars},
(* returns all parameters of the MSSM *)
    lPars = Thread[(Head/@ ParametersFunc[t]) -> (ParametersFunc[ pScale ]/.pSolution)[[1]]];
    
    lPars = lPars /. {Rule[M\[Nu]r,_] -> Rule[M\[Nu]r, GetM\[Nu]r[pScale,pSolution,pOpts]]};
    lPars = lPars /. {Rule[Y\[Nu],_]  -> Rule[Y\[Nu], GetY\[Nu][pScale,pSolution,pOpts]]};
    lPars = lPars /. {Rule[T\[Nu],_]  -> Rule[T\[Nu], GetT\[Nu][pscale,pSolution,pOpts]]};
    Return[lPars[[All,2]]];
];

ClearAll[GetMixingParameters];
GetMixingParameters[pScale_,pSolution_,pOpts___]:=Block[{lM,lYe},
(* returns the leptonic mixing parameters *)
    lM=GetM\[Nu][pScale,pSolution,pOpts];
    lYe=GetYe[pScale,pSolution,pOpts];
    Return[MNSParameters[lM,lYe]];
];

ClearAll[GetTwistingParameters];
GetTwistingParameters[pScale_,pSolution_,pOpts___]:=Block[{lY\[Nu],lYe},
(* returns the mixing parameters of the twisting matrix between Ye^\dagger Ye and Y\nu^\dagger Y\nu *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lY\[Nu]=GetY\[Nu][pScale,pSolution,pOpts];
    lYe=GetYe[pScale,pSolution,pOpts];
    Return[MNSParameters[Dagger[lY\[Nu]].lY\[Nu],Dagger[lYe].lYe]];
];

ClearAll[GetM1Tilde];
GetM1Tilde[pScale_,pSolution_,pOpts___]:=Block[{lv,lM,lM\[Nu],lm1},
(* returns m1 Tilde *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lv=(RGEv\[Nu]/Sqrt[2])/.Options[lOpts];
    lM=(M\[Nu]r[pScale]/.pSolution)[[1]];
    lM\[Nu]=lv*(Y\[Nu][pScale]/.pSolution)[[1]];
    {lM,lM\[Nu]}=RGERotateM[lM,lM\[Nu]];
    lM\[Nu]=lM\[Nu][[1]];
    lm1=(lM\[Nu].Conjugate[lM\[Nu]])/lM[[1,1]];
    Return[RGEFloor[Re[lm1]][[1]]*10^9];
];

ClearAll[Get\[Epsilon]1Max];
Get\[Epsilon]1Max[pScale_,pSolution_,pOpts___]:=Block[{lv,lM,lm,lm1Tilde,lm1,lm2,lm3,leps},
(* returns the upper bound on the CP asymmetry for leptogenesis in type I see-saw for M1<<M2,M3 *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lv=(RGEv\[Nu]/Sqrt[2])/.Options[lOpts];
    lM=(M\[Nu]r[pScale]/.pSolution)[[1]];
    lM\[Nu]=lv*(Y\[Nu][pScale]/.pSolution)[[1]];
    {lM,lM\[Nu]}=RGERotateM[lM,lM\[Nu]];
    lm1Tilde=(lM\[Nu].Dagger[lM\[Nu]])[[1,1]]/lM[[1,1]];
    {lm1,lm2,lm3}=MNSParameters[GetM\[Nu][pScale,pSolution,pOpts],GetYe[pScale,pSolution,pOpts]][[2]]*10^-9;
    leps=3/8/\[Pi]^2* lM[[1,1]] *lm3/lv^2*(1-lm1/lm3 Sqrt[1+(lm3^2-lm1^2)/lm1Tilde^2]);
    Return[RGEFloor[Abs[leps]][[1]]];
];

ClearAll[Get\[Epsilon]1];
Get\[Epsilon]1[pScale_,pSolution_,pOpts___]:=Block[{lv,lM,lm,lY,leps},
(* returns the CP asymmetry for leptogenesis for M1<<M2,M3 *)
    If[FreeQ[pSolution, Y\[Nu]],Throw[pScale, RGEOutOfRange]];
    lOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lv=(RGEv\[Nu]/Sqrt[2])/.Options[lOpts];
    lM=(M\[Nu]r[pScale]/.pSolution)[[1]];
    lY=(Y\[Nu][pScale]/.pSolution)[[1]];
    {lM,lY}=RGERotateM[lM,lY];
    lm=GetM\[Nu][pScale,pSolution,pOpts]*10^-9;
    lY=lY[[1]];
    leps=3/8/\[Pi]*lM[[1,1]]/lv^2*Im[(lY.Conjugate[lm].lY)]/(lY.Conjugate[lY]);
    Return[leps];
];

ClearAll[GetCL5qlqq];
GetCL5qlqq[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the superpotential CL coefficient of d=5 proton decay *)
    Return[(CL5qlqq[pScale]/.pSolution)[[1]]];
];

ClearAll[GetCR5udeu];
GetCR5udeu[pScale_,pSolution_,pOpts___]:=Block[{},
(* returns the superpotential CR coefficient of d=5 proton decay *)
    Return[(CR5udeu[pScale]/.pSolution)[[1]]];
];


ClearAll[Dagger];
(*RGEvu:=N[RGEvEW*Sin[ArcTan[RGEtan\[Beta]]]];*)
RGEvu:=N[RGEvEW*RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]];
(*RGEvd:=N[RGEvEW*Cos[ArcTan[RGEtan\[Beta]]]];*)
RGEvd:=N[RGEvEW/Sqrt[1+RGEtan\[Beta]^2]];
RGEv\[Nu]:=RGEvu;
RGEve:=RGEvd;

ClearAll[Dagger];
(*shortcuts*)
Dagger[x_] := ConjugateTranspose[x];

ClearAll[GetParameters];
GetParameters[]:= Block[{},
(* returns the parameters of the model *)
   Return[ParameterSymbols];
];

ClearAll[ModelSetOptions];
ModelSetOptions[pOpts_]:= Block[{},
(* sets the options of the model *)
    SetOptions[RGEOptions,RGEFilterOptions[RGEOptions,pOpts]];
];

ClearAll[ModelGetOptions];
ModelGetOptions[]:= Block[{},
(* returns the options *)
   Return[Options[RGEOptions]];
];

ClearAll[GetInitial];
GetInitial[pOpts___]:=Block[{lSuggestion,lIndexSuggestion,lInitial,lParameters,lParameterRepl,lMINPAR={RGEm0, RGEM12, RGEA0},lReplace},
(* returns the suggested initial values *)
   lOpts;
   Options[lOpts]=Options[RGEOptions];
   SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
   lSuggestion=(RGESuggestion/.pOpts)/.{RGESuggestion->"*"};
   lIndexSuggestion=1;
   While[lIndexSuggestion<=Length[Initial] && !StringMatchQ[Initial[[lIndexSuggestion,1]],lSuggestion],	lIndexSuggestion++ ];
   lInitial=Initial[[ lIndexSuggestion,2 ]];
   lReplace=Function[{x}, FixedPoint[# /.pOpts/.lInitial/.Options[lOpts] &, x]];
   lParameters=lReplace[ParameterSymbols];
   (*/.pOpts/.lInitial/.pOpts/.lInitial/.pOpts/.lInitial/.Options[lOpts]/.lInitial/.Options[lOpts];*)
   lMINPAR=Thread[lMINPAR -> lReplace[lMINPAR]];
   Return[Join[
    Table[ParameterSymbols[[li]]->lParameters[[li]], {li,Length[ParameterSymbols]}],
    lMINPAR
  ]];
];

TimingTrace[msg_:""] := (Print[msg,": ",#[[1]]];#[[2]])&

ClearAll[SolveModel];
SolveModel[{pUp_?NumericQ,pUpModel_,pUpOptions_},{pDown_?NumericQ,pDownModel_,pDownOptions_},pDirection_?NumericQ,pBoundary_?NumericQ,pInitial_,pNDSolveOpts_,pOpts___]:=Block[{
        lSolution, (* contains the solution *)
        lInitial, (* initial values in the format needed by NDSolve *)
        lODE, (* RGE and lInitial *)
        lAddedModels, (* number of added models *)
        lIntegratedOut, (* # of neutrinos integrated out *)
        lAlreadyIntegratedOut, (* # of neutrinos already integrated out *)
        lTransition, (* transition to be added *)
        lIndexModel, (* variant of the model *)
        lM,lY,l\[Kappa],lT,lm2\[Nu], (* needed for check of too high masses *)
        lAnyRemainingRHNeutrinos,lParameters,
        lDownGuess
    },
    (* solves the model; returns the solution, the new scale and the number of added models *)
    (* exceptions: too many iterations --> RGETooManyIterations
                   \[Nu] mass above cutoff --> RGE\[Nu]MassAboveCutoff 
    *)
    (* solve differential equation *)
    lOpts;
    lAddModelOpts;
    Options[lOpts]=Options[RGEOptions];
    SetOptions[lOpts,RGEFilterOptions[lOpts,pOpts]];
    lLogThresholdFactor=Log[(RGEThresholdFactor/.Options[lOpts,RGEThresholdFactor])];
    lInitial;
    (*Print["Initial: ",pInitial];*)
    (*Print["Boundary: ",pBoundary //Exp //N];*)
    Options[lInitial]=pInitial;
    lDownGuess = pDown;

    (* If there are RH neutrinos check whether some have masses above the current boundary scale *)
    If[Length[(RGEM\[Nu]r/.pInitial)]>0,
        {lM,lY,l\[Kappa],lT,lm2\[Nu]}={RGEM\[Nu]r,RGEY\[Nu],RGE\[Kappa],RGET\[Nu],RGEm2\[Nu]}/.pInitial;
        If[(RGESearchTransition/.Options[lOpts,RGESearchTransition]), (*CHECK THIS LINE: inverted condition*)
            {lM, lY, lT, lm2\[Nu]} = RotateRHNeutrinos[
              lM, lY, lT, lm2\[Nu]
            ];
            lDownGuess = With[{Mmax = Max[Abs@Diagonal[lM]]},
              Max[
                Log[Mmax] - 2 Abs[4 Norm[lY, "Frobenius"]^2 / (16 Pi^2) Log[Exp[pUp]/Mmax]],
                lDownGuess
              ]
            ];
            lIntegratedOut = Length[Select[Abs@Diagonal[lM], #1 > Exp[lLogThresholdFactor+pBoundary]&]];
            If[lIntegratedOut>0,
                Print[
                  "Warning: ",lIntegratedOut, " right-handed neutrinos have a mass above ", 
                  Exp[pBoundary], " GeV (",
                  Select[
                    Abs@Diagonal[lM],
                    (#1 > Exp[pBoundary]) &
                  ],"). Thus they have been integrated out."
                ];
                l\[Kappa] += RGEKappaMatching[lM,lY,lIntegratedOut];
                lY = RGEIntegrateOutY\[Nu][lY,lIntegratedOut];
                lT = RGEIntegrateOutY\[Nu][lT,lIntegratedOut];
                lM = RGEIntegrateOutM[lM, lIntegratedOut];
                lm2\[Nu] = RGEIntegrateOutM[lm2\[Nu], lIntegratedOut];

                SetOptions[
                  lOpts,
                  RGEIntegratedOut->(
                    ((RGEIntegratedOut/.Options[lOpts,RGEIntegratedOut])/.{RGEIntegratedOut->0})
                    + lIntegratedOut
                  )
                ];
                SetOptions[
                  lInitial,
                  RGE\[Kappa]->l\[Kappa],
                  RGEY\[Nu]->lY,RGET\[Nu]->lT,
                  RGEm2\[Nu]->lm2\[Nu],RGEM\[Nu]r->lM
                ];
                RGEChangeOptions[
                  Exp[pBoundary],
                  RGEIntegratedOut->(RGEIntegratedOut/.Options[lOpts,RGEIntegratedOut])
                ];
            ];
        ];
    ];
    
    lAnyRemainingRHNeutrinos = Length[RGEM\[Nu]r/.Options[lInitial]] > 0;
    
    lNDSolveOpts;
    Options[lNDSolveOpts]=Options[NDSolve];
    SetOptions[lNDSolveOpts,RGEFilterOptions[NDSolve,Options[RGEOptions]]];
    SetOptions[lNDSolveOpts,RGEFilterOptions[NDSolve,pOpts]];
    SetOptions[lNDSolveOpts,RGEFilterOptions[NDSolve,Sequence[pNDSolveOpts]]];
    
    lInitial=SetInitial[pBoundary,Options[lInitial]];
    lParameters=Parameters;
    lIndexModel=Flatten[ Position[ModelVariants,(RGEModelVariant/.Options[lOpts])] ][[ 1 ]];
    If[!lAnyRemainingRHNeutrinos && Mod[lIndexModel, 2] == 1,
      (* increment the model index, since after the ordinary nLoop comes the 0N nLoop RGEs *)
      lIndexModel += 1
    ];
    lODE=RGE[
      RGEForce1Loop /. Options[lOpts],
      lIndexModel
    ] /. Options[lOpts];
    
    If[!lAnyRemainingRHNeutrinos,
      lInitial=Select[lInitial, FreeQ[#[[1]], Y\[Nu][_] | T\[Nu][_] | m2\[Nu][_] | M\[Nu]r[_]] &];
      lParameters=Select[lParameters, FreeQ[#, Y\[Nu] | T\[Nu] | m2\[Nu] | M\[Nu]r] &];
    ];
    
    (*Print["Initial: ",lInitial];
    Print[lODE[[All,2]] /. (lInitial /. f_[pBoundary] == x_ :> f[t] -> x)];
    Print[{lODE[[All,1]], lParameters} // TableForm];*)

    (*Print["Running boundaries: ", {lDownGuess,pDown,pUp}//Exp//N];*)
    lSolution=NDSolve[
      lODE ~Join~ lInitial, lParameters,
      {t, lDownGuess, pUp},
      Sequence[Options[lNDSolveOpts]]
    ] (*// Timing // TimingTrace["NDSolve"]*);
    

    (* If there are no remaining RH neutrinos, no need to search for transitions *)
    If[!lAnyRemainingRHNeutrinos,
      lThreshold=pDown;
      lAddedModels=0;
      (*Check that there are no tachyons*)
	If[STCTachyonConstraints/.Options[lFromOpts,STCTachyonConstraints],
	(*Print["Check for tachyons..."];*)
	TachyonFree[(m2Q /. lSolution)[[1]], (m2u /. lSolution)[[1]], (m2d /. lSolution)[[1]], (m2L /. lSolution)[[1]], (m2e /. lSolution)[[1]], pDown, pUp]
	];



      (* Instead search for the SM transition *)
      If[STCSearchSMTransition/.Options[lOpts,STCSearchSMTransition],
	(*Print["Calculate SUSY scale..."];*)
	If[NumericQ[STCSusyScale /. Options[lOpts,STCSusyScale] ],
		If[(STCSusyScale /. Options[lOpts,STCSusyScale] )<0,Throw[STCSusyScale /. Options[lOpts,STCSusyScale],RGELessThanZero]];		
		lTransition = Log[STCSusyScale /. Options[lOpts,STCSusyScale] ],
		lTransition = Catch[Log @ SUSYScale[
        	  (m2Q /. lSolution)[[1]], (m2u /. lSolution)[[1]], (Tu /. lSolution)[[1]], 
        	  (Yu /. lSolution)[[1]], (Yd /. lSolution)[[1]], (g1 /. lSolution)[[1]], (g2 /. lSolution)[[1]], 
        	  ArcTan[RGEtan\[Beta] /. Options[lOpts,RGEtan\[Beta]]], 
        	  (m2Hd /. lSolution)[[1]], (m2Hu /. lSolution)[[1]], 
        	  STCsign\[Mu] /. Options[lOpts,STCsign\[Mu]], STCSusyScaleFromStops /. Options[lOpts,STCSusyScaleFromStops]
        	]]
	];
	(*Print["finished..."];*)
	If[NumericQ[lTransition] && lTransition < pDown,
		gSUSYScale = None;
		gSUSYSpectrum = None;
		gSCKMvalues = None;
		gOneLoopValues = None;
		ginternalValues = None;
		gVCKM = None;
		gVPMNS = None
	];
 	If[NumericQ[lTransition] && lTransition >= pDown, 
          Switch[pDownModel, 
            "" | "SM0N", (* no model or SM0N below us defined *)
            lThreshold = lTransition;
            Options[lAddModelOpts]=RGEFilterOptions[RGEOptions,pOpts];
            SetOptions[
              lAddModelOpts,
              RGEFilterOptions[lAddModelOpts, RGEAutoGenerated->True]
            ];
            RGEAddEFT[
              "SM0N",
              RGECutoff->Exp[lTransition],
              RGEFilterOptions[RGEOptions, Options[lAddModelOpts]]
            ];
            lAddedModels++;
            ,
            _, (* something unknown defined below us *)
            Print["Automatic matching of MSSM to ", pDownModel, " not implemented"]; Abort[];
          ];
        ],
	(*Without matching to the SM, susy spectrum is not calculated... therefore reset spectrum left from previous call*)
	gSUSYScale = None;
	gSUSYSpectrum = None;
	gSCKMvalues = None;
	gOneLoopValues = None;
	ginternalValues = None;
	gVCKM = None;
	gVPMNS = None
      ];
      Return[{lSolution,lThreshold,lAddedModels}]
    ];

    (* search transitions *)
    lAddedModels=0;
    lAlreadyIntegratedOut=RGEIntegratedOut/.Options[lOpts,RGEIntegratedOut] /. {RGEIntegratedOut->0};
    lPrecision=RGEPrecision/.Options[lOpts,RGEPrecision];
    lIntegratedOut=0;
    (* check whether transitions should not be searched for *)
    If[!(RGESearchTransition/.Options[lOpts,RGESearchTransition]),
      Return[{lSolution,pDown,lAddedModels}]
    ];
    lDownOpts;
    If[pDownModel!="",
        Options[lDownOpts]=RGEGetModelOptions[pDownModel][[1,2]],
        Options[lDownOpts]={RGEIntegratedOut->0}
    ];
    SetOptions[lDownOpts,RGEFilterOptions[lDownOpts,pDownOptions]];
    (* check whether there can not be any transitions *)
    lLengthM\[Nu]=Length[(M\[Nu]r[pUp]/.lSolution)[[1]] ];

    (* If the model below us already differs by one in the number of integrated out RH neutrinos, 
        there is no need to re-find that transition *)
    If[pDownModel==ModelName && 
      (RGEIntegratedOut/.Options[lDownOpts,RGEIntegratedOut])
        - (RGEIntegratedOut/.Options[lOpts,RGEIntegratedOut]) <= 1,
      Return[{lSolution,pDown,lAddedModels}]
    ];
    
    lMTransitions=RGESearchTransitions[
      (GetRawM\[Nu]r[#1,lSolution])&,pUp,pUp,pDown,Sequence[Options[lOpts]]
    ];
    (*Print["\[Nu] Transitions: ", lMTransitions // Exp];*)
    
    If[Length[lMTransitions]>0,
        lThreshold=N[lLogThresholdFactor+Max[lMTransitions],lPrecision];
        lMTransitions=N[(Select[lMTransitions,(#1>=lThreshold)&])+lLogThresholdFactor,lPrecision];
        While[Length[lMTransitions]>0,
            lTransition=First[lMTransitions];
            lDegeneracy=Length[Select[lMTransitions,(Chop[#1-lTransition,10^(-lPrecision)]==0)&]];
            lMTransitions=Sort[Select[
              lMTransitions,
              (Chop[#1-lTransition,10^(-lPrecision)]!=0)&
            ],Greater];
            lIntegratedOut+=lDegeneracy;
            Options[lAddModelOpts]=RGEFilterOptions[RGEOptions,pOpts];
            SetOptions[
              lAddModelOpts,
              RGEFilterOptions[lAddModelOpts,
                RGEIntegratedOut->lIntegratedOut+lAlreadyIntegratedOut,
                RGEAutoGenerated->True]
            ];
            Options[lAddModelOpts]=Options[lAddModelOpts]~Union~{
              RGEIntegratedOut->lIntegratedOut+lAlreadyIntegratedOut,RGEAutoGenerated->True
            };
            RGEAddEFT[
              ModelName,
              RGECutoff->Exp[lTransition],
              RGEFilterOptions[RGEOptions,Options[lAddModelOpts]]
            ];
            lAddedModels++;
        ],
        lThreshold=pDown;
    ];

    Return[{lSolution,lThreshold,lAddedModels}];
];

  


                      
Parameters={g1,g2,g3,Yu,Yd,Ye,Y\[Nu],\[Kappa],M\[Nu]r,Tu,Td,Te,T\[Nu],M1,M2,M3,m2Q,m2L,m2u,m2d,m2e,m2\[Nu],m2Hd,m2Hu,CL5qlqq,CR5udeu,Id3};

ParameterSymbols={RGEg1,RGEg2,RGEg3,RGEYu,RGEYd,RGEYe,RGEY\[Nu],RGE\[Kappa],RGEM\[Nu]r,RGETu,RGETd,RGETe,RGET\[Nu],RGEM1,RGEM2,RGEM3,RGEm2Q,RGEm2L,RGEm2u,RGEm2d,RGEm2e,RGEm2\[Nu],RGEm2Hd,RGEm2Hu,RGECL5qlqq,RGECR5udeu,Id3};

ClearAll[Initial, IdentityMatrixSameFormAs, MatrixMultiply];
(* 
  The following two functions are necessary because Mathematica tends to simplify "0 x",
  where "x" is a symbol, to 0 without any regard to matrix structure, messing up the 
  initial conditions for matrix-valued quantities.
  Using these functions ensures that e.g. the multiplication is only performed when the
  matrix nature is explicit.
*)
IdentityMatrixSameFormAs[x_?MatrixQ] := IdentityMatrix[Dimensions[x]]
MatrixMultiply[x_?NumericQ, m_?MatrixQ] := x m
  
Initial={
{"GUT",{
	RGEg1->0.7044110331165641,
	RGEg2->0.6965468498179075,
	RGEg3->0.6983661130877465,
	RGEYd->RGEGetYd[RGEyd,RGEys,RGEyb,RGEq\[Theta]12,RGEq\[Theta]13,RGEq\[Theta]23,RGEq\[Delta],RGEq\[Delta]e,RGEq\[Delta]\[Mu],RGEq\[Delta]\[Tau],RGEq\[CurlyPhi]1,RGEq\[CurlyPhi]2],
	RGEYu->DiagonalMatrix[{RGEyu,RGEyc,RGEyt}],
	RGE\[Kappa]->0*IdentityMatrix[3],
	RGEM\[Nu]r->RGEGetM[RGE\[Theta]12,RGE\[Theta]13,RGE\[Theta]23,RGE\[Delta],RGE\[Delta]e,RGE\[Delta]\[Mu],RGE\[Delta]\[Tau],RGE\[CurlyPhi]1,RGE\[CurlyPhi]2,RGEMlightest,RGE\[CapitalDelta]m2atm,RGE\[CapitalDelta]m2sol,RGEMassHierarchy,RGEvu,RGEY\[Nu]],
	RGEq\[Theta]12 -> 12.651 Degree,
	RGEq\[Theta]13 -> 0.147249 Degree, 
	RGEq\[Theta]23 -> 1.82387 Degree,
	RGEq\[Delta] -> 69.4 Degree,
	RGEq\[CurlyPhi]1 -> 0 Degree,
	RGEq\[CurlyPhi]2 -> 0 Degree, 
	RGEq\[Delta]e -> 0 Degree,
	RGEq\[Delta]\[Mu] -> 0 Degree,
	RGEq\[Delta]\[Tau] -> 0 Degree,
	RGEMassHierarchy -> "n",
	RGE\[Theta]12 -> 33.57 Degree,
	RGE\[Theta]13 -> 8.75 Degree, 
	RGE\[Theta]23 -> 41.4 Degree,
	RGE\[Delta] -> 0 Degree,
	RGE\[Delta]e -> 0 Degree,
	RGE\[Delta]\[Mu] -> 0 Degree,
	RGE\[Delta]\[Tau] -> 0 Degree,
	RGE\[CurlyPhi]1 -> 0 Degree,
	RGE\[CurlyPhi]2 -> 0 Degree, 
	RGEMlightest -> 0.02,
	RGE\[CapitalDelta]m2atm -> 4*10^-3,
	RGE\[CapitalDelta]m2sol -> 1.6 10^-4,
	RGEY\[Nu]33 -> 0.5,
	RGEY\[Nu]Ratio -> 0.1,
	RGEY\[Nu]->RGEGetY\[Nu][RGEY\[Nu]33,RGEY\[Nu]Ratio],
	RGEYe->DiagonalMatrix[{RGEye,RGEy\[Mu],RGEy\[Tau]}],
	RGEyu -> 0.00104/RGEvu*Sqrt[2],
	RGEyc -> 0.302/RGEvu*Sqrt[2],
	RGEyt -> 129/RGEvu*Sqrt[2],
	RGEyd -> 0.00133/RGEvd*Sqrt[2],
	RGEys -> 0.0265/RGEvd*Sqrt[2],
	RGEyb -> 1.00/RGEvd*Sqrt[2],
	RGEye -> 0.32502032*10^-3*Sqrt[2]/RGEve,
	RGEy\[Mu] -> 68.59813*10^-3*Sqrt[2]/RGEve,
	RGEy\[Tau] -> 1171.4*10^-3*Sqrt[2]/RGEve,
	RGETu-> MatrixMultiply[RGEA0, RGEYu],
	RGETd-> MatrixMultiply[RGEA0, RGEYd],
	RGETe-> MatrixMultiply[RGEA0, RGEYe],
	RGET\[Nu]-> MatrixMultiply[RGEA0, RGEY\[Nu]],
	RGEM1->RGEM12,
	RGEM2->RGEM12,
	RGEM3->RGEM12,
	RGEm2Q->MatrixMultiply[RGEm0^2, IdentityMatrix[3]],
	RGEm2L->MatrixMultiply[RGEm0^2, IdentityMatrix[3]],
	RGEm2u->MatrixMultiply[RGEm0^2, IdentityMatrix[3]],
	RGEm2d->MatrixMultiply[RGEm0^2, IdentityMatrix[3]],
	RGEm2e->MatrixMultiply[RGEm0^2, IdentityMatrix[3]],
	RGEm2\[Nu]->MatrixMultiply[RGEm0^2, IdentityMatrixSameFormAs[RGEM\[Nu]r]],
	RGEm2Hd->RGEm0^2,
	RGEm2Hu->RGEm0^2,
	RGEA0 -> -500,
	RGEM12 -> 750,
	RGEm0 -> 1500,
	RGECL5qlqq -> Normal[SparseArray[{},{3,3,3,3}]],
	RGECR5udeu -> Normal[SparseArray[{},{3,3,3,3}]]
}
},
{"MZ",{
	RGE\[Kappa] -> 0*IdentityMatrix[3], 
	RGEYe->DiagonalMatrix[{RGEye,RGEy\[Mu],RGEy\[Tau]}],
	RGEY\[Nu]33 -> 0.1,
	RGEY\[Nu]Ratio -> 0.5,
	RGEY\[Nu]->RGEGetY\[Nu][RGEY\[Nu]33,RGEY\[Nu]Ratio],
	RGEM\[Nu]r->RGEGetM[RGE\[Theta]12,RGE\[Theta]13,RGE\[Theta]23,RGE\[Delta],RGE\[Delta]e,RGE\[Delta]\[Mu],RGE\[Delta]\[Tau],RGE\[CurlyPhi]1,RGE\[CurlyPhi]2,RGEMlightest,RGE\[CapitalDelta]m2atm,RGE\[CapitalDelta]m2sol,RGEMassHierarchy,RGEvu,RGEY\[Nu]],
	RGEg1 -> RGEgMZ[1],
	RGEg2 -> RGEgMZ[2],
	RGEg3 -> RGEgMZ[3],
	RGE\[Lambda] -> 0.5,
	RGEYd->RGEGetYd[RGEyd,RGEys,RGEyb,RGEq\[Theta]12,RGEq\[Theta]13,RGEq\[Theta]23,RGEq\[Delta],RGEq\[Delta]e,RGEq\[Delta]\[Mu],RGEq\[Delta]\[Tau],RGEq\[CurlyPhi]1,RGEq\[CurlyPhi]2],
	RGEYu->DiagonalMatrix[{RGEyu,RGEyc,RGEyt}],
	RGEq\[Theta]12 -> 12.7652 Degree, 
	RGEq\[Theta]13 -> 0.170675 Degree,
	RGEq\[Theta]23 -> 2.14069 Degree,
	RGEq\[Delta] -> 69.4 Degree,
	RGEq\[CurlyPhi]1 -> 0 Degree,
	RGEq\[CurlyPhi]2 -> 0 Degree,
	RGEq\[Delta]e -> 0 Degree,
	RGEq\[Delta]\[Mu] -> 0 Degree,
	RGEq\[Delta]\[Tau] -> 0 Degree,
	RGEyu -> 2.33*10^-3*Sqrt[2]/RGEvu,
	RGEyc -> 0.677*Sqrt[2]/RGEvu,
	RGEyt -> 172.7*Sqrt[2]/RGEvu,
	RGEyd -> 4.69*10^-3*Sqrt[2]/RGEvd,
	RGEys -> 93.4*10^-3*Sqrt[2]/RGEvd,
	RGEyb -> 3.00*Sqrt[2]/RGEvd,
	RGEye -> 0.48684727*10^-3*Sqrt[2]/RGEve,
	RGEy\[Mu] -> 0.10275138*Sqrt[2]/RGEve,
	RGEy\[Tau] -> 1.7467*Sqrt[2]/RGEve,
	RGEMassHierarchy -> "n",
	RGE\[Theta]12 -> 33 Degree,
	RGE\[Theta]13 -> 0 Degree, 
	RGE\[Theta]23 -> 45 Degree,
	RGE\[Delta] -> 0 Degree,
	RGE\[Delta]e -> 0 Degree,
	RGE\[Delta]\[Mu] -> 0 Degree,
	RGE\[Delta]\[Tau] -> 0 Degree,
	RGE\[CurlyPhi]1 -> 0 Degree,
	RGE\[CurlyPhi]2 -> 0 Degree, 
	RGEMlightest -> 0.05,
	RGE\[CapitalDelta]m2atm -> 2.4 10^-3, 
	RGE\[CapitalDelta]m2sol -> 7.45 10^-5,
	RGETd->10^3*RGEYd,
	RGETu->10^3*RGEYu,
	RGETe->10^3*RGEYe,
	RGET\[Nu]->10^3*RGEY\[Nu],
	RGEM1->10^3,
	RGEM2->10^3,
	RGEM3->10^3,
	RGEm2Q->10^6*IdentityMatrix[3],
	RGEm2L->10^6*IdentityMatrix[3],
	RGEm2u->10^6*IdentityMatrix[3],
	RGEm2d->10^6*IdentityMatrix[3],
	RGEm2e->10^6*IdentityMatrix[3],
	RGEm2\[Nu]->10^6*IdentityMatrix[3],
	RGEm2Hd->10^6,
	RGEm2Hu->10^6,
	RGECL5qlqq -> Normal[SparseArray[{},{3,3,3,3}]],
	RGECR5udeu -> Normal[SparseArray[{},{3,3,3,3}]]
	}
}
}; (* a list containing suggestions for initial values *)



ClearAll[RGE1Loop];
RGE1Loop[_] := RGE1Loop[_] = With[{
        W = {g1[t],g2[t],g3[t],Yu[t],Yd[t],Ye[t],Y\[Nu][t],\[Kappa][t],M\[Nu]r[t]}, 
        Lsoft = {
          Tu[t],Td[t],Te[t],T\[Nu][t],
          M1[t],M2[t],M3[t],
          m2Q[t],m2L[t],m2u[t],m2d[t],m2e[t],m2\[Nu][t],m2Hd[t],m2Hu[t],Id3[t]
        }
    },
    {
        D[g1[t],t]          == Betag1 @@ W,
        D[g2[t],t]          == Betag2 @@ W,
        D[g3[t],t]          == Betag3 @@ W,
        D[Yu[t],t]          == BetaYu @@ W,
        D[Yd[t],t]          == BetaYd @@ W,
        D[Ye[t],t]          == BetaYe @@ W,
        D[Y\[Nu][t],t]          == BetaY\[Nu] @@ W,
        D[\[Kappa][t],t]           == Beta\[Kappa] @@ W,
        D[M\[Nu]r[t],t]         == BetaM\[Nu]r @@ W,
      
        D[Tu[t],t]          == BetaTu @@ Join[W, Lsoft],
        D[Td[t],t]          == BetaTd @@ Join[W, Lsoft],
        D[Te[t],t]          == BetaTe @@ Join[W, Lsoft],
        D[T\[Nu][t],t]          == BetaT\[Nu] @@ Join[W, Lsoft],
        D[M1[t],t]          == BetaM1 @@ Join[W, Lsoft],
        D[M2[t],t]          == BetaM2 @@ Join[W, Lsoft],
        D[M3[t],t]          == BetaM3 @@ Join[W, Lsoft],
        D[m2Q[t],t]         == Betam2Q @@ Join[W, Lsoft],
        D[m2L[t],t]         == Betam2L @@ Join[W, Lsoft],
        D[m2u[t],t]         == Betam2u @@ Join[W, Lsoft],
        D[m2d[t],t]         == Betam2d @@ Join[W, Lsoft],
        D[m2e[t],t]         == Betam2e @@ Join[W, Lsoft],
        D[m2\[Nu][t],t]         == Betam2\[Nu] @@ Join[W, Lsoft],
        D[m2Hd[t],t]        == Betam2Hd @@ Join[W, Lsoft],
        D[m2Hu[t],t]        == Betam2Hu @@ Join[W, Lsoft],
        
        D[Id3[t],t]         == 0 IdentityMatrix[3]
        (* Identity matrix for three generations is needed as extra parameter to make RGEs fully symbolic *)
        (* Due to the form of the m2\[Nu] beta function, no extra IdN for them is needed *)
    } /. (BetaTraces @@ Join[W, Lsoft])
]; (* renormalization group equations of the MSSM ( 1 Loop ) *)


ClearAll[RGE1LoopProton];
RGE1LoopProton[_] := RGE1LoopProton[_] = With[{
        W = {g1[t],g2[t],g3[t],Yu[t],Yd[t],Ye[t],Y\[Nu][t],\[Kappa][t],M\[Nu]r[t]}, 
        Lsoft = {
          Tu[t],Td[t],Te[t],T\[Nu][t],
          M1[t],M2[t],M3[t],
          m2Q[t],m2L[t],m2u[t],m2d[t],m2e[t],m2\[Nu][t],m2Hd[t],m2Hu[t],Id3[t]
        },
        Wnonrenormalizable={CL5qlqq[t],CR5udeu[t]}
    },
    {
        D[g1[t],t]          == Betag1 @@ W,
        D[g2[t],t]          == Betag2 @@ W,
        D[g3[t],t]          == Betag3 @@ W,
        D[Yu[t],t]          == BetaYu @@ W,
        D[Yd[t],t]          == BetaYd @@ W,
        D[Ye[t],t]          == BetaYe @@ W,
        D[Y\[Nu][t],t]          == BetaY\[Nu] @@ W,
        D[\[Kappa][t],t]           == Beta\[Kappa] @@ W,
        D[M\[Nu]r[t],t]         == BetaM\[Nu]r @@ W,
      
        D[Tu[t],t]          == BetaTu @@ Join[W, Lsoft],
        D[Td[t],t]          == BetaTd @@ Join[W, Lsoft],
        D[Te[t],t]          == BetaTe @@ Join[W, Lsoft],
        D[T\[Nu][t],t]          == BetaT\[Nu] @@ Join[W, Lsoft],
        D[M1[t],t]          == BetaM1 @@ Join[W, Lsoft],
        D[M2[t],t]          == BetaM2 @@ Join[W, Lsoft],
        D[M3[t],t]          == BetaM3 @@ Join[W, Lsoft],
        D[m2Q[t],t]         == Betam2Q @@ Join[W, Lsoft],
        D[m2L[t],t]         == Betam2L @@ Join[W, Lsoft],
        D[m2u[t],t]         == Betam2u @@ Join[W, Lsoft],
        D[m2d[t],t]         == Betam2d @@ Join[W, Lsoft],
        D[m2e[t],t]         == Betam2e @@ Join[W, Lsoft],
        D[m2\[Nu][t],t]         == Betam2\[Nu] @@ Join[W, Lsoft],
        D[m2Hd[t],t]        == Betam2Hd @@ Join[W, Lsoft],
        D[m2Hu[t],t]        == Betam2Hu @@ Join[W, Lsoft],
        D[CL5qlqq[t],t]     == BetaCL5qlqq @@ Join[W, Wnonrenormalizable],
        D[CR5udeu[t],t]     == BetaCR5udeu @@ Join[W, Wnonrenormalizable],
        
        D[Id3[t],t]         == 0 IdentityMatrix[3]
        (* Identity matrix for three generations is needed as extra parameter to make RGEs fully symbolic *)
        (* Due to the form of the m2\[Nu] beta function, no extra IdN for them is needed *)
    } /. (BetaTraces @@ Join[W, Lsoft])
]; (* renormalization group equations of the MSSM ( 1 Loop ) *)
(* Beta traces puts in the trace of the spread, no need to redefine it *)


(* Beta functions of the MSSM *)
ClearAll[Betag1, Betag2, Betag3, BetaYu, BetaYd, BetaYe, BetaY\[Nu], Beta\[Kappa], BetaM\[Nu]r]; 
ClearAll[BetaTu, BetaTd, BetaTe, BetaT\[Nu], BetaM1, BetaM2, BetaM3, Betam2Q, Betam2L, Betam2u, Betam2d, Betam2e, Betam2\[Nu], Betam2Hd, Betam2Hu, BetaTraces];

(* Clear proton decay parameters *)
ClearAll[contract,BetaCL5qlqq,BetaCR5udeu];


(* 1 loop contributions *)

(* SUSY conserving parameters *)

Betag1[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=
	(33/5) * 1/(16*Pi^2) * g1^3;

Betag2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=
	(1) * 1/(16*Pi^2) * g2^3;

Betag3[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=
	(-3) * 1/(16*Pi^2) * g3^3;


BetaYd[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(16*Pi^2) * (
    Yd.(
      + 3*Dagger[Yd].Yd
      + Dagger[Yu].Yu
    )
    + (
      - (7/15)*g1^2
      - 3*g2^2
      - (16/3)*g3^2
      + 3*Tr[Dagger[Yd].Yd]
      + Tr[Dagger[Ye].Ye]
    )*Yd
  );

BetaYu[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(16*Pi^2) * (
          Yu.(
          + Dagger[Yd].Yd
	  + 3*Dagger[Yu].Yu
          )
          + (
          - (13/15)*g1^2
	  - 3*g2^2
	  - (16/3)*g3^2
	  + Tr[Dagger[Y\[Nu]].Y\[Nu]]
	  + 3*Tr[Dagger[Yu].Yu]
          )*Yu
          );

BetaYe[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(16*Pi^2) * (
          Ye.(
          + 3*Dagger[Ye].Ye
	  + Dagger[Y\[Nu]].Y\[Nu]
          )
          + (
          - (9/5)*g1^2
	  - 3*g2^2
	  + 3*Tr[Dagger[Yd].Yd]
	  + Tr[Dagger[Ye].Ye]
          )*Ye
          );

BetaY\[Nu][g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(16*Pi^2) * (
          Y\[Nu].(
          + Dagger[Ye].Ye
	  + 3*Dagger[Y\[Nu]].Y\[Nu]
          )
          + (
          - (3/5)*g1^2
	  - 3*g2^2
	  + Tr[Dagger[Y\[Nu]].Y\[Nu]]
	  + 3*Tr[Dagger[Yu].Yu]
          )*Y\[Nu]
          );

Beta\[Kappa][g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=1/(16*Pi^2) * (
	\[Kappa].(
        + Dagger[Ye].Ye
        + Dagger[Y\[Nu]].Y\[Nu]
        )
	+ (
        + Transpose[Ye].Conjugate[Ye]
	+ Transpose[Y\[Nu]].Conjugate[Y\[Nu]]
        ).\[Kappa]
        + (
	- (6/5)*g1^2
	- 6*g2^2
	+ 6*Tr[Dagger[Yu].Yu]
        + 2*Tr[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ger[Y\[Nu]].T\[Nu]]
        + 26/15 g1^2 M1
        + 6 g2^2 M2
        + 32/3 g3^2 M3
    )
    + Tu . (
        + Dagger[Yd].Yd
        + 5 Dagger[Yu].Yu
    )
    + Tu * (
        + 3 Tr[Dagger[Yu].Yu]
        + Tr[Dagger[Y\[Nu]].Y\[Nu]]
        - 13/15 g1^2
        - 3 g2^2
        - 16/3 g3^2
    )
);

BetaTd[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + Yd . (
        + 4 Dagger[Yd].Td
        + 2 Dagger[Yu].Tu
    )
    + Yd * (
        + 6 Tr[Dagger[Yd].Td]
        + 2 Tr[Dagger[Ye].Te]
        + 14/15 g1^2 M1
        + 6 g2^2 M2
        + 32/3 g3^2 M3
    )
    + Td . (
        + 5 Dagger[Yd].Yd
        + Dagger[Yu].Yu
    )
    + Td * (
        + 3 Tr[Dagger[Yd].Yd]
        + Tr[Dagger[Ye].Ye]
        - 7/15 g1^2
        - 3 g2^2
        - 16/3 g3^2
    ) 
);

BetaTe[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + Ye . (
        + 4 Dagger[Ye].Te
        + 2 Dagger[Y\[Nu]].T\[Nu]
    )
    + Ye * (
        + 6 Tr[Dagger[Yd].Td]
        + 2 Tr[Dagger[Ye].Te]
        + 18/5 g1^2 M1
        + 6 g2^2 M2
    )
    + Te . (
        + 5 Dagger[Ye].Ye
        + Dagger[Y\[Nu]].Y\[Nu]
    )
    + Te * (
        + 3 Tr[Dagger[Yd].Yd]
        + Tr[Dagger[Ye].Ye]
        - 9/5 g1^2
        - 3 g2^2
    ) 
);

BetaT\[Nu][g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + Y\[Nu] . (
        + 4 Dagger[Y\[Nu]].T\[Nu]
        + 2 Dagger[Ye].Te
    )
    + Y\[Nu] * (
        + 6 Tr[Dagger[Yu].Tu]
        + 2 Tr[Dagger[Y\[Nu]].T\[Nu]]
        + 6/5 g1^2 M1
        + 6 g2^2 M2
    )
    + T\[Nu] . (
        + 5 Dagger[Y\[Nu]].Y\[Nu]
        + Dagger[Ye].Ye
    )
    + T\[Nu] * (
        + 3 Tr[Dagger[Yu].Yu]
        + Tr[Dagger[Y\[Nu]].Y\[Nu]]
        - 3/5 g1^2
        - 3 g2^2
    ) 
);

BetaTraces[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] := {
  S -> m2Hu - m2Hd + Tr[m2Q] - Tr[m2L] + Tr[m2d] + Tr[m2e] - 2 Tr[m2u]
}

Betam2L[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 2 Dagger[Ye].m2e.Ye
    + 2 Dagger[Y\[Nu]].m2\[Nu].Y\[Nu]
    + m2L.Dagger[Ye].Ye
    + m2L.Dagger[Y\[Nu]].Y\[Nu]
    + Dagger[Ye].Ye.m2L
    + Dagger[Y\[Nu]].Y\[Nu].m2L
    
    + 2 m2Hu Dagger[Y\[Nu]].Y\[Nu]
    + 2 m2Hd Dagger[Ye].Ye
      
    + 2 Dagger[Te].Te
    + 2 Dagger[T\[Nu]].T\[Nu]
      
    - 6/5 g1^2 M1 Conjugate[M1] Id3
    - 6 g2^2 M2 Conjugate[M2] Id3
    - 3/5 g1^2 S Id3
);

Betam2Q[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 2 Dagger[Yu].m2u.Yu
    + 2 Dagger[Yd].m2d.Yd
    + m2Q.Dagger[Yu].Yu
    + m2Q.Dagger[Yd].Yd
    + Dagger[Yu].Yu.m2Q
    + Dagger[Yd].Yd.m2Q
      
    + 2 m2Hu Dagger[Yu].Yu
    + 2 m2Hd Dagger[Yd].Yd
      
    + 2 Dagger[Tu].Tu
    + 2 Dagger[Td].Td
    
    - 2/15 g1^2 M1 Conjugate[M1] Id3
    - 6 g2^2 M2 Conjugate[M2] Id3
    - 32/3 g3^2 M3 Conjugate[M3] Id3
    + 1/5 g1^2 S Id3
);

Betam2u[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 4 Yu.m2Q.Dagger[Yu]
    + 2 Yu.Dagger[Yu].m2u
    + 2 m2u.Yu.Dagger[Yu]
    
    + 4 m2Hu Yu.Dagger[Yu]
      
    + 4 Tu.Dagger[Tu]
    
    - 32/15 g1^2 M1 Conjugate[M1] Id3
    - 32/3 g3^2 M3 Conjugate[M3] Id3
    - 4/5 g1^2 S Id3
);
    
Betam2d[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 4 Yd.m2Q.Dagger[Yd]
    + 2 Yd.Dagger[Yd].m2d
    + 2 m2d.Yd.Dagger[Yd]
    
    + 4 m2Hd Yd.Dagger[Yd]
      
    + 4 Td.Dagger[Td]
    
    - 8/15 g1^2 M1 Conjugate[M1] Id3
    - 32/3 g3^2 M3 Conjugate[M3] Id3
    + 2/5 g1^2 S Id3
);

Betam2e[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 4 Ye.m2L.Dagger[Ye]
    + 2 m2e.Ye.Dagger[Ye]
    + 2 Ye.Dagger[Ye].m2e
    
    + 4 m2Hd Ye.Dagger[Ye]
    
    + 4 Te.Dagger[Te]
      
    - 24/5 g1^2 M1 Conjugate[M1] Id3
    + 6/5 g1^2 S Id3
);

Betam2\[Nu][g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 4 Y\[Nu].m2L.Dagger[Y\[Nu]]
    + 2 Y\[Nu].Dagger[Y\[Nu]].m2\[Nu]
    + 2 m2\[Nu].Y\[Nu].Dagger[Y\[Nu]]
    
    + 4 m2Hu Y\[Nu].Dagger[Y\[Nu]]
    
    + 4 T\[Nu].Dagger[Y\[Nu]]
);

Betam2Hd[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * (
    + 6 Tr[Yd.m2Q.Dagger[Yd]]
    + 6 Tr[Dagger[Yd].m2d.Yd]
    + 2 Tr[Ye.m2L.Dagger[Ye]]
    + 2 Tr[Dagger[Ye].m2e.Ye]
    
    + 6 m2Hd Tr[Dagger[Yd].Yd]
    + 2 m2Hd Tr[Dagger[Ye].Ye]
    
    + 6 Tr[Dagger[Td].Td]
    + 2 Tr[Dagger[Te].Te]
    
    - 6/5 g1^2 M1 Conjugate[M1]
    - 6 g2^2 M2 Conjugate[M2]
    - 3/5 g1^2 S
);

Betam2Hu[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/(16*Pi^2) * ( 
    + 6 Tr[Yu.m2Q.Dagger[Yu]]
    + 6 Tr[Dagger[Yu].m2u.Yu]
    + 2 Tr[Y\[Nu].m2L.Dagger[Y\[Nu]]]
    + 2 Tr[Dagger[Y\[Nu]].m2\[Nu].Y\[Nu]]
    
    + 6 m2Hu Tr[Dagger[Yu].Yu]
    + 2 m2Hu Tr[Dagger[Y\[Nu]].Y\[Nu]]
    
    + 6 Tr[Dagger[Tu].Tu]
    + 2 Tr[Dagger[T\[Nu]].T\[Nu]]
    
    - 6/5 g1^2 M1 Conjugate[M1]
    - 6 g2^2 M2 Conjugate[M2]
    + 3/5 g1^2 S
);


(* d=5 Proton decay operators *)

contract[tensor_,matrix_,index_]:=Block[{indices},
If[index==1,
Return[matrix.tensor],
indices=Range[4];
indices[[index]]=1;
indices[[1]]=index;
Return[Transpose[matrix.Transpose[tensor,indices],indices]];
];
];

BetaCL5qlqq[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,CL5_,CR5_] := 1/(16*Pi^2) * (CL5* (-2/5*g1^2-6g2^2-8g3^2) +
+ contract[CL5,Transpose[Yd\[ConjugateTranspose].Yd+Yu\[ConjugateTranspose].Yu],1]+
+ contract[CL5,Transpose[Ye\[ConjugateTranspose].Ye],2]+
+ Transpose[Transpose[Y\[Nu]\[ConjugateTranspose].Y\[Nu]].Transpose[CL5]]+
+ contract[CL5,Transpose[Yd\[ConjugateTranspose].Yd+Yu\[ConjugateTranspose].Yu],3]+
+ contract[CL5,Transpose[Yd\[ConjugateTranspose].Yd+Yu\[ConjugateTranspose].Yu],4]);

BetaCR5udeu[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,CL5_,CR5_] := 1/(16*Pi^2) * (CR5 * (-12/5*g1^2-8g3^2)+
+ contract[CR5,2Yu.Yu\[ConjugateTranspose],1]+
+ contract[CR5,2Yd.Yd\[ConjugateTranspose],2]+
+ contract[CR5,2Ye.Ye\[ConjugateTranspose],3]+
+ contract[CR5,2Yu.Yu\[ConjugateTranspose],4]);



ClearAll[RGE2Loop];
RGE2Loop[Force1Loop_] := RGE2Loop[Force1Loop] = With[{
        W = {g1[t],g2[t],g3[t],Yu[t],Yd[t],Ye[t],Y\[Nu][t],\[Kappa][t],M\[Nu]r[t]}, 
        Lsoft = {
          Tu[t],Td[t],Te[t],T\[Nu][t],
          M1[t],M2[t],M3[t],
          m2Q[t],m2L[t],m2u[t],m2d[t],m2e[t],m2\[Nu][t],m2Hd[t],m2Hu[t],Id3[t]
        },
        TwoLoopQ = If[Or @@ Table[StringMatchQ[#, s], {s, Force1Loop}], 0, 1] &
    },
    {
        D[g1[t],t]          == Betag1 @@ W          + TwoLoopQ["g1"] Betag12 @@ W,
        D[g2[t],t]          == Betag2 @@ W          + TwoLoopQ["g2"] Betag22 @@ W,
        D[g3[t],t]          == Betag3 @@ W          + TwoLoopQ["g3"] Betag32 @@ W,
        D[Yu[t],t]          == BetaYu @@ W          + TwoLoopQ["Yu"] BetaYu2 @@ W,
        D[Yd[t],t]          == BetaYd @@ W          + TwoLoopQ["Yd"] BetaYd2 @@ W,
        D[Ye[t],t]          == BetaYe @@ W          + TwoLoopQ["Ye"] BetaYe2 @@ W,
        D[Y\[Nu][t],t]      == BetaY\[Nu] @@ W      + TwoLoopQ["Y\[Nu]"] BetaY\[Nu]2 @@ W,
        D[\[Kappa][t],t]    == Beta\[Kappa] @@ W    + TwoLoopQ["\[Kappa]"] Beta\[Kappa]2 @@ W,
        D[M\[Nu]r[t],t]     == BetaM\[Nu]r @@ W     + TwoLoopQ["M\[Nu]r"] BetaM\[Nu]r2 @@ W,

        D[M1[t],t]          == BetaM1 @@ Join[W, Lsoft]        + TwoLoopQ["M1"] BetaM12 @@ Join[W, Lsoft],
        D[M2[t],t]          == BetaM2 @@ Join[W, Lsoft]        + TwoLoopQ["M2"] BetaM22 @@ Join[W, Lsoft],
        D[M3[t],t]          == BetaM3 @@ Join[W, Lsoft]        + TwoLoopQ["M3"] BetaM32 @@ Join[W, Lsoft],
        
        D[Tu[t],t]          == BetaTu @@ Join[W, Lsoft]        + TwoLoopQ["Tu"] BetaTu2 @@ Join[W, Lsoft],
        D[Td[t],t]          == BetaTd @@ Join[W, Lsoft]        + TwoLoopQ["Td"] BetaTd2 @@ Join[W, Lsoft],
        D[Te[t],t]          == BetaTe @@ Join[W, Lsoft]        + TwoLoopQ["Te"] BetaTe2 @@ Join[W, Lsoft],
        D[T\[Nu][t],t]      == BetaT\[Nu] @@ Join[W, Lsoft]    + TwoLoopQ["T\[Nu]"] BetaT\[Nu]2 @@ Join[W, Lsoft],
        D[m2Q[t],t]         == Betam2Q @@ Join[W, Lsoft]       + TwoLoopQ["m2Q"] Betam2Q2 @@ Join[W, Lsoft],
        D[m2L[t],t]         == Betam2L @@ Join[W, Lsoft]       + TwoLoopQ["m2L"] Betam2L2 @@ Join[W, Lsoft],
        D[m2u[t],t]         == Betam2u @@ Join[W, Lsoft]       + TwoLoopQ["m2u"] Betam2u2 @@ Join[W, Lsoft],
        D[m2d[t],t]         == Betam2d @@ Join[W, Lsoft]       + TwoLoopQ["m2d"] Betam2d2 @@ Join[W, Lsoft],
        D[m2e[t],t]         == Betam2e @@ Join[W, Lsoft]       + TwoLoopQ["m2e"] Betam2e2 @@ Join[W, Lsoft],
        D[m2\[Nu][t],t]     == Betam2\[Nu] @@ Join[W, Lsoft]   + TwoLoopQ["m2\[Nu]"] Betam2\[Nu]2 @@ Join[W, Lsoft],
        D[m2Hd[t],t]        == Betam2Hd @@ Join[W, Lsoft]      + TwoLoopQ["m2Hd"] Betam2Hd2 @@ Join[W, Lsoft],
        D[m2Hu[t],t]        == Betam2Hu @@ Join[W, Lsoft]      + TwoLoopQ["m2Hu"] Betam2Hu2 @@ Join[W, Lsoft],
        
        D[Id3[t],t]         == 0 IdentityMatrix[3]
    } /. Join[BetaTraces @@ Join[W, Lsoft], BetaTraces2 @@ Join[W, Lsoft]]
]; (* renormalization group equations of the MSSM ( 2 Loop ) *)


ClearAll[RGE2LoopProton];
RGE2LoopProton[Force1Loop_] := RGE2LoopProton[Force1Loop] = With[{
        W = {g1[t],g2[t],g3[t],Yu[t],Yd[t],Ye[t],Y\[Nu][t],\[Kappa][t],M\[Nu]r[t]}, 
        Lsoft = {
          Tu[t],Td[t],Te[t],T\[Nu][t],
          M1[t],M2[t],M3[t],
          m2Q[t],m2L[t],m2u[t],m2d[t],m2e[t],m2\[Nu][t],m2Hd[t],m2Hu[t],Id3[t]
        },
        Wnonrenormalizable={CL5qlqq[t],CR5udeu[t]},
        TwoLoopQ = If[Or @@ Table[StringMatchQ[#, s], {s, Force1Loop}], 0, 1] &
    },
    {
        D[g1[t],t]          == Betag1 @@ W          + TwoLoopQ["g1"] Betag12 @@ W,
        D[g2[t],t]          == Betag2 @@ W          + TwoLoopQ["g2"] Betag22 @@ W,
        D[g3[t],t]          == Betag3 @@ W          + TwoLoopQ["g3"] Betag32 @@ W,
        D[Yu[t],t]          == BetaYu @@ W          + TwoLoopQ["Yu"] BetaYu2 @@ W,
        D[Yd[t],t]          == BetaYd @@ W          + TwoLoopQ["Yd"] BetaYd2 @@ W,
        D[Ye[t],t]          == BetaYe @@ W          + TwoLoopQ["Ye"] BetaYe2 @@ W,
        D[Y\[Nu][t],t]      == BetaY\[Nu] @@ W      + TwoLoopQ["Y\[Nu]"] BetaY\[Nu]2 @@ W,
        D[\[Kappa][t],t]    == Beta\[Kappa] @@ W    + TwoLoopQ["\[Kappa]"] Beta\[Kappa]2 @@ W,
        D[M\[Nu]r[t],t]     == BetaM\[Nu]r @@ W     + TwoLoopQ["M\[Nu]r"] BetaM\[Nu]r2 @@ W,

        D[M1[t],t]          == BetaM1 @@ Join[W, Lsoft]        + TwoLoopQ["M1"] BetaM12 @@ Join[W, Lsoft],
        D[M2[t],t]          == BetaM2 @@ Join[W, Lsoft]        + TwoLoopQ["M2"] BetaM22 @@ Join[W, Lsoft],
        D[M3[t],t]          == BetaM3 @@ Join[W, Lsoft]        + TwoLoopQ["M3"] BetaM32 @@ Join[W, Lsoft],
        
        D[Tu[t],t]          == BetaTu @@ Join[W, Lsoft]        + TwoLoopQ["Tu"] BetaTu2 @@ Join[W, Lsoft],
        D[Td[t],t]          == BetaTd @@ Join[W, Lsoft]        + TwoLoopQ["Td"] BetaTd2 @@ Join[W, Lsoft],
        D[Te[t],t]          == BetaTe @@ Join[W, Lsoft]        + TwoLoopQ["Te"] BetaTe2 @@ Join[W, Lsoft],
        D[T\[Nu][t],t]      == BetaT\[Nu] @@ Join[W, Lsoft]    + TwoLoopQ["T\[Nu]"] BetaT\[Nu]2 @@ Join[W, Lsoft],
        D[m2Q[t],t]         == Betam2Q @@ Join[W, Lsoft]       + TwoLoopQ["m2Q"] Betam2Q2 @@ Join[W, Lsoft],
        D[m2L[t],t]         == Betam2L @@ Join[W, Lsoft]       + TwoLoopQ["m2L"] Betam2L2 @@ Join[W, Lsoft],
        D[m2u[t],t]         == Betam2u @@ Join[W, Lsoft]       + TwoLoopQ["m2u"] Betam2u2 @@ Join[W, Lsoft],
        D[m2d[t],t]         == Betam2d @@ Join[W, Lsoft]       + TwoLoopQ["m2d"] Betam2d2 @@ Join[W, Lsoft],
        D[m2e[t],t]         == Betam2e @@ Join[W, Lsoft]       + TwoLoopQ["m2e"] Betam2e2 @@ Join[W, Lsoft],
        D[m2\[Nu][t],t]     == Betam2\[Nu] @@ Join[W, Lsoft]   + TwoLoopQ["m2\[Nu]"] Betam2\[Nu]2 @@ Join[W, Lsoft],
        D[m2Hd[t],t]        == Betam2Hd @@ Join[W, Lsoft]      + TwoLoopQ["m2Hd"] Betam2Hd2 @@ Join[W, Lsoft],
        D[m2Hu[t],t]        == Betam2Hu @@ Join[W, Lsoft]      + TwoLoopQ["m2Hu"] Betam2Hu2 @@ Join[W, Lsoft],
        
        D[Id3[t],t]         == 0 IdentityMatrix[3],
        
        D[CL5qlqq[t],t]  == BetaCL5qlqq @@ Join[W, Wnonrenormalizable],
        D[CR5udeu[t],t]  == BetaCR5udeu @@ Join[W, Wnonrenormalizable]
    } /. Join[BetaTraces @@ Join[W, Lsoft], BetaTraces2 @@ Join[W, Lsoft]]
]; (* renormalization group equations of the MSSM ( 2 Loop ) *)


ClearAll[Betag12, Betag22, Betag32, BetaYu2, BetaYd2, BetaYe2, BetaY\[Nu]2, Beta\[Kappa]2, BetaM\[Nu]r2]; 
ClearAll[BetaTu2, BetaTd2, BetaTe2, BetaT\[Nu]2, BetaM12, BetaM22, BetaM32, Betam2Q2, Betam2L2, Betam2u2, Betam2d2, Betam2e2, Betam2\[Nu]2, Betam2Hd2, Betam2Hu2, BetaTraces2];


(* 2 loop contributions *)
Betag12[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(4*Pi)^4 * With[{
        a = 1,
        g = {g1,g2,g3},
        T = { Tr[Yu.Dagger[Yu]], Tr[Yd.Dagger[Yd]], Tr[Ye.Dagger[Ye]], Tr[Y\[Nu].Dagger[Y\[Nu]]] },
        B = {{199/25, 27/5, 88/5}, {9/5, 25, 24}, {11/5, 9, 14}}, 
        c = {{26/5, 14/5, 18/5, 6/5}, {6, 6, 2, 2}, {4, 4, 0, 0}}
    },
    g[[a]]^3 (
        Sum[ B[[a,b]] g[[b]]^2 , {b,3}] +
        - Sum[ c[[a,f]] T[[f]], {f,4}]
    )
];

Betag22[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(4*Pi)^4 * With[{
        a = 2,
        g = {g1,g2,g3},
        T = { Tr[Yu.Dagger[Yu]], Tr[Yd.Dagger[Yd]], Tr[Ye.Dagger[Ye]], Tr[Y\[Nu].Dagger[Y\[Nu]]] },
        B = {{199/25, 27/5, 88/5}, {9/5, 25, 24}, {11/5, 9, 14}}, 
        c = {{26/5, 14/5, 18/5, 6/5}, {6, 6, 2, 2}, {4, 4, 0, 0}}
    },
    g[[a]]^3 (
        Sum[ B[[a,b]] g[[b]]^2 , {b,3}] +
        - Sum[ c[[a,f]] T[[f]], {f,4}]
    )
];

Betag32[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] := 1/(4*Pi)^4 * With[{
        a = 3,
        g = {g1,g2,g3},
        T = { Tr[Yu.Dagger[Yu]], Tr[Yd.Dagger[Yd]], Tr[Ye.Dagger[Ye]], Tr[Y\[Nu].Dagger[Y\[Nu]]] },
        B = {{199/25, 27/5, 88/5}, {9/5, 25, 24}, {11/5, 9, 14}}, 
        c = {{26/5, 14/5, 18/5, 6/5}, {6, 6, 2, 2}, {4, 4, 0, 0}}
    },
    g[[a]]^3 (
        Sum[ B[[a,b]] g[[b]]^2 , {b,3}] +
        - Sum[ c[[a,f]] T[[f]], {f,4}]
    )
];


BetaYu2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=1/(4*Pi)^4 * (
	 + Yu.(
         - 2*Dagger[Yd].Yd.Dagger[Yd].Yd
	 - 2*Dagger[Yd].Yd.Dagger[Yu].Yu
	 - 4*Dagger[Yu].Yu.Dagger[Yu].Yu
	 - 3*Dagger[Yd].Yd*Tr[Yd.Dagger[Yd]]
	 - Dagger[Yd].Yd*Tr[Ye.Dagger[Ye]]
	 - 9*Dagger[Yu].Yu*Tr[Yu.Dagger[Yu]]
	 - 3*Dagger[Yu].Yu*Tr[Y\[Nu].Dagger[Y\[Nu]]]
         + (2/5)*g1^2*Dagger[Yd].Yd
	 + (2/5)*g1^2*Dagger[Yu].Yu
	 + 6*g2^2*Dagger[Yu].Yu
         )
         + Yu*(
	 - 3*Tr[Dagger[Yu].Yd.Dagger[Yd].Yu]
	 - 9*Tr[Dagger[Yu].Yu.Dagger[Yu].Yu]
	 - Tr[Y\[Nu].Dagger[Ye].Ye.Dagger[Y\[Nu]]]
	 - 3*Tr[Dagger[Y\[Nu]].Y\[Nu].Dagger[Y\[Nu]].Y\[Nu]]
         + (4/5)*g1^2*Tr[Dagger[Yu].Yu]
	 + 16*g3^2*Tr[Dagger[Yu].Yu]
         + (2743/450)*g1^4
         + g1^2*g2^2
	 + (15/2)*g2^4
	 + (136/45)*g1^2*g3^2
	 + 8*g2^2*g3^2
	 - (16/9)*g3^4
         )
         );


BetaYd2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=1/(4*Pi)^4 * (
	+Yd.(
        - 4*Dagger[Yd].Yd.Dagger[Yd].Yd
	- 2*Dagger[Yu].Yu.Dagger[Yd].Yd
	- 2*Dagger[Yu].Yu.Dagger[Yu].Yu
	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/5)*g1^2*g2^2
	+ (15/2)*g2^4
        )
        );


Beta\[Kappa]2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=1/(4*Pi)^4 * (
	+ \[Kappa].(
        - 2*Dagger[Ye].Ye.Dagger[Ye].Ye
        - 2*Dagger[Y\[Nu]].Y\[Nu].Dagger[Y\[Nu]].Y\[Nu]
	- (Tr[Y\[Nu].Dagger[Y\[Nu]]]+3*Tr[Yu.Dagger[Yu]])*Transpose[Y\[Nu]].Conjugate[Y\[Nu]]
	+ ((6/5)*g1^2 - Tr[Ye.Dagger[Ye]]- 3*Tr[Yd.Dagger[Yd]])*Transpose[Ye].Conjugate[Ye]
        )
        + (
	- 2*Transpose[Ye].Conjugate[Ye].Transpose[Ye].Conjugate[Ye]
	- 2*Transpose[Y\[Nu]].Conjugate[Y\[Nu]].Transpose[Y\[Nu]].Conjugate[Y\[Nu]]
	- (Tr[Y\[Nu].Dagger[Y\[Nu]]]+3*Tr[Yu.Dagger[Yu]])*Transpose[Y\[Nu]].Conjugate[Y\[Nu]]
	+ ((6/5)*g1^2 - Tr[Ye.Dagger[Ye]]- 3*Tr[Yd.Dagger[Yd]])*Transpose[Ye].Conjugate[Ye]
        ).\[Kappa]
	+ \[Kappa]*(
	- 6*Tr[Dagger[Yu].Yd.Dagger[Yd].Yu]
	- 18*Tr[Dagger[Yu].Yu.Dagger[Yu].Yu]
	- 2*Tr[Y\[Nu].Dagger[Ye].Ye.Dagger[Y\[Nu]]]
	- 6*Tr[Dagger[Y\[Nu]].Y\[Nu].Dagger[Y\[Nu]].Y\[Nu]]
        + (8/5)*g1^2*Tr[Dagger[Yu].Yu]
	+ 32*g3^2*Tr[Dagger[Yu].Yu]
        + (207/25)*g1^4
	+ (18/5)*g1^2*g2^2
	+ 15*g2^4
        )
        );


BetaM\[Nu]r2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_] :=1/(4*Pi)^4 * (
	 + M\[Nu]r.(
         - 2*Conjugate[Y\[Nu]].Transpose[Ye].Conjugate[Ye].Transpose[Y\[Nu]]
	 - 2*Conjugate[Y\[Nu]].Transpose[Y\[Nu]].Conjugate[Y\[Nu]].Transpose[Y\[Nu]]
	 - 6*Tr[Yu.Dagger[Yu]]*Conjugate[Y\[Nu]].Transpose[Y\[Nu]]
	 - 2*Tr[Y\[Nu].Dagger[Y\[Nu]]]*Conjugate[Y\[Nu]].Transpose[Y\[Nu]]
	 + (6/5)*g1^2*Conjugate[Y\[Nu]].Transpose[Y\[Nu]]
	 + 6*g2^2*Conjugate[Y\[Nu]].Transpose[Y\[Nu]]
	 )
         + (
         - 2*Y\[Nu].Dagger[Ye].Ye.Dagger[Y\[Nu]]
	 - 2*Y\[Nu].Dagger[Y\[Nu]].Y\[Nu].Dagger[Y\[Nu]]
	 - 6*Tr[Yu.Dagger[Yu]]*Y\[Nu].Dagger[Y\[Nu]]
	 - 2*Tr[Y\[Nu].Dagger[Y\[Nu]]]*Y\[Nu].Dagger[Y\[Nu]]
	 + (6/5)*g1^2*Y\[Nu].Dagger[Y\[Nu]]
	 + 6*g2^2*Y\[Nu].Dagger[Y\[Nu]]
         ).M\[Nu]r
	 );

(* Soft SUSY breaking parameters *)

BetaM12[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/((4*Pi)^4) * (
    + 12/5 g1^2 Tr[T\[Nu].Dagger[Y\[Nu]]]
    + 28/5 g1^2 Tr[Td.Dagger[Yd]]
    + 36/5 g1^2 Tr[Te.Dagger[Ye]]
    + 52/5 g1^2 Tr[Tu.Dagger[Yu]]
    - 12/5 g1^2 M1 Tr[Y\[Nu].Dagger[Y\[Nu]]]
    - 28/5 g1^2 M1 Tr[Yd.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    - 4/5 g1^2 M1 Yu.Dagger[Yd].Yd
    - 4/5 g1^2 M1 Yu.Dagger[Yu].Yu
    + 32 g3^2 Yu Tr[Dagger[Yu].Tu]
    + 16 g3^2 Tu Tr[Dagger[Yu].Yu]
    + 4/5 g1^2 Tu Tr[Dagger[Yu].Yu]
    + 8/5 g1^2 Yu Tr[Dagger[Yu].Tu]
    + 136/45 g1^2 g3^2 Tu
    + 15/2 g2^4 Tu
    - 16/9 g3^4 Tu
    + 2743/450 g1^4 Tu
    + g1^2 g2^2 Tu
    + 8 g2^2 g3^2 Tu
    - 32 g3^2 M3 Yu Tr[Dagger[Yu].Yu]
    - 8/5 g1^2 M1 Yu Tr[Dagger[Yu].Yu]
    - 272/45 g1^2 g3^2 M1 Yu
    - 272/45 g1^2 g3^2 M3 Yu
    - 2 g1^2 g2^2 M1 Yu
    - 2 g1^2 g2^2 M2 Yu
    - 16 g2^2 g3^2 M2 Yu
    - 16 g2^2 g3^2 M3 Yu
    - 30 g2^4 M2 Yu
    - 5486/225 g1^4 M1 Yu
    + 64/9 g3^4 M3 Yu
);

BetaTd2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/((4*Pi)^4) * (
    - 6 Td.Dagger[Yd].Yd.Dagger[Yd].Yd
    - 4 Td.Dagger[Yu].Yu.Dagger[Yd].Yd
    - 2 Td.Dagger[Yu].Yu.Dagger[Yu].Yu
    - 8 Yd.Dagger[Yd].Td.Dagger[Yd].Yd
    - 6 Yd.Dagger[Yd].Yd.Dagger[Yd].Td
    - 4 Yd.Dagger[Yu].Tu.Dagger[Yd].Yd
    - 4 Yd.Dagger[Yu].Tu.Dagger[Yu].Yu
    - 2 Yd.Dagger[Yu].Yu.Dagger[Yd].Td
    - 4 Yd.Dagger[Yu].Y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Yd].Yd.Dagger[Yd]]
    - 6 Yd Tr[Yd.Dagger[Yd].Td.Dagger[Yd]]
    - 12 Yd Tr[Dagger[Yd].Td.Dagger[Yd].Yd]
    - 12 Yd Tr[Dagger[Yd].Yd.Dagger[Yd].Td]
    - 6 Yd Tr[Td.Dagger[Yu].Yu.Dagger[Yd]]
    - 6 Yd Tr[Yd.Dagger[Yu].Tu.Dagger[Yd]]
    + 6 g2^2 Yd.Dagger[Yd].Td
    + 12 g2^2 Td.Dagger[Yd].Yd
    + 4/5 g1^2 Td.Dagger[Yu].Yu
    + 6/5 g1^2 Td.Dagger[Yd].Yd
    + 6/5 g1^2 Yd.Dagger[Yd].Td
    + 8/5 g1^2 Yd.Dagger[Yu].Tu
    - 12 g2^2 M2 Yd.Dagger[Yd].Yd
    - 8/5 g1^2 M1 Yd.Dagger[Yd].Yd
    - 8/5 g1^2 M1 Yd.Dagger[Yu].Yu
    + 12/5 g1^2 Yd Tr[Dagger[Ye].Te]
    - 2/5 g1^2 Td Tr[Dagger[Yd].Yd]
    + 32 g3^2 Yd Tr[Dagger[Yd].Td]
    + 16 g3^2 Td Tr[Dagger[Yd].Yd]
    - 4/5 g1^2 Yd Tr[Dagger[Yd].Td]
    + 6/5 g1^2 Td Tr[Dagger[Ye].Ye]
    + 15/2 g2^4 Td
    - 16/9 g3^4 Td
    + 287/90 g1^4 Td
    + g1^2 g2^2 Td
    + 8 g2^2 g3^2 Td
    + 8/9 g1^2 g3^2 Td
    - 12/5 g1^2 M1 Yd Tr[Dagger[Ye].Ye]
    - 32 g3^2 M3 Yd Tr[Dagger[Yd].Yd]
    + 4/5 g1^2 M1 Yd Tr[Dagger[Yd].Yd]
    - 16/9 g1^2 g3^2 M1 Yd
    - 16/9 g1^2 g3^2 M3 Yd
    - 2 g1^2 g2^2 M1 Yd
    - 2 g1^2 g2^2 M2 Yd
    - 16 g2^2 g3^2 M2 Yd
    - 16 g2^2 g3^2 M3 Yd
    - 30 g2^4 M2 Yd
    - 574/45 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[Yu.Dagger[Yu]]
    - 2 Ye.Dagger[Y\[Nu]].Y\[Nu] Tr[T\[Nu].Dagger[Y\[Nu]]]
    - 6 Ye.Dagger[Y\[Nu]].Y\[Nu] Tr[Tu.Dagger[Yu]]
    - 1 Te Tr[Ye.Dagger[Y\[Nu]].Y\[Nu].Dagger[Ye]]
    - 1 Te Tr[Ye.Dagger[Ye].Ye.Dagger[Ye]]
    - 2 Te Tr[Dagger[Ye].Ye.Dagger[Ye].Ye]
    - 3 Te Tr[Yd.Dagger[Yd].Yd.Dagger[Yd]]
    - 6 Te Tr[Dagger[Yd].Yd.Dagger[Yd].Yd]
    - 3 Te Tr[Yd.Dagger[Yu].Yu.Dagger[Yd]]
    - 2 Ye Tr[Ye.Dagger[Y\[Nu]].T\[Nu].Dagger[Ye]]
    - 2 Ye Tr[Te.Dagger[Y\[Nu]].Y\[Nu].Dagger[Ye]]
    - 2 Ye Tr[Te.Dagger[Ye].Ye.Dagger[Ye]]
    - 2 Ye Tr[Ye.Dagger[Ye].Te.Dagger[Ye]]
    - 4 Ye Tr[Dagger[Ye].Te.Dagger[Ye].Ye]
    - 4 Ye Tr[Dagger[Ye].Ye.Dagger[Ye].Te]
    - 6 Ye Tr[Td.Dagger[Yd].Yd.Dagger[Yd]]
    - 6 Ye Tr[Yd.Dagger[Yd].Td.Dagger[Yd]]
    - 12 Ye Tr[Dagger[Yd].Td.Dagger[Yd].Yd]
    - 12 Ye Tr[Dagger[Yd].Yd.Dagger[Yd].Td]
    - 6 Ye Tr[Td.Dagger[Yu].Yu.Dagger[Yd]]
    - 6 Ye Tr[Yd.Dagger[Yu].Tu.Dagger[Yd]]
    + 6 g2^2 Ye.Dagger[Ye].Te
    + 12 g2^2 Te.Dagger[Ye].Ye
    - 6/5 g1^2 Te.Dagger[Ye].Ye
    + 6/5 g1^2 Ye.Dagger[Ye].Te
    - 12 g2^2 M2 Ye.Dagger[Ye].Ye
    + 12/5 g1^2 Ye Tr[Dagger[Ye].Te]
    - 2/5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].m2u.Yu
  + 8/5 g1^2 Dagger[Tu].Tu
  + 16/5 g1^2 M1 Conjugate[M1] Dagger[Yu].Yu
  - 4/5 g1^2 M1 Dagger[Td].Yd
  - 8/5 g1^2 M1 Dagger[Tu].Yu
  + 8/5 g1^2 M1 Conjugate[M1] Dagger[Yd].Yd
  - 2/5 g1^2 m2Hu Tr[Y\[Nu].Dagger[Y\[Nu]]] Id3
  + 2/5 g1^2 m2Hd Tr[Ye.Dagger[Ye]] Id3
  - 6/5 g1^2 m2Hu Tr[Yu.Dagger[Yu]] Id3
  + 6/5 g1^2 m2Hd Tr[Yd.Dagger[Yd]] Id3
  - 2/5 g1^2 Tr[m2Q.Dagger[Yd].Yd] Id3
  - 2/5 g1^2 Tr[m2Q.Dagger[Yu].Yu] Id3
  + 2/5 g1^2 Tr[m2L.Dagger[Y\[Nu]].Y\[Nu]] Id3
  + 2/5 g1^2 Tr[m2L.Dagger[Ye].Ye] Id3
  - 4/5 g1^2 Tr[Ye.Dagger[Ye].m2e] Id3
  - 4/5 g1^2 Tr[Yd.Dagger[Yd].m2d] Id3
  + 8/5 g1^2 Tr[Yu.Dagger[Yu].m2u] Id3
  + 12/25 g1^4 Tr[m2e] Id3
  - 128/3 g3^4 M3 Conjugate[M3] Id3 
  + 1/5 g1^2 g2^2 M2 Conjugate[M1] Id3
  + 1/5 g1^2 g2^2 M1 Conjugate[M2] Id3
  + 16/15 g1^2 g3^2 Tr[m2Q] Id3
  + 16/15 g1^2 g3^2 Tr[m2d] Id3
  + 16/45 g1^2 g3^2 M3 Conjugate[M1] Id3
  + 16/45 g1^2 g3^2 M1 Conjugate[M3] Id3
  + 1/75 g1^4 Tr[m2Q] Id3
  + 199/75 g1^4 M1 Conjugate[M1] Id3
  + 2/5 g1^2 g2^2 M1 Conjugate[M1] Id3
  + 2/5 g1^2 g2^2 M2 Conjugate[M2] Id3
  + 32 g2^2 g3^2 M2 Conjugate[M2] Id3
  + 16 g2^2 g3^2 M3 Conjugate[M2] Id3
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 g1^2 Tr[m2Q.Dagger[Yd].Yd] Id3
  + 8/5 g1^2 Tr[m2Q.Dagger[Yu].Yu] Id3
  - 12/25 g1^4 m2Hu Id3
  + 12/25 g1^4 Tr[m2L] Id3
  + 12/25 g1^4 m2Hd Id3
  - 12/5 g1^2 g2^2 Tr[m2Q] Id3
  - 12/5 g1^2 g2^2 m2Hu Id3
  + 12/5 g1^2 g2^2 Tr[m2L] Id3
  + 12/5 g1^2 g2^2 m2Hd Id3
  + 128/15 g1^2 g3^2 Tr[m2u] Id3
  - 128/3 g3^4 M3 Conjugate[M3] Id3
  + 128/75 g1^4 Tr[m2u] Id3
  - 16/75 g1^4 Tr[m2d] Id3
  + 256/45 g1^2 g3^2 M3 Conjugate[M1] Id3
  + 256/45 g1^2 g3^2 M1 Conjugate[M3] Id3
  + 3424/75 g1^4 M1 Conjugate[M1] Id3
  - 4/75 g1^4 Tr[m2Q] Id3
  - 48/25 g1^4 Tr[m2e] Id3
  + 512/45 g1^2 g3^2 M1 Conjugate[M1] Id3
  + 512/45 g1^2 g3^2 M3 Conjugate[M3] Id3
  - 64/15 g1^2 g3^2 Tr[m2Q] Id3
  - 64/15 g1^2 g3^2 Tr[m2d] Id3
);
  
Betam2d2[g1_,g2_,g3_,Yu_,Yd_,Ye_,Y\[Nu]_,\[Kappa]_,M\[Nu]r_,Tu_,Td_,Te_,T\[Nu]_,M1_,M2_,M3_,m2Q_,m2L_,m2u_,m2d_,m2e_,m2\[Nu]_,m2Hd_,m2Hu_,Id3_] :=1/((4*Pi)^4) * (
  - 2 m2d.Yd.Dagger[Yd].Yd.Dagger[Yd]
  - 2 m2d.Yd.Dagger[Yu].Yu.Dagger[Yd]
  - 8 m2Hd Yd.Dagger[Yd].Yd.Dagger[Yd]
  - 4 m2Hd Yd.Dagger[Yu].Yu.Dagger[Yd]
  - 4 m2Hu Yd.Dagger[Yu].Yu.Dagger[Yd]
  - 4 Td.Dagger[Td].Yd.Dagger[Yd]
  - 4 Td.Dagger[Tu].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g2^2 m2Hd
  + 9/5 g1^2 g2^2 M2 Conjugate[M1]
  + 9/5 g1^2 g2^2 M1 Conjugate[M2]
  + 9/5 g1^2 g2^2 Tr[m2Q]
  + 9/5 g1^2 g2^2 m2Hu
);



(* RGE 0\[Nu] versions *)
ClearAll[DropRHNeutrinos, MatrixExpand];

MatrixExpand[f_] := Expand[Map[Distribute[#, Plus, Dot] &, f, Infinity]];

DropRHNeutrinos[formulas_] := Block[{formulas$},
  formulas$ = Select[formulas, FreeQ[#[[1]], Y\[Nu] | T\[Nu] | m2\[Nu] | M\[Nu]r] &];

  (* First expand all right-hand sides of the RGE equations which contain neutrino couplings *)
  formulas$ = If[FreeQ[#, Y\[Nu] | T\[Nu] | m2\[Nu] | M\[Nu]r], #, MatrixExpand[#]] & /@ formulas$; 
  formulas$ = formulas$ /. Dot[a_, x__] /; ! FreeQ[{a, x}, Y\[Nu][t] | T\[Nu][t] | m2\[Nu][t] | M\[Nu]r[t]] :> MatrixExpand[Dot[a, x]];
  
  (* Replace all matrix products containing Y\[Nu], T\[Nu] or m2\[Nu] with 0 *)
  formulas$ = formulas$ /. Dot[a_, x__] /; ! FreeQ[{a, x}, Y\[Nu][t] | T\[Nu][t] | m2\[Nu][t] | M\[Nu]r[t]] :> 0;
  
  (* Also replace the possibly resulting traces with 0 or transposes of 0 *)
  formulas$ = formulas$ /. Tr[0] -> 0;
  formulas$ = formulas$ /. Transpose[0] -> 0;
  formulas$
]

RGE1Loop0N[Force1Loop_] := RGE1Loop0N[Force1Loop] = DropRHNeutrinos[RGE1Loop[Force1Loop]]
RGE2Loop0N[Force1Loop_] := RGE2Loop0N[Force1Loop] = DropRHNeutrinos[RGE2Loop[Force1Loop]]

(* Proton decay RGEs *)
RGE1Loop0NProton[Force1Loop_] := RGE1Loop0NProton[Force1Loop] = DropRHNeutrinos[RGE1LoopProton[Force1Loop]]
RGE2Loop0NProton[Force1Loop_] := RGE2Loop0NProton[Force1Loop] = DropRHNeutrinos[RGE2LoopProton[Force1Loop]]


STCTest[file_]:=Block[{gauge,input= ToUpperCase[Import[file, "String"]]},
gauge = GetValues[input, "Block GAUGE"];
	Return[gauge];
];



(* transition functions *)

ClearAll[RotateRHNeutrinos];
RotateRHNeutrinos[M\[Nu]r_,Y\[Nu]_,T\[Nu]_,m2\[Nu]_] := Block[
    {lU, lM\[Nu]rRotated, lY\[Nu]Rotated, lT\[Nu]Rotated, lm2\[Nu]Rotated}, 
    lU = Transpose[Reverse@Eigenvectors[Dagger[M\[Nu]r].M\[Nu]r]];
    lU = lU.DiagonalMatrix[Exp[-I/2 Arg[Diagonal[Transpose[lU].M\[Nu]r.lU]]]];
    
    lM\[Nu]rRotated = Transpose[lU].M\[Nu]r.lU;
    lY\[Nu]Rotated = Transpose[lU].Y\[Nu];
    lT\[Nu]Rotated = Transpose[lU].T\[Nu];
    lm2\[Nu]Rotated = ConjugateTranspose[lU].m2\[Nu].lU;
    
    Return[{lM\[Nu]rRotated, lY\[Nu]Rotated, lT\[Nu]Rotated, lm2\[Nu]Rotated}];
]

ClearAll[TransMSSMsoftbroken];
TransMSSMsoftbroken[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[{
      lPars, lParsNew,
      lU,
      lY\[Nu],lY\[Nu]Rotated,
      l\[Kappa],
      lM\[Nu]r,lM\[Nu]rRotated,
      lIntegrateOut, lUforM,lToIntegratedOut,lFromIntegratedOut,
  
      lT\[Nu], lT\[Nu]Rotated,
      lm2\[Nu], lm2\[Nu]Rotated
    },
    (* make a transition from the MSSM to the MSSM *)

    (* evaluate the options *)
    (* evaluate IntegratedOut in pToOpts and pFromOpts *)
    lToOpts;
    Options[lToOpts]=Options[RGEOptions];
    SetOptions[lToOpts,RGEFilterOptions[lToOpts,pToOpts]];
    lToIntegratedOut=RGEIntegratedOut/.Options[lToOpts,RGEIntegratedOut];
    lFromOpts;
    Options[lFromOpts]=Options[RGEOptions];
    SetOptions[lFromOpts,RGEFilterOptions[lFromOpts,pFromOpts]];
    lFromIntegratedOut=RGEIntegratedOut/.Options[lFromOpts,RGEIntegratedOut];

    (* calculate the new parameters *)
    lPars = Thread[(Head /@ ParametersFunc[t]) -> (ParametersFunc[ pScale ]/.pSolution)[[1]]];
    {lY\[Nu], lM\[Nu]r, l\[Kappa], lT\[Nu], lm2\[Nu]} = {Y\[Nu], M\[Nu]r, \[Kappa], T\[Nu], m2\[Nu]} /. lPars;
    
    (* rotation to diagonal lM\[Nu]r *)
    {lM\[Nu]rRotated, lY\[Nu]Rotated, lT\[Nu]Rotated, lm2\[Nu]Rotated} = RotateRHNeutrinos[
      lM\[Nu]r, lY\[Nu], lT\[Nu], lm2\[Nu]
    ];

    If[lFromIntegratedOut>lToIntegratedOut,
        Print["The model ", RGEGetModel[Exp[pScale]], " at the scale ",
        Exp[pScale], " pretends to have more particles, but new particles cannot be added: ",
        lFromIntegratedOut,"->",lToIntegratedOut, " Thus the model is changed."];
        RGEChangeOptions[Exp[pScale],RGEIntegratedOut->lFromIntegratedOut];
        lToIntegratedOut=lFromIntegratedOut;
        (*Throw[{lFromIntegratedOut,lToIntegratedOut},RGECanNotAddNewParticles];*)
    ];
    If[lToIntegratedOut>lFromIntegratedOut,
        lIntegrateOut=lToIntegratedOut-lFromIntegratedOut;
        l\[Kappa]+=RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,lIntegrateOut];
        lY\[Nu]=RGEIntegrateOutY\[Nu][lY\[Nu]Rotated, lIntegrateOut];
        lT\[Nu]=RGEIntegrateOutY\[Nu][lT\[Nu]Rotated, lIntegrateOut];
        lM\[Nu]r=RGEIntegrateOutM[lM\[Nu]rRotated, lIntegrateOut];
        (* Also use RGEIntegrateOutM for m2\[Nu], since it only corresponds to dropping specific rows/columns *)
        lm2\[Nu]=RGEIntegrateOutM[lm2\[Nu]Rotated, lIntegrateOut];
    ];
        
    lParsNew = Join[
        Thread[
          {Y\[Nu], M\[Nu]r, \[Kappa], T\[Nu], m2\[Nu]} 
            -> {lY\[Nu], lM\[Nu]r, l\[Kappa], lT\[Nu], lm2\[Nu]}
        ],
        FilterRules[lPars, Except[Y\[Nu] | M\[Nu]r | \[Kappa] | T\[Nu] | m2\[Nu]]]
    ];

    Return[Map[
      Symbol["RGE" <> SymbolName[#[[1]]]] -> #[[2]] &,
      lParsNew
    ]];
];

(*
ClearAll[TransMSSM0N];
TransMSSMsoftbroken0N[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[
    {
      lPars,lParsNew,
      lY\[Nu],lY\[Nu]Rotated,
      l\[Kappa],
      lM\[Nu]r,lM\[Nu]rRotated,
      lT\[Nu],lT\[Nu]Rotated,
      lm2\[Nu],lm2\[Nu]Rotated
    },
(* make a transition from the MSSM to the MSSM w/o heavy neutrinos *)

(* calculate the new parameters *)
    lPars = Thread[(Head /@ ParametersFunc[t]) -> (ParametersFunc[ pScale ]/.pSolution)[[1]]];
    {lY\[Nu], lM\[Nu]r, l\[Kappa], lT\[Nu], lm2\[Nu]} = {Y\[Nu], M\[Nu]r, \[Kappa], T\[Nu], m2\[Nu]} /. lPars;
    
    (* rotation to diagonal lM\[Nu]r *)
    {lM\[Nu]rRotated, lY\[Nu]Rotated, lT\[Nu]Rotated, lm2\[Nu]Rotated} = RotateRHNeutrinos[
      lM\[Nu]r, lY\[Nu], lT\[Nu], lm2\[Nu]
    ];

    l\[Kappa] += RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,Length[lM\[Nu]r]];
    
    lParsNew = Join[
      {\[Kappa] -> l\[Kappa]},
      FilterRules[lPars, Except[Y\[Nu] | M\[Nu]r | \[Kappa] | T\[Nu] | m2\[Nu]]]
    ];
    
    Return[Map[
      Symbol["RGE" <> SymbolName[#[[1]]]] -> #[[2]] &,
      lParsNew
    ]];
];
*)


ClearAll[Trans2HDM];
Trans2HDM[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],lY\[Nu]Rotated,l\[Kappa],lM\[Nu]r,lM\[Nu]rRotated,lIntegrateOut, lUforM,lToIntegratedOut,lFromIntegratedOut,le,lu,ld,l\[Nu],lTosb,lTocb,lsb,lcb},
(* make a transition from the MSSM to the MSSM *)

(* evaluate the options *)
(* evaluate IntegratedOut in pToOpts and pFromOpts *)
        lToOpts;
        Options[lToOpts]=Options[RGEGetModelOptions["2HDM"][[1,2]]];
        SetOptions[lToOpts,RGEFilterOptions[lToOpts,pToOpts]];
        lToIntegratedOut=RGEIntegratedOut/.Options[lToOpts,RGEIntegratedOut];
        lFromOpts;
        Options[lFromOpts]=Options[RGEOptions];
        SetOptions[lFromOpts,RGEFilterOptions[lFromOpts,pFromOpts]];
        lFromIntegratedOut=RGEIntegratedOut/.Options[lFromOpts,RGEIntegratedOut];

(* calculate the new parameters *)
	{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],l\[Kappa],lM\[Nu]r}=(ParametersFunc[ pScale ]/.pSolution)[[1]];
	{lM\[Nu]rRotated,lY\[Nu]Rotated}=RGERotateM[ lM\[Nu]r,lY\[Nu] ]; (*rotation matrix for lM\[Nu]r*)

	If[lFromIntegratedOut>lToIntegratedOut,
		   (* Print["The model ", RGEGetModel[Exp[pScale]], " at the
		   scale ", Exp[pScale]," pretends to have more particles, but
		   new particles can not be added:
		   ",lFromIntegratedOut,"->",lToIntegratedOut, " Thus the model
		   is changed."]; *)
		   RGEChangeOptions[Exp[pScale],RGEIntegratedOut->lFromIntegratedOut];
		   lToIntegratedOut=lFromIntegratedOut;
		   (*Throw[{lFromIntegratedOut,lToIntegratedOut},RGECanNotAddNewParticles];*)
	   ];
	If[lToIntegratedOut>lFromIntegratedOut,
		lIntegrateOut=lToIntegratedOut-lFromIntegratedOut;
                
			l\[Kappa]+=RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,lIntegrateOut];
			lY\[Nu]=RGEIntegrateOutY\[Nu][lY\[Nu]Rotated, lIntegrateOut];
			lM\[Nu]r=RGEIntegrateOutM[lM\[Nu]rRotated, lIntegrateOut];
	];
	lcb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	lsb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	lTocb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lToOpts,RGEtan\[Beta]];
	lTosb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lToOpts,RGEtan\[Beta]];

	lu=lsb/((RGEzu/.Options[lToOpts,RGEzu]).{lTocb,lTosb});
	ld=lcb/((RGEzd/.Options[lToOpts,RGEzd]).{lTocb,lTosb});
	l\[Nu]=lsb/((RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]]).{lTocb,lTosb});
	le=lcb/lTocb;

	
        Return[{RGEg1->lg1,RGEg2->lg2,RGEg3->lg3,RGEYu->lYu*lu,RGEYd->lYd*ld,RGEYe->lYe*le,RGEY\[Nu]->lY\[Nu]*l\[Nu],RGE\[Kappa]1->(RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]])[[1]]*l\[Kappa]*(l\[Nu])^2,RGE\[Kappa]2->(RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]])[[2]]*l\[Kappa]*(l\[Nu])^2,RGEM\[Nu]r->lM\[Nu]r,RGE\[Lambda]1->(lg2^2+lg1^2)/2.,RGE\[Lambda]2->(lg2^2+lg1^2)/2.,RGE\[Lambda]3->(lg2^2-lg1^2)/4,RGE\[Lambda]4->-(lg2^2)/2,RGE\[Lambda]5->0.}];
];


ClearAll[Trans2HDM0N];
Trans2HDM0N[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],lY\[Nu]Rotated,l\[Kappa],lM\[Nu]r,lM\[Nu]rRotated, lUforM,lsb,lcb,lTosb,lTocb,lu,ld,le,l\[Nu]},
(* make a transition from the MSSM to the MSSM w/o heavy neutrinos *)

        lToOpts;
        Options[lToOpts]=Options[RGEGetModelOptions["2HDM0N"][[1,2]]];
        SetOptions[lToOpts,RGEFilterOptions[lToOpts,pToOpts]];
        lFromOpts;
        Options[lFromOpts]=Options[RGEOptions];
        SetOptions[lFromOpts,RGEFilterOptions[lFromOpts,pFromOpts]];
(* calculate the new parameters *)
	{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],l\[Kappa],lM\[Nu]r}=(ParametersFunc[ pScale ]/.pSolution)[[1]];
	{lM\[Nu]rRotated,lY\[Nu]Rotated}=RGERotateM[ lM\[Nu]r,lY\[Nu] ]; (*rotation matrix for lM\[Nu]r*)

        l\[Kappa]+= RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,Length[lM\[Nu]r]];

	lcb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	lsb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	lTocb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lToOpts,RGEtan\[Beta]];
	lTosb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lToOpts,RGEtan\[Beta]];

	lu=lsb/((RGEzu/.Options[lToOpts,RGEzu]).{lTocb,lTosb});
	ld=lcb/((RGEzd/.Options[lToOpts,RGEzd]).{lTocb,lTosb});
	l\[Nu]=lsb/((RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]]).{lTocb,lTosb});
	le=lcb/lTocb;


        Return[{RGEg1->lg1,RGEg2->lg2,RGEg3->lg3,RGEYu->lYu*lu,RGEYd->lYd*ld,RGEYe->lYe*le,RGE\[Kappa]1->(RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]])[[1]]*l\[Kappa]*(l\[Nu])^2,RGE\[Kappa]2->(RGEz\[Nu]/.Options[lToOpts,RGEz\[Nu]])[[2]]*l\[Kappa]*(l\[Nu])^2,RGE\[Lambda]1->(lg2^2+lg1^2)/2.,RGE\[Lambda]2->(lg2^2+lg1^2)/2.,RGE\[Lambda]3->(lg2^2-lg1^2)/4,RGE\[Lambda]4->-(lg2^2)/2,RGE\[Lambda]5->0.}];
];

(*

ClearAll[TransSM];
TransSM[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],lY\[Nu]Rotated,l\[Kappa],lM\[Nu]r,lM\[Nu]rRotated,lIntegrateOut, lUforM,lToIntegratedOut,lFromIntegratedOut, lsb,lcb},
(* make a transition from the MSSM to the SM *)
(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!depends on RGESM.m !!!!!!!!!!!!!!!!!!!!!!!!!
the dependencies are marked by !!! *)


(* evaluate the options *)
(* evaluate IntegratedOut in pToOpts and pFromOpts *)
        lToOpts;
        Options[lToOpts]=Options[RGEGetModelOptions["SM"][[1,2]]];
        SetOptions[lToOpts,RGEFilterOptions[lToOpts,pToOpts]];
	lToIntegratedOut=RGEIntegratedOut/.Options[lToOpts,RGEIntegratedOut];
        lFromOpts;
        Options[lFromOpts]=Options[RGEOptions];
        SetOptions[lFromOpts,RGEFilterOptions[lFromOpts,pFromOpts]];
	lFromIntegratedOut=RGEIntegratedOut/.Options[lFromOpts,RGEIntegratedOut];
	
(* calculate the new parameters *)
	{lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],l\[Kappa],lM\[Nu]r}=(ParametersFunc[ pScale ]/.pSolution)[[1]];
	{lM\[Nu]rRotated,lY\[Nu]Rotated}=RGERotateM[ lM\[Nu]r,lY\[Nu] ]; (*rotation matrix for lM\[Nu]r*)

	If[lFromIntegratedOut>lToIntegratedOut,
		   (* Print["The model ", RGEGetModel[Exp[pScale]], " at the
		   scale ", Exp[pScale]," pretends to have more particles, but
		   new particles can not be added:
		   ",lFromIntegratedOut,"->",lToIntegratedOut, " Thus the model
		   is changed."]; *)
		   RGEChangeOptions[Exp[pScale],RGEIntegratedOut->lFromIntegratedOut];
		   lToIntegratedOut=lFromIntegratedOut;
		   (*Throw[{lFromIntegratedOut,lToIntegratedOut},RGECanNotAddNewParticles];*)
	   ];
	If[lToIntegratedOut>lFromIntegratedOut,
		lIntegrateOut=lToIntegratedOut-lFromIntegratedOut;

			l\[Kappa]+= RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,lIntegrateOut];
			lY\[Nu]= RGEIntegrateOutY\[Nu][lY\[Nu]Rotated, lIntegrateOut];
			lM\[Nu]r= RGEIntegrateOutM[lM\[Nu]rRotated, lIntegrateOut];
	];
	lcb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	lsb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
	Return[{RGEg1->lg1,RGEg2->lg2,RGEg3->lg3,RGEYu->lYu*lsb,RGEYd->lYd*lcb,RGEYe->lYe*lcb,RGEY\[Nu]->lY\[Nu]*lsb,RGE\[Kappa]->l\[Kappa]*(lsb)^2,RGEM\[Nu]r->lM\[Nu]r,RGE\[Lambda]->(RGE\[Lambda]/.Options[lToOpts,RGE\[Lambda]])}];
];

*)


ClearAll[TransSM0N];
TransSM0N[pScale_?NumericQ,pDirection_?NumericQ,pSolution_,pToOpts_,pFromOpts_]:=Block[{
    lPars,
    lg1,lg2,lg3,lYu,lYd,lYe,lY\[Nu],lY\[Nu]Rotated,l\[Kappa],lM\[Nu]r,lM\[Nu]rRotated,
    lsb,lcb,lMS2DR,
    lUL, lVL, lvu
  },
    (* make a transition from the MSSM to the SM w/o heavy neutrinos *)
    (* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!depends on RGESM.m !!!!!!!!!!!!!!!!!!!!!!!!!
    the dependencies are marked by !!! *)
    lFromOpts;
    Options[lFromOpts]=Options[RGEOptions];
    SetOptions[lFromOpts,RGEFilterOptions[lFromOpts,pFromOpts]];
    lToOpts;
    Options[lToOpts]=Options[RGEGetModelOptions["SM0N"][[1,2]]];
    SetOptions[lToOpts,RGEFilterOptions[lToOpts,pToOpts]];
    lvu=RGEv\[Nu]/.Options[lFromOpts];
  
    (* calculate the new parameters *)
    lPars = Thread[(Head /@ ParametersFunc[t]) -> (ParametersFunc[ pScale ]/.pSolution)[[1]]];
    {lg1,lg2,lg3,lYu,lYd,lYe,l\[Kappa]} = {g1,g2,g3,Yu,Yd,Ye,\[Kappa]} /. lPars;
    
    If[MemberQ[pSolution[[All,1]], M\[Nu]r],
      {lY\[Nu], lM\[Nu]r, l\[Kappa], lT\[Nu], lm2\[Nu]} = {Y\[Nu], M\[Nu]r, \[Kappa], T\[Nu], m2\[Nu]} /. lPars;
  
      (* rotation to diagonal lM\[Nu]r *)
      {lM\[Nu]rRotated, lY\[Nu]Rotated, lT\[Nu]Rotated, lm2\[Nu]Rotated} = RotateRHNeutrinos[
        lM\[Nu]r, lY\[Nu], lT\[Nu], lm2\[Nu]
      ];
      
      l\[Kappa] += RGEKappaMatching[lM\[Nu]rRotated,lY\[Nu]Rotated,Length[lM\[Nu]r]];
    ];
      
    x = Join[
      Map[
        SymbolName[#[[1]]] -> #[[2]] &,
        FilterRules[lPars, pSolution[[1, All, 1]]]
      ],
      {"gp" -> lg1 Sqrt[3/5.], "M\[Nu]" -> -lvu^2 * (1/2)^2 * 10^9 * l\[Kappa]},
      {
        "tan\[Beta]" -> RGEtan\[Beta],
        "sign\[Mu]" -> STCsign\[Mu],
	"cMSSM" -> STCcMSSM,
	"NonTan\[Beta]" -> Not[STCOnlyTan\[Beta]TC],
        "Q" -> Exp[pScale]
      } /. Options[lFromOpts,{RGEtan\[Beta],STCsign\[Mu],STCcMSSM,STCOnlyTan\[Beta]TC}] // N
    ];
    (*Print["TransSM0N transition scale: ", Exp[pScale]];*)
    (*Print["before: ",TableForm[x]];*)
    
    (
    (*STCGetSUSYScale returns Q*)
    gSUSYScale = "Q" /. x;
    
   
    x = SCKMRotate[x];
    
    (* STCGetProtonDecayOperators returns CL5qlqq and CR5udeu in the SuperCKM basis for Q,L,ec,uc,dc: 
    defined by  Yu and Ye being diagonal, and Yd almost diagonal escept for the VCKM contribution in the left mixing angles*)
  
    
    gProtonDecayOperators = {
     "FlavourBasis[CL5qlqq]" -> ( "FlavourBasis[CL5qlqq]" /. x), 
     "FlavourBasis[CR5udeu]" -> ( "FlavourBasis[CR5udeu]" /. x),
    "SCKMBasis[CL5qlqq]" -> ("SCKMBasis[CL5qlqq]" /. x), 
    "SCKMBasis[CR5udeu]" -> ("SCKMBasis[CR5udeu]" /. x)
    };
    

    x = CalcTreeValues[x];
    
    

    (*STCGetSUSYSpectrum returns treelevel values*)
    gSUSYSpectrum = {
	"Q" -> ("Q" /. x), "\[Mu]" -> ("\[Mu]" /. x), "m3" -> ("m3" /. x), "M1" -> ("M1" /. x), "M2" -> ("M2" /. x),  "M3" -> ("M3" /. x), "Mh" -> ("Mh" /. x), "MH" -> ("MH" /. x),  "MA" -> ("MA" /. x), "MHp" -> ("MHp" /. x),
	"m\[Chi]0" -> ("m\[Chi]0" /. x), "m\[Chi]p" -> ("m\[Chi]p" /. x),  "msude" -> ("msude" /. x), "ms\[Nu]" -> ("ms\[Nu]" /. x),  "\[Theta]W" -> ("\[Theta]W" /. x),
	"tan\[Alpha]" -> ("tan\[Alpha]" /. x), "N" -> ("N" /. x),  "U" -> ("U" /. x), "V" -> ("V" /. x), "Wude" -> ("Wude" /. x),  "W\[Nu]" -> ("W\[Nu]" /. x)};

    (*STCGetSCKMValues returns the SCKM masses*)
    gSCKMValues = {SCKMBasis["m2Q"] -> (SCKMBasis["m2Q"] /. x), SCKMBasis["m2u"] -> (SCKMBasis["m2u"] /. x), SCKMBasis["m2d"] -> (SCKMBasis["m2d"] /. x),"VCKM" -> ("VCKM" /. x), SCKMBasis["m2L"] -> (SCKMBasis["m2L"] /. x), SCKMBasis["m2e"] -> (SCKMBasis["m2e"] /. x), "VPMNS"-> ("VPMNS" /. x), SCKMBasis["Y"] -> (SCKMBasis["Y"] /. x)[[1;;3]], SCKMBasis["T"] -> (SCKMBasis["T"] /. x)[[1;;3]]};

    x = CalcOneLoopValues[x];

    ) (*// AbsoluteTiming // TimingTrace["SusyTCProton"]*);

	If[STCCCBConstraints/.Options[lFromOpts,STCCCBConstraints],
		Block[{ccbQ, ccbu, ccbH, ccbA, sum, type, i, j, n},
		type =
		 {
		  {
 		  ("VCKM"/.x).(SCKMBasis["m2Q"] /. x).ConjugateTranspose["VCKM"/.x],
		  (SCKMBasis["m2u"] /. x),
		  ("m2Hu" /.x),
		  (SCKMBasis["Y"] /. x)[[1]],
		  (SCKMBasis["T"] /. x)[[1]]
		  },
		  {
		  (SCKMBasis["m2Q"] /. x),
		  (SCKMBasis["m2d"] /. x),
		  ("m2Hd" /. x),
		  (SCKMBasis["Y"] /. x)[[2]],
		  (SCKMBasis["T"] /. x)[[2]]
		  },
		  {
		  (SCKMBasis["m2L"] /. x),
		  (SCKMBasis["m2e"] /. x),
		  ("m2Hd" /. x),
		  (SCKMBasis["Y"] /. x)[[3]],
		  (SCKMBasis["T"] /. x)[[3]]
		  }
		 };
		Do[		
		 Do[
		  Do[
		   ccbQ = type[[n, 1]][[i, i]];
		   ccbu = type[[n, 2]][[j, j]];
		   ccbH = type[[n, 3]] + Abs["\[Mu]" /. x]^2;
		   ccbA = type[[n, 5]][[i, j]];
		   sum = If[i != j,
		    Sqrt[type[[n, 4]][[i]]^2 + type[[n, 4]][[j]]^2] Sqrt[ccbH + ccbQ + ccbu], 
		    Sqrt[3] Sqrt[type[[n, 4]][[i]]^2 ] Sqrt[ccbH + ccbQ + ccbu]
		   ];
		   If[Im[sum]/Abs[sum]>10^-10,Print["Relatively large imaginary component ",Im[sum]/Abs[sum],"in CCB constraint check... Continue with Re[]..."]];
	           sum=Re[sum];
  		   If[Abs[ccbA] > sum, Print["Warning: CCB bound violated for ",Switch[n,1,"Tu(",2,"Td(",3,"Te("],j,",",i,") !"]](* indices tranposed for warning in REAP convention*);
		  ,{j, 3}]
		 ,{i, 3}]
		,{n, 3}]
		]
	];

If[STCUFBConstraints/.Options[lFromOpts,STCUFBConstraints],
		Block[{m3sq,i, msl = GetSoftMassMixing[FlavourBasis["m2L"] /. x][[1]],sum},
		  m3sq=Abs["m3" /. x]^2  // Chop;
		  Do[
		    sum = ("m2Hu" /. x) + Abs["\[Mu]" /. x]^2 + msl[[i]]^2 - m3sq^2/(("m2Hd" /. x) + Abs["\[Mu]" /. x]^2 - msl[[i]]^2 ) //Chop;
		    If[Im[sum]/Abs[sum]>10^-10,Print["Relatively large imaginary component ",Im[sum]/Abs[sum],"in UFB-2 constraint check... Continue with Re[]..."]];
		    sum=Re[sum];
		    If[sum < 0, Print["Warning: UFB-2 constraint violated for slepton \[Nu]_L ",i," !"]];
		    sum = ("m2Hu" /. x) + msl[[i]]^2 //Chop;
		    If[Im[sum]/Abs[sum]>10^-10,Print["Relatively large imaginary component ",Im[sum]/Abs[sum],"in UFB-3 constraint check... Continue with Re[]..."]];
		    sum=Re[sum];
		    If[sum < 0, Print["Warning: UFB-3 constraint violated for slepton \[Nu]_L ",i," !"]]
		  ,{i,3}]
		]
	];

     
    ginternalValues = SortBy[x, {Dimensions[#[[2]]], Head[#[[1]]], Length[Flatten[{#[[2]]}]], #[[1]]}&];
    
    gOneLoopValues = {"\[Mu]"-> ("\[Mu]" /. x), "m3"-> ("m3" /. x), If[("cMSSM" /. x) == True, "MHp" -> ("MHp" /. x), "MA" -> ("MA" /. x)], "vev"-> ("vev" /. x)};

    gVCKM = ("VCKM" /. x);

    gVPMNS = ("VPMNS" /. x);
    
    Switch[
      {RGEModelVariant == "2Loop" /. Options[lFromOpts,RGEModelVariant],
       RGEModelVariant == "2Loop" /. Options[lToOpts,RGEModelVariant]},
       
        {True, True},
        lDR2MS = {
            1,
            (1 - lg2^2/(48 Pi^2)),
            (1 - lg3^2/(32 Pi^2)),
            (1 + 1/(32 Pi^2) (-1/36 3/5 lg1^2 - 3/4 lg2^2 + 8/3 lg3^2)),
            (1 + 1/(32 Pi^2) (-13/36 3/5 lg1^2 - 3/4 lg2^2 + 8/3 lg3^2)),
            (1 + 1/(32 Pi^2) (3/4 3/5 lg1^2 - 3/4 lg2^2 ))
        },
        
        {False, False},
        lDR2MS = {1,1,1,1,1,1},
        _,
        Print["Loop level at SM/MSSM boundary not matching, no \
\!\(\*OverscriptBox[\(DR\), \(_\)]\) to \!\(\*OverscriptBox[\(MS\), \
\(_\)]\) conversion done"];
        lDR2MS = {1,1,1,1,1,1}
    ];


    lcb=1/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];
    lsb=RGEtan\[Beta]/Sqrt[1+RGEtan\[Beta]^2]/.Options[lFromOpts,RGEtan\[Beta]];

    Return[{
      RGEg1 -> lDR2MS[[1]] lg1,
      RGEg2 -> lDR2MS[[2]] lg2,
      RGEg3 -> lDR2MS[[3]] lg3,
      RGEYu -> lDR2MS[[4]] OneLoopSMYu[x],
      RGEYd -> lDR2MS[[5]] OneLoopSMYd[x],
      RGEYe -> lDR2MS[[6]] OneLoopSMYe[x],
      RGE\[Kappa] -> OneLoopSM\[Kappa][x],
      RGE\[Lambda] -> (RGE\[Lambda]/.Options[lToOpts,RGE\[Lambda]])
    }];
];




(* internal functions *)

ClearAll[ParametersFunc];
ParametersFunc[pScale_]:=
{
  g1[pScale],g2[pScale],g3[pScale],
  Yu[pScale],Yd[pScale],Ye[pScale],Y\[Nu][pScale],
  \[Kappa][pScale],M\[Nu]r[pScale],
  
  M1[pScale], M2[pScale], M3[pScale],
  Td[pScale], Te[pScale], Tu[pScale], T\[Nu][pScale],
  m2Q[pScale], m2L[pScale], m2u[pScale], m2d[pScale], m2e[pScale], m2\[Nu][pScale], m2Hd[pScale], m2Hu[pScale],
  
  CL5qlqq[pScale],CR5udeu[pScale]
};

ClearAll[SetInitial];
SetInitial[pBoundary_?NumericQ,pInitial_]:=Block[{values},
(* sets the initial values *)
values= {
      g1[pBoundary]==RGEg1,
      g2[pBoundary]==RGEg2,
      g3[pBoundary]==RGEg3,
      Yu[pBoundary]==RGEYu,
      Yd[pBoundary]==RGEYd,
      Ye[pBoundary]==RGEYe,
      Y\[Nu][pBoundary]==RGEY\[Nu],
      \[Kappa][pBoundary]==RGE\[Kappa],
      M\[Nu]r[pBoundary]==RGEM\[Nu]r,
      
      M1[pBoundary]==RGEM1,
      M2[pBoundary]==RGEM2,
      M3[pBoundary]==RGEM3,
      Tu[pBoundary]==RGETu,
      Td[pBoundary]==RGETd,
      Te[pBoundary]==RGETe,
      T\[Nu][pBoundary]==RGET\[Nu],
      m2Q[pBoundary]==RGEm2Q,
      m2L[pBoundary]==RGEm2L,
      m2u[pBoundary]==RGEm2u,
      m2d[pBoundary]==RGEm2d,
      m2e[pBoundary]==RGEm2e,
      m2\[Nu][pBoundary]==RGEm2\[Nu],
      m2Hd[pBoundary]==RGEm2Hd,
      m2Hu[pBoundary]==RGEm2Hu,
      
      CL5qlqq[pBoundary] == RGECL5qlqq,
      CR5udeu[pBoundary] == RGECR5udeu,
   
      Id3[pBoundary] == IdentityMatrix[3]
    };
   Return[values//.pInitial];
];


End[]; (* end of `Private`*)


EndPackage[];
