Skip to content

Commit

Permalink
Merge branch 'feature-slha-wrapper' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Nov 26, 2014
2 parents db75a15 + 20d29b2 commit 9f5de5e
Show file tree
Hide file tree
Showing 21 changed files with 696 additions and 47 deletions.
12 changes: 7 additions & 5 deletions meta/CConversion.m
Expand Up @@ -206,12 +206,12 @@
CreateInlineElementGetter[parameter, "const std::complex<double>&", dim1, dim2];

(* Creates a C++ inline getter *)
CreateInlineGetter[parameter_String, type_String] :=
type <> " get_" <> parameter <>
"() const { return " <> parameter <> "; }\n";
CreateInlineGetter[parameter_String, type_String, postFix_String:"", struct_String:""] :=
type <> " get_" <> parameter <> postFix <>
"() const { return " <> struct <> parameter <> "; }\n";

CreateInlineGetter[parameter_, type_] :=
CreateInlineGetter[parameter, CreateGetterReturnType[type]];
CreateInlineGetter[parameter_, type_, postFix_String:"", struct_String:""] :=
CreateInlineGetter[parameter, CreateGetterReturnType[type], postFix, struct];

(* Creates C++ getter prototype *)
CreateGetterPrototype[parameter_String, type_String] :=
Expand Down Expand Up @@ -522,6 +522,8 @@
*
* etc.
*)
RValueToCFormString[expr_String] := expr;

