This is the documentation for asr.c2db.relax-recipe. This recipe is comprised of a single instruction, namely:

Run this recipe through the CLI interface

$ asr run asr.c2db.relax

or as a python module

$ python -m asr.c2db.relax

Detailed description

Relax atomic structures.

By defaults read from “unrelaxed.json” from disk and relaxes structures and saves the final relaxed structure in “structure.json”.

The relax recipe has a couple of note-worthy features:

  • It automatically handles structures of any dimensionality

  • It tries to enforce symmetries

  • It continously checks after each step that no symmetries are broken, and raises an error if this happens.

The recipe also supports relaxing structure with vdW forces using DFTD3. To install DFTD3 do

$ mkdir ~/DFTD3 && cd ~/DFTD3
$ wget
$ tar -zxf dftd3.tgz
$ make
$ echo 'export ASE_DFTD3_COMMAND=$HOME/DFTD3/dftd3' >> ~/.bashrc
$ source ~/.bashrc


Relax without using DFTD3

$ ase build -x diamond Si unrelaxed.json
$ asr run "relax --nod3"

Relax using the LDA exchange-correlation functional

$ ase build -x diamond Si unrelaxed.json
$ asr run "relax --calculator {'xc':'LDA',...}"



asr.c2db.relax.main(atoms, calculator={'charge': 0, 'convergence': {'forces': 0.0001}, 'kpts': {'density': 6.0, 'gamma': True}, 'mode': {'ecut': 800, 'name': 'pw'}, 'name': 'gpaw', 'occupations': {'name': 'fermi-dirac', 'width': 0.05}, 'symmetry': {'symmorphic': False}, 'txt': 'relax.txt', 'xc': 'PBE'}, tmp_atoms=None, tmp_atoms_file='relax.traj', d3=False, fixcell=False, allow_symmetry_breaking=False, fmax=0.01, enforce_symmetry=True)[source]

Relax atomic positions and unit cell.

The relaxed structure is saved to structure.json which can be processed by other recipes.

  • atoms (ase.atoms.Atoms) – Atomic structure to relax.

  • calculator (dict) – Calculator dictionary description.

  • tmp_atoms (Optional[ase.atoms.Atoms]) – Atoms from a restarted calculation.

  • tmp_atoms_file (str) – Filename to save relaxed trajectory in.

  • d3 (bool) – Relax using DFTD3.

  • fixcell (bool) – Fix cell when relaxing, thus only relaxing atomic positions.

  • allow_symmetry_breaking (bool) – Allow structure to break symmetry.

  • fmax (float) – Maximum force tolerance.

  • enforce_symmetry (bool) – Enforce symmetries. When enabled, the atomic structure, forces and stresses will be symmetrized at each step of the relaxation.

Return type


class asr.c2db.relax.Result(a, symbols, gamma, c, images, beta, alpha, etot, forces, magmoms, spos, b, stress, atoms, edft)[source]

Result class for asr.c2db.relax.main().

  • a (float) –

  • symbols (List[str]) –

  • gamma (float) –

  • c (float) –

  • images (List[ase.atoms.Atoms]) –

  • beta (float) –

  • alpha (float) –

  • etot (float) –

  • forces (numpy.ndarray) –

  • magmoms (List[float]) –

  • spos (numpy.ndarray) –

  • b (float) –

  • stress (numpy.ndarray) –

  • atoms (ase.atoms.Atoms) –

  • edft (float) –

property a: float

Cell parameter a [Å]

property alpha: float

Cell parameter alpha [deg]

property atoms: ase.atoms.Atoms

Relaxed atomic structure.

property b: float

Cell parameter b [Å]

property beta: float

Cell parameter beta [deg]

property c: float

Cell parameter c [Å]

property edft: float

DFT total energy [eV]

property etot: float

Total energy [eV]

property forces: numpy.ndarray

Forces on atoms after relaxation.

property gamma: float

Cell parameter gamma [deg]

property images: List[ase.atoms.Atoms]

Path taken when relaxing structure.

property magmoms: List[float]

Atomic magnetic moments of relaxed structure [mu_B]

property spos: numpy.ndarray

Scaled positions



property stress: numpy.ndarray

Stress on cell after relaxation.

property symbols: List[str]

Chemical symbols