How do the recipes change: stiffness-recipeΒΆ

  • Takes atoms and calculator as arguments.

 1@command(module='asr.stiffness',
 2         returns=Result)
 3@option('--atoms', type=AtomsFile(), help='Atoms to be strained.')
 4@option('-c', '--calculator', help='Calculator and its parameters.',
 5        type=DictStr())
 6@option('--strain-percent', help='Magnitude of applied strain.', type=float)
 7def main(atoms,
 8         calculator: dict = {'name': 'gpaw',
 9                             'mode': {'name': 'pw', 'ecut': 800},
10                             'xc': 'PBE',
11                             'kpts': {'density': 6.0, 'gamma': True},
12                             'basis': 'dzp',
13                             'symmetry': {'symmorphic': False},
14                             'convergence': {'forces': 1e-4},
15                             'txt': 'relax.txt',
16                             'occupations': {'name': 'fermi-dirac',
17                                             'width': 0.05},
18                             'charge': 0},
19         strain_percent: float = 1.0) -> Result:
  • Forwards calculator to the relax-recipe.

 1    stiffness = np.zeros((6, 6), float)
 2    for i, j in ij:
 3        dstress = np.zeros((6,), float)
 4        for sign in [-1, 1]:
 5            strained_atoms = make_strained_atoms(
 6                atoms,
 7                strain_percent=sign * strain_percent,
 8                i=i, j=j).result
 9            relaxrecord = relax(strained_atoms, calculator=calculator)
10            stress = relaxrecord.result.stress
11            dstress += stress * sign
12        stiffness[:, ij_to_voigt[i][j]] = dstress / (strain_percent * 0.02)
13
14    stiffness = np.array(stiffness, float)