RValueToCFormString[expr_] :=
Module[{times, result, symbols, greekSymbols, greekSymbolsRules},
symbols = Cases[{expr}, x_Symbol | x_Symbol[__] :> x, Infinity];
Expand Down
35 changes: 32 additions & 3 deletions meta/FlexibleSUSY.m
Expand Up @@ -272,6 +272,15 @@
"@Neutrino@" -> ToValidCSymbolString[SARAH`Neutrino],
"@HiggsBoson@" -> ToValidCSymbolString[SARAH`HiggsBoson],
"@HiggsBoson_" ~~ num_ ~~ "@" /; IntegerQ[ToExpression[num]] :> ToValidCSymbolString[SARAH`HiggsBoson] <> If[TreeMasses`GetDimension[SARAH`HiggsBoson] > 1, "(" <> num <> ")", ""],
"@PseudoScalarBoson@" -> ToValidCSymbolString[SARAH`PseudoScalarBoson],
"@ChargedHiggs@" -> ToValidCSymbolString[SARAH`ChargedHiggs],
"@TopSquark@" -> ToValidCSymbolString[SARAH`TopSquark],
"@TopSquark_" ~~ num_ ~~ "@" /; IntegerQ[ToExpression[num]] :> ToValidCSymbolString[SARAH`TopSquark] <> If[TreeMasses`GetDimension[SARAH`TopSquark] > 1, "(" <> num <> ")", ""],
"@BottomSquark@" -> ToValidCSymbolString[SARAH`BottomSquark],
"@BottomSquark_" ~~ num_ ~~ "@" /; IntegerQ[ToExpression[num]] :> ToValidCSymbolString[SARAH`BottomSquark] <> If[TreeMasses`GetDimension[SARAH`BottomSquark] > 1, "(" <> num <> ")", ""],
"@Sneutrino@" -> ToValidCSymbolString[SARAH`Sneutrino],
"@Selectron@" -> ToValidCSymbolString[SARAH`Selectron],
"@Gluino@" -> ToValidCSymbolString[SARAH`Gluino],
"@UpYukawa@" -> ToValidCSymbolString[SARAH`UpYukawa],
"@DownYukawa@" -> ToValidCSymbolString[SARAH`DownYukawa],
"@ElectronYukawa@" -> ToValidCSymbolString[SARAH`ElectronYukawa],
Expand Down Expand Up @@ -361,13 +370,17 @@
WriteInputParameterClass[inputParameters_List, freePhases_List,
lesHouchesInputParameters_List,
files_List] :=
Module[{defineInputParameters, defaultInputParametersInit},
Module[{defineInputParameters, defaultInputParametersInit, printInputParameters,
allInputParameters},
allInputParameters = Join[inputParameters,freePhases,lesHouchesInputParameters];
defaultValues = {#, DefaultValueOf[#]}& /@ inputParameters;
defineInputParameters = Constraint`DefineInputParameters[Join[inputParameters,freePhases,lesHouchesInputParameters]];
defineInputParameters = Constraint`DefineInputParameters[allInputParameters];
defaultInputParametersInit = Constraint`InitializeInputParameters[Join[defaultValues,freePhases,lesHouchesInputParameters]];
printInputParameters = WriteOut`PrintInputParameters[allInputParameters,"ostr"];
WriteOut`ReplaceInFiles[files,
{ "@defineInputParameters@" -> IndentText[defineInputParameters],
"@defaultInputParametersInit@" -> WrapLines[defaultInputParametersInit],
"@printInputParameters@" -> IndentText[printInputParameters],
Sequence @@ GeneralReplacementRules[]
} ];
];
Expand Down Expand Up @@ -499,6 +512,7 @@
files_List, diagonalizationPrecision_List] :=
Module[{massGetters = "", k,
mixingMatrixGetters = "",
slhaPoleMassGetters = "", slhaPoleMixingMatrixGetters = "",
tadpoleEqPrototypes = "", tadpoleEqFunctions = "",
numberOfEWSBEquations = Length[ewsbEquations], calculateTreeLevelTadpoles = "",
ewsbInitialGuess = "", physicalMassesDef = "", mixingMatricesDef = "",
Expand Down Expand Up @@ -536,6 +550,8 @@
For[k = 1, k <= Length[massMatrices], k++,
massGetters = massGetters <> TreeMasses`CreateMassGetter[massMatrices[[k]]];
mixingMatrixGetters = mixingMatrixGetters <> TreeMasses`CreateMixingMatrixGetter[massMatrices[[k]]];
slhaPoleMassGetters = slhaPoleMassGetters <> TreeMasses`CreateSLHAPoleMassGetter[massMatrices[[k]]];
slhaPoleMixingMatrixGetters = slhaPoleMixingMatrixGetters <> TreeMasses`CreateSLHAPoleMixingMatrixGetter[massMatrices[[k]]];
physicalMassesDef = physicalMassesDef <> TreeMasses`CreatePhysicalMassDefinition[massMatrices[[k]]];
mixingMatricesDef = mixingMatricesDef <> TreeMasses`CreateMixingMatrixDefinition[massMatrices[[k]]];
physicalMassesInit = physicalMassesInit <> TreeMasses`CreatePhysicalMassInitialization[massMatrices[[k]]];
Expand Down Expand Up @@ -626,6 +642,8 @@
"@lspFunctions@" -> lspFunctions,
"@massGetters@" -> IndentText[massGetters],
"@mixingMatrixGetters@" -> IndentText[mixingMatrixGetters],
"@slhaPoleMassGetters@" -> IndentText[slhaPoleMassGetters],
"@slhaPoleMixingMatrixGetters@" -> IndentText[slhaPoleMixingMatrixGetters],
"@tadpoleEqPrototypes@" -> IndentText[tadpoleEqPrototypes],
"@tadpoleEqFunctions@" -> tadpoleEqFunctions,
"@numberOfEWSBEquations@"-> ToString[numberOfEWSBEquations],
Expand Down Expand Up @@ -1296,7 +1314,10 @@
Join[{#[[2]], #[[3]]}& /@ lesHouchesInputParameters,
{#[[1]], #[[3]]}& /@ FlexibleSUSY`FSExtraInputParameters],
{{FileNameJoin[{Global`$flexiblesusyTemplateDir, "input_parameters.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_input_parameters.hpp"}]}}
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_input_parameters.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "input_parameters.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_input_parameters.cpp"}]}
}
];

lesHouchesInputParameters = Join[lesHouchesInputParameters, FlexibleSUSY`FSExtraInputParameters];
Expand Down Expand Up @@ -1443,10 +1464,16 @@
nPointFunctions, vertexRules, phases,
{{FileNameJoin[{Global`$flexiblesusyTemplateDir, "model.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_model.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "model_slha.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_model_slha.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "two_scale_model.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_two_scale_model.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "two_scale_model.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_two_scale_model.cpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "two_scale_model_slha.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_two_scale_model_slha.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "two_scale_model_slha.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_two_scale_model_slha.cpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "physical.hpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_physical.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "physical.cpp.in"}],
Expand All @@ -1465,6 +1492,8 @@
FileNameJoin[{Global`$flexiblesusyOutputDir, FlexibleSUSY`FSModelName <> "_spectrum_generator.hpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "run.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, "run_" <> FlexibleSUSY`FSModelName <> ".cpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "run_cmd_line.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, "run_cmd_line_" <> FlexibleSUSY`FSModelName <> ".cpp"}]},
{FileNameJoin[{Global`$flexiblesusyTemplateDir, "scan.cpp.in"}],
FileNameJoin[{Global`$flexiblesusyOutputDir, "scan_" <> FlexibleSUSY`FSModelName <> ".cpp"}]}
}];
Expand Down
5 changes: 4 additions & 1 deletion meta/Parameters.m
Expand Up @@ -234,7 +234,7 @@
CConversion`ScalarType[CConversion`complexScalarCType]
];

GetTypeFromDimension[sym_, {1}] :=
GetTypeFromDimension[sym_, {0|1}] :=
GetTypeFromDimension[sym, {}];

GetTypeFromDimension[sym_, {num_?NumberQ}] :=
Expand All @@ -255,6 +255,9 @@
GetTypeFromDimension[{}] :=
CConversion`ScalarType[CConversion`realScalarCType];

GetTypeFromDimension[{0}] :=
GetTypeFromDimension[{}];

GetTypeFromDimension[{1}] :=
GetTypeFromDimension[{}];

Expand Down
30 changes: 21 additions & 9 deletions meta/TreeMasses.m
Expand Up @@ -9,6 +9,9 @@
CreateMassGetter::usage="creates a C function for
the mass getter";

CreateSLHAPoleMassGetter::usage="creates a C function for the pole mass
getter";

CreateParticleLaTeXNames::usage="creates a list of the particle's
LaTeX names";

Expand All @@ -24,6 +27,9 @@
CreateMixingMatrixGetter::usage="creates a getter for the mixing
matrix";

CreateSLHAPoleMixingMatrixGetter::usage="creates a getter for the pole
mixing matrix";

CreateMassCalculationPrototype::usage="creates a C function prototype
from a mass matrix";

Expand Down Expand Up @@ -362,7 +368,7 @@
Return[CConversion`MatrixType[type, dim, dim]];
];

CreateMassGetter[massMatrix_TreeMasses`FSMassMatrix] :=
CreateMassGetter[massMatrix_TreeMasses`FSMassMatrix, postFix_String:"", struct_String:""] :=
Module[{massESSymbol, returnType, dim, dimStr, massESSymbolStr},
massESSymbol = GetMassEigenstate[massMatrix];
massESSymbolStr = ToValidCSymbolString[FlexibleSUSY`M[massESSymbol]];
Expand All @@ -372,9 +378,12 @@
returnType = CConversion`ScalarType[CConversion`realScalarCType];,
returnType = CConversion`ArrayType[CConversion`realScalarCType, dim];
];
CConversion`CreateInlineGetter[massESSymbolStr, returnType]
CConversion`CreateInlineGetter[massESSymbolStr, returnType, postFix, struct]
];

