Debian Codegraph @

doc/tutorialsexercises/opticalresponse/tddft/lrtddft2/check_consistency_with_docs.py

raw
1 # This script helps to keep the documentation up-to-date.
2 # It checks that the values mentioned in .rst match
3 # with the actual output from the scripts.
4 #
5 # When updating the scripts, please update the .rst accordingly.
6
7 import numpy as np
8 from gpaw import GPAW
9
10
11 messages = []
12
13 calc = GPAW('unocc.gpw')
14 eig_n = calc.get_eigenvalues()
15
16 ref = 42
17 if not len(eig_n) == ref:
18 messages.append(
19 f'Number of bands is not {ref}. Check that discussion makes sense.')
20
21 ref = 8.2
22 if not np.isclose(eig_n[-2] - eig_n[11], ref, rtol=0, atol=0.1):
23 messages.append(
24 f'Update the energy difference of {ref}.')
25
26
27 data_ij = np.loadtxt('transitions_with_08.00eV.dat')
28 ref = 5.9
29 if not np.isclose(data_ij[0, 0], ref, rtol=0, atol=0.1):
30 messages.append(
31 f'Update the excitation energy of {ref}.')
32
33 if len(messages) > 0:
34 messages.insert(0, 'Scripts have changed. Please update the .rst too:')
35 message = '\n* '.join(messages)
36 raise AssertionError(message)