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

29 statements  

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

1""" 

2tests solvation parameters as in 

3 

4Damian A. Scherlis, Jean-Luc Fattebert, Francois Gygi, 

5Matteo Cococcioni and Nicola Marzari, 

6J. Chem. Phys. 124, 074103, 2006 

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 ElDensity 

21) 

22 

23 

24def test_solvation_sfgcm06(): 

25 SKIP_VAC_CALC = True 

26 

27 h = 0.24 

28 vac = 4.0 

29 

30 epsinf = 78.36 

31 rho0 = 0.00078 / Bohr ** 3 

32 beta = 1.3 

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

34 convergence = { 

35 'energy': 0.05 / 8., 

36 'density': 10., 

37 'eigenstates': 10., 

38 } 

39 

40 atoms = Atoms('Cl') 

41 adjust_cell(atoms, vac, h) 

42 

43 if not SKIP_VAC_CALC: 

44 atoms.calc = GPAW( 

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

46 Evac = atoms.get_potential_energy() 

47 print(Evac) 

48 else: 

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

50 Evac = -3.83245253419 

51 

52 atoms.calc = SolvationGPAW( 

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

54 cavity=FG02SmoothStepCavity( 

55 rho0=rho0, beta=beta, 

56 density=ElDensity(), 

57 surface_calculator=GradientSurface()), 

58 dielectric=LinearDielectric(epsinf=epsinf), 

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

60 Ewater = atoms.get_potential_energy() 

61 assert atoms.calc.get_number_of_iterations() < 40 

62 atoms.get_forces() 

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

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

65 

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