Skip to content

Na₂Ca₃Al₂F₁₄ on WISH

Fit Na₂Ca₃Al₂F₁₄ to time-of-flight neutron powder data from WISH at ISIS, all five detector bank pairs at once. Each bank has its own calibration and profile; the structure is shared.

The project is the catalogue case pd-neut-tof_ncaf-wish, the one the command line and the app's Examples open.

Fitting Joint pd neut tof Bragg Crystal structure

import easydiffraction as edi

Load the project

project_path = edi.download_data('pd-neut-tof_ncaf-wish', destination='data')
project = edi.Project.load(project_path)
structure = project.structures['ncaf']
wish_1_10 = project.experiments['wish_1_10']
wish_2_9 = project.experiments['wish_2_9']
wish_3_8 = project.experiments['wish_3_8']
wish_4_7 = project.experiments['wish_4_7']
wish_5_6 = project.experiments['wish_5_6']
Data 'pd-neut-tof_ncaf-wish' is at data/pd-neut-tof_ncaf-wish-b954a41f79ce/pd-neut-tof_ncaf-wish

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('wish_1_10')

Perform the analysis

Five banks fit together. diffraction-lib's tutorial of this case fits two banks at once with everything free; this one has five, so it stages them.

Scales and time-of-flight calibration

Each bank's scale and DIFC offset and linear term put its peaks in place and at the right height.

wish_1_10.linked_structures['ncaf'].scale.free = True
wish_1_10.instrument.calib_d_to_tof_offset.free = True
wish_1_10.instrument.calib_d_to_tof_linear.free = True
wish_2_9.linked_structures['ncaf'].scale.free = True
wish_2_9.instrument.calib_d_to_tof_offset.free = True
wish_2_9.instrument.calib_d_to_tof_linear.free = True
wish_3_8.linked_structures['ncaf'].scale.free = True
wish_3_8.instrument.calib_d_to_tof_offset.free = True
wish_3_8.instrument.calib_d_to_tof_linear.free = True
wish_4_7.linked_structures['ncaf'].scale.free = True
wish_4_7.instrument.calib_d_to_tof_offset.free = True
wish_4_7.instrument.calib_d_to_tof_linear.free = True
wish_5_6.linked_structures['ncaf'].scale.free = True
wish_5_6.instrument.calib_d_to_tof_offset.free = True
wish_5_6.instrument.calib_d_to_tof_linear.free = True
project.display.parameters.free()
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 15 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                       29.70       140.21
      1      0.153     21.43        73.01   47.9% ↓
      2      0.284     20.12        64.34   11.9% ↓
      3      0.414     19.93        63.15   1.8% ↓
      4      0.546     19.91        62.98   0.3% ↓
      5      0.683     19.90        62.95   
      6      0.840     19.90        62.95   
      7      0.995     19.90        62.95   
      8      1.154     19.90        62.95   
      9      1.377     19.90        62.95   
  done · converged · 9 iters · reduced χ² 62.95 · Rwp 19.90 % · 1.53 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')

Background

Each bank's background points; bank 1-10's first and last stay fixed, as its source has them.

for point in wish_1_10.background:
    point.intensity.free = True
for point in wish_2_9.background:
    point.intensity.free = True
for point in wish_3_8.background:
    point.intensity.free = True
for point in wish_4_7.background:
    point.intensity.free = True
for point in wish_5_6.background:
    point.intensity.free = True
wish_1_10.background[0].intensity.free = False
wish_1_10.background[35].intensity.free = False
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 149 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                       19.90        63.39
      1      0.318     13.97        31.22   50.8% ↓
      2      0.554     13.97        31.22   
      3      0.854     13.97        31.21   
  done · converged · 3 iters · reduced χ² 31.21 · Rwp 13.97 % · 1.11 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')

Peak asymmetry

Each bank's back-to-back exponentials, the terms its data determine; bank 1-10 keeps its instrument values.

wish_2_9.peak.rise_alpha_0.free = True
wish_2_9.peak.rise_alpha_1.free = True
wish_2_9.peak.decay_beta_0.free = True
wish_2_9.peak.decay_beta_1.free = True
wish_3_8.peak.rise_alpha_0.free = True
wish_3_8.peak.rise_alpha_1.free = True
wish_3_8.peak.decay_beta_0.free = True
wish_3_8.peak.decay_beta_1.free = True
wish_4_7.peak.rise_alpha_0.free = True
wish_4_7.peak.rise_alpha_1.free = True
wish_4_7.peak.decay_beta_0.free = True
wish_4_7.peak.decay_beta_1.free = True
wish_5_6.peak.rise_alpha_0.free = True
wish_5_6.peak.rise_alpha_1.free = True
wish_5_6.peak.decay_beta_0.free = True
wish_5_6.peak.decay_beta_1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 165 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                       13.97        31.24
      1      0.334     11.96        22.90   26.7% ↓
      2      0.562     11.20        20.09   12.3% ↓
      3      0.807     10.85        18.85   6.1% ↓
      4      1.047     10.62        18.05   4.2% ↓
      5      1.301     10.44        17.45   3.3% ↓
      6      1.536     10.34        17.11   1.9% ↓
      7      1.769     10.29        16.95   0.9% ↓
      8      2.004     10.26        16.86   0.6% ↓
      9      2.246     10.24        16.80   0.3% ↓
     10      2.496     10.24        16.78   0.1% ↓
     11      2.732     10.23        16.77   0.1% ↓
     12      2.961     10.23        16.77   
     13      3.227     10.23        16.77   
     14      3.500     10.23        16.77   
     15      3.779     10.23        16.77   
     16      4.063     10.23        16.77   
     17      4.441     10.23        16.77   
  done · converged · 17 iters · reduced χ² 16.77 · Rwp 10.23 % · 4.73 s
