ZnCu₃(OD)₆Cl₂ on HRPT¶
Fit herbertsmithite, ZnCu₃(OD)₆Cl₂, a deuterated kagome antiferromagnet, to constant-wavelength neutron powder data from HRPT at PSI, with a pseudo-Voigt profile and Bérar-Baldinozzi asymmetry.
It builds the catalogue case pd-neut-cwl_hs-hrpt step by step: the same project the command
line fits and the app's Examples open.
Import the library¶
import easydiffraction as edi
Define the project¶
A new project is empty: it holds no structure and no experiment until you add them.
project = edi.Project(name='pd-neut-cwl_hs-hrpt')
Define the structure¶
Load the structure from EasyDiffraction's collection. Its CIF gives the space group, the cell and the atom sites.
path = edi.download_data('pd-neut-cwl_hs-hrpt-hs', destination='data')
project.structures.add_from_cif_path(path)
structure = project.structures['hs']
Data 'pd-neut-cwl_hs-hrpt-hs' is at data/pd-neut-cwl_hs-hrpt-hs.edi
project.display.structure('hs')
Define the experiment¶
Create the experiment from the measured data in EasyDiffraction's collection, then describe the instrument, the peak profile, the background and the structure it links.
data_path = edi.download_data('pd-neut-cwl_hs-hrpt-hrpt-data', destination='data')
project.experiments.add_from_data_path(
name='hrpt',
data_path=data_path,
sample_form='powder',
beam_mode='constant wavelength',
radiation_probe='neutron',
scattering_type='bragg',
)
experiment = project.experiments['hrpt']
experiment.neutron_scattering_length = 'sears1992'
experiment.peak.type = 'cwl-pseudo-voigt-berar-baldinozzi'
experiment.instrument.name = 'HRPT'
experiment.instrument.facility = 'PSI'
experiment.peak.broad_gauss_u = 0.1
experiment.peak.broad_gauss_v = -0.2
experiment.peak.broad_gauss_w = 0.2
experiment.peak.mixing_eta_0 = 0.5
experiment.peak.cutoff_fwhm = 8
experiment.instrument.setup_wavelength = 1.89
experiment.linked_structures.create(structure_id='hs', scale=0.5)
experiment.background.create(position=4, intensity=460.0)
experiment.background.create(position=20, intensity=460.0)
experiment.background.create(position=40, intensity=460.0)
experiment.background.create(position=60, intensity=460.0)
experiment.background.create(position=80, intensity=460.0)
experiment.background.create(position=100, intensity=460.0)
experiment.background.create(position=120, intensity=460.0)
experiment.background.create(position=140, intensity=460.0)
experiment.background.create(position=160, intensity=460.0)
experiment.background.create(position=165, intensity=460.0)
Data 'pd-neut-cwl_hs-hrpt-hrpt-data' is at data/pd-neut-cwl_hs-hrpt-hrpt.xye
project.display.pattern('hrpt')
Perform the analysis¶
The fit follows diffraction-lib's four cycles for this case.
Cell, scale and 2θ zero¶
The cell lengths, the scale and the zero shift put the peaks in place and at the right height.
structure.cell.length_a.free = True
structure.cell.length_c.free = True
experiment.linked_structures['hs'].scale.free = True
experiment.instrument.calib_twotheta_offset.free = True
project.display.parameters.free()
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 4 free
iter time (s) Rwp (%) reduced χ² change
39.94 121.13
1 0.017 25.02 47.54 60.8% ↓
2 0.020 24.70 46.30 2.6% ↓
3 0.023 24.51 45.59 1.5% ↓
4 0.025 24.40 45.19 0.9% ↓
5 0.028 24.34 44.97 0.5% ↓
6 0.031 24.30 44.84 0.3% ↓
7 0.033 24.28 44.77 0.2% ↓
8 0.036 24.27 44.73 0.1% ↓
9 0.038 24.27 44.71
10 0.041 24.26 44.70
11 0.044 24.26 44.69
12 0.047 24.26 44.69
13 0.050 24.26 44.69
14 0.053 24.26 44.68
15 0.058 24.26 44.68
done · converged · 15 iters · reduced χ² 44.68 · Rwp 24.26 % · 0.06 s
project.display.pattern('hrpt')
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-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 14 free
iter time (s) Rwp (%) reduced χ² change
24.26 44.82
1 0.024 21.75 36.02 19.6% ↓
done · converged · 1 iters · reduced χ² 36.02 · Rwp 21.75 % · 0.03 s
project.display.pattern('hrpt')
Peak widths¶
The Gaussian widths and the mixing η₀, with the background staying free. diffraction-lib frees the Lorentzian Y where this profile has η₀.
for parameter in (
experiment.peak.broad_gauss_u,
experiment.peak.broad_gauss_v,
experiment.peak.broad_gauss_w,
experiment.peak.mixing_eta_0,
):
parameter.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 18 free
iter time (s) Rwp (%) reduced χ² change
21.75 36.07
1 0.024 13.45 13.79 61.8% ↓
2 0.029 13.44 13.77 0.1% ↓
3 0.033 13.44 13.77
4 0.038 13.44 13.77
5 0.043 13.44 13.77
6 0.050 13.44 13.77
done · converged · 6 iters · reduced χ² 13.77 · Rwp 13.44 % · 0.06 s
project.display.pattern('hrpt')
Atom positions¶
The coordinates the symmetry leaves free: O and H in x and z, Cl in z.
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: project pd-neut-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 23 free
iter time (s) Rwp (%) reduced χ² change
13.44 13.79
1 0.039 8.21 5.15 62.7% ↓
2 0.047 8.21 5.15
done · converged · 2 iters · reduced χ² 5.15 · Rwp 8.21 % · 0.05 s
project.display.pattern('hrpt')
Displacements¶
Every site's displacement.
for site in structure.atom_sites:
site.adp_iso.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 28 free
iter time (s) Rwp (%) reduced χ² change
8.21 5.16
1 0.042 5.45 2.27 56.0% ↓
done · converged · 1 iters · reduced χ² 2.27 · Rwp 5.45 % · 0.05 s
project.display.pattern('hrpt')
Asymmetry¶
Last, the four Bérar-Baldinozzi asymmetry terms.
for parameter in (
experiment.peak.asym_beba_a0,
experiment.peak.asym_beba_b0,
experiment.peak.asym_beba_a1,
experiment.peak.asym_beba_b1,
):
parameter.free = True
project.analysis.fit()
project.display.fit.results()
edi fit: project pd-neut-cwl_hs-hrpt, 3220 pts fitted / 3220 loaded, 32 free
iter time (s) Rwp (%) reduced χ² change
5.45 2.27
1 0.042 5.30 2.15 5.3% ↓
2 0.050 5.30 2.15
done · converged · 2 iters · reduced χ² 2.15 · Rwp 5.30 % · 0.06 s
project.display.pattern('hrpt')
project.display.fit.correlations()
project.display.structure('hs')
Report¶
The HTML report draws the measured, calculated and difference patterns with the reflection positions, and lists the structures, the experiments and the fit. Open it in a browser.
project.report.save_html('pd-neut-cwl_hs-hrpt.html')
Saving report to 'pd-neut-cwl_hs-hrpt.html'
Save the project¶
project.save_as('pd-neut-cwl_hs-hrpt')
Saving project to 'pd-neut-cwl_hs-hrpt'