Structure Refinement: LaM(7)O3, P02.1 Synchrotron XRD¶
This example refines the compositionally complex LaM(7)O3 perovskite, with La on the A site and an equimolar mixture of Ti, Cr, Mn, Fe, Co, Ni, and Cu on the B site. The low-temperature synchrotron X-ray powder diffraction pattern was collected at the P02.1 beamline at PETRA III. The workflow starts from approximate structural and profile parameters, estimates the background from the measured pattern, and improves the model in two fitting stages.
🛠️ Import Library¶
import easydiffraction as edi
project = edi.Project(
name='lam7o3_p021',
description='LaM(7)O3 refinement using P02.1 synchrotron X-ray data.',
)
Save Initial Project¶
Create the project directory before fitting so that analysis results can be written as they are produced.
project.save_as(dir_path='projects/refine-lam7o3-p021')
Saving project 📦 'lam7o3_p021' to '../../../projects/refine-lam7o3-p021'
├── 📄 project.edi
├── 📁 structures/
├── 📁 experiments/
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 lam7o3_p021.html
🧩 Define Structure¶
The Pnma structure is initialized from approximate values rather than the final refined values.
Create Structure¶
Define the structure as an inline CIF. Empty uncertainty parentheses,
such as 5.5(), mark a parameter as free without assigning an initial
standard uncertainty. Values without parentheses remain fixed.
structure_cif = """
data_lam7o3
_cell.length_a 5.5()
_cell.length_b 7.7()
_cell.length_c 5.5()
_cell.angle_alpha 90.
_cell.angle_beta 90.
_cell.angle_gamma 90.
_space_group.name_h_m "P n m a"
_space_group.coord_system_code abc
loop_
_atom_site.id
_atom_site.type_symbol
_atom_site.fract_x
_atom_site.fract_y
_atom_site.fract_z
_atom_site.occupancy
_atom_site.adp_iso
_atom_site.adp_type
La La 0.48() 0.25 0.004() 1. 0.1() Biso
Ti Ti 0. 0. 0. 0.14286 0.1() Biso
Cr Cr 0. 0. 0. 0.14286 0.1 Biso
Mn Mn 0. 0. 0. 0.14286 0.1 Biso
Fe Fe 0. 0. 0. 0.14286 0.1 Biso
Co Co 0. 0. 0. 0.14286 0.1 Biso
Ni Ni 0. 0. 0. 0.14286 0.1 Biso
Cu Cu 0. 0. 0. 0.14286 0.1 Biso
O1 O 0.51() 0.25 0.57() 1. 0.1() Biso
O2 O 0.22() 0.03() 0.27() 1. 0.1 Biso
"""
project.structures.add_from_cif_str(structure_cif)
project.structures.show_names()
Defined structures 🧩
['lam7o3']
Use a short alias to access the structure parameters below.
structure = project.structures['lam7o3']
Display Structure¶
Inspect the structure as text and as an interactive crystal model.
structure.show_as_text()
Structure 🧩 'lam7o3' as text
| Edi | |
|---|---|
| 1 | data_lam7o3 |
| 2 | |
| 3 | _cell.length_a 5.5() |
| 4 | _cell.length_b 7.7() |
| 5 | _cell.length_c 5.5() |
| 6 | _cell.angle_alpha 90. |
| 7 | _cell.angle_beta 90. |
| 8 | _cell.angle_gamma 90. |
| 9 | |
| 10 | _space_group.name_h_m "P n m a" |
| 11 | _space_group.coord_system_code abc |
| 12 | |
| 13 | _geom.min_bond_distance_cutoff 0. |
| 14 | _geom.bond_distance_inc 0.25 |
| 15 | |
| 16 | loop_ |
| 17 | _atom_site.id |
| 18 | _atom_site.type_symbol |
| 19 | _atom_site.fract_x |
| 20 | _atom_site.fract_y |
| 21 | _atom_site.fract_z |
| 22 | _atom_site.wyckoff_letter |
| 23 | _atom_site.multiplicity |
| 24 | _atom_site.occupancy |
| 25 | _atom_site.adp_iso |
| 26 | _atom_site.adp_type |
| 27 | La La 0.48() 0.25 0.004() c 4 1. 0.1() Biso |
| 28 | Ti Ti 0. 0. 0. a 4 0.14286 0.1() Biso |
| 29 | Cr Cr 0. 0. 0. a 4 0.14286 0.1 Biso |
| 30 | Mn Mn 0. 0. 0. a 4 0.14286 0.1 Biso |
| 31 | Fe Fe 0. 0. 0. a 4 0.14286 0.1 Biso |
| 32 | Co Co 0. 0. 0. a 4 0.14286 0.1 Biso |
| 33 | Ni Ni 0. 0. 0. a 4 0.14286 0.1 Biso |
| 34 | Cu Cu 0. 0. 0. a 4 0.14286 0.1 Biso |
| 35 | O1 O 0.51() 0.25 0.57() c 4 1. 0.1() Biso |
| 36 | O2 O 0.22() 0.03() 0.27() d 8 1. 0.1 Biso |
project.display.structure(struct_name='lam7o3')
Structure 🧩 'lam7o3' (Atom view type: 'covalent')
wheel = zoom
right-drag = pan
🔬 Define Experiment¶
Load the measured pattern, configure the instrument and peak profile, and link the structure to the experiment.
Download Data¶
The first two columns contain 2-theta and intensity. When a third column of standard uncertainties is absent, EasyDiffraction estimates it from the square root of the intensity.
data_path = edi.download_data('meas-hep7c-xray-synchrotron', destination='data')
Getting data...
Data 'meas-hep7c-xray-synchrotron': La high-entropy perovskite (7 B-cations), synchrotron X-ray
✅ Data 'meas-hep7c-xray-synchrotron' downloaded to '../../../data/meas-hep7c-xray-synchrotron.dat'
Create P02.1 Experiment¶
project.experiments.add_from_data_path(
name='p021',
data_path=data_path,
sample_form='powder',
beam_mode='constant wavelength',
radiation_probe='xray',
)
⚠️ No uncertainty (sy) column provided. Defaulting to sqrt(y).
Data loaded successfully
Experiment 🔬 'p021'. Number of data points: 1459.
Use a short alias to access the P02.1 experiment parameters below.
experiment = project.experiments['p021']
Set Linked Structures¶
Link the structural model to the measured pattern and use an order-of-magnitude estimate for the scale factor.
experiment.linked_structures.create(
structure_id='lam7o3',
scale=0.000005,
)
Set P02.1 Instrument Parameters¶
Set the monochromatic X-ray wavelength reported for the P02.1 beamline measurement and initialize the unknown 2-theta zero shift at zero.
experiment.instrument.setup_wavelength = 0.207109
experiment.instrument.calib_twotheta_offset = 0.0
Set Peak Profile¶
Select a pseudo-Voigt profile and provide approximate broadening parameters. U, V, and W define the Gaussian contribution; X and Y define the Lorentzian contribution.
experiment.peak.show_supported()
Peak types
| Type | Description | ||
|---|---|---|---|
| 1 | * | pseudo-voigt | CWL pseudo-Voigt profile |
| 2 | pseudo-voigt + berar-baldinozzi asymmetry | CWL pseudo-Voigt profile with Berar-Baldinozzi asymmetry correction. |
experiment.peak.type = 'pseudo-voigt'
Peak profile type for experiment 'p021' changed to
pseudo-voigt
experiment.peak.broad_gauss_u = 0.04
experiment.peak.broad_gauss_v = -0.01
experiment.peak.broad_gauss_w = 0.001
experiment.peak.broad_lorentz_x = 0.1
experiment.peak.broad_lorentz_y = 0.0
Set Excluded Regions¶
Restrict the fit to the useful measured range from 2 to 15 degrees.
experiment.excluded_regions.create(id='1', start=0.0, end=2.0)
experiment.excluded_regions.create(id='2', start=15.0, end=20.0)
Set Background¶
Estimate initial background points from the measured pattern alone.
experiment.background.auto_estimate(use_model=False)
experiment.background.show()
Line-segment background points
| Position | Intensity | |
|---|---|---|
| 1 | 2.00330 | 584.02820 |
| 2 | 3.19170 | 616.43436 |
| 3 | 3.49660 | 608.10597 |
| 4 | 3.72800 | 594.63226 |
| 5 | 3.95940 | 574.02994 |
| 6 | 4.94790 | 457.72470 |
| 7 | 5.17920 | 443.13978 |
| 8 | 5.46320 | 433.01395 |
| 9 | 6.02050 | 432.92677 |
| 10 | 6.97750 | 421.29697 |
| 11 | 7.75570 | 444.89668 |
| 12 | 8.61800 | 453.76679 |
| 13 | 11.28920 | 346.83990 |
| 14 | 11.93060 | 357.71449 |
| 15 | 14.73850 | 302.43079 |
| 16 | 14.99090 | 278.31547 |
Inspect Experiment¶
Display the configured experiment as text.
experiment.show_as_text()
Experiment 🔬 'p021' as text
| Edi | |
|---|---|
| 1 | data_p021 |
| 2 | |
| 3 | _experiment_type.sample_form powder |
| 4 | _experiment_type.beam_mode "constant wavelength" |
| 5 | _experiment_type.radiation_probe xray |
| 6 | _experiment_type.scattering_type bragg |
| 7 | |
| 8 | _diffrn.ambient_temperature ? |
| 9 | _diffrn.ambient_pressure ? |
| 10 | _diffrn.ambient_magnetic_field ? |
| 11 | _diffrn.ambient_electric_field ? |
| 12 | |
| 13 | _calculator.type cryspy |
| 14 | |
| 15 | _peak.broad_gauss_u 0.04 |
| 16 | _peak.broad_gauss_v -0.01 |
| 17 | _peak.broad_gauss_w 0.001 |
| 18 | _peak.broad_lorentz_x 0.1 |
| 19 | _peak.broad_lorentz_y 0. |
| 20 | _peak.cutoff_fwhm 0. |
| 21 | _peak.type cwl-pseudo-voigt |
| 22 | |
| 23 | _instrument.setup_wavelength 0.207109 |
| 24 | _instrument.setup_wavelength_2 0. |
| 25 | _instrument.setup_wavelength_2_to_1_ratio 0. |
| 26 | _instrument.calib_twotheta_offset 0. |
| 27 | _instrument.calib_sample_displacement 0. |
| 28 | _instrument.calib_sample_transparency 0. |
| 29 | _instrument.setup_polarization_coefficient 0. |
| 30 | _instrument.setup_monochromator_twotheta 0. |
| 31 | |
| 32 | _absorption.type none |
| 33 | |
| 34 | loop_ |
| 35 | _linked_structure.structure_id |
| 36 | _linked_structure.scale |
| 37 | lam7o3 0.000005 |
| 38 | |
| 39 | loop_ |
| 40 | _excluded_region.id |
| 41 | _excluded_region.start |
| 42 | _excluded_region.end |
| 43 | 1 0. 2. |
| 44 | 2 15. 20. |
| 45 | |
| 46 | _background.type line-segment |
| 47 | |
| 48 | loop_ |
| 49 | _background.id |
| 50 | _background.position |
| 51 | _background.intensity |
| 52 | 1 2.0033 584.0282 |
| 53 | 2 3.1917 616.4343557 |
| 54 | 3 3.4966 608.10596651 |
| 55 | 4 3.728 594.63226302 |
| 56 | 5 3.9594 574.02993766 |
| 57 | 6 4.9479 457.7247 |
| 58 | 7 5.1792 443.13977867 |
| 59 | 8 5.4632 433.01395145 |
| 60 | 9 6.0205 432.92676858 |
| 61 | 10 6.9775 421.2969741 |
| 62 | 11 7.7557 444.89668148 |
| 63 | 12 8.618 453.76678528 |
| 64 | 13 11.2892 346.83989649 |
| 65 | 14 11.9306 357.71448643 |
| 66 | 15 14.7385 302.43079253 |
| 67 | 16 14.9909 278.31546798 |
| 68 | |
| 69 | loop_ |
| 70 | _data.two_theta |
| 71 | _data.id |
| 72 | _data.d_spacing |
| 73 | _data.intensity_meas |
| 74 | _data.intensity_meas_su |
| 75 | _data.intensity_calc |
| 76 | _data.intensity_bkg |
| 77 | _data.calc_status |
| 78 | 0.0053 1 0. 0. 1. 0. 0. excl |
| 79 | 0.0158 2 0. 0. 1. 0. 0. excl |
| 80 | 0.0263 3 0. 0. 1. 0. 0. excl |
| 81 | 0.0368 4 0. 0. 1. 0. 0. excl |
| 82 | 0.0473 5 0. 0. 1. 0. 0. excl |
| 83 | 0.0578 6 0. 0. 1. 0. 0. excl |
| 84 | 0.0684 7 0. 0. 1. 0. 0. excl |
| 85 | 0.0789 8 0. 0. 1. 0. 0. excl |
| 86 | 0.0894 9 0. 0. 1. 0. 0. excl |
| 87 | 0.0999 10 0. 0. 1. 0. 0. excl |
| 88 | ... |
| 89 | 15.2432 1450 0. 65.524826 8.09474064 0. 0. excl |
| 90 | 15.2538 1451 0. 43.702377 6.61077734 0. 0. excl |
| 91 | 15.2643 1452 0. 31.145777 5.58084017 0. 0. excl |
| 92 | 15.2748 1453 0. 20.166813 4.49074749 0. 0. excl |
| 93 | 15.2853 1454 0. 14.170188 3.76433102 0. 0. excl |
| 94 | 15.2958 1455 0. 7.3013401 2.7020992 0. 0. excl |
| 95 | 15.3063 1456 0. 12.101576 3.47873195 0. 0. excl |
| 96 | 15.3169 1457 0. 6.531918 2.55576173 0. 0. excl |
| 97 | 15.3274 1458 0. 3.1248069 1.76771234 0. 0. excl |
| 98 | 15.3379 1459 0. 3.6774037 1.91765578 0. 0. excl |
| 99 | |
| 100 | loop_ |
| 101 | _refln.id |
| 102 | _refln.structure_id |
| 103 | _refln.d_spacing |
| 104 | _refln.sin_theta_over_lambda |
| 105 | _refln.index_h |
| 106 | _refln.index_k |
| 107 | _refln.index_l |
| 108 | _refln.f_calc |
| 109 | _refln.f_squared_calc |
| 110 | _refln.two_theta |
| 111 | 1 lam7o3 7.7 0.06493506 0 1 0 0. 0. 1.54114667 |
| 112 | 2 lam7o3 5.5 0.09090909 0 0 1 0. 0. 2.15766778 |
| 113 | 3 lam7o3 5.5 0.09090909 1 0 0 0. 0. 2.15766778 |
| 114 | 4 lam7o3 4.47553409 0.11171851 0 1 1 3.59310475 12.91040172 2.65164569 |
| 115 | 5 lam7o3 4.47553409 0.11171851 1 1 0 0. 0. 2.65164569 |
| 116 | 6 lam7o3 3.8890873 0.12856487 1 0 1 84.40914375 7124.90354832 3.05158341 |
| 117 | 7 lam7o3 3.85 0.12987013 0 2 0 85.84489383 7369.34579669 3.08257218 |
| 118 | 8 lam7o3 3.47142809 0.14403294 1 1 1 24.66596148 608.40965573 3.4188328 |
| 119 | 9 lam7o3 3.15404289 0.1585267 1 2 0 0. 0. 3.76298134 |
| 120 | 10 lam7o3 3.15404289 0.1585267 0 2 1 0. 0. 3.76298134 |
| 121 | ... |
| 122 | 605 lam7o3 0.63080858 0.79263348 0 10 5 0. 0. 18.89705877 |
| 123 | 606 lam7o3 0.63072392 0.79273987 5 2 7 107.42119834 11539.3138528 18.89961836 |
| 124 | 607 lam7o3 0.63072392 0.79273987 7 2 5 90.76949065 8239.10043243 18.89961836 |
| 125 | 608 lam7o3 0.63021671 0.79337789 2 4 8 97.82362003 9569.46063649 18.91496894 |
| 126 | 609 lam7o3 0.63021671 0.79337789 8 4 2 76.04580662 5782.96470497 18.91496894 |
| 127 | 610 lam7o3 0.62937406 0.79444012 3 6 7 108.33293447 11736.02469019 18.94052659 |
| 128 | 611 lam7o3 0.62937406 0.79444012 7 6 3 78.37832345 6143.16158631 18.94052659 |
| 129 | 612 lam7o3 0.62845104 0.79560693 6 3 6 53.64286926 2877.55742291 18.9686017 |
| 130 | 613 lam7o3 0.62778229 0.79645445 8 5 0 76.32628817 5825.702266 18.98899484 |
| 131 | 614 lam7o3 0.62778229 0.79645445 0 5 8 0. 0. 18.98899484 |
🚀 Perform Analysis¶
Select the refinement parameters, apply the shared-Biso constraints, and improve the model in two fitting stages.
Set Free Parameters¶
The independent cell lengths, selected fractional coordinates, and
three independent Biso values were marked free by () in the inline
CIF. They do not need to be selected again here.
Refine the scale factor, zero shift, U/V/W/X profile terms, and active background-point intensities.
experiment.linked_structures['lam7o3'].scale.free = True
experiment.instrument.calib_twotheta_offset.free = True
experiment.peak.broad_gauss_u.free = True
experiment.peak.broad_gauss_v.free = True
experiment.peak.broad_gauss_w.free = True
experiment.peak.broad_lorentz_x.free = True
for point in experiment.background:
point.intensity.free = True
Display all parameters selected for refinement.
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 | lam7o3 | cell | length_a | 5.50000 | -inf | inf | Å | ||
| 2 | lam7o3 | cell | length_b | 7.70000 | -inf | inf | Å | ||
| 3 | lam7o3 | cell | length_c | 5.50000 | -inf | inf | Å | ||
| 4 | lam7o3 | atom_site | La | fract_x | 0.48000 | -inf | inf | ||
| 5 | lam7o3 | atom_site | La | fract_z | 0.00400 | -inf | inf | ||
| 6 | lam7o3 | atom_site | La | adp_iso | 0.10000 | -inf | inf | Ų | |
| 7 | lam7o3 | atom_site | Ti | adp_iso | 0.10000 | -inf | inf | Ų | |
| 8 | lam7o3 | atom_site | O1 | fract_x | 0.51000 | -inf | inf | ||
| 9 | lam7o3 | atom_site | O1 | fract_z | 0.57000 | -inf | inf | ||
| 10 | lam7o3 | atom_site | O1 | adp_iso | 0.10000 | -inf | inf | Ų | |
| 11 | lam7o3 | atom_site | O2 | fract_x | 0.22000 | -inf | inf | ||
| 12 | lam7o3 | atom_site | O2 | fract_y | 0.03000 | -inf | inf | ||
| 13 | lam7o3 | atom_site | O2 | fract_z | 0.27000 | -inf | inf | ||
| 14 | p021 | linked_structure | lam7o3 | scale | 0.00001 | -inf | inf | ||
| 15 | p021 | peak | broad_gauss_u | 0.04000 | -inf | inf | deg² | ||
| 16 | p021 | peak | broad_gauss_v | -0.01000 | -inf | inf | deg² | ||
| 17 | p021 | peak | broad_gauss_w | 0.00100 | -inf | inf | deg² | ||
| 18 | p021 | peak | broad_lorentz_x | 0.10000 | -inf | inf | deg | ||
| 19 | p021 | instrument | twotheta_offset | 0.00000 | -inf | inf | deg | ||
| 20 | p021 | background | 1 | intensity | 584.02820 | -inf | inf | ||
| 21 | p021 | background | 2 | intensity | 616.43436 | -inf | inf | ||
| 22 | p021 | background | 3 | intensity | 608.10597 | -inf | inf | ||
| 23 | p021 | background | 4 | intensity | 594.63226 | -inf | inf | ||
| 24 | p021 | background | 5 | intensity | 574.02994 | -inf | inf | ||
| 25 | p021 | background | 6 | intensity | 457.72470 | -inf | inf | ||
| 26 | p021 | background | 7 | intensity | 443.13978 | -inf | inf | ||
| 27 | p021 | background | 8 | intensity | 433.01395 | -inf | inf | ||
| 28 | p021 | background | 9 | intensity | 432.92677 | -inf | inf | ||
| 29 | p021 | background | 10 | intensity | 421.29697 | -inf | inf | ||
| 30 | p021 | background | 11 | intensity | 444.89668 | -inf | inf | ||
| 31 | p021 | background | 12 | intensity | 453.76679 | -inf | inf | ||
| 32 | p021 | background | 13 | intensity | 346.83990 | -inf | inf | ||
| 33 | p021 | background | 14 | intensity | 357.71449 | -inf | inf | ||
| 34 | p021 | background | 15 | intensity | 302.43079 | -inf | inf | ||
| 35 | p021 | background | 16 | intensity | 278.31547 | -inf | inf |
Set Constraints¶
Create aliases for the constrained Biso parameters. The seven elements share one B site and therefore one Biso value; O1 and O2 are also modeled with one shared Biso value.
# B sites: Ti, Cr, Mn, Fe, Co, Ni, Cu
project.analysis.aliases.create(
id='biso_Ti',
param=structure.atom_sites['Ti'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Cr',
param=structure.atom_sites['Cr'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Mn',
param=structure.atom_sites['Mn'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Fe',
param=structure.atom_sites['Fe'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Co',
param=structure.atom_sites['Co'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Ni',
param=structure.atom_sites['Ni'].adp_iso,
)
project.analysis.aliases.create(
id='biso_Cu',
param=structure.atom_sites['Cu'].adp_iso,
)
# O sites: O1, O2
project.analysis.aliases.create(
id='biso_O1',
param=structure.atom_sites['O1'].adp_iso,
)
project.analysis.aliases.create(
id='biso_O2',
param=structure.atom_sites['O2'].adp_iso,
)
Apply the equality constraints using the aliases.
project.analysis.constraints.create(id='1', expression='biso_Cr = biso_Ti')
project.analysis.constraints.create(id='2', expression='biso_Mn = biso_Ti')
project.analysis.constraints.create(id='3', expression='biso_Fe = biso_Ti')
project.analysis.constraints.create(id='4', expression='biso_Co = biso_Ti')
project.analysis.constraints.create(id='5', expression='biso_Ni = biso_Ti')
project.analysis.constraints.create(id='6', expression='biso_Cu = biso_Ti')
project.analysis.constraints.create(id='7', expression='biso_O2 = biso_O1')
Display the defined constraints.
project.analysis.display.constraints()
User defined constraints
| id | expression | |
|---|---|---|
| 1 | 1 | biso_Cr = biso_Ti |
| 2 | 2 | biso_Mn = biso_Ti |
| 3 | 3 | biso_Fe = biso_Ti |
| 4 | 4 | biso_Co = biso_Ti |
| 5 | 5 | biso_Ni = biso_Ti |
| 6 | 6 | biso_Cu = biso_Ti |
| 7 | 7 | biso_O2 = biso_O1 |
Constraints enabled: True
project.display.pattern(expt_name='p021')
project.display.pattern(expt_name='p021', x_min=2.2, x_max=4.0)
Run Fitting¶
project.analysis.fit()
Standard fitting
📋 Using experiment 🔬 'p021' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.21 | 276.18 | |
| 2 | 20 | 5.71 | 276.18 | |
| 3 | 39 | 10.84 | 46.46 | 83.2% ↓ |
| 4 | 57 | 16.14 | 46.46 | |
| 5 | 75 | 21.08 | 15.97 | 65.6% ↓ |
| 6 | 93 | 26.39 | 15.97 | |
| 7 | 111 | 31.49 | 3.89 | 75.7% ↓ |
| 8 | 129 | 36.58 | 3.89 | |
| 9 | 146 | 41.80 | 3.89 | |
| 10 | 149 | 42.41 | 1.71 | 55.9% ↓ |
| 11 | 167 | 47.65 | 1.71 | |
| 12 | 185 | 52.68 | 1.12 | 34.9% ↓ |
| 13 | 203 | 57.71 | 1.12 | |
| 14 | 220 | 62.88 | 1.12 | |
| 15 | 221 | 63.08 | 0.88 | 20.9% ↓ |
| 16 | 239 | 68.22 | 0.88 | |
| 17 | 257 | 73.47 | 0.88 | |
| 18 | 270 | 78.57 | 0.88 | |
| 19 | 283 | 83.72 | 0.88 | |
| 20 | 296 | 89.05 | 0.88 | |
| 21 | 309 | 94.19 | 0.88 | |
| 22 | 322 | 99.24 | 0.88 | |
| 23 | 340 | 104.29 | 0.88 | |
| 24 | 358 | 109.42 | 0.88 | |
| 25 | 375 | 114.42 | 0.88 | |
| 26 | 392 | 119.62 | 0.88 | |
| 27 | 410 | 124.72 | 0.88 | |
| 28 | 427 | 129.83 | 0.88 | |
| 29 | 438 | 133.76 | 0.88 |
🏆 Best goodness-of-fit (reduced χ²) is 0.88 at iteration 437
✅ Fitting complete.
Saving project 📦 'lam7o3_p021' to '../../../projects/refine-lam7o3-p021'
├── 📄 project.edi
├── 📁 structures/
│ └── 📄 lam7o3.edi
├── 📁 experiments/
│ └── 📄 p021.edi
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 lam7o3_p021.html
Display the initial fit summary and the strongest parameter correlations.
project.display.fit.results()
⚙️ 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) | 133.76 |
| 4 | 🔁 Iterations | 435 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 0.88 |
| 6 | 📏 R-factor (Rf, %) | 2.39 |
| 7 | 📏 R-factor squared (Rf², %) | 2.55 |
| 8 | 📏 Weighted R-factor (wR, %) | 1.91 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | lam7o3 | cell | length_a | Å | 5.5000 | 5.4623 | 0.0002 | 0.69 % ↓ | |
| 2 | lam7o3 | cell | length_b | Å | 7.7000 | 7.7332 | 0.0004 | 0.43 % ↑ | |
| 3 | lam7o3 | cell | length_c | Å | 5.5000 | 5.4903 | 0.0002 | 0.18 % ↓ | |
| 4 | lam7o3 | atom_site | La | fract_x | 0.4800 | 0.4766 | 0.0002 | 0.72 % ↓ | |
| 5 | lam7o3 | atom_site | La | fract_z | 0.0040 | 0.0053 | 0.0006 | 31.47 % ↑ | |
| 6 | lam7o3 | atom_site | La | adp_iso | Ų | 0.1000 | 0.5942 | 0.0216 | 494.21 % ↑ |
| 7 | lam7o3 | atom_site | Ti | adp_iso | Ų | 0.1000 | 0.3425 | 0.0291 | 242.51 % ↑ |
| 8 | lam7o3 | atom_site | O1 | fract_x | 0.5100 | 0.5070 | 0.0021 | 0.58 % ↓ | |
| 9 | lam7o3 | atom_site | O1 | fract_z | 0.5700 | 0.5589 | 0.0035 | 1.96 % ↓ | |
| 10 | lam7o3 | atom_site | O1 | adp_iso | Ų | 0.1000 | 0.5941 | 0.1573 | 494.11 % ↑ |
| 11 | lam7o3 | atom_site | O2 | fract_x | 0.2200 | 0.2303 | 0.0033 | 4.68 % ↑ | |
| 12 | lam7o3 | atom_site | O2 | fract_y | 0.0300 | 0.0378 | 0.0020 | 25.89 % ↑ | |
| 13 | lam7o3 | atom_site | O2 | fract_z | 0.2700 | 0.2794 | 0.0029 | 3.47 % ↑ | |
| 14 | p021 | linked_structure | lam7o3 | scale | 0.0000 | 0.0000 | 0.0000 | 27.30 % ↓ | |
| 15 | p021 | peak | broad_gauss_u | deg² | 0.0400 | 0.0485 | 0.0174 | 21.19 % ↑ | |
| 16 | p021 | peak | broad_gauss_v | deg² | -0.0100 | -0.0066 | 0.0022 | 33.63 % ↓ | |
| 17 | p021 | peak | broad_gauss_w | deg² | 0.0010 | 0.0012 | 0.0001 | 18.94 % ↑ | |
| 18 | p021 | peak | broad_lorentz_x | deg | 0.1000 | 0.1637 | 0.0042 | 63.65 % ↑ | |
| 19 | p021 | instrument | twotheta_offset | deg | 0.0000 | -0.0004 | 0.0001 | N/A | |
| 20 | p021 | background | 1 | intensity | 584.0282 | 624.0578 | 4.4509 | 6.85 % ↑ | |
| 21 | p021 | background | 2 | intensity | 616.4344 | 988.2570 | 4.8160 | 60.32 % ↑ | |
| 22 | p021 | background | 3 | intensity | 608.1060 | 654.0695 | 6.6736 | 7.56 % ↑ | |
| 23 | p021 | background | 4 | intensity | 594.6323 | 626.9762 | 6.4339 | 5.44 % ↑ | |
| 24 | p021 | background | 5 | intensity | 574.0299 | 565.5692 | 4.4366 | 1.47 % ↓ | |
| 25 | p021 | background | 6 | intensity | 457.7247 | 449.1935 | 3.8087 | 1.86 % ↓ | |
| 26 | p021 | background | 7 | intensity | 443.1398 | 431.1709 | 5.7132 | 2.70 % ↓ | |
| 27 | p021 | background | 8 | intensity | 433.0140 | 423.0607 | 4.3495 | 2.30 % ↓ | |
| 28 | p021 | background | 9 | intensity | 432.9268 | 424.7706 | 3.6020 | 1.88 % ↓ | |
| 29 | p021 | background | 10 | intensity | 421.2970 | 406.9977 | 3.1857 | 3.39 % ↓ | |
| 30 | p021 | background | 11 | intensity | 444.8967 | 425.4509 | 3.2033 | 4.37 % ↓ | |
| 31 | p021 | background | 12 | intensity | 453.7668 | 462.3426 | 2.3750 | 1.89 % ↑ | |
| 32 | p021 | background | 13 | intensity | 346.8399 | 348.6887 | 2.3885 | 0.53 % ↑ | |
| 33 | p021 | background | 14 | intensity | 357.7145 | 349.4878 | 2.1675 | 2.30 % ↓ | |
| 34 | p021 | background | 15 | intensity | 302.4308 | 290.9154 | 2.2866 | 3.81 % ↓ | |
| 35 | p021 | background | 16 | intensity | 278.3155 | 258.7194 | 5.5684 | 7.04 % ↓ |
• 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
project.display.fit.correlations(max_parameters=5)
Display Pattern (After Initial Fit)¶
Inspect the full fitted pattern and the nonuniform low-angle background region.
project.display.pattern(expt_name='p021')
project.display.pattern(expt_name='p021', x_min=2.2, x_max=4.0)
Improve Background Estimate¶
With a fitted peak model available, repeat automatic estimation using the calculated peak contribution. This replaces the original points with a model-guided estimate. Replacement points are fixed by default, so mark their intensities free again.
experiment.background.auto_estimate(use_model=True)
experiment.background.show()
Line-segment background points
| Position | Intensity | |
|---|---|---|
| 1 | 2.00330 | 576.07930 |
| 2 | 2.17160 | 638.44269 |
| 3 | 2.23470 | 662.65186 |
| 4 | 2.29780 | 695.09265 |
| 5 | 2.40300 | 752.13934 |
| 6 | 2.75000 | 948.88708 |
| 7 | 2.79210 | 960.58868 |
| 8 | 2.83410 | 967.29542 |
| 9 | 2.87620 | 968.71605 |
| 10 | 2.91820 | 964.86104 |
| 11 | 2.97080 | 953.16247 |
| 12 | 3.14960 | 876.76893 |
| 13 | 3.32840 | 781.24539 |
| 14 | 3.49660 | 699.51489 |
| 15 | 3.64390 | 640.61808 |
| 16 | 3.72800 | 601.48366 |
| 17 | 3.81210 | 556.51417 |
| 18 | 4.03300 | 428.78047 |
| 19 | 4.08550 | 400.97938 |
| 20 | 4.14860 | 371.19048 |
| 21 | 4.21170 | 346.60070 |
| 22 | 4.26430 | 331.07531 |
| 23 | 4.43260 | 318.49330 |
| 24 | 4.50620 | 328.33475 |
| 25 | 4.77960 | 400.14924 |
| 26 | 4.94790 | 435.19050 |
| 27 | 5.02150 | 440.50098 |
| 28 | 5.46320 | 422.43300 |
| 29 | 5.82070 | 425.38983 |
| 30 | 6.08360 | 420.22464 |
| 31 | 6.43070 | 417.57909 |
| 32 | 6.78820 | 410.64869 |
| 33 | 7.40870 | 409.16031 |
| 34 | 7.75570 | 427.93405 |
| 35 | 7.86090 | 433.58138 |
| 36 | 8.17640 | 441.57902 |
| 37 | 8.33410 | 442.13621 |
| 38 | 8.97560 | 435.40766 |
| 39 | 9.97460 | 432.32693 |
| 40 | 10.38480 | 396.20254 |
| 41 | 10.85800 | 351.40050 |
| 42 | 11.69930 | 347.23352 |
| 43 | 11.85700 | 347.83931 |
| 44 | 12.53010 | 340.09138 |
| 45 | 14.24420 | 301.93226 |
| 46 | 14.99090 | 260.58927 |
for point in experiment.background:
point.intensity.free = True
Run Fitting¶
project.analysis.fit()
Standard fitting
📋 Using experiment 🔬 'p021' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.27 | 2.77 | |
| 2 | 18 | 5.36 | 2.77 | |
| 3 | 35 | 10.37 | 2.77 | |
| 4 | 53 | 15.49 | 2.77 | |
| 5 | 69 | 20.04 | 0.16 | 94.1% ↓ |
| 6 | 86 | 25.24 | 0.16 | |
| 7 | 104 | 30.32 | 0.16 | |
| 8 | 122 | 35.45 | 0.16 | |
| 9 | 140 | 40.93 | 0.16 | |
| 10 | 158 | 45.99 | 0.16 | |
| 11 | 176 | 51.26 | 0.16 | |
| 12 | 194 | 56.33 | 0.16 | |
| 13 | 212 | 61.44 | 0.16 | |
| 14 | 230 | 66.96 | 0.16 | |
| 15 | 248 | 72.09 | 0.16 | |
| 16 | 266 | 77.52 | 0.16 | |
| 17 | 283 | 82.59 | 0.16 | |
| 18 | 301 | 87.73 | 0.16 | |
| 19 | 319 | 92.79 | 0.16 | |
| 20 | 336 | 98.10 | 0.16 | |
| 21 | 354 | 103.19 | 0.16 | |
| 22 | 372 | 108.32 | 0.16 | |
| 23 | 389 | 113.55 | 0.16 | |
| 24 | 400 | 122.00 | 0.16 |
🏆 Best goodness-of-fit (reduced χ²) is 0.16 at iteration 399
✅ Fitting complete.
Saving project 📦 'lam7o3_p021' to '../../../projects/refine-lam7o3-p021'
├── 📄 project.edi
├── 📁 structures/
│ └── 📄 lam7o3.edi
├── 📁 experiments/
│ └── 📄 p021.edi
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 lam7o3_p021.html
project.display.fit.results()
⚙️ 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) | 122.00 |
| 4 | 🔁 Iterations | 397 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 0.16 |
| 6 | 📏 R-factor (Rf, %) | 1.01 |
| 7 | 📏 R-factor squared (Rf², %) | 1.61 |
| 8 | 📏 Weighted R-factor (wR, %) | 1.48 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | lam7o3 | cell | length_a | Å | 5.4623 | 5.4622 | 0.0001 | 0.00 % ↓ | |
| 2 | lam7o3 | cell | length_b | Å | 7.7332 | 7.7331 | 0.0002 | 0.00 % ↓ | |
| 3 | lam7o3 | cell | length_c | Å | 5.4903 | 5.4902 | 0.0001 | 0.00 % ↓ | |
| 4 | lam7o3 | atom_site | La | fract_x | 0.4766 | 0.4767 | 0.0001 | 0.03 % ↑ | |
| 5 | lam7o3 | atom_site | La | fract_z | 0.0053 | 0.0045 | 0.0003 | 15.23 % ↓ | |
| 6 | lam7o3 | atom_site | La | adp_iso | Ų | 0.5942 | 0.6260 | 0.0095 | 5.35 % ↑ |
| 7 | lam7o3 | atom_site | Ti | adp_iso | Ų | 0.3425 | 0.3376 | 0.0126 | 1.44 % ↓ |
| 8 | lam7o3 | atom_site | O1 | fract_x | 0.5070 | 0.5083 | 0.0010 | 0.25 % ↑ | |
| 9 | lam7o3 | atom_site | O1 | fract_z | 0.5589 | 0.5708 | 0.0016 | 2.14 % ↑ | |
| 10 | lam7o3 | atom_site | O1 | adp_iso | Ų | 0.5941 | 0.3583 | 0.0654 | 39.69 % ↓ |
| 11 | lam7o3 | atom_site | O2 | fract_x | 0.2303 | 0.2218 | 0.0014 | 3.71 % ↓ | |
| 12 | lam7o3 | atom_site | O2 | fract_y | 0.0378 | 0.0340 | 0.0009 | 9.90 % ↓ | |
| 13 | lam7o3 | atom_site | O2 | fract_z | 0.2794 | 0.2748 | 0.0014 | 1.63 % ↓ | |
| 14 | p021 | linked_structure | lam7o3 | scale | 0.0000 | 0.0000 | 0.0000 | 0.49 % ↑ | |
| 15 | p021 | peak | broad_gauss_u | deg² | 0.0485 | 0.0513 | 0.0075 | 5.81 % ↑ | |
| 16 | p021 | peak | broad_gauss_v | deg² | -0.0066 | -0.0076 | 0.0010 | 15.15 % ↑ | |
| 17 | p021 | peak | broad_gauss_w | deg² | 0.0012 | 0.0012 | 0.0000 | 2.99 % ↑ | |
| 18 | p021 | peak | broad_lorentz_x | deg | 0.1637 | 0.1669 | 0.0025 | 2.00 % ↑ | |
| 19 | p021 | instrument | twotheta_offset | deg | -0.0004 | -0.0005 | 0.0001 | 25.23 % ↑ | |
| 20 | p021 | background | 1 | intensity | 576.0793 | 583.7057 | 4.4597 | 1.32 % ↑ | |
| 21 | p021 | background | 2 | intensity | 638.4427 | 637.0138 | 4.1454 | 0.22 % ↓ | |
| 22 | p021 | background | 3 | intensity | 662.6519 | 661.4446 | 5.3649 | 0.18 % ↓ | |
| 23 | p021 | background | 4 | intensity | 695.0927 | 691.5221 | 4.8034 | 0.51 % ↓ | |
| 24 | p021 | background | 5 | intensity | 752.1393 | 751.6693 | 3.3433 | 0.06 % ↓ | |
| 25 | p021 | background | 6 | intensity | 948.8871 | 967.4276 | 3.8652 | 1.95 % ↑ | |
| 26 | p021 | background | 7 | intensity | 960.5887 | 968.7470 | 7.8377 | 0.85 % ↑ | |
| 27 | p021 | background | 8 | intensity | 967.2954 | 981.1793 | 8.0417 | 1.44 % ↑ | |
| 28 | p021 | background | 9 | intensity | 968.7160 | 991.6844 | 8.0566 | 2.37 % ↑ | |
| 29 | p021 | background | 10 | intensity | 964.8610 | 978.2161 | 7.5124 | 1.38 % ↑ | |
| 30 | p021 | background | 11 | intensity | 953.1625 | 961.7701 | 5.2263 | 0.90 % ↑ | |
| 31 | p021 | background | 12 | intensity | 876.7689 | 877.8444 | 4.0526 | 0.12 % ↑ | |
| 32 | p021 | background | 13 | intensity | 781.2454 | 775.4285 | 3.7077 | 0.74 % ↓ | |
| 33 | p021 | background | 14 | intensity | 699.5149 | 689.0055 | 3.7740 | 1.50 % ↓ | |
| 34 | p021 | background | 15 | intensity | 640.6181 | 649.7581 | 4.0686 | 1.43 % ↑ | |
| 35 | p021 | background | 16 | intensity | 601.4837 | 615.5274 | 4.5230 | 2.33 % ↑ | |
| 36 | p021 | background | 17 | intensity | 556.5142 | 597.0830 | 3.4872 | 7.29 % ↑ | |
| 37 | p021 | background | 18 | intensity | 428.7805 | 551.2716 | 3.5847 | 28.57 % ↑ | |
| 38 | p021 | background | 19 | intensity | 400.9794 | 548.1756 | 5.2366 | 36.71 % ↑ | |
| 39 | p021 | background | 20 | intensity | 371.1905 | 583.1060 | 5.3080 | 57.09 % ↑ | |
| 40 | p021 | background | 21 | intensity | 346.6007 | 514.8713 | 5.4911 | 48.55 % ↑ | |
| 41 | p021 | background | 22 | intensity | 331.0753 | 523.4231 | 7.0097 | 58.10 % ↑ | |
| 42 | p021 | background | 23 | intensity | 318.4933 | 508.0645 | 4.9871 | 59.52 % ↑ | |
| 43 | p021 | background | 24 | intensity | 328.3347 | 497.3337 | 3.1594 | 51.47 % ↑ | |
| 44 | p021 | background | 25 | intensity | 400.1492 | 467.0731 | 2.6516 | 16.72 % ↑ | |
| 45 | p021 | background | 26 | intensity | 435.1905 | 452.4149 | 3.2856 | 3.96 % ↑ | |
| 46 | p021 | background | 27 | intensity | 440.5010 | 438.9108 | 2.5440 | 0.36 % ↓ | |
| 47 | p021 | background | 28 | intensity | 422.4330 | 420.9219 | 2.0607 | 0.36 % ↓ | |
| 48 | p021 | background | 29 | intensity | 425.3898 | 426.8501 | 2.1298 | 0.34 % ↑ | |
| 49 | p021 | background | 30 | intensity | 420.2246 | 418.4449 | 2.8849 | 0.42 % ↓ | |
| 50 | p021 | background | 31 | intensity | 417.5791 | 417.3651 | 2.0005 | 0.05 % ↓ | |
| 51 | p021 | background | 32 | intensity | 410.6487 | 411.7042 | 1.8668 | 0.26 % ↑ | |
| 52 | p021 | background | 33 | intensity | 409.1603 | 410.5187 | 2.0424 | 0.33 % ↑ | |
| 53 | p021 | background | 34 | intensity | 427.9340 | 431.2367 | 2.5606 | 0.77 % ↑ | |
| 54 | p021 | background | 35 | intensity | 433.5814 | 435.4782 | 2.5649 | 0.44 % ↑ | |
| 55 | p021 | background | 36 | intensity | 441.5790 | 441.4029 | 2.4132 | 0.04 % ↓ | |
| 56 | p021 | background | 37 | intensity | 442.1362 | 440.3573 | 1.9173 | 0.40 % ↓ | |
| 57 | p021 | background | 38 | intensity | 435.4077 | 436.7917 | 1.4636 | 0.32 % ↑ | |
| 58 | p021 | background | 39 | intensity | 432.3269 | 440.6909 | 1.6017 | 1.93 % ↑ | |
| 59 | p021 | background | 40 | intensity | 396.2025 | 399.2762 | 1.7705 | 0.78 % ↑ | |
| 60 | p021 | background | 41 | intensity | 351.4005 | 345.2537 | 1.4677 | 1.75 % ↓ | |
| 61 | p021 | background | 42 | intensity | 347.2335 | 344.8956 | 1.8053 | 0.67 % ↓ | |
| 62 | p021 | background | 43 | intensity | 347.8393 | 350.5874 | 1.6163 | 0.79 % ↑ | |
| 63 | p021 | background | 44 | intensity | 340.0914 | 339.5041 | 1.1339 | 0.17 % ↓ | |
| 64 | p021 | background | 45 | intensity | 301.9323 | 302.4185 | 1.0953 | 0.16 % ↑ | |
| 65 | p021 | background | 46 | intensity | 260.5893 | 273.9354 | 1.5148 | 5.12 % ↑ |
• 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
project.display.fit.correlations(max_parameters=5)
Display Pattern (After Final Fit)¶
project.display.pattern(expt_name='p021')
project.display.pattern(expt_name='p021', x_min=2.2, x_max=4.0)
📊 Report¶
The HTML report is written automatically when the project is saved. PDF generation can be enabled before the final save when required.
# Enable PDF report generation before the last save (time consuming)
# project.report.pdf = True
💾 Save Project¶
project.save()
Saving project 📦 'lam7o3_p021' to '../../../projects/refine-lam7o3-p021'
├── 📄 project.edi
├── 📁 structures/
│ └── 📄 lam7o3.edi
├── 📁 experiments/
│ └── 📄 p021.edi
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 lam7o3_p021.html