PbSO₄ on D1A and a laboratory diffractometer¶
Fit PbSO₄ to two patterns at once, the Rietveld round robin's neutron pattern from D1A at ILL and its laboratory X-ray pattern: one structure, two experiments.
The project is the catalogue case pd-neut-xray-cwl_pbso4-d1a-lab, the one the command line and
the app's Examples open.
Fitting
Joint pd neut xray cwl Bragg
Crystal structure
import easydiffraction as edi
Load the project¶
project_path = edi.download_data('pd-neut-xray-cwl_pbso4-d1a-lab', destination='data')
project = edi.Project.load(project_path)
structure = project.structures['pbso4']
d1a = project.experiments['d1a']
lab = project.experiments['lab']
Data 'pd-neut-xray-cwl_pbso4-d1a-lab' is at data/pd-neut-xray-cwl_pbso4-d1a-lab-ce92206a5a9d/pd-neut-xray-cwl_pbso4-d1a-lab
The project marks what its fit frees. The fit below frees it in stages, so start with all of it fixed.
for parameter in project.free_parameters:
parameter.free = False
project.display.pattern('d1a')
Perform the analysis¶
Both patterns fit together. diffraction-lib's tutorial of this case frees everything at once, and also the D1A wavelength, which this case keeps fixed.
Scales, 2θ zeros and cell¶
d1a.linked_structures['pbso4'].scale.free = True
lab.linked_structures['pbso4'].scale.free = True
d1a.instrument.calib_twotheta_offset.free = True
lab.instrument.calib_twotheta_offset.free = True
structure.cell.length_a.free = True
structure.cell.length_b.free = True
structure.cell.length_c.free = True
project.display.parameters.free()
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 7 free
iter time (s) Rwp (%) reduced χ² change
64.60 241.50
1 0.043 32.57 61.40 74.6% ↓
2 0.077 29.36 49.90 18.7% ↓
3 0.111 28.47 46.91 6.0% ↓
4 0.143 27.86 44.92 4.2% ↓
5 0.178 27.34 43.27 3.7% ↓
6 0.211 26.85 41.72 3.6% ↓
7 0.247 26.38 40.29 3.4% ↓
8 0.279 25.94 38.96 3.3% ↓
9 0.313 25.50 37.63 3.4% ↓
10 0.346 25.02 36.22 3.7% ↓
11 0.380 24.52 34.79 4.0% ↓
12 0.414 24.01 33.36 4.1% ↓
13 0.450 23.47 31.88 4.4% ↓
14 0.485 22.90 30.35 4.8% ↓
15 0.523 22.34 28.88 4.9% ↓
16 0.563 21.80 27.51 4.7% ↓
17 0.602 21.31 26.28 4.5% ↓
18 0.636 20.89 25.26 3.9% ↓
19 0.670 20.57 24.49 3.0% ↓
20 0.704 20.35 23.96 2.2% ↓
21 0.737 20.21 23.63 1.4% ↓
22 0.769 20.12 23.44 0.8% ↓
23 0.803 20.08 23.33 0.5% ↓
24 0.843 20.05 23.27 0.2% ↓
25 0.881 20.04 23.24 0.1% ↓
26 0.919 20.03 23.23 0.1% ↓
27 0.956 20.03 23.22
28 0.993 20.03 23.22
29 1.032 20.03 23.22
30 1.069 20.03 23.21
31 1.107 20.03 23.21
32 1.143 20.03 23.21
33 1.202 20.03 23.21
done · converged · 33 iters · reduced χ² 23.21 · Rwp 20.03 % · 1.24 s
project.display.pattern('d1a')
project.display.pattern('lab')
Backgrounds¶
D1A's points and the laboratory pattern's Chebyshev terms.
for point in d1a.background:
point.intensity.free = True
for term in lab.background_terms:
term.coef.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 21 free
iter time (s) Rwp (%) reduced χ² change
20.03 23.25
1 0.057 19.11 21.17 9.0% ↓
2 0.095 19.11 21.17
3 0.134 19.11 21.17
4 0.191 19.11 21.17
done · converged · 4 iters · reduced χ² 21.17 · Rwp 19.11 % · 0.24 s
project.display.pattern('d1a')
project.display.pattern('lab')
Peak widths¶
d1a.peak.broad_gauss_u.free = True
d1a.peak.broad_gauss_v.free = True
d1a.peak.broad_gauss_w.free = True
d1a.peak.mixing_eta_0.free = True
lab.peak.broad_gauss_u.free = True
lab.peak.broad_gauss_v.free = True
lab.peak.broad_gauss_w.free = True
lab.peak.mixing_eta_0.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 29 free
iter time (s) Rwp (%) reduced χ² change
19.11 21.19
1 0.058 13.96 11.31 46.6% ↓
2 0.106 12.37 8.88 21.5% ↓
3 0.166 11.88 8.18 7.8% ↓
4 0.239 11.62 7.84 4.2% ↓
5 0.315 11.49 7.66 2.3% ↓
6 0.398 11.42 7.57 1.1% ↓
7 0.490 11.40 7.54 0.4% ↓
8 0.580 11.39 7.53 0.1% ↓
9 0.664 11.39 7.53
10 0.747 11.39 7.53
11 0.833 11.39 7.53
12 0.952 11.39 7.53
done · converged · 12 iters · reduced χ² 7.53 · Rwp 11.39 % · 1.07 s
project.display.pattern('d1a')
project.display.pattern('lab')
Peak asymmetry, D1A¶
The D1A pattern's four Bérar-Baldinozzi terms.
d1a.peak.asym_beba_a0.free = True
d1a.peak.asym_beba_b0.free = True
d1a.peak.asym_beba_a1.free = True
d1a.peak.asym_beba_b1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 33 free
iter time (s) Rwp (%) reduced χ² change
11.39 7.53
1 0.133 10.50 6.40 15.1% ↓
2 0.220 9.87 5.66 11.6% ↓
3 0.295 9.70 5.46 3.4% ↓
4 0.366 9.65 5.40 1.1% ↓
5 0.432 9.64 5.39 0.2% ↓
6 0.495 9.64 5.39
7 0.558 9.64 5.39
8 0.619 9.64 5.39
9 0.710 9.64 5.39
done · converged · 9 iters · reduced χ² 5.39 · Rwp 9.64 % · 0.78 s
project.display.pattern('d1a')
project.display.pattern('lab')
Peak asymmetry, laboratory¶
The laboratory pattern's first-order terms.
lab.peak.asym_beba_a0.free = True
lab.peak.asym_beba_b0.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 35 free
iter time (s) Rwp (%) reduced χ² change
9.64 5.39
1 0.101 9.46 5.20 3.7% ↓
2 0.170 9.45 5.19 0.2% ↓
3 0.240 9.45 5.19
4 0.312 9.45 5.19
5 0.383 9.45 5.19
6 0.453 9.45 5.19
7 0.524 9.45 5.19
8 0.632 9.45 5.19
done · converged · 8 iters · reduced χ² 5.19 · Rwp 9.45 % · 0.72 s
project.display.pattern('d1a')
project.display.pattern('lab')
Atom positions¶
The neutron and X-ray patterns together see the oxygen as well as the lead, so all free coordinates fit at once.
for site in structure.atom_sites:
for coordinate in (site.fract_x, site.fract_y, site.fract_z):
coordinate.free = not coordinate.symmetry_constrained
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 46 free
iter time (s) Rwp (%) reduced χ² change
9.45 5.19
1 0.129 8.48 4.18 19.5% ↓
2 0.231 8.47 4.17 0.2% ↓
3 0.333 8.47 4.17
4 0.461 8.47 4.17
done · converged · 4 iters · reduced χ² 4.17 · Rwp 8.47 % · 0.57 s
project.display.pattern('d1a')
project.display.pattern('lab')
Displacements¶
for site in structure.atom_sites:
site.adp_iso.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-xray-cwl_pbso4-d1a-lab, 2 banks (d1a, lab), 8709 pts fitted / 8911 loaded, 51 free
iter time (s) Rwp (%) reduced χ² change
8.47 4.17
1 0.103 6.05 2.13 49.0% ↓
2 0.168 5.80 1.96 8.0% ↓
3 0.232 5.80 1.96 0.1% ↓
4 0.290 5.80 1.96
5 0.369 5.80 1.96
done · converged · 5 iters · reduced χ² 1.96 · Rwp 5.80 % · 0.45 s
project.display.pattern('d1a')
project.display.pattern('lab')
project.display.fit.correlations()
project.display.structure('pbso4')
Save the project¶
project.save_as('pd-neut-xray-cwl_pbso4-d1a-lab')
project.report.save_html('pd-neut-xray-cwl_pbso4-d1a-lab.html')
Saving project to 'pd-neut-xray-cwl_pbso4-d1a-lab'
Saving report to 'pd-neut-xray-cwl_pbso4-d1a-lab.html'