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/tutorial.rst
+85-22Lines changed: 85 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -17,51 +17,114 @@ Input files:
17
17
1. Ni-xray.gr - experimental X-ray PDF data
18
18
2. Ni.stru - Ni f.c.c. structure in PDFfit format
19
19
20
+
This manual will help you to get started with ``PDFgui``. We strongly recommend that that you refer to
21
+
the book `Atomic pair distribution function analysis: a primer` by Simon J. L. Billinge, Kirsten Jensen
22
+
Soham Banerjee, Emil S. Bozin, Benjamin A. Frandsen, Maxwell W. Terban and Robert J. Koch, Oxford:
23
+
Oxford University Press, 2024. URL: https://global.oup.com/academic/product/atomicpair-distribution-function-analysis-9780198885801?cc=us&lang=en&
24
+
for much more extensive and detailed descriptions of carrying out fits with PDFgui (and the related program diffpy-cmi).
25
+
20
26
Procedure:
21
27
22
-
1. Open a terminal and type ``pdfgui`` to start the program.
28
+
1. Open ``pdfgui``. Instructions for doing this depend on your system, but an example would be
29
+
to open a terminal, activate your pdfgui conda environment, and type ``pdfgui`` at the prompt,
30
+
or to double-click a project file on windows.
23
31
24
32
2. Create a new Fit:
25
-
1. Select "FITTING" in the left-most vertical tab.
26
-
2. Click right mouse button in the left panel and choose "New Fit" in the pop-up menu.
33
+
1. In the GUI locate the ``Fit Tree`` panel. In the default layout it is at the top left of the page.
34
+
2. With your mouse on that panel, right-click the mouse and select "New Fit" from the pop-up menu.
35
+
3. By default, your fit will be called ``Fit 1``. To give it a more meaningful name, left
36
+
click the ``Fit 1`` name. It should open an editable box and you can type in a name for your
37
+
fit such as "Fit of Ni structure to Ni data"
38
+
4. Note, an alternative workflow to create a new fit is to find ``New fit`` under the ``Fits`` dropdown menu.
27
39
28
40
3. Load structure model:
29
-
1. Place the cursor of the mouse onto the title of the Fit, click the right button and choose "Insert Phase" in the pop-up menu.
30
-
2. Click the "Open" button and load the `Ni.stru` file.
41
+
1. Carefully place your cursor on to the title of the Fit and right-click. Select "Insert Phase" from the pop-up menu.
42
+
2. Click the "Open" button and navigate to and load the ``Ni.stru`` file that you downloaded. You could select
43
+
valid structure model file, a ``.stru`` or a ``.cif`` file.
44
+
3. Note, an alternative workflow for adding structural models is to select ``New Phase`` from the ``Phases`` dropdown menu.
45
+
46
+
If you select the Phase in the ``Fit Tree`` by left clicking on it, you will see in the
47
+
right panel 3 tabs, ``Configure`` ``Constraints``, ``Results``. Feel free to click one
48
+
these tabs and look inside. The Configure panel has the initial inputs from the loaded str or cif file,
49
+
The ``Constraints`` panel will hold the constraints we will set up for our fits, it should be empty now,
50
+
and the results tab will contain the results of any fit.
31
51
32
-
The right panel has 3 tabs for the initial configuration, constraints panel for expressing structure properties as functions of tunable parameters, and Results panel for refined structure.
52
+
Note that what you see on the right is "Context Dependent", it depends on what you have selected on the left.
53
+
By selecting a phase on the left, the tabs on the right contain information about that phase, and so on.
33
54
34
55
4. Load experimental PDF data:
35
-
1. Select the title of "Fit 1", click the right button and choose "Insert Data Set" in the pop-up menu.
36
-
2. Load the `Ni-xray.gr` file.
56
+
1. As before, hover over your cursor over the title of your fit and right-click. This time select
57
+
``Insert Data Set`` from the pop-up menu.
58
+
2. Navigate to and load the `Ni-xray.gr` file that you downloaded.
37
59
38
-
Again, the right panel shows 3 tabs for properties of this dataset.
60
+
Again, the right panel shows 3 tabs, now for properties of this dataset.
39
61
40
62
5. Define what is refined:
41
63
1. Click on the `Ni-xray.gr` data and select the "Constraints" tab.
42
-
2. Type ``@1`` into "Scale Factor" edit box.
64
+
2. Type ``@1`` into the "Scale Factor" edit box.
43
65
3. Select the `Ni.stru` phase and its "Constraints" tab.
44
66
4. Fill "a", "b", "c" boxes with ``@5``.
45
67
46
-
A refined variable can be expressed as a math expression:
68
+
Here we are defining "variables" that will be refined and giving them names
69
+
variable "@1", "@5", etc. and linking them to model parameters by typing them
70
+
in the text-box associated with the parameter. So by typing ``@1`` in the
71
+
data "Scale-Factor" text box we are saying that we are logically assigning the constraint
72
+
equation ``data.scale_factor = variable("@1")``.
73
+
74
+
When we assign the three parameters ``a``, ``b`` and ``c`` to the same variable,
75
+
``@5``, we are implicitly ensuring that the refinement will respect
76
+
the cubic symmetry of the nickel structure and that ``a = b = c``, because the
77
+
three parameters are assigned to the same variable, so however much ``a``
78
+
is changed in the refinement, ``b`` and ``c`` will be changed by the same amount.
79
+
Note that the variable ensures that changes to ``a``, ``b`` and ``c`` are always
80
+
the same, so we have to also ensure that the initial values of ``a``, ``b`` and ``c``
81
+
are the same as each other to ensure that the structure is cubic and remains so.
82
+
83
+
PDFgui allows us to express more complex constraint equations than
84
+
simply assigning a parameter to a variable.
85
+
In general, we can type into be Constraints tab text box any math expression:
47
86
``f(@n1, @n2, @n3, ...)`` where
48
-
``@n1`` stands for fitted parameter and
87
+
``@n1`` stands for the fitted parameter, where it is understood that
49
88
``n1, n2, ...`` are arbitrary positive integers.
50
-
This allows simple linking of related variables - for example, since
51
-
cell lengths a, b, c are all expressed as ``@5``, the refined structure will remain cubic.
89
+
This allows simple linking of related variables. For example, if we want to allow a
90
+
crystallographic site to contain either Ni or Pt, we don't know how much Ni or Pt is
91
+
on the site, but we want it to be always fully occupied, we could create two lattice
92
+
site entries with the same fractional coordinates, with one assigned Ni as the element and the other
93
+
assigned Pt as the element. Then we could assign the Ni occupancy as ``@100``. Then
94
+
typing ``1-@100`` into the constraint text box of the Pt occupancy ensures that however
95
+
much the occupancy of the Ni site goes down in a refinement, the occupancy of the Pt on that
96
+
same site goes up by the same amount. This ensures full occupancy of that site, as long
97
+
as the initial occupancies of the Ni and Pt added up to 1.
52
98
53
99
6. Start the refinement:
54
-
1. Select "Fit 1" in the left panel. The parameters panel shows a list of used parameters and their initial values.
55
-
2. Click the "gear" icon on the toolbar and watch the fit progress in the terminal window.
100
+
1. Select the fit to run by left clicking the title of the fit in the ``Fit Tree`` panel.
101
+
The ``Parameters`` panel on the right shows a list of variables that you have defined
102
+
and their initial values. Each one also has a check-box that allows you to fix them
103
+
(prevent them from varying in the subsequent refinement). Unchecked boxes mean the variable
104
+
will be refined.
105
+
2. When you are satisfied with the configuration, click the "gear" icon on the toolbar
106
+
and watch the fit progress in the terminal window.
56
107
57
108
7. Plot the results:
58
-
1. Select "PLOTTING" in the left-most vertical tab.
59
-
2. Select the `Ni-xray.gr` dataset.
60
-
3. Select "r" as the X plotting variable.
61
-
4. Hold down shift and select "Gcalc" and "Gtrunc" as the Y plotting variables.
62
-
5. Click "Plot" button.
109
+
1. Select the data in the fit (in this case the `Ni-xray.gr` dataset) by left clicking it.
110
+
2. Click the ``plot`` icon in the toolbar. This is the icon that looks a bit like a PDF
111
+
to the right of the Gear and the red/grey X.
112
+
113
+
A new window pops up with the plots. It will show the data in blue, the best-fit model
114
+
curve in red, and offset below, the difference curve in green. The offset of the difference
115
+
curve appears at a default value of ``-5.0``. You can make your plot more pretty and meaningful
116
+
by typing a different offset into the ``offset`` text box and hitting ``Plot`` again.
117
+
118
+
It is possible to configure the plot in the ``Plot Control`` panel in the GUI.
119
+
In the default layout it will be at the lower-left of the GUI panel.
120
+
121
+
1. To plot the fit (as was done above) elect "r" as the X plotting variable.
122
+
2. Hold down shift and select "Gcalc" and "Gtrunc" as the Y plotting variables.
123
+
3. Click the "Plot" button.
124
+
125
+
This panel allows more plotting options for advanced cases such as plotting the values
126
+
of parameters refined across multiple fits to extract temperature dependent information.
63
127
64
-
A new window pops up with plots. You can try out the buttons in the toolbar below.
0 commit comments