@@ -4,8 +4,13 @@ diffpy.morph Tutorial
4
4
#####################
5
5
6
6
Welcome! This will be a quick tutorial to accquaint users with ``diffpy.morph ``
7
- and some of what it can do. For a more detailed tutorial, check out
8
- our :download: `user manual <../manual/diffpy.morph.pdf >`.
7
+ and some of what it can do. To see more details and definitions about
8
+ the morphs please see the publication describing ``diffpy.morph ``.
9
+
10
+ To be published:
11
+
12
+ *
13
+
9
14
10
15
As we described in the README and installation instructions, please make
11
16
sure that you are familiar with working with your command line terminal
@@ -14,6 +19,11 @@ before using this application.
14
19
Before you've started this tutorial, please ensure that you've installed
15
20
all necessary software and dependencies.
16
21
22
+ In this tutorial, we will demonstrate how to use ``diffpy.morph `` to compare
23
+ two
24
+ PDFs measured from the same material at different temperatures.
25
+ The morphs showcased include "stretch", "scale", and "smear".
26
+
17
27
Basic diffpy.morph Workflow
18
28
===========================
19
29
@@ -51,7 +61,8 @@ Basic diffpy.morph Workflow
51
61
* Note that these files have the ``.gr `` extension, which
52
62
indicates that they are measured PDFs. The ``.cgr `` file
53
63
extension indicates that a file is a calculated PDF, such as
54
- those generated by the `PDFgui <https://www.diffpy.org/products/pdfgui.html >`_
64
+ those generated by the
65
+ `PDFgui <https://www.diffpy.org/products/pdfgui.html >`_
55
66
program.
56
67
57
68
4. First, we will run the ``diffpy.morph `` application without any morphing
@@ -81,6 +92,12 @@ Basic diffpy.morph Workflow
81
92
and the second as the "target", as the ``diffpy.morph `` display
82
93
does.
83
94
95
+ .. figure :: images/qs_tutorial_unmorphed.png
96
+ :align: center
97
+ :figwidth: 100%
98
+
99
+ Using ``diffpy.morph `` to compare two different PDFs without morphing.
100
+
84
101
6. Now, we will start the morphing process, which requires us to
85
102
provide initial guesses for our scaling factor, Gaussian smear,
86
103
and stretch, separately. We will start with the scaling factor.
@@ -117,6 +134,12 @@ Basic diffpy.morph Workflow
117
134
In this tutorial, we will use it every time to check
118
135
for convergence.
119
136
137
+ .. figure :: images/qs_tutorial_scaled.png
138
+ :align: center
139
+ :figwidth: 100%
140
+
141
+ ``diffpy.morph `` found an optimal value for the scale factor.
142
+
120
143
7. Now, we will examine the Gaussian smearing factor. We provide an
121
144
initial guess by typing ::
122
145
@@ -168,6 +191,12 @@ Basic diffpy.morph Workflow
168
191
the optimized ``--stretch=0.001762 ``. We have now reached
169
192
the optimal fit for our PDF!
170
193
194
+ .. figure :: images/qs_tutorial_morphed.png
195
+ :align: center
196
+ :figwidth: 100%
197
+
198
+ The optimal fit after applying the scale, smear, and stretch morphs.
199
+
171
200
9. Now, try it on your own! If you have personally collected or
172
201
otherwise readily available PDF data, try this process to see if
173
202
you can morph your PDFs to one another. Many of the parameters
@@ -197,41 +226,94 @@ at various temperatures to determine whether a phase change has occurred.
197
226
``diffpy.morph `` currently allows users to morph a PDF against all files in a
198
227
selected directory and plot resulting :math: `R_w` values from each morph.
199
228
200
- 1. Within the ``additionalData `` directory, ``cd `` into the ``morphMultiple `` directory.
201
- Inside, you will find multiple PDFs of :math: `SrFe_2 As_2 ` measured at various temperatures.
202
- These PDFs are from `"Atomic Pair Distribution Function Analysis: A primer" <https://github.com/Billingegroup/pdfttp_data/ >`_.
203
- 2. Let us start by getting the Rw of ``SrFe2As2_150K.gr `` compared to all other files in the
204
- directory. Run ::
229
+ 1. Within the ``additionalData `` directory, ``cd `` into the
230
+ ``morphsequence `` directory. Inside, you will find multiple PDFs of
231
+ :math: `SrFe_2 As_2 ` measured at various temperatures. These PDFs are
232
+ from `"Atomic Pair Distribution Function Analysis: A primer"
233
+ <https://global.oup.com/academic/product/
234
+ atomic-pair-distribution-function-analysis-9780198885801> `_.
235
+
236
+ 2. Let us start by getting the Rw of ``SrFe2As2_150K.gr `` compared to
237
+ all other files in the directory. Run ::
205
238
206
239
diffpy.morph SrFe2As2_150K.gr . --multiple-targets
207
240
208
- The multiple tag indicates we are comparing PDF file (first input) against all PDFs in
209
- a directory (second input). Our choice of file was ``SeFe2As2_150K.gr ``
210
- and directory was the cwd, which should be ``morphMultiple ``.
211
- 3. After running this, we get chart of Rw values for each target file. However, this chart can
212
- be a bit confusing to interpret. To get a more understandable plot, run ::
241
+ The multiple tag indicates we are comparing PDF file (first input)
242
+ against all PDFs in a directory (second input). Our choice of file
243
+ was ``SeFe2As2_150K.gr `` and directory was the cwd, which should be
244
+ ``morphsequence ``.::
245
+
246
+ diffpy.morph SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
247
+
248
+ .. figure :: images/ex_tutorial_bar.png
249
+ :align: center
250
+ :figwidth: 100%
251
+
252
+ Bar chart of :math: `R_W` values for each target file. Target files are
253
+ listed in ASCII sort order.
254
+
255
+ 3. After running this, we get chart of Rw values for each target file.
256
+ However, this chart can be a bit confusing to interpret. To get a
257
+ more understandable plot, run ::
213
258
214
259
diffpy.morph SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
215
260
216
- This plots the Rw against the temperature parameter value provided at the top of each file.
217
- Parameters are entries of the form ``<parameter_name> = <parameter_value> `` and are located
218
- above the ``r `` versus ``gr `` table in each PDF file.
219
- 4. Between 192K and 198K, the Rw has a sharp increase, indicating that we may have a phase change.
220
- To confirm, let us now apply morphs onto ``SrFe2As2_150K.gr `` with all other files in ``morphMultiple ``
221
- as targets ::
261
+ This plots the Rw against the temperature parameter value provided
262
+ at the top of each file. Parameters are entries of the form
263
+ ``<parameter_name> = <parameter_value> `` and are located above
264
+ the ``r `` versus ``gr `` table in each PDF file.::
265
+
266
+ # SrFe2As2_150K.gr
267
+ [PDF Parameters]
268
+ temperature = 150
269
+ wavelength = 0.1
270
+ ...
271
+
272
+ .. figure :: images/ex_tutorial_temp.png
273
+ :align: center
274
+ :figwidth: 100%
275
+
276
+ The :math: `R_W` plotted against the temperature the target PDF was
277
+ measured at.
278
+
279
+ 4. Between 192K and 198K, the Rw has a sharp increase, indicating that
280
+ we may have a phase change. To confirm, let us now apply morphs
281
+ onto `` SrFe2As2_150K.gr`` with all other files in
282
+ ``morphsequence `` as targets ::
222
283
223
284
diffpy.morph --scale=1 --stretch=0 SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
224
285
225
- Note that we are not applying a smear since it takes a long time to apply and does not significantly
226
- change the Rw values in this example.
286
+ Note that we are not applying a smear since it takes a long time to
287
+ apply and does not significantly change the Rw values in this example.
288
+
227
289
5. We should now see a sharper increase in Rw between 192K and 198K.
290
+
228
291
6. Go back to the terminal to see optimized morphing parameters from each morph.
229
- 7. On the morph with ``SrFe2As2_192K.gr `` as target, ``scale = 0.972085 `` and ``stretch = 0.000508 ``
230
- and with ``SrFe2As2_198K.gr `` as target, ``scale = 0.970276 `` and ``stretch = 0.000510 ``.
231
- These are very similar, meaning that thermal lattice expansion (accounted for by ``stretch ``)
232
- is not occurring. This, coupled with the fact that the Rw significantly increases suggests
233
- a phase change in this temperature regime. (In fact, :math: `SrFe_2 As_2 ` does transition from
234
- orthorhombic at lower temperature to tetragonal at higher temperature!)
292
+
293
+ 7. On the morph with ``SrFe2As2_192K.gr `` as target, ``scale =
294
+ 0.972085 `` and ``stretch = 0.000508 `` and with ``SrFe2As2_198K.gr ``
295
+ as target, ``scale = 0.970276 `` and ``stretch = 0.000510 ``. These
296
+ are very similar, meaning that thermal lattice expansion (accounted
297
+ for by ``stretch ``) is not occurring. This, coupled with the fact
298
+ that the Rw significantly increases suggests a phase change in this
299
+ temperature regime. (In fact, :math: `SrFe_2 As_2 ` does transition
300
+ from orthorhombic at lower temperature to tetragonal at higher
301
+ temperature!). More sophisticated analysis can be done with
302
+ `PDFgui <https://www.diffpy.org/products/pdfgui.html >`_.
303
+
304
+ 8. Finally, let us save all the morphed PDFs into a directory
305
+ named ``saved-morphs ``. ::
306
+
307
+ diffpy.morph SrFe2As2_150K.gr . --scale=1 --stretch=0 --multiple-targets \
308
+ --sort-by=temperature --plot-parameter=stretch \
309
+ --save=saved-morphs
310
+
311
+ Entering the directory with ``cd `` and viewing its contents with
312
+ ``ls ``, we see a file named ``morph-reference-table.txt `` with data
313
+ about the input morph parameters and re- fined output parameters
314
+ and a directory named ``morphs `` containing all the morphed
315
+ PDFs. See the ``--save-names-file `` option to see how you can set
316
+ the names for these saved morphs!
235
317
236
318
Nanoparticle Shape Effects
237
319
--------------------------
@@ -240,56 +322,80 @@ A nanoparticle's finite size and shape can affect the shape of its PDF.
240
322
We can use ``diffpy.morph `` to morph a bulk material PDF to simulate these shape effects.
241
323
Currently, the supported nanoparticle shapes include: spheres and spheroids.
242
324
243
- * Within the ``additionalData `` directory, ``cd `` into the ``morphShape `` subdirectory.
244
- Inside, you will find a sample Ni bulk material PDF ``Ni_bulk.gr ``.
245
- This PDF is from `"Atomic Pair Distribution Function Analysis: A primer" <https://github.com/Billingegroup/pdfttp_data/ >`_.
325
+ * Within the ``additionalData `` directory, ``cd `` into the
326
+ ``morphShape `` subdirectory. Inside, you will find a sample Ni bulk
327
+ material PDF ``Ni_bulk.gr ``. This PDF is from `"Atomic Pair
328
+ Distribution Function Analysis:
329
+ A primer" <https://global.oup.com/academic/product/
330
+ atomic-pair-distribution-function-analysis-9780198885801> `_.
246
331
There are also multiple ``.cgr `` files with calculated Ni nanoparticle PDFs.
247
332
248
- * Let us apply various shape effect morphs on the bulk material to reproduce these calculated PDFs.
333
+ * Let us apply various shape effect morphs on the bulk material to
334
+ reproduce these calculated PDFs.
249
335
250
336
* Spherical Shape
251
- 1. The ``Ni_nano_sphere.cgr `` file contains a generated spherical nanoparticle with unknown radius.
252
- First, let us plot ``Ni_blk.gr `` against ``Ni_nano_sphere.cgr `` ::
337
+ 1. The ``Ni_nano_sphere.cgr `` file contains a generated
338
+ spherical nanoparticle with unknown radius. First, let us
339
+ plot ``Ni_blk.gr `` against ``Ni_nano_sphere.cgr `` ::
253
340
254
341
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr
255
342
256
343
Despite the two being the same material, the Rw is quite large.
257
344
To reduce the Rw, we will apply spherical shape effects onto the PDF.
258
- However, in order to do so, we first need the radius of the spherical nanoparticle.
259
- 2. To get the radius, we can first observe a plot of ``Ni_nano_sphere.cgr `` ::
345
+ However, in order to do so, we first need the radius of the
346
+ spherical nanoparticle.
347
+
348
+ 2. To get the radius, we can first observe a plot of
349
+ ``Ni_nano_sphere.cgr `` ::
260
350
261
351
diffpy.morph Ni_nano_sphere.cgr Ni_nano_sphere.cgr
262
352
263
- 3. Nanoparticles tend to have broader peaks at r-values larger than the particle size,
264
- corresponding to the much weaker correlations between molecules.
265
- On our plot, beyond r=22.5, peaks are too broad to be visible ,
266
- indicating our particle size to be about 22.4.
267
- The approximate radius of a sphere would be half of that, or 11.2.
268
- 4. Now, we are ready to perform a morph applying spherical effects. To do so, we use the `` --radius `` parameter ::
353
+ 3. Nanoparticles tend to have broader peaks at r-values larger
354
+ than the particle size, corresponding to the much weaker
355
+ correlations between molecules. On our plot, beyond r=22.5,
356
+ peaks are too broad to be visible, indicating our particle
357
+ size to be about 22.4. The approximate radius of a sphere
358
+ would be half of that, or 11.2. ::
269
359
270
360
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
271
361
272
- 5. We can see that the Rw value has significantly decreased from before. Run without the ``-a `` tag to refine ::
362
+
363
+ 4. Now, we are ready to perform a morph applying spherical
364
+ effects. To do so, we use the ``--radius `` parameter ::
365
+
366
+ diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
367
+
368
+ 5. We can see that the Rw value has significantly decreased
369
+ from before. Run without the ``-a `` tag to refine ::
273
370
274
371
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2
275
372
276
- 6. After refining, we see the actual radius of the nanoparticle was closer to 12.
373
+ 6. After refining, we see the actual radius of the
374
+ nanoparticle was closer to 12.
375
+
277
376
* Spheroidal Shape
278
- 1. The ``Ni_nano_spheroid.cgr `` file contains a calculated spheroidal Ni nanoparticle.
279
- Again, we can begin by plotting the bulk material against our nanoparticle ::
377
+
378
+ 1. The ``Ni_nano_spheroid.cgr `` file contains a calculated
379
+ spheroidal Ni nanoparticle. Again, we can begin by plotting
380
+ the bulk material against our nanoparticle ::
280
381
281
382
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr
282
383
283
- 2. Inside the ``Ni_nano_spheroid.cgr `` file, we are given that the equatorial radius is 12 and polar radius is 6.
284
- This is enough information to define our spheroid. To apply spheroid shape effects onto our bulk, run ::
384
+ 2. Inside the ``Ni_nano_spheroid.cgr `` file, we are given that
385
+ the equatorial radius is 12 and polar radius is 6. This is
386
+ enough information to define our spheroid. To apply
387
+ spheroid shape effects onto our bulk, run ::
285
388
286
389
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr --radius=12 --pradius=6 -a
287
390
288
- Note that the equatorial radius corresponds to the ``--radius `` parameter and polar radius to ``--pradius ``.
391
+ Note that the equatorial radius corresponds to the
392
+ ``--radius `` parameter and polar radius to ``--pradius ``.
393
+
289
394
3. Remove the ``-a `` tag to refine.
290
395
291
- There is also support for morphing from a nanoparticle to a bulk. When applying the inverse morphs,
292
- it is recommended to set ``--rmax=psize `` where ``psize `` is the longest diameter of the nanoparticle.
396
+ There is also support for morphing from a nanoparticle to a bulk. When
397
+ applying the inverse morphs, it is recommended to set ``--rmax=psize ``
398
+ where ``psize `` is the longest diameter of the nanoparticle.
293
399
294
400
Bug Reports
295
401
===========
0 commit comments