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

14 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1import numpy as np 

2 

3from ase.eos import birchmurnaghan 

4 

5 

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

7 v2: float, B2: float, Bp2: float, 

8 symmetric=True) -> float: 

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

10 

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

12 

13 Parameters 

14 ---------- 

15 v1,v2: float 

16 Volume per atom. 

17 B1,B2: float 

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

19 Bp1,Bp2: float 

20 Pressure derivative of bulk-modulus. 

21 symmetric: bool 

22 Default is to calculate a symmetric delta. 

23 

24 Returns 

25 ------- 

26 delta: float 

27 Delta value in eV/atom. 

28 """ 

29 if symmetric: 

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

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

32 else: 

33 va = 0.94 * v2 

34 vb = 1.06 * v2 

35 npoints = 100 

36 dv = (vb - va) / npoints 

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

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

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

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