gnrs.core¶
gnrs.core.task¶
Core task class for all 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.core.task.TaskABC[source]¶
Bases:
ABCAbstract base class for all tasks.
This class defines the common interface and workflow for tasks like: - Structure generation - Descriptor evaluation - Energy evaluation - Geometry optimization - Clustering and selection
Initialize the task with MPI communicator and settings.
- Parameters:
comm – MPI communicator
config – Config dictionary
gnrs_info – Genarris info dictionary
- run()[source]¶
Execute the complete task workflow.
The workflow consists of: 1. Initialize task 2. Pack settings 3. Print settings 4. Create folders 5. Perform task 6. Collect results 7. Analyze results 8. Finalize task
- Return type:
None
- abstractmethod pack_settings()[source]¶
Collect and pack settings needed for the task.
- Returns:
Task settings dictionary
- Return type:
- abstractmethod print_settings(task_set)[source]¶
Print task settings in a formatted table.
- Parameters:
task_set (dict) – Task settings dictionary
- Return type:
None
- abstractmethod create_folders()[source]¶
Create the folder structure required for the task.
- Return type:
None
- abstractmethod perform_task(task_set)[source]¶
Execute the main task.
- Parameters:
task_set (dict) – Task settings dictionary
- Return type:
None
gnrs.core.energy¶
Abstract base class for energy calculators.
This module provides the base class for implementing energy calculators.
It supports a GPU worker/feeder pattern: when running with more MPI ranks than GPUs, only a subset of ranks (workers) load models onto GPUs. The remaining ranks (feeders) send structures to workers via MPI.
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.core.energy.EnergyCalculatorABC[source]¶
Bases:
ABCAbstract base class for energy calculators.
Supports two execution modes: 1. Direct mode (ranks <= GPUs or CPU-only calculators): Every rank loads the model and computes locally.
2. Worker/feeder mode (ranks > GPUs, GPU-based calculators): Worker ranks (one per GPU) load models. Feeder ranks send structures to their assigned worker and receive results back.
Initialize the energy calculations.
- Parameters:
comm – MPI communicator
task_settings – Task settings
energy_name – Energy name
- run(xtal)[source]¶
Run the energy calculation on a single structure (direct mode only).
- Parameters:
xtal (ase.Atoms) – Crystal structure
- Return type:
None
- run_batch(structs, on_structure_done=None)[source]¶
Run energy calculations on a batch of structures.
gnrs.core.optimizer¶
Abstract base class for geometry optimization.
This module provides the base class for implementing geometry optimization.
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.core.optimizer.GeometryOptimizerABC[source]¶
Bases:
ABCAbstract class for Geometry optimization methods.
All optimizers should inherit this class.
Initialize the geometry optimizer.
- Parameters:
comm – MPI communicator for parallel computation
task_set – Optimization settings
opt_name – Optimizer
energy_method – Energy calculation method
- __init__(comm, task_set, opt_name='relax', energy_method=None, energy_calc=None)[source]¶
Initialize the geometry optimizer.
- run(xtal)[source]¶
Run the optimization workflow.
Initialize
Perform optimization
Update structure information
Finalize
- Parameters:
xtal (ase.atoms.Atoms) – ASE Atoms object representing the crystal structure
- Return type:
None
- abstractmethod optimize(xtal)[source]¶
Perform optimization.
- Parameters:
xtal (ase.atoms.Atoms) – ASE Atoms object
- Return type:
None
- abstractmethod update(xtal)[source]¶
Update the geometry and add energy information.
- Parameters:
xtal (ase.atoms.Atoms) – ASE Atoms object
- Return type:
None
- finalize(xtal)[source]¶
Finalize the optimization and clean up.
- Parameters:
xtal (ase.atoms.Atoms) – ASE Atoms object
- Return type:
None
gnrs.core.descriptor¶
Abstract base class for crystal structure descriptors.
This module provides the base class for implementing crystal structure descriptors.
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.core.descriptor.DescriptorABC[source]¶
Bases:
ABCAbstract base class for crystal structure descriptors.
This class defines the interface for computing descriptors for crystal structures. All descriptor implementations should inherit from this class and implement the abstract methods.
Initialize the descriptor calculator.
- Parameters:
comm – MPI communicator
task_settings – Task settings
- __init__(comm, task_settings)[source]¶
Initialize the descriptor calculator.
- Parameters:
comm (mpi4py.MPI.Comm) – MPI communicator
task_settings (dict) – Task settings
- Return type:
None
- run(xtal)[source]¶
Run the descriptor computation workflow.
Initialize
Compute descriptor
Finalize
- Parameters:
xtal (ase.Atoms) – Crystal structure
- Return type:
None
gnrs.core.cluster¶
Abstract base class for clustering methods.
This module provides the base class for implementing clustering methods.
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.core.cluster.ClusterABC[source]¶
Bases:
ABCAbstract base class for clustering methods.
This class defines the interface for implementing crystal structure clustering algorithms. All clustering implementations should inherit from this class and implement the abstract methods.
Initialize the clustering method.
- Parameters:
comm – MPI communicator
task_settings – Task settings
- __init__(comm, task_settings)[source]¶
Initialize the clustering method.
- Parameters:
comm (mpi4py.MPI.Comm) – MPI communicator
task_settings (dict) – Task settings
- Return type:
None
- run(struct_dict)[source]¶
Run the clustering workflow.
Initialize
Fit the clustering model
Predict clusters
Finalize
Clean up
gnrs.core.selection¶
Abstract base class for crystal structure selection.
This module provides the base class for implementing crystal structure selection.
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.core.selection.SelectionABC[source]¶
Bases:
ABCAbstract base class for crystal structure selection algorithms.
This class defines the interface for selecting crystal structures from a pool. All selection implementations should inherit from this class and implement the abstract methods.
Initialize the selection algorithm.
- Parameters:
comm – MPI communicator for parallel computation
settings – Selection settings
- __init__(comm, settings)[source]¶
Initialize the selection algorithm.
- Parameters:
comm (mpi4py.MPI.Comm) – MPI communicator for parallel computation
settings (dict) – Selection settings
- Return type:
None
- run(struct_dict)[source]¶
Run the selection workflow.
Initialize
Perform selection
Finalize
- Parameters:
struct_dict (dict) – Crystal structures
- Return type:
None
gnrs.core.molecule¶
This module provides functions for handling molecules.
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.core.molecule.Molecule[source]¶
Bases:
AtomsA class inherited from ase for hanlding molecules. probably will NOT be used much.
Initialize the molecule.
- Parameters:
*args – Arguments
**kwargs – Keyword arguments
- __init__(*args, **kwargs)[source]¶
Initialize the molecule.
- Parameters:
*args – Arguments
**kwargs – Keyword arguments
- Return type:
None
gnrs.core.gpu¶
GPU device management for MPI-parallel workloads.
Implements a worker/feeder pattern where only a subset of MPI ranks (GPU workers) load models onto GPUs, while the remaining ranks (feeders) send structures to workers via MPI for computation. This avoids GPU OOM when running with many MPI ranks and few GPUs.
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.core.gpu.GPUDeviceManager[source]¶
Bases:
objectManages GPU device allocation across MPI ranks.
Partitions ranks into GPU workers and CPU feeders. Workers are assigned to GPUs. Feeders offload computation to workers via MPI.
- Typical usage in HPC:
1 GPU node with 1-4 GPUs, 32-128 CPU cores
Workers: 1 per GPU (or configurable)
Feeders: all remaining ranks
Initialize GPU device manager.
- Parameters:
comm – MPI communicator.
max_workers_per_gpu – Maximum number of worker ranks per GPU.
gnrs.core.structure¶
This is the old structure class. Kept for compatibility of PyMoVE.
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.core.structure.StoicDict[source]¶
Bases:
defaultdict
- gnrs.core.structure.get_geo_from_file(file_name)[source]¶
given the path to a geometry-style file, returns the geometry in proper format
- gnrs.core.structure.convert_array(list_of_list)[source]¶
takes the array stored in json format and return it to a np array with proper dtype
- class gnrs.core.structure.Structure[source]¶
Bases:
objectAn optimized structure with relevant information information includes: geometry, energy, stoichiometry, distance array,
Creates a structure from a given geometry and it’s associated properties Properties are stored in a dictionary
- __init__()[source]¶
Creates a structure from a given geometry and it’s associated properties Properties are stored in a dictionary
- Return type:
None
- build_geo_by_atom(x, y, z, element, spin=None, charge=None, fixed=False)[source]¶
THIS METHOD SHOULD JUST BE CALLED APPEND
- Return type:
None
- build_geo_by_atom_array(x, y, z, element, spin=None, charge=None, fixed=False)[source]¶
These auxillary functions are silly. There should be a single append method that handles all cases of adding a single atom, an array of atoms, etc.
- Return type:
None
- from_geo_array(array, elements)[source]¶
Set geometry of structure to the input array and elements
- Parameters:
Array (np.matrix of numbers) – Atom coordinates should be stored row-wise
Elements (np.matrix of strings) – Element strings using shorthand notations of same number of rows as the array argument
- Return type:
None
- build_geo_whole_atom_format(atom_string)[source]¶
- Constructs relevant geometry properties from an FHI-aims geometry
file.
- Return type:
None
- get_geometry_atom_format()[source]¶
Convert structure to FHI-aims geometry format.
Takes a np.ndarray with standard “geometry” format. Returns a string with structure in standard aims format. If atom’s spin is specified, its value is located on the line below the atom’s coordinates. Similarly with charge and relaxation constraint.
Modified to handle molecules without lattice vectors.
- get_ase_atoms()[source]¶
Works for periodic and non-periodic systems
Purpose: Returns ase atoms object
- get_pymatgen_structure()[source]¶
Inputs: A np.ndarry structure with standard “geometry” format Outputs: A pymatgen core structure object with basic geometric properties
- get_frac_data()[source]¶
Inputs: A np.ndarry structure with standard “geometry” format Outputs: Fractional coordinate data in the form of positions (list), atom_types (list), lattice vector a magnitude, lattice vector b magnitude, lattice vector c magnitude, alpha beta, gamma.
gnrs.core.registry¶
Task registry for Genarris.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
gnrs.core.folders¶
This module provides functions for managing folder.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
- gnrs.core.folders.init_folders(is_master_in)[source]¶
Initialize folder management.
- Parameters:
is_master_in (bool)
- Return type:
None
- gnrs.core.folders.mkdir(dir_path)[source]¶
Create a directory if it doesn’t exist.
- Parameters:
dir_path (str)
- Return type:
None
- gnrs.core.folders.rmdir(dir_path)[source]¶
Remove a directory if it exists.
- Parameters:
dir_path (str)
- Return type:
None
gnrs.core.logging¶
This module provides functions for logging.
This source code is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.