Skip to content

Commit

Permalink
reformulate generation of beta functions
Browse files Browse the repository at this point in the history
in order to be able to extend it
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Dec 7, 2016
1 parent 0f9f5c8 commit b6eadc8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 69 deletions.
90 changes: 39 additions & 51 deletions meta/BetaFunction.m
Expand Up @@ -57,13 +57,13 @@
Module[{result = ""},
(result = result <> CConversion`CreateCType[GetType[#]] <>
" calc_beta_" <> CConversion`ToValidCSymbolString[GetName[#]] <>
"_one_loop(const TRACE_STRUCT_TYPE&) const;\n" <>
"_1_loop(const TRACE_STRUCT_TYPE&) const;\n" <>
CConversion`CreateCType[GetType[#]] <>
" calc_beta_" <> CConversion`ToValidCSymbolString[GetName[#]] <>
"_two_loop(const TRACE_STRUCT_TYPE&) const;\n" <>
"_2_loop(const TRACE_STRUCT_TYPE&) const;\n" <>
CConversion`CreateCType[GetType[#]] <>
" calc_beta_" <> CConversion`ToValidCSymbolString[GetName[#]] <>
"_three_loop(const TRACE_STRUCT_TYPE&) const;\n";)& /@ betaFun;
"_3_loop(const TRACE_STRUCT_TYPE&) const;\n";)& /@ betaFun;
Return[result];
];

Expand Down Expand Up @@ -212,58 +212,46 @@
Return[{localDecl, betaStr}];
];

CreateBetaFunctionCall[betaFunction_BetaFunction] :=
Module[{beta1L, beta2L = "", beta3L = "", betaName = "", name = "",
oneLoopBetaStr, cType, localDecl = "",
twoLoopBetaStr, threeLoopBetaStr, type = ErrorType},
name = ToValidCSymbolString[GetName[betaFunction]];
type = GetType[betaFunction];
ctype = CConversion`CreateCType[type];
betaName = "beta_" <> name;
localDecl = ctype <> " " <> CConversion`SetToDefault[betaName, type];
If[Length[GetAllBetaFunctions[betaFunction]] > 0,
oneLoopBetaStr = "calc_beta_" <> name <> "_one_loop(TRACE_STRUCT)";
beta1L = betaName <> " += " <> oneLoopBetaStr <> ";\n";
];
If[Length[GetAllBetaFunctions[betaFunction]] > 1,
twoLoopBetaStr = "calc_beta_" <> name <> "_two_loop(TRACE_STRUCT)";
beta2L = betaName <> " += " <> twoLoopBetaStr <> ";\n";
];
If[Length[GetAllBetaFunctions[betaFunction]] > 2,
threeLoopBetaStr = "calc_beta_" <> name <> "_three_loop(TRACE_STRUCT)";
beta3L = betaName <> " += " <> threeLoopBetaStr <> ";\n";
DeclareBetaFunction[betaFunction_BetaFunction] :=
Module[{name, betaName, type, ctype},
name = ToValidCSymbolString[GetName[betaFunction]];
betaName = "beta_" <> name;
type = GetType[betaFunction];
ctype = CConversion`CreateCType[type];
ctype <> " " <> CConversion`SetToDefault[betaName, type]
];

CreateBetaFunctionCall[betaFunction_BetaFunction, loopOrder_Integer] :=
Module[{name, betaName, result = ""},
If[Length[GetAllBetaFunctions[betaFunction]] >= loopOrder,
name = ToValidCSymbolString[GetName[betaFunction]];
betaName = "beta_" <> name;
result = betaName <> " += " <>
"calc_" <> betaName <> "_" <> ToString[loopOrder] <> "_loop(TRACE_STRUCT);\n";
];
Return[{localDecl, beta1L, beta2L, beta3L}];
result
];

CreateBetaFunction[betaFunctions_List, sarahTraces_List] :=
Module[{def = "",
localDecl = "", beta1L = "", beta2L = "", beta3L = "",
allDecl = "", allBeta = "",
allBeta1L = "", allBeta2L = "", allBeta3L = "", i, inputParsDecl},
For[i = 1, i <= Length[betaFunctions], i++,
{localDecl, beta1L, beta2L, beta3L} = CreateBetaFunctionCall[betaFunctions[[i]]];
allDecl = allDecl <> localDecl;
allBeta1L = allBeta1L <> beta1L;
allBeta2L = allBeta2L <> TextFormatting`IndentText[beta2L];
allBeta3L = allBeta3L <> TextFormatting`IndentText[beta3L];
];
allBeta = allDecl <> "\n" <>
"if (get_loops() > 0) {\n" <>
TextFormatting`IndentText[
"const auto TRACE_STRUCT = CALCULATE_TRACES();\n\n" <>
allBeta1L <> "\n" <>
"if (get_loops() > 1) {\n" <>
allBeta2L <> "\n" <>
TextFormatting`IndentText[
"if (get_loops() > 2) {\n" <>
allBeta3L <>
"\n}"
] <>
"\n}"
] <>
"\n}\n";
Return[allBeta];
Module[{allBeta1L, allBeta2L, allBeta3L},
allBeta1L = StringJoin[CreateBetaFunctionCall[#,1]& /@ betaFunctions];
allBeta2L = TextFormatting`IndentText @ StringJoin[CreateBetaFunctionCall[#,2]& /@ betaFunctions];
allBeta3L = TextFormatting`IndentText @ StringJoin[CreateBetaFunctionCall[#,3]& /@ betaFunctions];
StringJoin[DeclareBetaFunction /@ betaFunctions] <> "\n" <>
"if (get_loops() > 0) {\n" <>
TextFormatting`IndentText[
"const auto TRACE_STRUCT = CALCULATE_TRACES();\n\n" <>
allBeta1L <> "\n" <>
"if (get_loops() > 1) {\n" <>
allBeta2L <> "\n" <>
TextFormatting`IndentText[
"if (get_loops() > 2) {\n" <>
allBeta3L <>
"\n}"
] <>
"\n}"
] <>
"\n}\n"
];

(* Converts SARAH beta functions to our own format.
Expand Down
18 changes: 9 additions & 9 deletions templates/soft_beta_.cpp.in
Expand Up @@ -63,11 +63,11 @@ typename Eigen::MatrixBase<Derived>::PlainObject operator-(double n, const Eigen
} // anonymous namespace

/**
* Calculates the one-loop beta function of @parameterName@.
* Calculates the 1-loop beta function of @parameterName@.
*
* @return one-loop beta function
* @return 1-loop beta function
*/
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_one_loop(const Soft_traces& soft_traces) const
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_1_loop(const Soft_traces& soft_traces) const
{
@localDeclOneLoop@

Expand All @@ -79,11 +79,11 @@ typename Eigen::MatrixBase<Derived>::PlainObject operator-(double n, const Eigen
}

/**
* Calculates the two-loop beta function of @parameterName@.
* Calculates the 2-loop beta function of @parameterName@.
*
* @return two-loop beta function
* @return 2-loop beta function
*/
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_two_loop(const Soft_traces& soft_traces) const
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_2_loop(const Soft_traces& soft_traces) const
{
@localDeclTwoLoop@

Expand All @@ -95,11 +95,11 @@ typename Eigen::MatrixBase<Derived>::PlainObject operator-(double n, const Eigen
}

/**
* Calculates the three-loop beta function of @parameterName@.
* Calculates the 3-loop beta function of @parameterName@.
*
* @return three-loop beta function
* @return 3-loop beta function
*/
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_three_loop(const Soft_traces& soft_traces) const
@parameterType@ @ModelName@_soft_parameters::calc_beta_@parameterName@_3_loop(const Soft_traces& soft_traces) const
{
DEFINE_PROJECTOR(3,3,3,3)

Expand Down
18 changes: 9 additions & 9 deletions templates/susy_beta_.cpp.in
Expand Up @@ -27,11 +27,11 @@ namespace flexiblesusy {
#define TRACE_STRUCT susy_traces

/**
* Calculates the one-loop beta function of @parameterName@.
* Calculates the 1-loop beta function of @parameterName@.
*
* @return one-loop beta function
* @return 1-loop beta function
*/
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_one_loop(const Susy_traces& susy_traces) const
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_1_loop(const Susy_traces& susy_traces) const
{
@localDeclOneLoop@

Expand All @@ -43,11 +43,11 @@ namespace flexiblesusy {
}

/**
* Calculates the two-loop beta function of @parameterName@.
* Calculates the 2-loop beta function of @parameterName@.
*
* @return two-loop beta function
* @return 2-loop beta function
*/
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_two_loop(const Susy_traces& susy_traces) const
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_2_loop(const Susy_traces& susy_traces) const
{
@localDeclTwoLoop@

Expand All @@ -59,11 +59,11 @@ namespace flexiblesusy {
}

/**
* Calculates the three-loop beta function of @parameterName@.
* Calculates the 3-loop beta function of @parameterName@.
*
* @return three-loop beta function
* @return 3-loop beta function
*/
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_three_loop(const Susy_traces& susy_traces) const
@parameterType@ @ModelName@_susy_parameters::calc_beta_@parameterName@_3_loop(const Susy_traces& susy_traces) const
{
DEFINE_PROJECTOR(3,3,3,3)

Expand Down

0 comments on commit b6eadc8

Please sign in to comment.