forked from fang-ren/Useful_code_for_HiTp_WAXS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scherrer equation.py
61 lines (45 loc) · 1.2 KB
/
Scherrer equation.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 17 09:37:57 2016
@author: fangren
"""
"""
Scherrer equation
"""
import numpy as np
import matplotlib.pyplot as plt
lamda = 1.5406
K = 0.9 # shape factor
theta1 = np.array(range(1000))
theta1 = 0.00314 * theta1/4
theta2 = np.array(range(1000))
theta2 = 0.00314 * theta2/4
Q1 = 4 * np.pi * np.sin(theta1) / lamda
Q2 = 4 * np.pi * np.sin(theta2) / lamda
BETA = []
TAU = []
BETA_r = []
#theta = 0.61
for i in range(1000):
for j in range(i, 1000):
beta_in_Q = Q1[j] - Q2[i]
beta_in_radian = (theta1[j] - theta2[i]) * 2
theta = (theta1[j] + theta2[i])/2
tau = K * lamda /(10* beta_in_radian * np.cos(theta))
BETA.append(beta_in_Q)
BETA_r.append(beta_in_radian)
TAU.append(tau)
BETA_r = np.array(BETA_r)
BETA_degree = BETA_r * 180 / np.pi
crystalline = [3.5] * len(BETA)
amorphous = [2.2] * len(BETA)
plt.figure(1)
plt.plot(TAU, BETA, label = 'Scherrer equation')
plt.plot(crystalline, BETA, label = 'crystalline, D = 3.5 nm')
plt.plot(amorphous, BETA, label = 'amorphous, D = 2.2 nm')
plt.ylabel('FWHM in Q')
plt.xlabel('D, nm')
plt.xscale('log')
plt.xlim((1, 100))
plt.ylim((0, 0.6))
plt.legend()