forked from diffpy/diffpy.pdffit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNi_calculation.py
More file actions
executable file
·52 lines (35 loc) · 1.41 KB
/
Ni_calculation.py
File metadata and controls
executable file
·52 lines (35 loc) · 1.41 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Calculate PDF of FCC nickel.
Save data to Ni_calculation.cgr and plot it using matplotlib.
"""
import matplotlib.pyplot as plt
from diffpy.pdffit2 import PdfFit
# create new PDF calculator object
P = PdfFit()
# Load data ------------------------------------------------------------------
# load structure file in PDFFIT or DISCUS format
P.read_struct("Ni.stru")
# Configure calculation ------------------------------------------------------
radiation_type = "X" # x-rays
qmax = 30.0 # Q-cutoff used in PDF calculation in 1/A
qdamp = 0.01 # instrument Q-resolution factor, responsible for PDF decay
rmin = 0.01 # minimum r-value
rmax = 30.0 # maximum r-value
npts = 3000 # number of points in the r-grid
# allocate and configure PDF calculation
P.alloc(radiation_type, qmax, qdamp, rmin, rmax, npts)
# Calculate -------------------------------------------------------------------
P.calc()
# Save results ---------------------------------------------------------------
P.save_pdf(1, "Ni_calculation.cgr")
# Plot results ---------------------------------------------------------------
# obtain list of r-points and corresponding G values
r = P.getR()
G = P.getpdf_fit()
plt.plot(r, G)
plt.xlabel("r (Å)")
plt.ylabel("G (Å$^{-2}$)")
plt.title("x-ray PDF of nickel simulated at Qmax = %g" % qmax)
# display plot window, this must be the last command in the script
plt.show()