CreateSLHAPoleMassGetter[massMatrix_TreeMasses`FSMassMatrix] :=
CreateMassGetter[massMatrix, "_pole_slha", "physical_slha."];

CreateParticleEnum[particles_List] :=
Module[{i, par, name, result = ""},
For[i = 1, i <= Length[particles], i++,
Expand Down Expand Up @@ -444,23 +453,26 @@
Return[result];
];

CreateMixingMatrixGetter[massMatrix_TreeMasses`FSMassMatrix] :=
CreateMixingMatrixGetter[massMatrix_TreeMasses`FSMassMatrix, postFix_String:"", struct_String:""] :=
Module[{mixingMatrixSymbol, returnType},
mixingMatrixSymbol = GetMixingMatrixSymbol[massMatrix];
returnType = GetMixingMatrixType[massMatrix];
CreateMixingMatrixGetter[mixingMatrixSymbol, returnType]
CreateMixingMatrixGetter[mixingMatrixSymbol, returnType, postFix, struct]
];

CreateMixingMatrixGetter[mixingMatrixSymbol_List, returnType_] :=
CreateMixingMatrixGetter[mixingMatrixSymbol_List, returnType_, postFix_String:"", struct_String:""] :=
Module[{result = ""},
(result = result <> CreateMixingMatrixGetter[#,returnType])& /@ mixingMatrixSymbol;
(result = result <> CreateMixingMatrixGetter[#,returnType, postFix, struct])& /@ mixingMatrixSymbol;
Return[result];
];

CreateMixingMatrixGetter[Null, returnType_] := "";
CreateMixingMatrixGetter[Null, returnType_, postFix_String:"", struct_String:""] := "";

CreateMixingMatrixGetter[mixingMatrixSymbol_Symbol, returnType_, postFix_String:"", struct_String:""] :=
CConversion`CreateInlineGetter[ToValidCSymbolString[mixingMatrixSymbol], returnType, postFix, struct];

CreateMixingMatrixGetter[mixingMatrixSymbol_Symbol, returnType_] :=
CConversion`CreateInlineGetter[ToValidCSymbolString[mixingMatrixSymbol], returnType];
CreateSLHAPoleMixingMatrixGetter[massMatrix_TreeMasses`FSMassMatrix] :=
CreateMixingMatrixGetter[massMatrix, "_pole_slha", "physical_slha."];

