Commit c368aeac authored by Kevin Jacques's avatar Kevin Jacques

square & t32 with Flag_ItLoopNRes to select Error Calculation type for ItLoopN

parent 7519c53d
Pipeline #1652 passed with stage
in 9 minutes and 48 seconds
......@@ -722,26 +722,42 @@ Resolution {
If(Flag_NLRes==NLRES_ITERATIVELOOPN)
// I T E R A T I V E . L O O P . N ..............................
// INIT for h_only case::::::::::::
/*
//:::::::::::::::::::::::::::::::::::::::::::
If(Flag_ItLoopNDoFirstIter)
GenerateJac[A] ;
If (!Flag_AdaptRelax)
SolveJac[A] ;
Else
SolveJac_AdaptRelax[A, List[RelaxFac_Lin],TestAllFactors ] ;
EndIf
//*/
//:::::::::::::::::::::::::::::::::
EndIf
//:::::::::::::::::::::::::::::::::::::::::::
//*****Choose between one of the following possibilities:*****
If(Flag_ItLoopNRes==NLITLOOPN_SOLUTION)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
System { { A , Reltol_Mag, Abstol_Mag, Solution MeanL2Norm }} ]{ // 0 : Solution (dx=x-xp; x=x)
EndIf
If(Flag_ItLoopNRes==NLITLOOPN_RESIDUAL)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
System { { A , Reltol_Mag, Abstol_Mag, Residual MeanL2Norm }} ]{ //1 : Residual (dx=res=b-Ax; x=b)
EndIf
If(Flag_ItLoopNRes==NLITLOOPN_RECALCRESIDUAL)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
System { { A , Reltol_Mag, Abstol_Mag, RecalcResidual MeanL2Norm }} ]{ //2 : RecalcResidual (dx=res=b-Ax; x=b)
EndIf
If(Flag_ItLoopNRes==NLITLOOPN_POSTOPX)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
PostOperation { { az_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ // 31 : PostOp unknown field az
EndIf
If(Flag_ItLoopNRes==NLITLOOPN_POSTOPB)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
PostOperation { { b_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ // 32 : PostOp b field
EndIf
If(Flag_ItLoopNRes==NLITLOOPN_POSTOPH)
IterativeLoopN[ Nb_max_iter, RF_tuned[],
//*****Choose between one of the 3 following possibilities:*****
//System { { A , Reltol_Mag, Abstol_Mag, Solution MeanL2Norm }} ]{ //1a) //dx=x-xp; x=x
//System { { A , Reltol_Mag, Abstol_Mag, RecalcResidual MeanL2Norm }} ]{ //1b) //dx=res=b-Ax; x=b
System { { A , Reltol_Mag, Abstol_Mag, Residual MeanL2Norm }} ]{ //1c) //dx=res=b-Ax; x=b #(default for square) #CHECK here
//PostOperation { { az_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ //2)
//PostOperation { { b_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ //3)
//PostOperation { { h_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ //4) //(default for t32) #CHECK here //Need the above "INIT" for square with EnergHyst or JA because h_only = 0 at iter 1
//**************************************************************
PostOperation { { h_only , Reltol_Mag, Abstol_Mag, MeanL2Norm }} ]{ // 33 : PostOp h field
EndIf
//**************************************************************
Evaluate[$res = $ResidualN, $resL = $Residual,$resN = $ResidualN,$iter = $Iteration-1];
Test[ $iter>0]{
......
......@@ -72,6 +72,16 @@ TestAllFactors00 = 2; // 0 : try first relaxation factors (from the list) an
// - the relaxation factor is multiplied by a ratio as long as the residual decreases
// - the relaxation factor is decreased by a ratio until a decreasing residual is found
// [3 : Build a parabola based on three relaxation factors and deduce a minimizing relaxation factor (NOT WORKING!!)]
Flag_ItLoopNRes00 = 1;// 0 : Solution (dx=x-xp; x=x)
// 1 : Residual (dx=res=b-Ax; x=b) (default for square ???)
// 2 : RecalcResidual (dx=res=b-Ax; x=b)
// 31 : PostOp unknown field (az or f)
// 32 : PostOp b field
// 33 : PostOp h field (default for t32)
Flag_ItLoopNDoFirstIter00 = 0;// set to 1 if one wants to force the first NL iteration before evaluating the error with IterativeLoopN
// helpfull for square.pro with EnergHyst or JA because PostOp h field = 0 at iter 1, which stops IterativeLoopN prematurely
EndIf
Reltol_Mag00 = stop_criterion00; // 0 before with IterativeLoopN
......@@ -96,6 +106,13 @@ NLRES_ITERATIVELOOP = 0;
NLRES_ITERATIVELOOPN = 1;
NLRES_ITERATIVELOOPPRO = 2;
NLITLOOPN_SOLUTION = 0;
NLITLOOPN_RESIDUAL = 1;
NLITLOOPN_RECALCRESIDUAL = 2;
NLITLOOPN_POSTOPX = 31;
NLITLOOPN_POSTOPB = 32;
NLITLOOPN_POSTOPH = 33;
AN_STATIC = 0;
AN_TIME = 1;
AN_FREQUENCY = 2;
......@@ -193,6 +210,23 @@ DefineConstant[
Help Str["- Use 'IterativeLoop' to solve the NL (non linear) problem with classical IterativeLoop Operation",
"- Use 'IterativeLoopN' to solve the NL (non linear) problem with IterativeLoopN Operation",
"- Use 'IterativeLoopPro' to solve the NL (non linear) problem 'by hand'"]},
Flag_ItLoopNRes = { (Flag_NLRes!=NLRES_ITERATIVELOOPN)? NLITLOOPN_SOLUTION:Flag_ItLoopNRes00 , Choices {
NLITLOOPN_SOLUTION ="Solution",
NLITLOOPN_RESIDUAL ="RecalcResidual",
NLITLOOPN_RECALCRESIDUAL ="Residual",
NLITLOOPN_POSTOPX ="PostOp Potential",
NLITLOOPN_POSTOPB ="PostOp b field",
NLITLOOPN_POSTOPH ="PostOp h field"},
Name StrCat[ppNL, "1Error Calculation based on ..."], Highlight Str[colNL1], Visible Flag_NL ,ReadOnly (Flag_NLRes!=NLRES_ITERATIVELOOPN),
Help Str["- the solution (dx=x-xp; x=x)",
"- the residual (dx=res=b-Ax; x=b)",
"- the recalculated residual (dx=res=b-Ax; x=b)",
"- the post-operated potential field (az or phi)",
"- the post-operated flux density field (b)",
"- the post-operated magnetic field (h)"]},
Flag_ItLoopNDoFirstIter = {Flag_ItLoopNDoFirstIter00, Choices{0,1}, Name StrCat[ppNL, "1First iteration done before error calculation"],
Highlight Str[colNL1], Visible (Flag_NL && Flag_NLRes==NLRES_ITERATIVELOOPN),
Help Str["Set to 1 to force the first NL iteration to be done before evaluating the error with IterativeLoopN"]},
Nb_max_iter = {Nb_max_iter00, Name StrCat[ppNL, "1Nb max iter"],
Highlight Str[colNL4], Visible Flag_NL}
......
......@@ -56,6 +56,15 @@ TestAllFactors00 = 1; // 0 : try first relaxation factors (from the list) an
// - the relaxation factor is multiplied by a ratio as long as the residual decreases
// - the relaxation factor is decreased by a ratio until a decreasing residual is found
// [3 : Build a parabola based on three relaxation factors and deduce a minimizing relaxation factor (NOT WORKING!!)]
Flag_ItLoopNRes00 = 33;// 0 : Solution (dx=x-xp; x=x)
// 1 : Residual (dx=res=b-Ax; x=b) (default for square ???)
// 2 : RecalcResidual (dx=res=b-Ax; x=b)
// 31 : PostOp unknown field (az or f)
// 32 : PostOp b field
// 33 : PostOp h field (default for t32)
Flag_ItLoopNDoFirstIter00 = 0;// set to 1 if one wants to force the first NL iteration before evaluating the error with IterativeLoopN
// helpfull for square.pro with EnergHyst or JA because PostOp h field = 0 at iter 1, which stops IterativeLoopN prematurely
Reltol_Mag00 = stop_criterion00; // 0 before with IterativeLoopN
Abstol_Mag00 = stop_criterion00;
Reltoldx_Mag00 = 1e-5*stop_criterion00;
......@@ -78,6 +87,13 @@ NLRES_ITERATIVELOOP = 0;
NLRES_ITERATIVELOOPN = 1;
NLRES_ITERATIVELOOPPRO = 2;
NLITLOOPN_SOLUTION = 0;
NLITLOOPN_RESIDUAL = 1;
NLITLOOPN_RECALCRESIDUAL = 2;
NLITLOOPN_POSTOPX = 31;
NLITLOOPN_POSTOPB = 32;
NLITLOOPN_POSTOPH = 33;
AN_STATIC = 0;
AN_TIME = 1;
AN_FREQUENCY = 2;
......@@ -214,6 +230,25 @@ DefineConstant[
Help Str["- Use 'IterativeLoop' to solve the NL (non linear) problem with classical IterativeLoop Operation",
"- Use 'IterativeLoopN' to solve the NL (non linear) problem with IterativeLoopN Operation",
"- Use 'IterativeLoopPro' to solve the NL (non linear) problem 'by hand'"]},
Flag_ItLoopNRes = { (Flag_NLRes!=NLRES_ITERATIVELOOPN)? NLITLOOPN_SOLUTION:Flag_ItLoopNRes00 , Choices {
NLITLOOPN_SOLUTION ="Solution",
NLITLOOPN_RESIDUAL ="RecalcResidual",
NLITLOOPN_RECALCRESIDUAL ="Residual",
NLITLOOPN_POSTOPX ="PostOp Potential",
NLITLOOPN_POSTOPB ="PostOp b field",
NLITLOOPN_POSTOPH ="PostOp h field"},
Name StrCat[ppNL, "1Error Calculation based on ..."], Highlight Str[colNL1], Visible Flag_NL ,ReadOnly (Flag_NLRes!=NLRES_ITERATIVELOOPN),
Help Str["- the solution (dx=x-xp; x=x)",
"- the residual (dx=res=b-Ax; x=b)",
"- the recalculated residual (dx=res=b-Ax; x=b)",
"- the post-operated potential field (az or phi)",
"- the post-operated flux density field (b)",
"- the post-operated magnetic field (h)"]},
Flag_ItLoopNDoFirstIter = {Flag_ItLoopNDoFirstIter00, Choices{0,1}, Name StrCat[ppNL, "1First iteration done before error calculation"],
Highlight Str[colNL1], Visible (Flag_NL && Flag_NLRes==NLRES_ITERATIVELOOPN),
Help Str["Set to 1 to force the first NL iteration to be done before evaluating the error with IterativeLoopN"]},
Nb_max_iter = {Nb_max_iter00, Name StrCat[ppNL, "1Nb max iter"],
Highlight Str[colNL4], Visible Flag_NL}
stop_criterion = {stop_criterion00, Name StrCat[ppNL, "2stop criterion"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment