File: optimization.rst

package info (click to toggle)
gpaw 25.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,888 kB
  • sloc: python: 174,804; ansic: 17,564; cpp: 5,668; sh: 972; csh: 139; makefile: 45
file content (33 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.. _structure_optimization:

========================
 Structure optimization
========================

In the tutorial on :ref:`how to calculate atomization energies
<atomization_energy>`, we calculated the atomization energy for
`\rm{H}_2` using the experimental bond length of 0.74 Å.  In
this tutorial, we ask an :mod:`ASE optimizer <ase.optimize>`
to iteratively find
the structural energy minimum, where all atomic forces are below 0.05
eV/Å.  The following script will do the job:

.. literalinclude:: relax.py

The result is:

.. literalinclude:: optimization.txt

.. note::
   You must run the :ref:`atomization <atomization_energy>` script first.

To save time you could have told the minimizer to keep one atom fixed,
and only relaxing the other. This is achieved through the use of
constraints::

  molecule.set_constraint(FixAtoms(mask=[0, 1]))

The keyword ``mask`` contains list of booleans for each atom indicating
whether the atom's position should be fixed or not. See the
:mod:`ase.constraints` module on the ASE page for
more information and examples for setting constraints.