gnrs.optimize


gnrs.optimize.optimization_task

This module provides the GeometryOptimizationTask class for performing geometry optimization tasks.

This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.

class gnrs.optimize.optimization_task.GeometryOptimizationTask[source]

Bases: TaskABC

Task for relaxing geometry of crystal structures.

Initialize the geometry optimization task.

Parameters:
  • comm – MPI communicator

  • config – Config dictionary

  • gnrs_info – Genarris info dictionary

  • optimizer – Optimizer

  • energy_method – Energy calculator(optional)

__init__(comm, config, gnrs_info, optimizer, energy_method=None)[source]

Initialize the geometry optimization task.

Parameters:
  • comm (mpi4py.MPI.Comm) – MPI communicator

  • config (dict) – Config dictionary

  • gnrs_info (dict) – Genarris info dictionary

  • optimizer (str) – Optimizer

  • energy_method (str | None) – Energy calculator(optional)

Return type:

None

initialize()[source]

Initialize the optimization task.

Return type:

None

pack_settings()[source]

Pack settings for the optimization task.

Returns:

Task settings dictionary

Return type:

dict

print_settings(task_set)[source]

Print the task settings.

Parameters:

task_set (dict) – Task settings dictionary

Return type:

None

create_folders()[source]

Create the necessary folders for the optimization task.

Return type:

None

perform_task(task_set)[source]

Perform the optimization task.

Parameters:

task_set (dict) – Task settings dictionary

Return type:

None

collect_results()[source]

Collect and save the results of the task.

analyze()[source]

Analyze the results of the optimization task.

Return type:

None

finalize()[source]

Finalize the optimization task.

Return type:

None

gnrs.optimize.bfgs

This module provides a wrapper around the BFGS implementation from ASE.

This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.

class gnrs.optimize.bfgs.BFGSOptimizer[source]

Bases: GeometryOptimizerABC

Limited-memory BFGS optimization using ASE’s BFGS implementation.

fmax

Maximum force tolerance for convergence criterion

steps

Maximum number of optimization steps to perform

fix_sym

Whether to fix the symmetry of the structure

cell_opt

Whether to optimize the cell parameters as well

opt_name

Name of the optimizer for storing in the crystal info

converged

Whether the optimization successfully converged

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

__init__(*args)[source]

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

optimize(xtal)[source]

Performs geometry optimization using BFGS algorithm.

Parameters:

xtal (ase.atoms.Atoms) – ASE Atoms object

Return type:

None

update(xtal)[source]

Update the optimizer with the new structure.

Parameters:

xtal (ase.atoms.Atoms)

Return type:

None

gnrs.optimize.lbfgs

This module provides a wrapper around the LBFGS implementation from ASE.

This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.

class gnrs.optimize.lbfgs.LBFGSOptimizer[source]

Bases: GeometryOptimizerABC

Limited-memory BFGS optimization using ASE’s LBFGS implementation.

fmax

Maximum force tolerance for convergence criterion

steps

Maximum number of optimization steps to perform

fix_sym

Whether to fix the symmetry of the structure

cell_opt

Whether to optimize the cell parameters as well

opt_name

Name of the optimizer for storing in the crystal info

converged

Whether the optimization successfully converged

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

__init__(*args)[source]

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

optimize(xtal)[source]

Performs geometry optimization using LBFGS algorithm.

Parameters:

xtal (ase.atoms.Atoms) – ASE Atoms object

Return type:

None

update(xtal)[source]

Update the optimizer with the new structure.

Parameters:

xtal (ase.atoms.Atoms)

Return type:

None

gnrs.optimize.rigid_press

This module provides a wrapper around the rigid_press C code.

This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.

class gnrs.optimize.rigid_press.RIGID_PRESSOptimizer[source]

Bases: GeometryOptimizerABC

Optimizes structure using rigid_press C code.

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

__init__(*args)[source]

Initialize the geometry optimizer.

Parameters:
  • comm – MPI communicator for parallel computation

  • task_set – Optimization settings

  • opt_name – Optimizer

  • energy_method – Energy calculation method

initialize()[source]

Initialize the optimizer.

Return type:

None

optimize(xtal)[source]

Optimize the structure using rigid_press C code.

Parameters:

xtal (ase.Atoms)

Return type:

None

update(xtal)[source]

Update the optimizer with the new structure.

Parameters:

xtal (ase.Atoms)

Return type:

None

gnrs.optimize.symm_rigid_press

This module provides a wrapper around the Rigid Press implementation with symmetry constraints.

This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.

class gnrs.optimize.symm_rigid_press.SYMM_RIGID_PRESSOptimizer[source]

Bases: GeometryOptimizerABC

Optimizes crystal structures using rigid_press algorithm with symmetry constraints.

This optimizer uses van der Waals cutoff matrices for tight molecular packing and preserves symmetry during optimization.

opt_name

Name identifier for the optimizer

int_scale

Interaction scale factor

method

Optimization method to use

tol

Convergence tolerance

maxiter

Maximum number of iterations

vol_tol

Volume tolerance

debug_flag

Whether to enable debug output

Initialize the symmetry-preserving rigid press optimizer.

__init__(*args)[source]

Initialize the symmetry-preserving rigid press optimizer.

initialize()[source]

Initialize the optimizer.

Return type:

None

optimize(xtal)[source]

Perform structure optimization using the RigidPressSymm algorithm.

Parameters:

xtal (ase.Atoms) – ASE Atoms object

Return type:

None

update(xtal)[source]

Update crystal info with optimization status.

Parameters:

xtal (ase.Atoms) – ASE Atoms object

Return type:

None