@@ -343,7 +343,9 @@ function CommonSolve.solve(
343
343
println (" [e]volution: start in $(extrema (lambdas)) " )
344
344
end
345
345
346
+ λ0 = 0
346
347
istep = 0
348
+ solved = false
347
349
t1 = @elapsed for i = 1 : (length (lambdas)- 1 )
348
350
Δλ = max (Δλ, Δλ_min (control, transient))
349
351
λstart = lambdas[i]
@@ -402,58 +404,74 @@ function CommonSolve.solve(
402
404
if ! solved
403
405
# reduce time step and retry solution
404
406
Δλ = Δλ * 0.5
407
+ rd (x)= round (x,sigdigits= 5 )
405
408
if Δλ < Δλ_min (control, transient)
406
409
if ! (control. force_first_step && istep == 0 )
407
- throw (
408
- EmbeddingError (
409
- " Δ$(λstr) _min=$(Δλ_min (control,transient)) reached while Δu=$(Δu) >> Δu_opt=$(control. Δu_opt) " ,
410
- ),
411
- )
410
+ err= " At $(λstr) =$(λ|> rd) : Δ$(λstr) _min=$(Δλ_min (control,transient)|> rd) reached while Δu=$(Δu|> rd) and Δu_opt=$(control. Δu_opt|> rd) "
411
+ if control. handle_exceptions
412
+ @warn err
413
+ else
414
+ throw (DomainError (err))
415
+ end
416
+ break
412
417
else
413
- solved = true
418
+ solved= true
414
419
end
415
420
end
416
421
if doprint (control, ' e' )
417
422
@printf (" [e]volution: Δu=%.3e => retry: Δ%s=%.3e\n " , Δu, λstr, Δλ)
418
423
end
419
424
end
420
- end
421
- istep = istep + 1
422
- if doprint (control, ' e' )
423
- @printf (
424
- " [e]volution: step=%d %s=%.3e Δ%s=%.3e Δu=%.3e\n " ,
425
- istep,
426
- λstr,
427
- λ,
428
- λstr,
429
- Δλ,
430
- Δu
431
- )
432
- end
433
- if control. log
434
- push! (allhistory, system. history)
435
- push! (allhistory. updates, Δu)
436
- push! (allhistory. times, λ)
437
- end
438
- if control. store_all
439
- append! (tsol, λ, solution)
440
- end
441
- control. post (solution, oldsolution, λ, Δλ)
442
- oldsolution .= solution
443
- if λ < λend
444
- Δλ = min (
445
- Δλ_max (control, transient),
446
- Δλ * Δλ_grow (control, transient),
447
- Δλ * control. Δu_opt / (Δu + 1.0e-14 ),
448
- λend - λ,
449
- )
450
- end
425
+ end # while !solved
426
+
427
+ if solved
428
+ istep = istep + 1
429
+ if doprint (control, ' e' )
430
+ @printf (
431
+ " [e]volution: step=%d %s=%.3e Δ%s=%.3e Δu=%.3e\n " ,
432
+ istep,
433
+ λstr,
434
+ λ,
435
+ λstr,
436
+ Δλ,
437
+ Δu
438
+ )
439
+ end
440
+ if control. log
441
+ push! (allhistory, system. history)
442
+ push! (allhistory. updates, Δu)
443
+ push! (allhistory. times, λ)
444
+ end
445
+ if control. store_all
446
+ append! (tsol, λ, solution)
447
+ end
448
+ control. post (solution, oldsolution, λ, Δλ)
449
+ oldsolution .= solution
450
+ if λ < λend
451
+ Δλ = min (
452
+ Δλ_max (control, transient),
453
+ Δλ * Δλ_grow (control, transient),
454
+ Δλ * control. Δu_opt / (Δu + 1.0e-14 ),
455
+ λend - λ,
456
+ )
457
+ end
458
+ else
459
+ break
460
+ end # if solved
461
+ end # while λ<λ_end
462
+
463
+ if ! control. store_all # store last solutionobtained
464
+ append! (tsol, λ0, solution)
451
465
end
452
- if ! control. store_all
453
- append! (tsol, lambdas[i+ 1 ], solution)
466
+ control. sample (solution, λ0)
467
+ if solved
468
+ if ! (λ≈ lambdas[i+ 1 ])
469
+ @warn " λ=$(λ) , lambdas[i+1]=$(lambdas[i+ 1 ]) "
470
+ end
471
+ else
472
+ break
454
473
end
455
- control. sample (solution, lambdas[i+ 1 ])
456
- end
474
+ end # for i = 1:(length(lambdas)-1)
457
475
458
476
if doprint (control, ' e' )
459
477
println (" [e]volution: $(round (t0+ t1,sigdigits= 3 )) seconds" )
0 commit comments