matcalc._gb module
Grain Boundary Energy calculations.
- class GBCalc(calculator: Calculator | str, *, relax_bulk: bool = True, relax_gb: bool = True, fmax: float = 0.1, optimizer: str | Optimizer = 'FIRE', max_steps: int = 500, relax_calc_kwargs: dict | None = None)[source]
Bases:
PropCalcA class for performing grain boundary energy calculations by generating grain boundary structures from a bulk structure using pymatgen’s GrainBoundaryGenerator, optionally relaxing bulk and GB, and computing gamma_GB via (E_GB - N_GB * E_bulk_per_atom) / (2 * A).
- Parameters:
calculator – ASE Calculator or string identifier for a universal calculator.
relax_bulk – Whether to relax the bulk structure before GB generation. Default True.
relax_gb – Whether to relax the GB structures after generation. Default True.
fmax – Force tolerance (eV/Å) for relaxations. Default 0.1.
optimizer – ASE optimizer or name for relaxations. Default “FIRE”.
max_steps – Max optimization steps. Default 500.
relax_calc_kwargs – Additional keyword arguments for relaxation calculations. Defaults to None.
- calc(structure: dict[str, Any]) dict[str, Any][source]
Compute grain boundary energy for a single grain boundary structure dict produced by calc_gb or direct input. The function handles relaxation of both bulk and grain boundary structures when necessary.
- Parameters:
structure – Dictionary containing information about the bulk and grain boundary structures. It must have the format:
{'grain_boundary': gb_structure, 'bulk': bulk_structure}or{'grain_boundary': gb_structure, 'bulk_energy_per_atom': energy}.- Returns:
A dictionary containing the updated structure data, including fields like ‘grain_boundary’, ‘final_grain_boundary’, ‘gb_relax_energy’, ‘grain_boundary_energy’, and possibly updated ‘bulk_energy_per_atom’ and ‘final_bulk’.
- Raises:
ValueError – If structure is not a dict with the required keys.
- calc_gb(structure: Structure | Atoms, sigma: int, rotation_axis: tuple[int, int, int], gb_plane: tuple[int, int, int], rotation_angle: float, expand_times: int = 4, vacuum_thickness: float = 0.0, ab_shift: tuple[float, float] = (0.0, 0.0), rotation_angle_tolerance: float = 0.1, normal: bool = True, rm_ratio: float = 0.7, gb_generator_kwargs: dict | None = None, gb_from_parameters_kwargs: dict | None = None) dict[str, Any][source]
Generate grain boundary structures from bulk, relax them, and compute GB energies.
- Parameters:
structure – Bulk Structure for GB generation.
sigma – Sigma value of the coincident site lattice (CSL) grain boundary.
rotation_axis – Rotation axis vector for GB (u, v, w).
gb_plane – Miller indices of GB plane.
rotation_angle – Rotation angle in degrees.
expand_times – Multiplier for cell expansion to avoid interactions. Default 4.
vacuum_thickness – Vacuum layer thickness (Å) between grains. Default 0.0.
ab_shift – In-plane shift along a, b vectors. Default (0.0, 0.0).
rotation_angle_tolerance – Tolerance (degrees) for matching rotation angle. Default 0.1.
normal – Whether the c axis of top grain should be perpendicular to the surface. Default True.
rm_ratio – Criteria to remove atoms which are too close with each other. Default 0.7.
gb_generator_kwargs – Additional args for GrainBoundaryGenerator(). Default None.
gb_from_parameters_kwargs – Additional args for gb_from_parameters(). Default None.
- Returns:
A dictionary containing the updated structure data, including fields like ‘grain_boundary’, ‘final_grain_boundary’, ‘gb_relax_energy’, ‘grain_boundary_energy’, and possibly updated ‘bulk_energy_per_atom’ and ‘final_bulk’.
- Raises:
ValueError – If no rotation angle within
rotation_angle_toleranceofrotation_angleexists for the givensigma.