You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/examples.rst
+46-13
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,23 @@ Files needed:
14
14
Example 1: Calculate PDF of FCC nickel
15
15
======================================
16
16
17
-
The first example shows how to calculates the PDF for FCC nickel and saves the resulting data to a file and plot it using matplotlib.
17
+
The first example shows how to calculate the PDF for FCC nickel and save the resulting data
18
+
to a file and plot it using matplotlib.
18
19
19
-
1. Imports the PdfFit class from the diffpy.pdffit2 module::
20
+
1. Import the ``PdfFit`` class from the ``diffpy.pdffit2`` module
21
+
22
+
.. code-block:: python
20
23
21
24
from diffpy.pdffit2 import PdfFit
22
25
23
-
2. Create a PDF calculator object and assigned to the variable ``P``. Make sure the ``Ni.stru`` file is in the same directory as the script and you've cd to the directory, load structure file. Then allocate and configure PDF calculation and run the calculation::
26
+
2. Create a PDF calculator object and assign it to the variable ``P``.
27
+
Make sure the ``Ni.stru`` file is in the same directory as the script (or specify
28
+
the relative path to where it resides)
29
+
and you are currently in this directory. Then use ``read_struct`` to read the structure
30
+
file, ``alloc`` to configure the PDF
31
+
calculation, and then use ``calc`` to carry out the the calculation.
32
+
33
+
.. code-block:: python
24
34
25
35
# create new PDF calculator object
26
36
P = PdfFit()
@@ -39,11 +49,15 @@ The first example shows how to calculates the PDF for FCC nickel and saves the r
The second example shows how to perform simple refinement of Ni structure to the experimental x-ray PDF. The example uses the same data files as the first example.
83
+
The second example shows how to perform a simple refinement of the Ni structure to
84
+
the experimental x-ray PDF. The example uses the same data files as the first example.
85
+
86
+
1. Import the PdfFit class from the diffpy.pdffit2 module
69
87
70
-
1. Imports the PdfFit class from the diffpy.pdffit2 module::
88
+
.. code-block:: python
71
89
72
90
from diffpy.pdffit2 import PdfFit
73
91
74
-
2. Create a PDF calculator object and assigned to the variable ``pf``. Load experimental x-ray PDF data and nickel structure file::
92
+
2. Create a PDF calculator object and assign it to the variable ``pf``.
93
+
Load the experimental x-ray PDF data using ``read_data`` and also load
94
+
the nickel structure file.
95
+
96
+
.. code-block:: python
75
97
76
98
# Create new PDF calculator object.
77
99
pf = PdfFit()
@@ -84,7 +106,13 @@ The second example shows how to perform simple refinement of Ni structure to the
84
106
# Load nickel structure, must be in PDFFIT or DISCUS format
85
107
pf.read_struct("Ni.stru")
86
108
87
-
3. Configure refinement and refine::
109
+
3. Configure the refinement, assigning structural parameters to variables. For more
110
+
information on how to do this correctly, please read the PDFgui documentation.
111
+
Set initial values for the variables using ``setpar``.
112
+
Finally, you can configure the range over which to refine (``pdfrange``) and
113
+
run the refinement (``refine``).
114
+
115
+
.. code-block:: python
88
116
89
117
# Refine lattice parameters a, b, c.
90
118
# Make them all equal to parameter @1.
@@ -118,13 +146,18 @@ The second example shows how to perform simple refinement of Ni structure to the
118
146
pf.pdfrange(1, 1.5, 19.99)
119
147
pf.refine()
120
148
121
-
4. Save the refined result::
149
+
4. Save the refined result. ``save_struct`` saves the new, refined, structure to a
150
+
``.stru`` format file. ``save_res`` saves the outputs in a structured text file.
151
+
152
+
.. code-block:: python
122
153
123
154
pf.save_pdf(1, "Ni_refinement.fgr")
124
155
pf.save_struct(1, "Ni_refinement.rstr")
125
156
pf.save_res("Ni_refinement.res")
126
157
127
-
5. We can also plot it using matplotlib::
158
+
5. We can also plot it using matplotlib
159
+
160
+
.. code-block:: python
128
161
129
162
import matplotlib.pyplot as plt
130
163
import numpy
@@ -149,4 +182,4 @@ The second example shows how to perform simple refinement of Ni structure to the
149
182
# display plot window, this must be the last command in the script
150
183
plt.show()
151
184
152
-
The scripts can be downloaded :download:`here <examples/Ni_refinement.py>`.
185
+
The scripts can be downloaded from :download:`here <examples/Ni_refinement.py>`.
0 commit comments