Stiffness tensor recipe issuesΒΆ

The stiffness tensor recipe also has a bad smell originating from the fact that relaxations have to be performed in separate subfolders

 1    links = {}
 2    stiffness = np.zeros((6, 6), float)
 3    for i, j in ij:
 4        dstress = np.zeros((6,), float)
 5        for sign in [-1, 1]:
 6            folder = get_strained_folder_name(sign * strain_percent, i, j)
 7            with chdir(folder):
 8                if not relax.done:
 9                    relax()
10
11                if not computemf.done:
12                    computemf()
13            mf = read_json(folder / ('results-asr.database.'
14                                     'material_fingerprint.json'))
15            links[str(folder)] = mf['uid']
16            structurefile = folder / 'structure.json'
17            structure = read(str(structurefile))
18            # The structure already has the stress if it was
19            # calculated
20            stress = structure.get_stress(voigt=True)
21            dstress += stress * sign
22        stiffness[:, ij_to_voigt[i][j]] = dstress / (strain_percent * 0.02)