Coverage for gpaw/test/radial/test_pseudize.py: 100%
20 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import numpy as np
2from gpaw.atom.radialgd import EquidistantRadialGridDescriptor
5def test_smoothness():
6 """Make sure pseudize_smooth() produces the most smooth function."""
7 rgd = EquidistantRadialGridDescriptor(0.05, 200)
8 r = rgd.r_g
10 a = 3.0
11 l = 0
12 ecut = 10
13 Gcut = (2 * ecut)**0.5
14 gc = 20
16 f0 = np.exp(-a * r**2)
17 f1, _ = rgd.pseudize_normalized(f0, gc, l, 4)
18 f2, _ = rgd.pseudize(f0, gc, l, 4)
19 f3, _ = rgd.pseudize_smooth(f0, gc, l, 4, Gcut)
21 # Calculate weight of large wave vectors (G > Gcut):
22 weights = []
23 for f in [f0, f1, f2, f3]:
24 x, ft = rgd.fft(f * r, l=l)
25 weights.append(((x * ft)[x > Gcut]**2).sum())
27 print(weights)
28 assert (np.diff(weights) < 0).all()