322322 end
323323end
324324
325- @testset " LBFGS Hessian Approximation" begin
325+ @testset verbose = true " LBFGS Hessian Approximation" begin
326326 # Based on https://madsuite.org/MadNLP.jl/dev/tutorials/lbfgs/
327327
328328 @testset " Unconstrained LBFGS" begin
383383 end
384384 end
385385
386- @testset " Constrained LBFGS - Electrons on Sphere" begin
386+ @testset verbose = true " Constrained LBFGS - Electrons on Sphere" begin
387387 # Quasi-uniform distribution of electrons on a unit sphere
388388 # Minimize electrostatic potential energy (Coulomb potential)
389389 # Variables are organized as [x1, x2, ..., xn, y1, y2, ..., yn, z1, z2, ..., zn]
436436 return x0
437437 end
438438
439- @testset " N=$np electrons with $approx " for np in [6 , 8 , 10 ],
440- approx in [MadNLP. CompactLBFGS, MadNLP. ExactHessian]
441-
439+ @testset " N=5 electrons with $approx " for approx in [MadNLP. CompactLBFGS, MadNLP. ExactHessian]
440+ np = 5
442441 x0 = init_electrons_on_sphere (np)
443442
444443 if approx == MadNLP. CompactLBFGS
@@ -477,18 +476,11 @@ end
477476 unit_sphere_constraints (cons_vals, sol. u, nothing )
478477 @test all (abs .(cons_vals) .< 1e-5 )
479478
480- # Known optimal energies for small electron numbers
479+ # Known optimal energy for 5 electrons on unit sphere
481480 # Reference: https://en.wikipedia.org/wiki/Thomson_problem
482- # Note: These are the minimum Coulomb potential energies for N electrons on unit sphere
483- expected_energies = Dict (
484- 6 => 9.985281374 , # Octahedron (Oh symmetry)
485- 8 => 19.675287861 , # Square antiprism (D4d)
486- 10 => 32.716949460 # Gyroelongated square dipyramid (D4d)
487- )
488-
489- if haskey (expected_energies, np)
490- @test isapprox (sol. objective, expected_energies[np], rtol = 1e-3 )
491- end
481+ # Configuration: Triangular dipyramid (trigonal bipyramid, D3h symmetry)
482+ expected_energy = 6.474691495
483+ @test isapprox (sol. objective, expected_energy, rtol = 1e-3 )
492484
493485 # Verify minimum distance between electrons
494486 x = sol. u[1 : np]
505497 @test min_dist > 0.5 # Electrons should be well-separated
506498 end
507499
508- @testset " LBFGS vs Exact Hessian" begin
500+ @testset verbose = true " LBFGS vs Exact Hessian" begin
509501 # Test with moderate size to show LBFGS efficiency
510- np = 12 # Icosahedron configuration
502+ np = 10 # Gyroelongated square dipyramid configuration
511503 x0 = init_electrons_on_sphere (np)
512504
513505 results = []
517509 (" ExactHessian" ,
518510 MadNLP. ExactHessian,
519511 SecondOrder (
520- AutoForwardDiff (), AutoForwardDiff ()))]
512+ AutoForwardDiff (), AutoZygote ()))]
521513 optfunc = OptimizationFunction (
522514 coulomb_potential, ad,
523515 cons = unit_sphere_constraints
@@ -543,11 +535,11 @@ end
543535 # All methods should converge
544536 @test all (r[2 ]. success for r in values (results))
545537
546- # All should find similar objective values (icosahedron energy)
538+ # All should find similar objective values (gyroelongated square dipyramid energy)
547539 # Reference: https://en.wikipedia.org/wiki/Thomson_problem
548540 objectives = [r[2 ]. objective for r in values (results)]
549541 @testset " $(results[i][1 ]) " for (i, o) in enumerate (objectives)
550- @test o ≈ 49.165253058 rtol= 1e-2
542+ @test o ≈ 32.716949460 rtol= 1e-2
551543 end
552544
553545 # LBFGS methods typically need more iterations but less cost per iteration
0 commit comments