Coverage for /builds/ericyuan00000/ase/ase/utils/deltacodesdft.py: 21.43%

14 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-06-18 01:20 +0000

1# fmt: off 

2 

3import numpy as np 

4 

5from ase.eos import birchmurnaghan 

6 

7 

8def delta(v1: float, B1: float, Bp1: float, 

9 v2: float, B2: float, Bp2: float, 

10 symmetric=True) -> float: 

11 """Calculate Delta-value between two equation of states. 

12 

13 .. seealso:: https://github.com/molmod/DeltaCodesDFT 

14 

15 Parameters 

16 ---------- 

17 v1,v2: float 

18 Volume per atom. 

19 B1,B2: float 

20 Bulk-modulus (in eV/Ang^3). 

21 Bp1,Bp2: float 

22 Pressure derivative of bulk-modulus. 

23 symmetric: bool 

24 Default is to calculate a symmetric delta. 

25 

26 Returns 

27 ------- 

28 delta: float 

29 Delta value in eV/atom. 

30 """ 

31 if symmetric: 

32 va = 0.94 * (v1 + v2) / 2 

33 vb = 1.06 * (v1 + v2) / 2 

34 else: 

35 va = 0.94 * v2 

36 vb = 1.06 * v2 

37 npoints = 100 

38 dv = (vb - va) / npoints 

39 v = np.linspace(va + dv / 2, vb - dv / 2, npoints) 

40 e1 = birchmurnaghan(v, 0.0, B1, Bp1, v1) 

41 e2 = birchmurnaghan(v, 0.0, B2, Bp2, v2) 

42 return (((e1 - e2)**2).sum() * dv / (vb - va))**0.5