CreateFSMassMatrixForUnmixedParticle[TreeMasses`FSMassMatrix[expr_, massESSymbol_, Null]] :=
Module[{matrix, dim},
Expand Down
21 changes: 21 additions & 0 deletions meta/WriteOut.m
Expand Up @@ -4,6 +4,7 @@

ReplaceInFiles::usage="Replaces tokens in files.";
PrintParameters::usage="Creates parameter printout statements";
PrintInputParameters::usage="Creates input parameter printout statements";
WriteSLHAExtparBlock::usage="";
WriteSLHAMassBlock::usage="";
WriteSLHAMixingMatricesBlocks::usage="";
Expand Down Expand Up @@ -64,6 +65,9 @@
TransposeIfVector[parameter_, CConversion`VectorType[__]] :=
SARAH`Tp[parameter];

TransposeIfVector[p:FlexibleSUSY`Sign[parameter_], _] :=
CConversion`ToValidCSymbolString[p];

TransposeIfVector[parameter_, _] := parameter;

PrintParameter[Null, streamName_String] := "";
Expand All @@ -85,6 +89,23 @@
Return[result];
];

PrintInputParameter[Null, _] := "";

PrintInputParameter[parameter_, streamName_String] :=
Module[{parameterStr, expr, type},
parameterStr = CConversion`ToValidCSymbolString[parameter];
type = Parameters`GetType[parameter];
expr = TransposeIfVector[parameter, type];
Return[streamName <> " << \"" <> parameterStr <> " = \" << " <>
"INPUT(" <> CConversion`RValueToCFormString[expr] <> ") << \", \";\n"];
];

PrintInputParameters[parameters_List, streamName_String] :=
Module[{result = ""},
(result = result <> PrintInputParameter[#,streamName])& /@ parameters;
Return[result];
];

(* Write constant MW from ew_input.hpp
*
* Note: This function can be removed as soon as we no longer
Expand Down
33 changes: 33 additions & 0 deletions templates/input_parameters.cpp.in
@@ -0,0 +1,33 @@
// ====================================================================
// This file is part of FlexibleSUSY.
//
// FlexibleSUSY is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// FlexibleSUSY is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FlexibleSUSY. If not, see
// <http://www.gnu.org/licenses/>.
// ====================================================================

// File generated at @DateAndTime@

#include "@ModelName@_input_parameters.hpp"

#define INPUT(p) input.p

namespace flexiblesusy {

std::ostream& operator<<(std::ostream& ostr, const @ModelName@_input_parameters& input)
{
@printInputParameters@
return ostr;
}

} // namespace flexiblesusy
2 changes: 2 additions & 0 deletions templates/input_parameters.hpp.in
Expand Up @@ -33,6 +33,8 @@ struct @ModelName@_input_parameters {
{}
};

std::ostream& operator<<(std::ostream&, const @ModelName@_input_parameters&);

} // namespace flexiblesusy

#endif
31 changes: 31 additions & 0 deletions templates/model_slha.hpp.in
@@ -0,0 +1,31 @@
// ====================================================================
// This file is part of FlexibleSUSY.
//
// FlexibleSUSY is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// FlexibleSUSY is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FlexibleSUSY. If not, see
// <http://www.gnu.org/licenses/>.
// ====================================================================

// File generated at @DateAndTime@

#ifndef @ModelName@_SLHA_H
#define @ModelName@_SLHA_H

namespace flexiblesusy {

template <class T>
class @ModelName@_slha;

}

#endif
5 changes: 5 additions & 0 deletions templates/module.mk
Expand Up @@ -8,11 +8,14 @@ TEMPLATES := \
$(DIR)/info.hpp.in \
$(DIR)/info.cpp.in \
$(DIR)/input_parameters.hpp.in \
$(DIR)/input_parameters.cpp.in \
$(DIR)/low_scale_constraint.hpp.in \
$(DIR)/model.hpp.in \
$(DIR)/model_slha.hpp.in \
$(DIR)/physical.hpp.in \
$(DIR)/physical.cpp.in \
$(DIR)/run.cpp.in \
$(DIR)/run_cmd_line.cpp.in \
$(DIR)/scan.cpp.in \
$(DIR)/slha_io.hpp.in \
$(DIR)/slha_io.cpp.in \
Expand All @@ -33,6 +36,8 @@ TEMPLATES := \
$(DIR)/two_scale_low_scale_constraint.cpp.in \
$(DIR)/two_scale_model.hpp.in \
$(DIR)/two_scale_model.cpp.in \
$(DIR)/two_scale_model_slha.hpp.in \
$(DIR)/two_scale_model_slha.cpp.in \
$(DIR)/two_scale_soft_beta_.cpp.in \
$(DIR)/two_scale_soft_parameters.hpp.in \
$(DIR)/two_scale_soft_parameters.cpp.in \
Expand Down

0 comments on commit 9f5de5e

Please sign in to comment.