root / ase / gui / bulk_modulus.py @ 12
Historique | Voir | Annoter | Télécharger (1,02 ko)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
from math import sqrt |
3 |
|
4 |
import numpy as np |
5 |
|
6 |
from ase.units import kJ |
7 |
from ase.utils.eos import EquationOfState |
8 |
|
9 |
|
10 |
def BulkModulus(images): |
11 |
v = np.array([abs(np.linalg.det(A)) for A in images.A]) |
12 |
#import matplotlib.pyplot as plt
|
13 |
import pylab as plt |
14 |
plt.ion() |
15 |
EquationOfState(v, images.E).plot() |
16 |
|
17 |
"""
|
18 |
fit = np.poly1d(np.polyfit(v**-(1.0 / 3), images.E, 3))
|
19 |
fit1 = np.polyder(fit, 1)
|
20 |
fit2 = np.polyder(fit1, 1)
|
21 |
for t in np.roots(fit1):
|
22 |
if t > 0 and fit2(t) > 0:
|
23 |
break
|
24 |
v0 = t**-3
|
25 |
e0 = fit(t)
|
26 |
B = t**5 * fit2(t) / 9 / kJ * 1.0e24 # Gpa
|
27 |
|
28 |
import pylab
|
29 |
import matplotlib
|
30 |
#matplotlib.use('GTK')
|
31 |
|
32 |
pylab.ion()
|
33 |
x = 3.95
|
34 |
pylab.figure(figsize=(x * 2.5**0.5, x))
|
35 |
|
36 |
pylab.plot(v, images.E, 'o')
|
37 |
|
38 |
x = np.linspace(min(v), max(v), 100)
|
39 |
pylab.plot(x, fit(x**-(1.0 / 3)), '-r')
|
40 |
pylab.xlabel(u'volume [Å^3]')
|
41 |
pylab.ylabel(u'energy [eV]')
|
42 |
pylab.title(u'E: %.3f eV, V: %.3f Å^3, B: %.3f GPa' % (e0, v0, B))
|
43 |
pylab.show()
|
44 |
"""
|