Skip to content

Commit

Permalink
Generalise EWSB solution to allow making substitutions in EWSB equations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Harries committed Dec 7, 2016
1 parent db79072 commit 676fba4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions meta/EWSB.m
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,13 @@
{{},{}}
];

FindSolutionAndFreePhases[equations_List, parametersFixedByEWSB_List, outputFile_String:""] :=
Module[{solution, reducedSolution, freePhases},
solution = FindSolution[equations, parametersFixedByEWSB];
FindSolutionAndFreePhases[equations_List, parametersFixedByEWSB_List, outputFile_String:"", substitutions_List:{}] :=
Module[{eqsToSolve, solution, reducedSolution, freePhases},
If[substitutions =!= {},
eqsToSolve = equations /. (Rule[#[[1]], #[[2]]]& /@ substitutions);,
eqsToSolve = equations;
];
solution = FindSolution[eqsToSolve, parametersFixedByEWSB];
{reducedSolution, freePhases} = ReduceSolution[solution];
DebugPrint["The full, reduced solution to the EWSB eqs. is:",
reducedSolution];
Expand All @@ -631,7 +635,7 @@
Return[{Flatten[reducedSolution], freePhases}];
];

CreateTreeLevelEwsbSolver[solution_List] :=
CreateTreeLevelEwsbSolver[solution_List, substitutions_List:{}] :=
Module[{result = "", body = "",
i, par, expr, parStr, oldParStr, reducedSolution,
type},
Expand Down Expand Up @@ -681,10 +685,18 @@
body = body <> Parameters`SetParameter[par, oldParStr, None];
];
body = body <> "error = 1;\n";
result = result <>
"if (!is_finite) {\n" <>
IndentText[body] <>
"}";
If[substitutions === {},
result = result <>
"if (!is_finite) {\n" <>
IndentText[body] <>
"}";,
result = result <>
"if (is_finite) {\n" <>
IndentText[WrapLines[SetModelParametersFromEWSB[substitutions]]] <>
"} else {\n" <>
IndentText[body] <>
"}";
];
,
result = "error = solve_ewsb_iteratively(0);\n";
];
Expand Down

0 comments on commit 676fba4

Please sign in to comment.