Structure Refinement: Si, SEPD¶
This example demonstrates a Rietveld refinement of Si crystal structure using time-of-flight neutron powder diffraction data from SEPD at Argonne.
It also shows how to switch calculation engine and peak profile type.
🛠️ Import Library¶
In [2]:
Copied!
from easydiffraction import ExperimentFactory
from easydiffraction import Project
from easydiffraction import StructureFactory
from easydiffraction import download_data
from easydiffraction import ExperimentFactory
from easydiffraction import Project
from easydiffraction import StructureFactory
from easydiffraction import download_data
In [3]:
Copied!
structure = StructureFactory.from_scratch(name='si')
structure = StructureFactory.from_scratch(name='si')
Set Space Group¶
In [4]:
Copied!
structure.space_group.name_h_m = 'F d -3 m'
structure.space_group.it_coordinate_system_code = '2'
structure.space_group.name_h_m = 'F d -3 m'
structure.space_group.it_coordinate_system_code = '2'
Set Unit Cell¶
In [5]:
Copied!
structure.cell.length_a = 5.431
structure.cell.length_a = 5.431
Set Atom Sites¶
In [6]:
Copied!
structure.atom_sites.create(
label='Si',
type_symbol='Si',
fract_x=0.125,
fract_y=0.125,
fract_z=0.125,
adp_iso=0.5,
)
structure.atom_sites.create(
label='Si',
type_symbol='Si',
fract_x=0.125,
fract_y=0.125,
fract_z=0.125,
adp_iso=0.5,
)
In [7]:
Copied!
data_path = download_data(id=7, destination='data')
data_path = download_data(id=7, destination='data')
Getting data...
Data #7: Si, SEPD (Argonne)
✅ Data #7 already present at '../../../data/ed-7.xye'. Keeping existing.
Create Experiment¶
In [8]:
Copied!
expt = ExperimentFactory.from_data_path(
name='sepd', data_path=data_path, beam_mode='time-of-flight'
)
expt = ExperimentFactory.from_data_path(
name='sepd', data_path=data_path, beam_mode='time-of-flight'
)
Set Instrument¶
In [9]:
Copied!
expt.instrument.setup_twotheta_bank = 144.845
expt.instrument.calib_d_to_tof_offset = 0.0
expt.instrument.calib_d_to_tof_linear = 7476.91
expt.instrument.calib_d_to_tof_quad = -1.54
expt.instrument.setup_twotheta_bank = 144.845
expt.instrument.calib_d_to_tof_offset = 0.0
expt.instrument.calib_d_to_tof_linear = 7476.91
expt.instrument.calib_d_to_tof_quad = -1.54
Set Peak Profile¶
In [10]:
Copied!
expt.peak.show_supported()
expt.peak.broad_gauss_sigma_0 = 3.0
expt.peak.broad_gauss_sigma_1 = 40.0
expt.peak.broad_gauss_sigma_2 = 2.0
expt.peak.exp_decay_beta_0 = 0.04221
expt.peak.exp_decay_beta_1 = 0.00946
expt.peak.exp_rise_alpha_0 = 0.0
expt.peak.exp_rise_alpha_1 = 0.5971
expt.peak.show_supported()
expt.peak.broad_gauss_sigma_0 = 3.0
expt.peak.broad_gauss_sigma_1 = 40.0
expt.peak.broad_gauss_sigma_2 = 2.0
expt.peak.exp_decay_beta_0 = 0.04221
expt.peak.exp_decay_beta_1 = 0.00946
expt.peak.exp_rise_alpha_0 = 0.0
expt.peak.exp_rise_alpha_1 = 0.5971
Peak types
| Type | Description | ||
|---|---|---|---|
| 1 | pseudo-voigt | TOF non-convoluted pseudo-Voigt profile | |
| 2 | * | jorgensen | TOF Jorgensen profile: back-to-back exponentials ⊗ Gaussian |
| 3 | jorgensen-von-dreele | TOF Jorgensen-Von Dreele profile: back-to-back exponentials ⊗ pseudo-Voigt | |
| 4 | double-jorgensen-von-dreele | TOF Double-Jorgensen-Von Dreele profile: double back-to-back exponentials ⊗ pseudo-Voigt (Z-Rietveld type0m) |
Set Background¶
In [11]:
Copied!
expt.background.type = 'line-segment'
for x in range(0, 35000, 5000):
expt.background.create(id=str(x), x=x, y=200)
expt.background.type = 'line-segment'
for x in range(0, 35000, 5000):
expt.background.create(id=str(x), x=x, y=200)
Background type for experiment 'sepd' already set to
line-segment
Set Linked Phases¶
In [12]:
Copied!
expt.linked_phases.create(id='si', scale=10.0)
expt.linked_phases.create(id='si', scale=10.0)
In [13]:
Copied!
project = Project(name='si_sepd')
project = Project(name='si_sepd')
Add Structure¶
In [14]:
Copied!
project.structures.add(structure)
project.structures.add(structure)
Add Experiment¶
In [15]:
Copied!
project.experiments.add(expt)
project.experiments.add(expt)
In [16]:
Copied!
project.display.structure(struct_name='si')
project.display.structure(struct_name='si')
Structure 🧩 'si' (Atom view type: 'covalent')
Loading plot…
drag = rotate
wheel = zoom
right-drag = pan
wheel = zoom
right-drag = pan
Display Pattern¶
In [17]:
Copied!
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
Loading plot…
Perform Fit 1/5¶
Set parameters to be refined.
In [18]:
Copied!
structure.cell.length_a.free = True
expt.linked_phases['si'].scale.free = True
expt.instrument.calib_d_to_tof_offset.free = True
structure.cell.length_a.free = True
expt.linked_phases['si'].scale.free = True
expt.instrument.calib_d_to_tof_offset.free = True
Show free parameters after selection.
In [19]:
Copied!
project.display.parameters.free()
project.display.parameters.free()
Free parameters for both structures (🧩 data blocks) and experiments (🔬 data blocks)
| datablock | category | entry | parameter | value | uncertainty | min | max | units | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | 5.43100 | -inf | inf | Å | ||
| 2 | sepd | linked_phases | si | scale | 10.00000 | -inf | inf | ||
| 3 | sepd | instrument | d_to_tof_offset | 0.00000 | -inf | inf | μs |
Run Fitting¶
In [20]:
Copied!
project.analysis.fit()
project.display.fit.results()
project.analysis.fit()
project.display.fit.results()
Standard fitting
📋 Using experiment 🔬 'sepd' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.36 | 113.06 | |
| 2 | 7 | 2.47 | 72.20 | 36.1% ↓ |
| 3 | 11 | 4.19 | 66.76 | 7.5% ↓ |
| 4 | 25 | 9.47 | 66.72 | |
| 5 | 30 | 11.58 | 66.72 |
🏆 Best goodness-of-fit (reduced χ²) is 66.72 at iteration 26
✅ Fitting complete.
⚙️ Settings used:
| Name | Value | Description | |
|---|---|---|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
📋 Least-squares fit results:
| Metric | Value | |
|---|---|---|
| 1 | 🧪 Minimizer | lmfit (leastsq) |
| 2 | ✅ Overall status | success |
| 3 | ⏱️ Fitting time (seconds) | 11.58 |
| 4 | 🔁 Iterations | 27 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 66.72 |
| 6 | 📏 R-factor (Rf, %) | 23.08 |
| 7 | 📏 R-factor squared (Rf², %) | 12.55 |
| 8 | 📏 Weighted R-factor (wR, %) | 12.51 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | Å | 5.4310 | 5.4314 | 0.0002 | 0.01 % ↑ | |
| 2 | sepd | linked_phases | si | scale | 10.0000 | 13.3619 | 0.1153 | 33.62 % ↑ | |
| 3 | sepd | instrument | d_to_tof_offset | μs | 0.0000 | -9.2543 | 0.2503 | N/A |
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
Display Pattern¶
In [21]:
Copied!
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd')
Loading plot…
In [22]:
Copied!
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
Perform Fit 2/5¶
Set more parameters to be refined.
In [23]:
Copied!
for point in expt.background:
point.y.free = True
for point in expt.background:
point.y.free = True
Show free parameters after selection.
In [24]:
Copied!
project.display.parameters.free()
project.display.parameters.free()
Free parameters for both structures (🧩 data blocks) and experiments (🔬 data blocks)
| datablock | category | entry | parameter | value | uncertainty | min | max | units | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | 5.43135 | 0.00018 | -inf | inf | Å | |
| 2 | sepd | linked_phases | si | scale | 13.36187 | 0.11531 | -inf | inf | |
| 3 | sepd | instrument | d_to_tof_offset | -9.25432 | 0.25033 | -inf | inf | μs | |
| 4 | sepd | background | 0 | y | 200.00000 | -inf | inf | ||
| 5 | sepd | background | 5000 | y | 200.00000 | -inf | inf | ||
| 6 | sepd | background | 10000 | y | 200.00000 | -inf | inf | ||
| 7 | sepd | background | 15000 | y | 200.00000 | -inf | inf | ||
| 8 | sepd | background | 20000 | y | 200.00000 | -inf | inf | ||
| 9 | sepd | background | 25000 | y | 200.00000 | -inf | inf | ||
| 10 | sepd | background | 30000 | y | 200.00000 | -inf | inf |
Run Fitting¶
In [25]:
Copied!
project.analysis.fit()
project.display.fit.results()
project.analysis.fit()
project.display.fit.results()
Standard fitting
📋 Using experiment 🔬 'sepd' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.36 | 66.80 | |
| 2 | 13 | 5.38 | 66.80 | |
| 3 | 14 | 5.77 | 3.38 | 94.9% ↓ |
| 4 | 27 | 10.81 | 3.38 | |
| 5 | 40 | 16.29 | 3.38 | |
| 6 | 48 | 19.22 | 3.38 |
🏆 Best goodness-of-fit (reduced χ²) is 3.38 at iteration 47
✅ Fitting complete.
⚙️ Settings used:
| Name | Value | Description | |
|---|---|---|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
📋 Least-squares fit results:
| Metric | Value | |
|---|---|---|
| 1 | 🧪 Minimizer | lmfit (leastsq) |
| 2 | ✅ Overall status | success |
| 3 | ⏱️ Fitting time (seconds) | 19.22 |
| 4 | 🔁 Iterations | 45 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 3.38 |
| 6 | 📏 R-factor (Rf, %) | 9.29 |
| 7 | 📏 R-factor squared (Rf², %) | 6.33 |
| 8 | 📏 Weighted R-factor (wR, %) | 5.95 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | Å | 5.4314 | 5.4314 | 0.0000 | 0.00 % ↑ | |
| 2 | sepd | linked_phases | si | scale | 13.3619 | 14.6317 | 0.0265 | 9.50 % ↑ | |
| 3 | sepd | instrument | d_to_tof_offset | μs | -9.2543 | -9.2534 | 0.0515 | 0.01 % ↓ | |
| 4 | sepd | background | 0 | y | 200.0000 | 268.6002 | 0.9745 | 34.30 % ↑ | |
| 5 | sepd | background | 5000 | y | 200.0000 | 144.7589 | 0.4071 | 27.62 % ↓ | |
| 6 | sepd | background | 10000 | y | 200.0000 | 120.0247 | 0.4282 | 39.99 % ↓ | |
| 7 | sepd | background | 15000 | y | 200.0000 | 135.8494 | 0.8169 | 32.08 % ↓ | |
| 8 | sepd | background | 20000 | y | 200.0000 | 132.6887 | 1.4317 | 33.66 % ↓ | |
| 9 | sepd | background | 25000 | y | 200.0000 | 175.1775 | 2.8755 | 12.41 % ↓ | |
| 10 | sepd | background | 30000 | y | 200.0000 | 180.4556 | 5.8525 | 9.77 % ↓ |
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
Display Pattern¶
In [26]:
Copied!
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd')
Loading plot…
In [27]:
Copied!
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
Perform Fit 3/5¶
Fix background points.
In [28]:
Copied!
for point in expt.background:
point.y.free = False
for point in expt.background:
point.y.free = False
Set more parameters to be refined.
In [29]:
Copied!
expt.peak.broad_gauss_sigma_0.free = True
expt.peak.broad_gauss_sigma_1.free = True
expt.peak.broad_gauss_sigma_2.free = True
expt.peak.broad_gauss_sigma_0.free = True
expt.peak.broad_gauss_sigma_1.free = True
expt.peak.broad_gauss_sigma_2.free = True
Show free parameters after selection.
In [30]:
Copied!
project.display.parameters.free()
project.display.parameters.free()
Free parameters for both structures (🧩 data blocks) and experiments (🔬 data blocks)
| datablock | category | entry | parameter | value | uncertainty | min | max | units | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | 5.43137 | 0.00004 | -inf | inf | Å | |
| 2 | sepd | linked_phases | si | scale | 14.63167 | 0.02651 | -inf | inf | |
| 3 | sepd | peak | gauss_sigma_0 | 3.00000 | -inf | inf | μs² | ||
| 4 | sepd | peak | gauss_sigma_1 | 40.00000 | -inf | inf | μs/Å | ||
| 5 | sepd | peak | gauss_sigma_2 | 2.00000 | -inf | inf | μs²/Ų | ||
| 6 | sepd | instrument | d_to_tof_offset | -9.25336 | 0.05153 | -inf | inf | μs |
Run Fitting¶
In [31]:
Copied!
project.analysis.fit()
project.display.fit.results()
project.analysis.fit()
project.display.fit.results()
Standard fitting
📋 Using experiment 🔬 'sepd' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.36 | 3.38 | |
| 2 | 10 | 3.92 | 3.21 | 5.0% ↓ |
| 3 | 24 | 9.28 | 3.21 | |
| 4 | 36 | 14.30 | 3.21 | |
| 5 | 39 | 15.42 | 3.21 |
🏆 Best goodness-of-fit (reduced χ²) is 3.21 at iteration 38
✅ Fitting complete.
⚙️ Settings used:
| Name | Value | Description | |
|---|---|---|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
📋 Least-squares fit results:
| Metric | Value | |
|---|---|---|
| 1 | 🧪 Minimizer | lmfit (leastsq) |
| 2 | ✅ Overall status | success |
| 3 | ⏱️ Fitting time (seconds) | 15.42 |
| 4 | 🔁 Iterations | 36 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 3.21 |
| 6 | 📏 R-factor (Rf, %) | 8.99 |
| 7 | 📏 R-factor squared (Rf², %) | 5.52 |
| 8 | 📏 Weighted R-factor (wR, %) | 4.88 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | Å | 5.4314 | 5.4314 | 0.0000 | 0.00 % ↑ | |
| 2 | sepd | linked_phases | si | scale | 14.6317 | 14.7057 | 0.0257 | 0.51 % ↑ | |
| 3 | sepd | peak | gauss_sigma_0 | μs² | 3.0000 | 5.7727 | 0.4206 | 92.42 % ↑ | |
| 4 | sepd | peak | gauss_sigma_1 | μs/Å | 40.0000 | 44.2827 | 0.7966 | 10.71 % ↑ | |
| 5 | sepd | peak | gauss_sigma_2 | μs²/Ų | 2.0000 | 1.2962 | 0.1680 | 35.19 % ↓ | |
| 6 | sepd | instrument | d_to_tof_offset | μs | -9.2534 | -9.2506 | 0.0546 | 0.03 % ↓ |
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
Display Pattern¶
In [32]:
Copied!
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd')
Loading plot…
In [33]:
Copied!
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
Perform Fit 4/5¶
Set more parameters to be refined.
In [34]:
Copied!
structure.atom_sites['Si'].adp_iso.free = True
expt.peak.exp_decay_beta_0.free = True
expt.peak.exp_decay_beta_1.free = True
expt.peak.exp_rise_alpha_1.free = True
structure.atom_sites['Si'].adp_iso.free = True
expt.peak.exp_decay_beta_0.free = True
expt.peak.exp_decay_beta_1.free = True
expt.peak.exp_rise_alpha_1.free = True
Show free parameters after selection.
In [35]:
Copied!
project.display.parameters.free()
project.display.parameters.free()
Free parameters for both structures (🧩 data blocks) and experiments (🔬 data blocks)
| datablock | category | entry | parameter | value | uncertainty | min | max | units | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | 5.43143 | 0.00004 | -inf | inf | Å | |
| 2 | si | atom_site | Si | adp_iso | 0.50000 | -inf | inf | Ų | |
| 3 | sepd | linked_phases | si | scale | 14.70568 | 0.02567 | -inf | inf | |
| 4 | sepd | peak | rise_alpha_1 | 0.59710 | -inf | inf | μs/Å | ||
| 5 | sepd | peak | decay_beta_0 | 0.04221 | -inf | inf | μs | ||
| 6 | sepd | peak | decay_beta_1 | 0.00946 | -inf | inf | μs/Å | ||
| 7 | sepd | peak | gauss_sigma_0 | 5.77274 | 0.42055 | -inf | inf | μs² | |
| 8 | sepd | peak | gauss_sigma_1 | 44.28265 | 0.79664 | -inf | inf | μs/Å | |
| 9 | sepd | peak | gauss_sigma_2 | 1.29621 | 0.16795 | -inf | inf | μs²/Ų | |
| 10 | sepd | instrument | d_to_tof_offset | -9.25065 | 0.05458 | -inf | inf | μs |
Run Fitting¶
In [36]:
Copied!
project.analysis.fit()
project.display.fit.results()
project.analysis.fit()
project.display.fit.results()
Standard fitting
📋 Using experiment 🔬 'sepd' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.37 | 3.21 | |
| 2 | 13 | 5.37 | 3.21 | |
| 3 | 15 | 6.10 | 3.17 | 1.2% ↓ |
| 4 | 16 | 6.47 | 3.13 | 1.5% ↓ |
| 5 | 26 | 10.43 | 3.01 | 3.7% ↓ |
| 6 | 38 | 15.14 | 2.96 | 1.7% ↓ |
| 7 | 50 | 20.27 | 2.93 | |
| 8 | 60 | 24.27 | 2.93 | 1.1% ↓ |
| 9 | 73 | 29.40 | 2.93 | |
| 10 | 86 | 34.94 | 2.93 | |
| 11 | 99 | 40.00 | 2.93 | |
| 12 | 105 | 42.61 | 2.93 |
🏆 Best goodness-of-fit (reduced χ²) is 2.93 at iteration 104
✅ Fitting complete.
⚙️ Settings used:
| Name | Value | Description | |
|---|---|---|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
📋 Least-squares fit results:
| Metric | Value | |
|---|---|---|
| 1 | 🧪 Minimizer | lmfit (leastsq) |
| 2 | ✅ Overall status | success |
| 3 | ⏱️ Fitting time (seconds) | 42.61 |
| 4 | 🔁 Iterations | 102 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 2.93 |
| 6 | 📏 R-factor (Rf, %) | 8.39 |
| 7 | 📏 R-factor squared (Rf², %) | 4.16 |
| 8 | 📏 Weighted R-factor (wR, %) | 2.48 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | Å | 5.4314 | 5.4325 | 0.0001 | 0.02 % ↑ | |
| 2 | si | atom_site | Si | adp_iso | Ų | 0.5000 | 0.5240 | 0.0033 | 4.80 % ↑ |
| 3 | sepd | linked_phases | si | scale | 14.7057 | 14.9693 | 0.0355 | 1.79 % ↑ | |
| 4 | sepd | peak | rise_alpha_1 | μs/Å | 0.5971 | 0.2370 | 0.0043 | 60.31 % ↓ | |
| 5 | sepd | peak | decay_beta_0 | μs | 0.0422 | 0.0386 | 0.0002 | 8.65 % ↓ | |
| 6 | sepd | peak | decay_beta_1 | μs/Å | 0.0095 | 0.0106 | 0.0002 | 11.67 % ↑ | |
| 7 | sepd | peak | gauss_sigma_0 | μs² | 5.7727 | 6.9657 | 0.4577 | 20.67 % ↑ | |
| 8 | sepd | peak | gauss_sigma_1 | μs/Å | 44.2827 | 25.6509 | 1.0250 | 42.07 % ↓ | |
| 9 | sepd | peak | gauss_sigma_2 | μs²/Ų | 1.2962 | 1.1001 | 0.1584 | 15.13 % ↓ | |
| 10 | sepd | instrument | d_to_tof_offset | μs | -9.2506 | -8.7248 | 0.0740 | 5.68 % ↓ |
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
Display Correlations¶
In [37]:
Copied!
project.display.fit.correlations()
project.display.fit.correlations()
Loading plot…
Display Pattern¶
In [38]:
Copied!
project.display.pattern(expt_name='sepd')
project.display.pattern(expt_name='sepd')
Loading plot…
In [39]:
Copied!
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
In [40]:
Copied!
project.display.pattern(expt_name='sepd', x='d_spacing')
project.display.pattern(expt_name='sepd', x='d_spacing')
Loading plot…
In [41]:
Copied!
expt.calculator.show_supported()
expt.calculator.show_supported()
Calculator types
| Type | Description | ||
|---|---|---|---|
| 1 | crysfml | CrysFML library for crystallographic calculations | |
| 2 | * | cryspy | CrysPy library for crystallographic calculations |
In [42]:
Copied!
expt.calculator.type = 'crysfml'
expt.calculator.type = 'crysfml'
Calculator for experiment 'sepd' changed to
crysfml
Change peak profile type¶
In [43]:
Copied!
expt.peak.show_supported()
expt.peak.show_supported()
Peak types
| Type | Description | ||
|---|---|---|---|
| 1 | * | jorgensen | TOF Jorgensen profile: back-to-back exponentials ⊗ Gaussian |
| 2 | jorgensen-von-dreele | TOF Jorgensen-Von Dreele profile: back-to-back exponentials ⊗ pseudo-Voigt |
In [44]:
Copied!
expt.peak.type = 'jorgensen-von-dreele'
expt.peak.type = 'jorgensen-von-dreele'
⚠️ Switching peak profile type adds these settings with defaults: • lorentz_gamma_0=0.0 • lorentz_gamma_1=0.0 • lorentz_gamma_2=0.0
⚠️ Switching peak profile type resets these settings to defaults: • decay_beta_0: 0.03855828522823083 -> 0.04 • decay_beta_1: 0.010563672401281192 -> 0.0 • gauss_sigma_0: 6.965738091176624 -> 7.0 • gauss_sigma_1: 25.650869859687543 -> 0.0 • gauss_sigma_2: 1.1000945752526443 -> 0.0 • rise_alpha_1: 0.2370115284481651 -> 0.2
Peak profile type for experiment 'sepd' changed to
jorgensen-von-dreele
In [45]:
Copied!
expt.peak.broad_gauss_sigma_0 = 3.0148
expt.peak.broad_gauss_sigma_1 = 33.3451
expt.peak.broad_lorentz_gamma_1 = 2.5489
expt.peak.exp_decay_beta_0 = 0.04221
expt.peak.exp_decay_beta_1 = 0.00946
expt.peak.exp_rise_alpha_1 = 0.5971
expt.peak.broad_gauss_sigma_0 = 3.0148
expt.peak.broad_gauss_sigma_1 = 33.3451
expt.peak.broad_lorentz_gamma_1 = 2.5489
expt.peak.exp_decay_beta_0 = 0.04221
expt.peak.exp_decay_beta_1 = 0.00946
expt.peak.exp_rise_alpha_1 = 0.5971
Add new free parameters¶
In [46]:
Copied!
expt.peak.broad_gauss_sigma_0.free = True
expt.peak.broad_gauss_sigma_1.free = True
expt.peak.broad_lorentz_gamma_1.free = True
expt.peak.exp_decay_beta_0.free = True
expt.peak.exp_decay_beta_1.free = True
expt.peak.exp_rise_alpha_1.free = True
expt.peak.broad_gauss_sigma_0.free = True
expt.peak.broad_gauss_sigma_1.free = True
expt.peak.broad_lorentz_gamma_1.free = True
expt.peak.exp_decay_beta_0.free = True
expt.peak.exp_decay_beta_1.free = True
expt.peak.exp_rise_alpha_1.free = True
Run Fitting¶
In [47]:
Copied!
project.analysis.fit()
project.display.fit.results()
project.analysis.fit()
project.display.fit.results()
Standard fitting
📋 Using experiment 🔬 'sepd' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.31 | 190.52 | |
| 2 | 15 | 13.52 | nan | |
| 3 | 17 | 22.48 | nan | |
| 4 | 35 | 27.57 | 189.33 | |
| 5 | 40 | 28.96 | 187.77 | 1.4% ↓ |
| 6 | 51 | 31.91 | 185.01 | 1.5% ↓ |
| 7 | 62 | 34.80 | 180.22 | 2.6% ↓ |
| 8 | 73 | 37.66 | 172.36 | 4.4% ↓ |
| 9 | 84 | 40.49 | 160.47 | 6.9% ↓ |
| 10 | 95 | 43.35 | 141.18 | 12.0% ↓ |
| 11 | 106 | 46.29 | 107.78 | 23.7% ↓ |
| 12 | 117 | 49.43 | 62.69 | 41.8% ↓ |
| 13 | 128 | 52.83 | 17.06 | 72.8% ↓ |
| 14 | 140 | 56.59 | 10.03 | 41.2% ↓ |
| 15 | 151 | 60.07 | 4.43 | 55.9% ↓ |
| 16 | 163 | 63.91 | 3.80 | 14.1% ↓ |
| 17 | 174 | 67.36 | 3.25 | 14.4% ↓ |
| 18 | 175 | 67.70 | 3.22 | 1.0% ↓ |
| 19 | 186 | 71.12 | 3.06 | 4.9% ↓ |
| 20 | 198 | 74.79 | 3.01 | 1.6% ↓ |
| 21 | 215 | 79.94 | 3.00 | |
| 22 | 232 | 85.12 | 2.98 | 1.0% ↓ |
| 23 | 249 | 90.22 | 2.98 | |
| 24 | 266 | 95.31 | 2.98 | |
| 25 | 283 | 100.40 | 2.98 | |
| 26 | 286 | 101.35 | 2.98 |
🏆 Best goodness-of-fit (reduced χ²) is 2.98 at iteration 275
✅ Fitting complete.
⚙️ Settings used:
| Name | Value | Description | |
|---|---|---|---|
| 1 | max_iterations | 1000 | Maximum solver iterations. |
📋 Least-squares fit results:
| Metric | Value | |
|---|---|---|
| 1 | 🧪 Minimizer | lmfit (leastsq) |
| 2 | ✅ Overall status | success |
| 3 | ⏱️ Fitting time (seconds) | 101.35 |
| 4 | 🔁 Iterations | 283 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 2.98 |
| 6 | 📏 R-factor (Rf, %) | 8.65 |
| 7 | 📏 R-factor squared (Rf², %) | 5.01 |
| 8 | 📏 Weighted R-factor (wR, %) | 4.16 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | si | cell | length_a | Å | 5.4325 | 5.4326 | 0.0001 | 0.00 % ↑ | |
| 2 | si | atom_site | Si | adp_iso | Ų | 0.5240 | 0.5243 | 0.0033 | 0.05 % ↑ |
| 3 | sepd | linked_phases | si | scale | 14.9693 | 1113.8694 | 2.6270 | 7341.04 % ↑ | |
| 4 | sepd | peak | rise_alpha_1 | μs/Å | 0.5971 | 0.2385 | 0.0044 | 60.05 % ↓ | |
| 5 | sepd | peak | decay_beta_0 | μs | 0.0422 | 0.0388 | 0.0002 | 8.20 % ↓ | |
| 6 | sepd | peak | decay_beta_1 | μs/Å | 0.0095 | 0.0101 | 0.0001 | 7.23 % ↑ | |
| 7 | sepd | peak | lorentz_gamma_1 | μs/Å | 2.5489 | -0.0335 | 0.0222 | 101.32 % ↓ | |
| 8 | sepd | peak | gauss_sigma_0 | μs² | 3.0148 | 5.2457 | 0.3644 | 74.00 % ↑ | |
| 9 | sepd | peak | gauss_sigma_1 | μs/Å | 33.3451 | 30.2975 | 0.8410 | 9.14 % ↓ | |
| 10 | sepd | instrument | d_to_tof_offset | μs | -8.7248 | -8.9036 | 0.0084 | 2.05 % ↑ |
• start = parameter value before refinement
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
• value = refined value from least-squares minimization
• s.u. = standard uncertainty (one sigma), from the covariance matrix
• change = relative change from start, in %; ↑ = increase, ↓ = decrease
Display Correlations¶
In [48]:
Copied!
project.display.fit.correlations()
project.display.fit.correlations()
Loading plot…
Display Pattern¶
In [49]:
Copied!
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
project.display.pattern(expt_name='sepd', x_min=23200, x_max=23700)
Loading plot…
In [50]:
Copied!
project.display.pattern(expt_name='sepd', x='d_spacing')
project.display.pattern(expt_name='sepd', x='d_spacing')
Loading plot…
💾 Save Project¶
In [51]:
Copied!
project.save_as(dir_path='projects/ed_7_si_sepd')
project.save_as(dir_path='projects/ed_7_si_sepd')
Saving project 📦 'si_sepd' to '../../../projects/ed_7_si_sepd'
├── 📄 project.cif
├── 📁 structures/
│ └── 📄 si.cif
├── 📁 experiments/
│ └── 📄 sepd.cif
├── 📁 analysis/
│ └── 📄 analysis.cif
└── 📁 reports/
└── 📄 si_sepd.html