Si on SEPD¶
Fit silicon to time-of-flight neutron powder data from SEPD at Argonne, with the Jorgensen-Von Dreele profile.
The project is the catalogue case pd-neut-tof_si-sepd, the one the command line and the app's
Examples open.
Fitting
Single pd neut tof Bragg
Crystal structure
import easydiffraction as edi
Load the project¶
project_path = edi.download_data('pd-neut-tof_si-sepd', destination='data')
project = edi.Project.load(project_path)
structure = project.structures['si']
experiment = project.experiments['sepd']
Data 'pd-neut-tof_si-sepd' is at data/pd-neut-tof_si-sepd-d8aba2784c50/pd-neut-tof_si-sepd
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
Estimate the background¶
Start the background from an automatic estimate. The default method, arPLS, fits a smooth curve under the pattern that ignores the peaks, and places 14 points along it.
experiment.background.auto_estimate(n_points=14)
project.display.pattern('sepd')
Perform the analysis¶
The fit follows diffraction-lib's four cycles for this case, then frees the background once more so it ends with the case's free set.
Cell, scale and time-of-flight calibration¶
structure.cell.length_a.free = True
experiment.linked_structures['si'].scale.free = True
experiment.instrument.calib_d_to_tof_offset.free = True
project.display.parameters.free()
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 3 free
iter time (s) Rwp (%) reduced χ² change
52.36 204.71
1 0.016 19.80 29.28 85.7% ↓
2 0.028 10.94 8.93 69.5% ↓
3 0.040 10.45 8.16 8.7% ↓
4 0.052 10.45 8.16
5 0.077 10.45 8.16
done · converged · 5 iters · reduced χ² 8.16 · Rwp 10.45 % · 0.09 s
project.display.pattern('sepd')
Background¶
The estimated points are a starting point; fit them now that the peaks are in place.
for point in experiment.background:
point.intensity.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 17 free
iter time (s) Rwp (%) reduced χ² change
10.45 8.18
1 0.028 7.45 4.16 49.1% ↓
2 0.056 7.45 4.16
done · converged · 2 iters · reduced χ² 4.16 · Rwp 7.45 % · 0.07 s
project.display.pattern('sepd')
Gaussian widths¶
The background stays free while the widths join. diffraction-lib fixes it for this step and leaves it fixed; here the fit reaches the same result with it free, as every other case does. The Gaussian terms come first.
experiment.peak.broad_gauss_sigma_0.free = True
experiment.peak.broad_gauss_sigma_1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 19 free
iter time (s) Rwp (%) reduced χ² change
7.45 4.16
1 0.025 7.42 4.13 0.8% ↓
2 0.037 7.42 4.13
3 0.049 7.42 4.13
4 0.079 7.42 4.13
done · converged · 4 iters · reduced χ² 4.13 · Rwp 7.42 % · 0.09 s
project.display.pattern('sepd')
Lorentzian width¶
Then the Lorentzian term.
experiment.peak.broad_lorentz_gamma_1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 20 free
iter time (s) Rwp (%) reduced χ² change
7.42 4.13
1 0.029 7.28 3.98 3.7% ↓
2 0.042 7.28 3.97
3 0.069 7.28 3.97
done · converged · 3 iters · reduced χ² 3.97 · Rwp 7.28 % · 0.08 s
project.display.pattern('sepd')
Displacement¶
structure.atom_sites['Si'].adp_iso.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 21 free
iter time (s) Rwp (%) reduced χ² change
7.28 3.98
1 0.030 7.28 3.97 0.2% ↓
2 0.043 7.28 3.97
3 0.073 7.28 3.97
done · converged · 3 iters · reduced χ² 3.97 · Rwp 7.28 % · 0.09 s
project.display.pattern('sepd')
Peak decay¶
The back-to-back exponential decay terms β₀ and β₁.
experiment.peak.decay_beta_0.free = True
experiment.peak.decay_beta_1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-tof_si-sepd, 5600 pts fitted / 5600 loaded, 23 free
iter time (s) Rwp (%) reduced χ² change
7.28 3.97
1 0.028 7.18 3.87 2.5% ↓
2 0.040 7.18 3.86 0.2% ↓
3 0.053 7.18 3.86
4 0.066 7.18 3.86
5 0.097 7.18 3.86
done · converged · 5 iters · reduced χ² 3.86 · Rwp 7.18 % · 0.11 s
project.display.pattern('sepd')
project.display.fit.correlations()
project.display.structure('si')
Save the project¶
project.save_as('pd-neut-tof_si-sepd')
project.report.save_html('pd-neut-tof_si-sepd.html')
Saving project to 'pd-neut-tof_si-sepd'
Saving report to 'pd-neut-tof_si-sepd.html'
Your own measured data¶
Measured data can also come from a file on your own disk. add_from_data_path reads a file of
time-of-flight, intensity and uncertainty columns into a new experiment, here in a project of its
own; the experiment then needs its instrument, profile and linked structure, as above. The file
here is SEPD's pattern from the collection, saved to disk first.
data_path = edi.download_data('pd-neut-tof_si-sepd-sepd-data', destination='data')
own = edi.Project(name='own_sepd')
own.experiments.add_from_data_path(
name='mine',
data_path=data_path,
sample_form='powder',
beam_mode='time-of-flight',
radiation_probe='neutron',
)
own.display.pattern('mine')
Data 'pd-neut-tof_si-sepd-sepd-data' is at data/pd-neut-tof_si-sepd-sepd.xye