# AceFEM: Continue despite error

I am testing different FE formulations on a series of simple benchmark tests. Not all elements converge to the final solution for all the examples, so it occurs that a following (or a similar) message appears

The analysis is aborted and all the subsequent commands, like plotting the results are not executed.

What I would like to achieve is to run all analyses that are nested inside one big chapter in my notebook and when a certain analysis is aborted (either due to divergence or because maximum number of iterations is reached), the evaluation inside Mathematica would continue. So all the following commands would still be executed and the rest of my examples would be calculated.

Anyone has any idea if this can be done? If it makes a difference, I am using a simple loop for the time stepping algorithm

Do[SMTNextStep["dLambda"->0.1];
While[SMTConvergence[10^-8,10], SMTNewtonIteration[];];
AppendTo[SomeDataVector,DataToAppendToThisVector];
,{i,1,10}]

• Isn't this a duplicate of this question (with answers)? I think the most straightforward method is to use CheckAbort. Feb 28 '18 at 7:53

<< AceFEM;
Elements = {"MySEPST1DFLET1DHooke", "MySEPST1DFHYT1DNeoHookeWA"};
ResultsPerElement = {};
Do[
SMTInputData[];
CurrentElement, {"E *" -> 21000, "\[Nu] *" -> 0.3}];
L = 48; H = 44; \[CapitalDelta]H = 16;
Polygon[{{0, 0}, {L, H}, {L, H + \[CapitalDelta]H}, {0, H}}],
"Cook", "T1", {40, 20}];
SMTAddEssentialBoundary[{"X" == 0 &, 1 -> 0, 2 -> 0}];
SMTAddNaturalBoundary[Line[{{L, H}, {L, H + \[CapitalDelta]H}}],
2 -> Line[{800}]];
SMTAnalysis[]; CurrentResults = {};
Do[
SMTNextStep[.1, 1.];
While[SMTConvergence[], SMTNewtonIteration[]];
AppendTo[
CurrentResults, {SMTNodeData["X" == 48 && "Y" == 60 &, "at"][[1,
2]], SMTData["Multiplier"]}];
, {Step, 10}];
AppendTo[ResultsPerElement, CurrentResults];
, {CurrentElement, Elements}];

ListLinePlot[ResultsPerElement,
PlotMarkers -> {"\[FilledDiamond]", 18},
PlotLegends -> {"Linear Formulation", "Nonlinear Formulation"},
AxesLabel -> {"\!$$\*SubscriptBox[\(u$$, $$y$$]\)-disp.",

• I am sorry, but I think this code doesn't answer OP's question on how to continue with evaluation even though \$Aborted was encountered. Mar 1 '18 at 8:44
• @Pinti may I ask, how can we use SMSEigenvalues command? the same to Eigenvalue? Aug 2 '19 at 1:08
• @ABCDEMMM I have no experience with SMSEigenvalues. I only know what is written in documentation. Aug 2 '19 at 7:47
• @Pinti thanks a lot, ihis issue has been solved Aug 2 '19 at 8:51

The answer by Sascha gives an interesting idea on running the same test for different FE formulations, but as Pinti pointed out, it does not answer the problem that I was facing.

Also using the CheckAbort function will not do the trick, since I want the analysis to continue, starting the next example if this one is aborted. Using the proposed function is useful if I am running only one example and want to collect the results despite the analysis being Aborted, but the evaluation inside the notebook still stops after the results are collected.

Checking the link that Pinti provided, I found the answer by BHudobivnik, which I used in my code.

err = False;

nstep = 20; dLambda = 1/nstep;
Do[
SMTNextStep["dLambda"-> dLambda];
While[(If[Not[BooleanQ[#]],
Print["Error in iterative procedure step ",i,":",#];
err = True; False,
#]) &@
SMTConvergence[10^-8,16,"Analyze"], SMTNewtonIteration[];];
If[err, Return[],
AppendTo[SomeDataVector,DataToAppendToThisVector];
]
, {i, 1, nstep}]


Using the code that he proposed, with the option "Analyze" inside the SMTConvergence` function, enables me to run multiple examples inside one notebook while even if one is aborted, the results are collected and the notebook evaluation continues with the next example.