forked from maxim5/cs229-2018-autumn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (24 loc) · 877 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pymatgen.analysis.wulff import WulffShape
from pymatgen.core.surface import SlabGenerator, Structure
from mp_api.client import MPRester
import matplotlib.pyplot as plt
API_KEY = "CwDgVg8Lg2X5oRNSNIsj7qBbRyvhjTUf"
mpr = MPRester(API_KEY)
# Example: Get the structure for Silicon (mp-149)
structure = mpr.get_structure_by_material_id("mp-149")
# Example surface energies (in J/m^2) for Si facets
surface_energies = {
(1, 0, 0): 1.5,
(1, 1, 0): 1.2,
(1, 1, 1): 1.0,
(2, 1, 1): 1.8
}
# Extract Miller indices and corresponding surface energies into separate lists
miller_list = list(surface_energies.keys())
e_surf_list = list(surface_energies.values())
# Create the WulffShape object
wulff_shape = WulffShape(structure.lattice, miller_list, e_surf_list)
# Visualize the Wulff shape
fig = wulff_shape.get_plot()
# Customize and show the plot
plt.show()