Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nonlinear battery example to NonlinearProblem #790

Closed

Conversation

MarcBerliner
Copy link
Contributor

@MarcBerliner MarcBerliner commented Dec 7, 2023

This is an example nonlinear problem resulting from JuliaSimCompiler with 33 equations whose unknowns span ~13 orders of magnitude. The solution is quite sensitive to the algorithm choice and error tolerances. 15/20 of the tested algorithms failed to solve this problem (the solution L2-norm should be ~8e-7):

[Warn] Solver Newton Raphson (No line search) returned retcode Unstable with an residual norm = 292.3000724036127.
[Warn] Solver Newton Raphson (Hager & Zhang line search) returned retcode MaxIters with an residual norm = 274.02709301352945.
[Warn] Solver Newton Raphson (More & Thuente line search) returned retcode MaxIters with an residual norm = 272.9369057669025.
[Warn] Solver Newton Raphson (Nocedal & Wright line search) returned retcode MaxIters with an residual norm = 282.3447679256991.
[Warn] Solver Newton Trust Region returned retcode MaxIters with an residual norm = 87.55359385515213.
[Info] Solver Newton Trust Region (NLsolve radius update) successfully solved the problem.
[Warn] Solver Newton Trust Region (Nocedal Wright radius update) returned retcode MaxIters with an residual norm = 87.55359358466573.
[Warn] Solver Newton Trust Region (Hei radius update) returned retcode MaxIters with an residual norm = 87.72887154657568.
[Warn] Solver Newton Trust Region (Yuan radius update) returned retcode ConvergenceFailure with an residual norm = 292.3000724036127.
[Info] Solver Newton Trust Region (Bastin radius update) successfully solved the problem.
[Warn] Solver Newton Trust Region (Fan radius update) returned retcode MaxIters with an residual norm = 125.99151156402642.
[Info] Solver Levenberg-Marquardt (α_geodesic=0.75) successfully solved the problem.
[Warn] Solver Levenberg-Marquardt (α_geodesic, with CCholesky) returned retcode MaxIters with an residual norm = 0.0004065143786534784.
[Info] Solver Levenberg-Marquardt (α_geodesic=0.5) successfully solved the problem.
[Warn] Solver Levenberg-Marquardt (α_geodesic=0.5, with CCholesky) returned retcode MaxIters with an residual norm = 0.0004065143786534784.
[Warn] Solver Modified Powell (CMINPACK) threw an error: ErrorException("cfunction: closures are not supported on this platform").
[Warn] Solver Levenberg-Marquardt (CMINPACK) threw an error: ErrorException("cfunction: closures are not supported on this platform").
[Info] Solver Newton Raphson (NLSolveJL) successfully solved the problem.
[Warn] Solver Newton Trust Region (NLSolveJL) returned retcode Failure with an residual norm = 136.6473626403987.
[Warn] Solver Newton-Krylov (Sundials) had a residual of NaN.

image

cc @ChrisRackauckas

@avik-pal
Copy link
Member

avik-pal commented Dec 8, 2023

With the new release and some changes:

  1. maxiters = 10000
  2. termination_condition = AbsNormTerminationMode(). We are figuring out if we need to relax the current default here.
  3. LM without the Normal Form has a subtle bug, which I will patch tomorrow

plot_5

We are still the fastest here!

@MarcBerliner
Copy link
Contributor Author

One suggestion on the above changes is that L2 errors > 1e-3 should not be considered converged. Can we do something to exclude those results?

@avik-pal
Copy link
Member

avik-pal commented Dec 8, 2023

I will create a PR with these changes. It seems MINPACK was returning converged even when it did not 🤷

plot_8

@ChrisRackauckas
Copy link
Member

Continuing with #792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants