diff --git a/ChangeLog b/ChangeLog index 24efca2da..3686acaa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -87,6 +87,11 @@ FlexibleSUSY 2.0.0 [not released yet] FlexibleSUSY-1.7.3 [not released yet] + * Change (commit 43bb03a): FlexibleSUSY now aborts the code + generation if the user tries to fix an unknown parameter in a + constraint. (Before this commit, FlexibleSUSY did only print a + warning.) + * Bugfix (commit 4a5ada7): Adding missing return statement in function recalculate_mw_pole(). This bug was only present if the W pole mass is used as input (not GF). diff --git a/doc/images/FS-models.xcf b/doc/images/FS-models.xcf index c8138643a..2d2976552 100644 Binary files a/doc/images/FS-models.xcf and b/doc/images/FS-models.xcf differ diff --git a/meta/Constraint.m b/meta/Constraint.m index 119d909e4..c5d1a0e14 100644 --- a/meta/Constraint.m +++ b/meta/Constraint.m @@ -25,8 +25,6 @@ SetTemporarily::usage="set temporary variables"; -ResetTemporarily::usage="set temporary variables"; - Begin["`Private`"]; allBetaFunctions = {}; @@ -43,7 +41,9 @@ Parameters`IsExtraParameter[parameter], Parameters`SetParameter[parameter, value, modelPrefix], True, - Print["Error: ", parameter, " is neither a model nor an input parameter!"]; + Print["Error: ", parameter, " cannot be set in the constraint,", + " because it is neither a model nor an input parameter!"]; + Quit[1]; "" ]; @@ -599,30 +599,30 @@ Parameters`CreateLocalConstRefs[pars] <> "\n" <> StringJoin[CheckPerturbativityForParameter[#,thresh]& /@ pars]; -SaveValue[par_[idx__], prefix_String] := +SaveValue[par_[idx__]] := Module[{parStr = CConversion`ToValidCSymbolString[par], - parStrIdx = CConversion`ToValidCSymbolString[par[idx]]}, - "const auto " <> prefix <> parStrIdx <> " = MODELPARAMETER(" <> parStr <> ")" <> - "(" <> Utils`StringJoinWithSeparator[ToString /@ {idx},","] <> ");" + parStrIdx = CConversion`ToValidCSymbolString[par[idx]], oldVal}, + oldVal = "old_" <> parStrIdx; + "const auto " <> oldVal <> " = MODELPARAMETER(" <> parStr <> ")" <> + "(" <> Utils`StringJoinWithSeparator[ToString /@ {idx},","] <> ");\n" <> + "const auto save_" <> parStrIdx <> " = make_raii_guard([this," <> oldVal <> "]{ " <> + Parameters`SetParameter[par[idx], oldVal, "MODEL->"] <> " });\n" ]; -SaveValue[par_, prefix_String] := - Module[{parStr = CConversion`ToValidCSymbolString[par]}, - "const auto " <> prefix <> parStr <> " = MODELPARAMETER(" <> parStr <> ");" +SaveValue[par_] := + Module[{parStr = CConversion`ToValidCSymbolString[par], oldVal}, + oldVal = "old_" <> parStr; + "const auto " <> oldVal <> " = MODELPARAMETER(" <> parStr <> ");\n" <> + "const auto save_" <> parStr <> " = make_raii_guard([this," <> oldVal <> "]{ " <> + Parameters`SetParameter[par, oldVal, "MODEL->"] <> " });\n" ]; -RestoreValue[par_, prefix_String] := - Parameters`SetParameter[ - par, - prefix <> CConversion`ToValidCSymbolString[par], - "MODEL->"]; - SetTemporarily[settings_List] := Module[{tempSettings = Cases[settings, {FlexibleSUSY`Temporary[p_], v_} :> {p,v}], set, savedVals}, If[tempSettings === {}, Return[""];]; set = ApplyConstraints[tempSettings]; - savedVals = Utils`StringJoinWithSeparator[SaveValue[#[[1]], "old_"]& /@ tempSettings, "\n"]; + savedVals = Utils`StringJoinWithSeparator[SaveValue[#[[1]]]& /@ tempSettings, "\n"]; "// temporary parameter re-definitons\n" <> savedVals <> "\n{\n" <> IndentText[set] <> "}" ]; diff --git a/meta/FlexibleSUSY.m b/meta/FlexibleSUSY.m index 66bd2f374..bbbd148d4 100644 --- a/meta/FlexibleSUSY.m +++ b/meta/FlexibleSUSY.m @@ -739,7 +739,7 @@ FlexibleSUSY model file (FlexibleSUSY.m). {minimumScale_, maximumScale_}, files_List] := Module[{applyConstraint = "", calculateScale, scaleGuess, restrictScale, - temporarySetting = "", temporaryResetting = "", + temporarySetting = "", setDRbarYukawaCouplings, calculateDRbarMasses, calculateDeltaAlphaEm, calculateDeltaAlphaS, @@ -753,7 +753,6 @@ FlexibleSUSY model file (FlexibleSUSY.m). scaleGuess = Constraint`CalculateScale[scaleFirstGuess, "initial_scale_guess"]; restrictScale = Constraint`RestrictScale[{minimumScale, maximumScale}]; temporarySetting = Constraint`SetTemporarily[settings]; - temporaryResetting = Constraint`ResetTemporarily[settings]; calculateDeltaAlphaEm = ThresholdCorrections`CalculateDeltaAlphaEm[FlexibleSUSY`FSRenormalizationScheme]; calculateDeltaAlphaS = ThresholdCorrections`CalculateDeltaAlphaS[FlexibleSUSY`FSRenormalizationScheme]; calculateThetaW = ThresholdCorrections`CalculateThetaW[FSWeakMixingAngleOptions,SARAH`SupersymmetricModel]; @@ -791,7 +790,6 @@ FlexibleSUSY model file (FlexibleSUSY.m). "@scaleGuess@" -> IndentText[WrapLines[scaleGuess]], "@restrictScale@" -> IndentText[WrapLines[restrictScale]], "@temporarySetting@" -> IndentText[WrapLines[temporarySetting]], - "@temporaryResetting@" -> IndentText[WrapLines[temporaryResetting]], "@calculateGaugeCouplings@" -> IndentText[WrapLines[calculateGaugeCouplings]], "@calculateDeltaAlphaEm@" -> IndentText[WrapLines[calculateDeltaAlphaEm]], "@calculateDeltaAlphaS@" -> IndentText[WrapLines[calculateDeltaAlphaS]], diff --git a/meta/LoopMasses.m b/meta/LoopMasses.m index 0c0d75bdc..3839692e5 100644 --- a/meta/LoopMasses.m +++ b/meta/LoopMasses.m @@ -143,7 +143,7 @@ "const double self_energy = Re(" <> selfEnergyFunction <> "(p));\n" <> "const double mass_sqr = " <> massMatrixName <> " - self_energy;\n\n" <> "if (mass_sqr < 0.)\n" <> - IndentText["problems.flag_pole_tachyon(" <> particleName <> ");"] <> "\n\n" <> + IndentText[TreeMasses`FlagPoleTachyon[particleName]] <> "\n" <> "PHYSICAL(" <> massName <> ") = AbsSqrt(mass_sqr);\n"; @@ -686,7 +686,7 @@ be set to the (positive) tree-level mass. M_tree Module[{result, body = ""}, If[!IsFermion[particle] && !(IsUnmixed[particle] && GetMassOfUnmixedParticle[particle] === 0), - body = "if (!force_output && problems.is_running_tachyon(" <> ToValidCSymbolString[particle] <> "))\n" <> + body = "if (!force_output && problems.is_running_tachyon(" <> FlexibleSUSY`FSModelName <> "_info::" <> ToValidCSymbolString[particle] <> "))\n" <> IndentText["return;"] <> "\n\n"; ]; body = body <> DoDiagonalization[particle, precision, tadpole]; @@ -715,7 +715,7 @@ be set to the (positive) tree-level mass. M_tree Return[""]; ]; If[!(IsUnmixed[particle] && GetMassOfUnmixedParticle[particle] === 0), - body = "if (!force_output && problems.is_running_tachyon(" <> ToValidCSymbolString[particle] <> "))\n" <> + body = "if (!force_output && problems.is_running_tachyon(" <> FlexibleSUSY`FSModelName <> "_info::" <> ToValidCSymbolString[particle] <> "))\n" <> IndentText["return 0.;"] <> "\n\n"; ]; If[!IsMassless[particle], @@ -734,7 +734,7 @@ be set to the (positive) tree-level mass. M_tree "const double self_energy = Re(" <> selfEnergyFunction <> "(p));\n" <> "const double mass_sqr = " <> mTree <> " - self_energy;\n\n" <> "if (mass_sqr < 0.)\n" <> - IndentText["problems.flag_pole_tachyon(" <> particleName <> ");"] <> "\n\n" <> + IndentText[TreeMasses`FlagPoleTachyon[particleName]] <> "\n" <> "return AbsSqrt(mass_sqr);\n"; , body = "return 0.;\n"; @@ -1085,7 +1085,7 @@ be set to the (positive) tree-level mass. M_tree "const double self_energy = Re(" <> selfEnergyFunction <> "(p));\n" <> "const double mass_sqr = Sqr(m_pole) + self_energy;\n\n" <> "if (mass_sqr < 0.) {\n" <> - IndentText["problems.flag_running_tachyon(" <> particleName <> ");\n" <> + IndentText[TreeMasses`FlagPoleTachyon[particleName] <> "return m_pole;"] <> "\n}\n\n" <> "return AbsSqrt(mass_sqr);\n"; ]; diff --git a/meta/SelfEnergies.m b/meta/SelfEnergies.m index adc2d1c67..adf65f539 100644 --- a/meta/SelfEnergies.m +++ b/meta/SelfEnergies.m @@ -589,8 +589,12 @@ DivideTadpoleByVEV[higgsAndVEV_List, arrayName_String] := Module[{body = "", v, vev}, For[v = 1, v <= Length[higgsAndVEV], v++, - vev = CConversion`RValueToCFormString[higgsAndVEV[[v,3]]]; - body = body <> arrayName <> "[" <> ToString[v-1] <> "] /= " <> vev <> ";\n"; + vev = higgsAndVEV[[v,3]]; + If[vev === 0, + body = body <> arrayName <> "[" <> ToString[v-1] <> "] = 0.;\n";, + vev = CConversion`RValueToCFormString[vev]; + body = body <> arrayName <> "[" <> ToString[v-1] <> "] /= " <> vev <> ";\n"; + ]; ]; body ]; diff --git a/meta/ThresholdCorrections.m b/meta/ThresholdCorrections.m index 77456129d..7325a37c8 100644 --- a/meta/ThresholdCorrections.m +++ b/meta/ThresholdCorrections.m @@ -601,8 +601,7 @@ const double mw_pole_sqr = Sqr(mw_drbar) - self_energy_w_at_mw; if (mw_pole_sqr < 0.) - MODEL->get_problems().flag_pole_tachyon(" <> FlexibleSUSY`FSModelName <> "_info::" <> wStr <> "); - + " <> TreeMasses`FlagPoleTachyon[wStr, "MODEL->get_problems()."] <> " return AbsSqrt(mw_pole_sqr);" ]; diff --git a/meta/TreeMasses.m b/meta/TreeMasses.m index e7b25673c..f543b3af3 100644 --- a/meta/TreeMasses.m +++ b/meta/TreeMasses.m @@ -198,6 +198,9 @@ CallDiagonalizeSymmetricFunction::usage=""; CallDiagonalizeHermitianFunction::usage=""; +FlagPoleTachyon::usage = ""; +FlagRunningTachyon::usage = ""; + Begin["`Private`"]; unrotatedParticles = {}; @@ -1250,7 +1253,7 @@ the fundamental representation of SU(3) in SARAH. WrapMacro[CConversion`ToValidCSymbolString[FlexibleSUSY`M[particle]],macro] <> If[dimEnd > 1, ".tail<" <> ToString[dimEnd - dimStart + 1] <> ">().minCoeff()", ""]<> " < 0.) " <> - "problems.flag_pole_tachyon(" <> particleName <> ");\n" + FlagPoleTachyon[particleName] ]; CheckPoleMassesForTachyons[macro_String] := @@ -1338,20 +1341,25 @@ the fundamental representation of SU(3) in SARAH. {prototype, def} ]; -FlagTachyon[particle_String] := - "problems.flag_running_tachyon(" <> +FlagPoleTachyon[particle_String, problems_String:"problems."] := + problems <> "flag_pole_tachyon(" <> + FlexibleSUSY`FSModelName <> "_info::" <> particle <> + ");\n"; + +FlagRunningTachyon[particle_String, problems_String:"problems."] := + problems <> "flag_running_tachyon(" <> FlexibleSUSY`FSModelName <> "_info::" <> particle <> ");\n"; -FlagTachyon[particles_List] := - StringJoin[FlagTachyon /@ particles]; +FlagRunningTachyon[particles_List] := + StringJoin[FlagRunningTachyon /@ particles]; -FlagTachyon[particle_] := - FlagTachyon[ToValidCSymbolString[GetHead[particle]]]; +FlagRunningTachyon[particle_] := + FlagRunningTachyon[ToValidCSymbolString[GetHead[particle]]]; -CheckTachyon[particle_, eigenvector_String] := +CheckRunningTachyon[particle_, eigenvector_String] := "if (" <> eigenvector <> If[GetDimension[particle] > 1, ".minCoeff()", ""] <> " < 0.) {\n" <> - IndentText[FlagTachyon[particle]] <> + IndentText[FlagRunningTachyon[particle]] <> "}\n"; FlagBadMass[particle_String, eigenvalue_String] := @@ -1473,7 +1481,7 @@ the fundamental representation of SU(3) in SARAH. body = body <> "\n" <> IndentText[ If[ContainsMassless[eigenVector], "", - CheckTachyon[eigenVector, ev] <> "\n"] <> + CheckRunningTachyon[eigenVector, ev] <> "\n"] <> ev <> " = AbsSqrt(" <> ev <> ");\n" ]; ]; @@ -1541,7 +1549,7 @@ the fundamental representation of SU(3) in SARAH. !IsMassless[massESSymbol], body = body <> "\n" <> If[ContainsMassless[eigenVector], "", - CheckTachyon[massESSymbol, ev] <> "\n"] <> + CheckRunningTachyon[massESSymbol, ev] <> "\n"] <> ev <> " = AbsSqrt(" <> ev <> ");\n"; ]; body = IndentText[body]; diff --git a/src/raii.hpp b/src/raii.hpp index f6795b50b..57968a89e 100644 --- a/src/raii.hpp +++ b/src/raii.hpp @@ -29,7 +29,11 @@ template class RAII_save { public: RAII_save(T& var_) noexcept : var(var_), value(var_) {} + RAII_save(const RAII_save&) = delete; + RAII_save(RAII_save&&) = default; ~RAII_save() { var = value; } + RAII_save& operator=(const RAII_save&) = delete; + RAII_save& operator=(RAII_save&& other) = default; private: T& var; diff --git a/templates/mass_eigenstates.cpp.in b/templates/mass_eigenstates.cpp.in index 3150bae19..3dde26fe0 100644 --- a/templates/mass_eigenstates.cpp.in +++ b/templates/mass_eigenstates.cpp.in @@ -57,8 +57,6 @@ namespace flexiblesusy { -using namespace @ModelName@_info; - #define CLASSNAME @ModelName@_mass_eigenstates #define PHYSICAL(parameter) physical.parameter diff --git a/templates/two_scale_high_scale_constraint.cpp.in b/templates/two_scale_high_scale_constraint.cpp.in index 2ef81fbd7..0ad0e4d4d 100644 --- a/templates/two_scale_high_scale_constraint.cpp.in +++ b/templates/two_scale_high_scale_constraint.cpp.in @@ -26,6 +26,7 @@ #include "ew_input.hpp" #include "gsl_utils.hpp" #include "minimizer.hpp" +#include "raii.hpp" #include "root_finder.hpp" #include "threshold_loop_functions.hpp" #include "numerics2.hpp" @@ -75,8 +76,6 @@ void @ModelName@_high_scale_constraint::apply() @applyConstraint@ check_non_perturbative(); - -@temporaryResetting@ } bool @ModelName@_high_scale_constraint::check_non_perturbative() diff --git a/templates/two_scale_low_scale_constraint.cpp.in b/templates/two_scale_low_scale_constraint.cpp.in index 2b06f9069..d9a5caa39 100644 --- a/templates/two_scale_low_scale_constraint.cpp.in +++ b/templates/two_scale_low_scale_constraint.cpp.in @@ -27,6 +27,7 @@ #include "ew_input.hpp" #include "gsl_utils.hpp" #include "minimizer.hpp" +#include "raii.hpp" #include "root_finder.hpp" #include "threshold_loop_functions.hpp" #include "weinberg_angle.hpp" @@ -86,8 +87,6 @@ void @ModelName@_low_scale_constraint::apply() if (model->get_thresholds()) qedqcd.setPoleMW(recalculate_mw_pole(qedqcd.displayPoleMW())); - -@temporaryResetting@ } const Eigen::Matrix,3,3>& @ModelName@_low_scale_constraint::get_ckm() diff --git a/templates/two_scale_model.cpp.in b/templates/two_scale_model.cpp.in index 4a5574131..444dc40e9 100644 --- a/templates/two_scale_model.cpp.in +++ b/templates/two_scale_model.cpp.in @@ -34,8 +34,6 @@ namespace flexiblesusy { -using namespace @ModelName@_info; - #define CLASSNAME @ModelName@ CLASSNAME::@ModelName@(const @ModelName@_input_parameters& input_) diff --git a/templates/two_scale_susy_scale_constraint.cpp.in b/templates/two_scale_susy_scale_constraint.cpp.in index 4fff95211..4f9436665 100644 --- a/templates/two_scale_susy_scale_constraint.cpp.in +++ b/templates/two_scale_susy_scale_constraint.cpp.in @@ -26,6 +26,7 @@ #include "ew_input.hpp" #include "gsl_utils.hpp" #include "minimizer.hpp" +#include "raii.hpp" #include "root_finder.hpp" #include "threshold_loop_functions.hpp" @@ -73,7 +74,6 @@ void @ModelName@_susy_scale_constraint::apply() // apply user-defined susy scale constraints @applyConstraint@ -@temporaryResetting@ } double @ModelName@_susy_scale_constraint::get_scale() const