2727
2828class AdsorptionCalc (PropCalc ):
2929 """
30- Calculator for adsorption energies on surfaces.
31- Combines bulk relaxation, slab generation and relaxation, adsorbate
32- relaxation, and adsorption energy calculations.
33- Uses :class:`RelaxCalc` for structure relaxations.
34- Parameters allow control over which parts are relaxed and how.
35-
36- :param calculator: An ASE calculator object used to perform energy and force
37- calculations. If string is provided, the corresponding universal calculator is loaded.
38- :type calculator: Calculator | str
39- :param relax_adsorbate: Whether to relax the adsorbate structure. If note relaxed,
40- a single point or the adsorbate energy provided downstream is used. Default is True.
41- :type relax_adsorbate: bool, optional
42- :param relax_slab: Whether to relax each clean slab structure (cell fixed). Default is True.
43- :type relax_slab: bool, optional
44- :param relax_bulk: Whether to relax the bulk structure used to generate slabs, including its cell. Default is True.
45- :type relax_bulk: bool, optional
46- :param fmax: Force tolerance in eV/Å for relaxation. Default is 0.1.
47- :type fmax: float, optional
48- :param optimizer: The ASE optimizer to use in RelaxCalc. Can be a string (e.g. "BFGS") or
49- an :class:`Optimizer` instance. Default is "BFGS".
50- :type optimizer: str | Optimizer, optional
51- :param max_steps: Maximum number of optimization steps for relaxation. Default is 500.
52- :type max_steps: int, optional
53- :param relax_calc_kwargs: Additional keyword arguments passed to the
54- :class:`RelaxCalc` constructor for both bulk and slabs. Default is None.
55- :type relax_calc_kwargs: dict | None, optional
30+ Adsorption energies on surfaces via bulk, slab, adsorbate, and adslab relaxations.
31+
32+ Uses ``RelaxCalc`` for geometry optimizations. Attributes mirror constructor arguments
33+ plus optional cached bulk state after ``calc_bulk`` / ``calc_adslabs``.
5634 """
5735
5836 def __init__ (
@@ -68,27 +46,15 @@ def __init__(
6846 relax_calc_kwargs : dict [str , Any ] | None = None ,
6947 ) -> None :
7048 """
71- Initialize the AdsorptionCalc.
72-
73- :param calculator: An ASE calculator object used to perform energy and force
74- calculations. If string is provided, the corresponding universal calculator is loaded.
75- :type calculator: Calculator | str
76- :param relax_adsorbate: Whether to relax the adsorbate structure. Default is True.
77- :type relax_adsorbate: bool, optional
78- :param relax_slab: Whether to relax each slab structure (cell fixed). Default is True.
79- :type relax_slab: bool, optional
80- :param relax_bulk: Whether to relax the bulk structure, including its cell. Default is True.
81- :type relax_bulk: bool, optional
82- :param fmax: Force tolerance in eV/Å for relaxation. Default is 0.1.
83- :type fmax: float, optional
84- :param optimizer: The ASE optimizer to use. Can be a string (e.g. "BFGS") or
85- an :class:`Optimizer` instance. Default is "BFGS".
86- :type optimizer: str | Optimizer, optional
87- :param max_steps: Maximum number of optimization steps for relaxation. Default is 500.
88- :type max_steps: int, optional
89- :param relax_calc_kwargs: Additional keyword arguments passed to the
90- :class:`RelaxCalc` constructor for both bulk and slabs. Default is None.
91- :type relax_calc_kwargs: dict | None, optional
49+ Args:
50+ calculator: ASE calculator or universal model name string.
51+ relax_adsorbate: Relax isolated adsorbate in a box when True.
52+ relax_slab: Relax clean slab (fixed cell) when True.
53+ relax_bulk: Relax bulk with cell when True.
54+ fmax: Force tolerance (eV/Å).
55+ optimizer: ASE optimizer name or class.
56+ max_steps: Max relaxation steps.
57+ relax_calc_kwargs: Optional kwargs for ``RelaxCalc``.
9258 """
9359 self .calculator = calculator # type: ignore[assignment]
9460 self .relax_adsorbate = relax_adsorbate
@@ -109,15 +75,12 @@ def calc_bulk(
10975 bulk_energy : float | None = None ,
11076 ) -> dict [str , Any ]:
11177 """
112- Prepare the bulk structure for slab generation, optionally relaxing it.
113-
114- :param bulk: The bulk structure to be calculated.
115- :type bulk: Structure | Atoms
116- :param bulk_energy: Optional pre-calculated energy of the bulk. If not provided,
117- the bulk will be relaxed and its energy calculated.
118- :type bulk_energy: float | None, optional
119- :return: A dictionary containing the bulk energy and final structure.
120- :rtype: dict[str, Any]
78+ Args:
79+ bulk: Bulk pymatgen structure or ASE atoms.
80+ bulk_energy: If ``relax_bulk`` is False and this is set, used as energy; else relaxed.
81+
82+ Returns:
83+ Dict with ``final_structure`` and ``energy`` (when available).
12184 """
12285 initial_bulk = to_pmg_structure (bulk )
12386
@@ -147,12 +110,12 @@ def calc_adsorbate(
147110 adsorbate_energy : float | None = None ,
148111 ) -> dict [str , Any ]:
149112 """
150- Calculate the energy of the adsorbate, optionally relaxing it.
113+ Args:
114+ adsorbate: Adsorbate as molecule or atoms.
115+ adsorbate_energy: Optional fixed energy; otherwise from calculator on final geometry.
151116
152- :param adsorbate: The adsorbate structure to be calculated.
153- :type adsorbate: Molecule | Atoms
154- :return: A dictionary containing the adsorbate energy and final structure.
155- :rtype: dict[str, Any]
117+ Returns:
118+ Dict with ``adsorbate_energy``, ``adsorbate``, ``final_adsorbate``.
156119 """
157120 initial_adsorbate = to_pmg_molecule (adsorbate )
158121
@@ -196,15 +159,12 @@ def calc_slab(
196159 slab_energy : float | None = None ,
197160 ) -> dict [str , Any ]:
198161 """
199- Calculate the energy of the slab, optionally relaxing it.
200-
201- :param slab: The slab structure to be calculated.
202- :type slab: Structure | Atoms
203- :param slab_energy: Optional pre-calculated energy of the slab. If not provided,
204- the slab will be relaxed and its energy calculated.
205- :type slab_energy: float | None, optional
206- :return: A dictionary containing the slab energy and final structure.
207- :rtype: dict[str, Any]
162+ Args:
163+ slab: Slab structure or atoms.
164+ slab_energy: Optional total slab energy; if None, taken from calculator.
165+
166+ Returns:
167+ Dict with ``slab``, ``slab_energy``, ``slab_energy_per_atom``, ``final_slab``.
208168 """
209169 if self .relax_slab :
210170 relaxer = RelaxCalc (
@@ -257,53 +217,28 @@ def calc_adslabs( # noqa: C901
257217 ** kwargs : dict [str , Any ],
258218 ) -> list [dict [str , Any ]] | dict [Any , Any ]:
259219 """
260- Calculate adsorption energies for adsorbates on slabs generated from a bulk structure.
261- :param adsorbate: The adsorbate structure to be placed on the slab.
262- :type adsorbate: Molecule | Atoms
263- :param bulk: The bulk structure from which slabs will be generated. Be careful
264- to provide conventional cells if that is your intention for miller indices.
265- :type bulk: Structure | Atoms
266- :param miller_index: The Miller index defining the slab orientation.
267- :type miller_index: tuple[int, int, int]
268- :param adsorbate_energy: Optional pre-calculated energy of the adsorbate. If not provided,
269- the adsorbate will be relaxed and its energy calculated.
270- :type adsorbate_energy: float | None, optional
271- :param min_slab_size: Minimum thickness of the slab in Å. Default is 10.0.
272- :type min_slab_size: float, optional
273- :param min_vacuum_size: Minimum size of the vacuum layer in Å. Default is 20.0.
274- :type min_vacuum_size: float, optional
275- :param min_area_extent: Minimum in-plane dimensions of the slab in Å. If provided,
276- the slab will be expanded to at least these dimensions in the a and perpendicular
277- to a directions by projecting the b lattice vector onto a. Default is None.
278- :type min_area_extent: tuple[float, float] | None, optional
279- :param inplane_supercell: Tuple defining the in-plane supercell size. Default is (1, 1).
280- :type inplane_supercell: tuple[int, int], optional
281- :param slab_gen_kwargs: Additional keyword arguments passed to the SlabGenerator. Default is None.
282- :type slab_gen_kwargs: dict[str, Any] | None, optional
283- :param get_slabs_kwargs: Additional keyword arguments passed to the get_slabs method of
284- SlabGenerator. Default is None.
285- :type get_slabs_kwargs: dict[str, Any] | None, optional
286- :param adsorption_sites: Either a string specifying which adsorption sites to consider
287- (e.g., "all", "ontop", "bridge", "hollow"), or a dictionary specifying custom adsorption sites
288- with site names as keys and lists of fractional coordinates as values.
289- Default is "all".
290- :type adsorption_sites: dict[str:tuple[float, float]] | str, optional
291- :param height: Height above the surface to place the adsorbate in Å. Default is 0.9.
292- :type height: float, optional
293- :param mi_vec: Optional in-plane vector defining the slab orientation. If None, it is
294- automatically determined. Default is None.
295- :type mi_vec: tuple[float, float] | None, optional
296- :param fixed_height: Height below which slab atoms are fixed during relaxation in Å.
297- Default is 5 Å.
298- :type fixed_height: float, optional
299- :param find_adsorption_sites_args: Additional keyword arguments passed to the
300- find_adsorption_sites method of AdsorbateSiteFinder. Default is None.
301- :type find_adsorption_sites_args: dict[str, Any] | None, optional
302- :param dry_run: If True, only generates the adslab structures without performing calculations.
303- Default is False.
304- :type dry_run: bool, optional
305- :return: A list of dictionaries containing results for each adslab, or just the structures if dry_run is True.
306- :rtype: list[dict[str, Any]] | dict[Any, Any].
220+ Args:
221+ adsorbate: Adsorbate species.
222+ bulk: Bulk structure (use conventional cell if needed for Miller indices).
223+ miller_index: Surface orientation.
224+ adsorbate_energy: Optional fixed adsorbate energy.
225+ slab_energy: Optional fixed clean-slab energy for all slabs.
226+ min_slab_size: Minimum slab thickness (Å).
227+ min_vacuum_size: Vacuum thickness (Å).
228+ min_area_extent: Minimum in-plane extent (Å); may expand ``inplane_supercell``.
229+ inplane_supercell: In-plane supercell factors.
230+ slab_gen_kwargs: Kwargs for ``SlabGenerator``.
231+ get_slabs_kwargs: Kwargs for ``SlabGenerator.get_slabs``.
232+ adsorption_sites: ``"all"``, site name string, or custom fractional-coordinate dict.
233+ height: Adsorbate height above surface (Å).
234+ mi_vec: Optional in-plane vector for ``AdsorbateSiteFinder``.
235+ fixed_height: Fix slab atoms below this height (Å) during relaxation.
236+ find_adsorption_sites_args: Kwargs for ``find_adsorption_sites``.
237+ dry_run: If True, return adslab dicts without ``calc_many``.
238+ **kwargs: Forwarded to ``calc_many``.
239+
240+ Returns:
241+ List of per-configuration results, or raw adslab dicts if ``dry_run``.
307242 """
308243 adslab_dict = {}
309244 bulk = to_pmg_structure (bulk )
@@ -406,13 +341,12 @@ def calc(
406341 structure : dict [str , Any ], # type: ignore[override]
407342 ) -> dict [str , Any ]:
408343 """
409- Calculate the adsorption energy for a given adslab structure.
344+ Args:
345+ structure: Dict with ``adslab``, ``slab``, ``adsorbate``; optional ``slab_energy`` /
346+ ``adsorbate_energy``.
410347
411- :param structure: A dictionary containing 'adslab', 'slab', and 'adsorbate' structures,
412- and optionally 'slab_energy' and/or 'adsorbate_energy'.
413- :type structure: dict[str, Any]
414- :return: A dictionary containing the adsorption energy and related information.
415- :rtype: dict[str, Any]
348+ Returns:
349+ Dict including ``adsorption_energy`` and merged slab/adsorbate fields.
416350 """
417351 result_dict = structure .copy ()
418352
0 commit comments