Coverage for gpaw/test/solvation/test_sss09.py: 90%

30 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-14 00:18 +0000

1""" 

2 

3tests solvation parameters as in 

4 

5V. M. Sanchez, M. Sued, and D. A. Scherlis, 

6The Journal of Chemical Physics, vol. 131, no. 17, p. 174108, 2009 

7""" 

8 

9from gpaw import GPAW 

10from gpaw.utilities.adjust_cell import adjust_cell 

11import pytest 

12from ase import Atoms 

13from ase.units import mol, kcal, Pascal, m, Bohr 

14from gpaw.solvation import ( 

15 SolvationGPAW, 

16 FG02SmoothStepCavity, 

17 LinearDielectric, 

18 GradientSurface, 

19 SurfaceInteraction, 

20 SSS09Density) 

21 

22 

23def test_solvation_sss09(): 

24 SKIP_VAC_CALC = True 

25 

26 h = 0.24 

27 vac = 4.0 

28 

29 epsinf = 78.36 

30 rho0 = 1.0 / Bohr ** 3 

31 beta = 2.4 

32 st = 72. * 1e-3 * Pascal * m 

33 

34 atomic_radii = {'Cl': 2.059} 

35 

36 convergence = { 

37 'energy': 0.05 / 8., 

38 'density': 10., 

39 'eigenstates': 10.} 

40 

41 atoms = Atoms('Cl') 

42 adjust_cell(atoms, vac, h) 

43 

44 if not SKIP_VAC_CALC: 

45 atoms.calc = GPAW(mode='fd', 

46 xc='PBE', 

47 h=h, 

48 charge=-1, 

49 convergence=convergence) 

50 Evac = atoms.get_potential_energy() 

51 print(Evac) 

52 else: 

53 # h=0.24, vac=4.0, setups: 0.9.11271, convergence: only energy 0.05 / 8 

54 Evac = -3.83245253419 

55 

56 atoms.calc = SolvationGPAW( 

57 mode='fd', xc='PBE', h=h, charge=-1, convergence=convergence, 

58 cavity=FG02SmoothStepCavity( 

59 rho0=rho0, beta=beta, 

60 density=SSS09Density(atomic_radii=atomic_radii), 

61 surface_calculator=GradientSurface()), 

62 dielectric=LinearDielectric(epsinf=epsinf), 

63 interactions=[SurfaceInteraction(surface_tension=st)]) 

64 Ewater = atoms.get_potential_energy() 

65 assert atoms.calc.get_number_of_iterations() < 40 

66 atoms.get_forces() 

67 DGSol = (Ewater - Evac) / (kcal / mol) 

68 print('Delta Gsol: %s kcal / mol' % DGSol) 

69 

70 assert DGSol == pytest.approx(-75., abs=10.)