File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ @testitem " Test NLopt solver via Optimization.jl interface" begin
2+ using AtomsBase
3+ using AtomsBuilder
4+ using AtomsCalculators
5+ using EmpiricalPotentials
6+ using GeometryOptimization
7+ using OptimizationNLopt
8+ using Unitful
9+ using UnitfulAtomic
10+ AC = AtomsCalculators
11+ calculator = StillingerWeber ()
12+ solver = NLopt. LD_TNEWTON ()
13+
14+ # Get a minimised reference
15+ reference = minimize_energy! (bulk (:Si ; cubic= true ), calculator;
16+ tol_forces= 1e-10 , maxiters= 200 )
17+
18+ # Equilibrate a perturbed Si crystal using a solver from Optimization.jl
19+ silicon_init = rattle! (bulk (:Si ; cubic= true ), 0.2 u " Å" )
20+ energy_init = AC. potential_energy (silicon_init, calculator)
21+ results = minimize_energy! (silicon_init, calculator, solver;
22+ tol_energy= 1e-10 , tol_forces= 1e-4 u " eV/Å" , maxeval= 100 )
23+ @test results. energy ≤ energy_init
24+ @test austrip (abs (results. energy - reference. energy)) < 1e-10
25+ end
You can’t perform that action at this time.
0 commit comments