From 4da9d1e718169b277cecf068aefa6cf3c78cc9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 23 Mar 2022 17:33:05 +0100 Subject: [PATCH] Block (without bytecode): avoid silent failures in some corner cases Either ensure that oo_.determinstic_simulation.status is set, or really error out. --- matlab/solve_one_boundary.m | 21 ++++++++++++--------- matlab/solve_two_boundaries.m | 6 ++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m index 360ae648a..12b2dd07a 100644 --- a/matlab/solve_one_boundary.m +++ b/matlab/solve_one_boundary.m @@ -143,6 +143,14 @@ for it_=start:incr:finish if verbose disp('The singularity of the jacobian matrix could not be corrected') end + if is_dynamic + oo_.deterministic_simulation.status = false; + oo_.deterministic_simulation.error = max_res; + oo_.deterministic_simulation.iterations = iter; + oo_.deterministic_simulation.block(Block_Num).status = false;% Convergency failed. + oo_.deterministic_simulation.block(Block_Num).error = max_res; + oo_.deterministic_simulation.block(Block_Num).iterations = iter; + end info = -Block_Num*10; return end @@ -275,16 +283,11 @@ for it_=start:incr:finish end end else - if verbose - disp('unknown option : ') - if is_dynamic - disp(['options_.stack_solve_algo = ' num2str(stack_solve_algo) ' not implemented']) - else - disp(['options_.solve_algo = ' num2str(options.solve_algo) ' not implemented']) - end + if is_dynamic + error(['options_.stack_solve_algo = ' num2str(stack_solve_algo) ' not implemented']) + else + error(['options_.solve_algo = ' num2str(options.solve_algo) ' not implemented']) end - info = -Block_Num*10; - return end iter=iter+1; max_resa = max_res; diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m index 7cf42fbb1..b85bdfe50 100644 --- a/matlab/solve_two_boundaries.m +++ b/matlab/solve_two_boundaries.m @@ -136,6 +136,12 @@ while ~(cvg || iter>maxit_) continue else disp('The singularity of the jacobian matrix could not be corrected'); + oo.deterministic_simulation.status = false; + oo.deterministic_simulation.error = max_res; + oo.deterministic_simulation.iterations = iter; + oo.deterministic_simulation.block(Block_Num).status = false;% Convergency failed. + oo.deterministic_simulation.block(Block_Num).error = max_res; + oo.deterministic_simulation.block(Block_Num).iterations = iter; return end end