project.display.pattern('wish_2_9')

Gaussian widths

The Gaussian width terms the banks' data determine.

wish_2_9.peak.broad_gauss_sigma_1.free = True
wish_2_9.peak.broad_gauss_sigma_2.free = True
wish_3_8.peak.broad_gauss_sigma_1.free = True
wish_3_8.peak.broad_gauss_sigma_2.free = True
wish_4_7.peak.broad_gauss_sigma_1.free = True
wish_4_7.peak.broad_gauss_sigma_2.free = True
wish_5_6.peak.broad_gauss_sigma_2.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 172 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                       10.23        16.78
      1      0.374     10.02        16.09   4.1% ↓
      2      0.646     10.00        16.03   0.4% ↓
      3      0.941     10.00        16.02   
      4      1.279     10.00        16.02   
      5      1.616     10.00        16.02   
      6      1.922     10.00        16.02   
      7      2.219     10.00        16.02   
      8      2.522     10.00        16.02   
      9      2.835     10.00        16.02   
     10      3.105     10.00        16.01   
     11      3.383      9.99        16.00   0.1% ↓
     12      3.648      9.99        15.98   0.2% ↓
     13      3.918      9.98        15.96   0.1% ↓
     14      4.189      9.97        15.93   0.2% ↓
     15      4.508      9.97        15.93   
     16      4.929      9.97        15.93   
  done · converged · 16 iters · reduced χ² 15.93 · Rwp 9.97 % · 5.26 s
project.display.pattern('wish_2_9')

Lorentzian width

Bank 2-9's Lorentzian term.

wish_2_9.peak.broad_lorentz_gamma_1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 173 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                        9.97        15.93
      1      0.710      9.97        15.93   
      2      1.341      9.97        15.93   
  done · converged · 2 iters · reduced χ² 15.93 · Rwp 9.97 % · 1.82 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')

Absorption

Banks 2-9 to 5-6 each fit their absorption.

wish_2_9.absorption.abscor1.free = True
wish_3_8.absorption.abscor1.free = True
wish_4_7.absorption.abscor1.free = True
wish_5_6.absorption.abscor1.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: joint project pd-neut-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 177 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                        9.97        15.94
      1      0.640      9.91        15.75   1.2% ↓
      2      0.928      9.91        15.74   
      3      1.259      9.91        15.74   
      4      1.584      9.91        15.74   
      5      1.920      9.91        15.74   
      6      2.345      9.91        15.74   
  done · converged · 6 iters · reduced χ² 15.74 · Rwp 9.91 % · 2.70 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')

Atom positions

The coordinates the cubic symmetry leaves free.

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-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 187 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                        9.91        15.75
      1      0.712      8.11        10.56   32.9% ↓
      2      0.996      8.07        10.43   1.2% ↓
      3      1.292      8.07        10.43   
      4      1.626      8.07        10.43   
      5      1.957      8.07        10.43   
      6      2.377      8.07        10.43   
  done · converged · 6 iters · reduced χ² 10.43 · Rwp 8.07 % · 2.85 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')

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-tof_ncaf-wish, 5 banks (wish_1_10, wish_2_9, wish_3_8, wish_4_7, wish_5_6), 18973 pts fitted / 20475 loaded, 193 free
   iter   time (s)   Rwp (%)  reduced χ²   change
                        8.07        10.43
      1      6.315      7.77         9.68   7.3% ↓
      2      7.046      7.70         9.50   1.8% ↓
      3      7.756      7.69         9.50   
      4      8.677      7.69         9.50   
      5      9.549      7.69         9.50   
  done · converged · 5 iters · reduced χ² 9.50 · Rwp 7.69 % · 10.36 s
project.display.pattern('wish_1_10')
project.display.pattern('wish_2_9')
project.display.pattern('wish_3_8')
project.display.pattern('wish_4_7')
project.display.pattern('wish_5_6')
project.display.fit.correlations()
project.display.structure('ncaf')

Save the project

project.save_as('pd-neut-tof_ncaf-wish')
project.report.save_html('pd-neut-tof_ncaf-wish.html')
Saving project to 'pd-neut-tof_ncaf-wish'
Saving report to 'pd-neut-tof_ncaf-wish.html'