1717// #include "lattice_minimizer.hpp"
1818#include " lattice_common.hpp"
1919#include " atom_minimizer.hpp"
20- #include " combined_optimizer.hpp"
20+ #include " alternating_optimizer.hpp"
21+ // #include "combined_optimizer.hpp"
2122
2223// #include "gdevice.hpp"
2324
@@ -39,7 +40,8 @@ enum class RelaxCombinedTask {
3940 // --- 1. Classical Ground State Structural Modes ---
4041 GeometryOnly = 0 , // Frozen cell box; adjust inner coordinates
4142 LatticeOnly = 1 , // Frozen atom coordinates; scale bounding box
42- Both = 2 , // Co-optimize atoms and bounding box in tandem
43+ Alternating = 2 , // Co-optimize atoms and bounding box in tandem
44+ Combined = 3 , // Co-optimize atoms and bounding box in tandem
4345
4446};
4547
@@ -335,7 +337,8 @@ int driver_optimizer(MPI_Comm comm_world0, std::string &rtdbstring, std::ostream
335337 // coutput << tag << " Cell optimization : RTDB unita_frozen reference lattice\n";
336338 if (driver_relax_type == RelaxCombinedTask::GeometryOnly) coutput << tag << " Geometry only optimization : RTDB unita_frozen reference lattice\n " ;
337339 if (driver_relax_type == RelaxCombinedTask::LatticeOnly) coutput << tag << " Lattice only optimization : RTDB unita_frozen reference lattice\n " ;
338- if (driver_relax_type == RelaxCombinedTask::Both) coutput << tag << " Geometry and Cell optimization : RTDB unita_frozen reference lattice\n " ;
340+ if (driver_relax_type == RelaxCombinedTask::Alternating) coutput << tag << " Alternating Geometry and Cell optimization : RTDB unita_frozen reference lattice\n " ;
341+ if (driver_relax_type == RelaxCombinedTask::Combined) coutput << tag << " Combined Geometry and Cell optimization : RTDB unita_frozen reference lattice\n " ;
339342
340343 coutput << tag << " Numerical grid : fixed during optimization stage\n "
341344 << tag << " Lattice tolerance : " << lattice_tolerance << ' \n '
@@ -497,40 +500,44 @@ int driver_optimizer(MPI_Comm comm_world0, std::string &rtdbstring, std::ostream
497500 }
498501
499502 // Dispatch to the crystal-system-specific geometry and lattice minimizer.
500- if (driver_relax_type == RelaxCombinedTask::Both)
503+ if (driver_relax_type == RelaxCombinedTask::Alternating)
504+ {
505+ // --- atom context ---
506+ AtomContext atom_ctx;
507+ atom_ctx.oprint = oprint;
508+ atom_ctx.tag = tag;
509+ atom_ctx.max_steps = control.driver_maxiter ();
510+ atom_ctx.minimum_gradient = control.driver_gmax ();
511+ atom_ctx.initial_step = control.driver_step ();
512+ atom_ctx.use_symmetry = true ;
513+ atom_ctx.ops = symmetry_info.ops ;
514+
515+ // --- lattice context ---
516+ LatticeContext lat_ctx;
517+ lat_ctx.oprint = oprint;
518+ lat_ctx.tag = tag;
519+ lat_ctx.max_steps = control.driver_lattice_maxiter ();
520+ lat_ctx.minimum_gradient = control.driver_lattice_gmax ();
521+ lat_ctx.initial_step = control.driver_lattice_step ();
522+ lat_ctx.minimum_step = control.driver_lattice_xmin ();
523+
524+ // --- dispatched lattice minimizer ---
525+ lattice_minimizer lm = pick_lattice_minimizer (symmetry_info.system );
526+
527+ const int ierr = alternating_optimizer (comm_world0, rtdbstring, coutput,
528+ minimizer,
529+ atom_ctx, lat_ctx, lm,
530+ 10 , // max_outer
531+ 1.0e-5 ); // energy_tol
532+ if (ierr != 0 )
533+ {
534+ coutput << tag << " combined minimizer returned " << ierr << ' \n ' ;
535+ return ierr;
536+ }
537+ }
538+
539+ if (driver_relax_type == RelaxCombinedTask::Combined)
501540 {
502- // --- atom context ---
503- AtomContext atom_ctx;
504- atom_ctx.oprint = oprint;
505- atom_ctx.tag = tag;
506- atom_ctx.max_steps = control.driver_maxiter ();
507- atom_ctx.minimum_gradient = control.driver_gmax ();
508- atom_ctx.initial_step = control.driver_step ();
509- atom_ctx.use_symmetry = true ;
510- atom_ctx.ops = symmetry_info.ops ;
511-
512- // --- lattice context ---
513- LatticeContext lat_ctx;
514- lat_ctx.oprint = oprint;
515- lat_ctx.tag = tag;
516- lat_ctx.max_steps = control.driver_lattice_maxiter ();
517- lat_ctx.minimum_gradient = control.driver_lattice_gmax ();
518- lat_ctx.initial_step = control.driver_lattice_step ();
519- lat_ctx.minimum_step = control.driver_lattice_xmin ();
520-
521- // --- dispatched lattice minimizer ---
522- lattice_minimizer lm = pick_lattice_minimizer (symmetry_info.system );
523-
524- const int ierr = combined_optimizer (comm_world0, rtdbstring, coutput,
525- minimizer,
526- atom_ctx, lat_ctx, lm,
527- 10 , // max_outer
528- 1.0e-5 ); // energy_tol
529- if (ierr != 0 )
530- {
531- coutput << tag << " combined minimizer returned " << ierr << ' \n ' ;
532- return ierr;
533- }
534541 }
535542
536543 return 0 ;
0 commit comments