### H2 Molecule Energy and Forces Calculation with GPAW (Python) Source: https://gpaw.readthedocs.io/en/latest/index This snippet demonstrates how to calculate the potential energy and forces for an H2 molecule using the GPAW code. It utilizes the ASE library for atomic structure manipulation and GPAW's Plane-Wave (PW) mode for calculations. The output includes the calculated energy in eV and forces in eV/Å. ```python >>> # H2-molecule example: >>> import numpy as np >>> from ase import Atoms >>> from gpaw import GPAW, PW >>> h2 = Atoms('H2', [(0, 0, 0), (0, 0, 0.74)]) >>> h2.center(vacuum=2.5) >>> h2.cell Cell([5.0, 5.0, 5.74]) >>> h2.positions array([[2.5 , 2.5 , 2.5 ], [2.5 , 2.5 , 3.24]]) >>> h2.calc = GPAW(xc='PBE', ... mode=PW(300), ... txt='h2.txt') >>> energy = h2.get_potential_energy() >>> print(f'Energy: {energy:.3f} eV') Energy: -6.631 eV >>> forces = h2.get_forces() >>> forces.shape (2, 3) >>> print(f'Force: {forces[0, 2]:.2f} eV/Å') Force: -0.64 eV/Å ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.