Instrument calibration: BEER at ESS¶
This example demonstrates a Rietveld refinement of a duplex steel structure using time-of-flight neutron powder diffraction data simulated with McStas.
Two datasets from two symmetrically positioned banks (S2 and N2) of the BEER instrument are analyzed in this tutorial.
🛠️ 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 extract_data_paths_from_zip
from easydiffraction import extract_metadata
from easydiffraction import ExperimentFactory
from easydiffraction import Project
from easydiffraction import StructureFactory
from easydiffraction import download_data
from easydiffraction import extract_data_paths_from_zip
from easydiffraction import extract_metadata
In [3]:
Copied!
ferrite = StructureFactory.from_scratch(name='ferrite')
ferrite.space_group.name_h_m = 'I m -3 m'
ferrite.space_group.coord_system_code = '1'
ferrite.cell.length_a = 2.886
ferrite.atom_sites.create(
id='Fe',
type_symbol='Fe',
fract_x=0.0,
fract_y=0.0,
fract_z=0.0,
adp_type='Biso',
adp_iso=1.0,
)
ferrite = StructureFactory.from_scratch(name='ferrite')
ferrite.space_group.name_h_m = 'I m -3 m'
ferrite.space_group.coord_system_code = '1'
ferrite.cell.length_a = 2.886
ferrite.atom_sites.create(
id='Fe',
type_symbol='Fe',
fract_x=0.0,
fract_y=0.0,
fract_z=0.0,
adp_type='Biso',
adp_iso=1.0,
)
Create Austenite Structure¶
In [4]:
Copied!
austenite = StructureFactory.from_scratch(name='austenite')
austenite.space_group.name_h_m = 'F m -3 m'
austenite.space_group.coord_system_code = '1'
austenite.cell.length_a = 3.6468
austenite.atom_sites.create(
id='Fe',
type_symbol='Fe',
fract_x=0.0,
fract_y=0.0,
fract_z=0.0,
adp_type='Biso',
adp_iso=1.0,
)
austenite = StructureFactory.from_scratch(name='austenite')
austenite.space_group.name_h_m = 'F m -3 m'
austenite.space_group.coord_system_code = '1'
austenite.cell.length_a = 3.6468
austenite.atom_sites.create(
id='Fe',
type_symbol='Fe',
fract_x=0.0,
fract_y=0.0,
fract_z=0.0,
adp_type='Biso',
adp_iso=1.0,
)
In [5]:
Copied!
zip_path = download_data('meas-ferrite-austenite-beer', destination='data')
data_paths = extract_data_paths_from_zip(zip_path, destination='data/calibrate-beer-ess')
data_path_s2 = data_paths[1] # 'Duplex_in_HR_for_IRF_S2.dat'
data_path_n2 = data_paths[0] # 'Duplex_in_HR_for_IRF_N2.dat'
zip_path = download_data('meas-ferrite-austenite-beer', destination='data')
data_paths = extract_data_paths_from_zip(zip_path, destination='data/calibrate-beer-ess')
data_path_s2 = data_paths[1] # 'Duplex_in_HR_for_IRF_S2.dat'
data_path_n2 = data_paths[0] # 'Duplex_in_HR_for_IRF_N2.dat'
Getting data...
Data 'meas-ferrite-austenite-beer': ferrite + austenite, BEER (ESS), S2 and N2 detector bank datasets
✅ Data 'meas-ferrite-austenite-beer' downloaded to '../../../data/meas-ferrite-austenite-beer.zip'
Create Experiment¶
In [6]:
Copied!
expt_s2 = ExperimentFactory.from_data_path(
name='expt_s2',
data_path=data_path_s2,
beam_mode='time-of-flight',
)
expt_s2 = ExperimentFactory.from_data_path(
name='expt_s2',
data_path=data_path_s2,
beam_mode='time-of-flight',
)
In [7]:
Copied!
expt_n2 = ExperimentFactory.from_data_path(
name='expt_n2',
data_path=data_path_n2,
beam_mode='time-of-flight',
)
expt_n2 = ExperimentFactory.from_data_path(
name='expt_n2',
data_path=data_path_n2,
beam_mode='time-of-flight',
)
Set Instrument¶
In [8]:
Copied!
expt_s2.instrument.setup_twotheta_bank = extract_metadata(
data_path_s2, r'two_theta\s*=\s*(\d*\.?\d+)'
)
expt_s2.instrument.calib_d_to_tof_linear = extract_metadata(
data_path_s2, r'DIFC\s*=\s*(\d*\.?\d+)'
)
expt_s2.instrument.setup_twotheta_bank = extract_metadata(
data_path_s2, r'two_theta\s*=\s*(\d*\.?\d+)'
)
expt_s2.instrument.calib_d_to_tof_linear = extract_metadata(
data_path_s2, r'DIFC\s*=\s*(\d*\.?\d+)'
)
In [9]:
Copied!
expt_n2.instrument.setup_twotheta_bank = extract_metadata(
data_path_n2, r'two_theta\s*=\s*(\d*\.?\d+)'
)
expt_n2.instrument.calib_d_to_tof_linear = extract_metadata(
data_path_n2, r'DIFC\s*=\s*(\d*\.?\d+)'
)
expt_n2.instrument.setup_twotheta_bank = extract_metadata(
data_path_n2, r'two_theta\s*=\s*(\d*\.?\d+)'
)
expt_n2.instrument.calib_d_to_tof_linear = extract_metadata(
data_path_n2, r'DIFC\s*=\s*(\d*\.?\d+)'
)
Set Peak Profile¶
In [10]:
Copied!
expt_s2.peak.show_supported()
expt_s2.peak.show_supported()
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) |
In [11]:
Copied!
expt_s2.peak.type = 'pseudo-voigt'
expt_s2.peak.type = 'pseudo-voigt'
⚠️ Switching peak profile type removes these settings: • decay_beta_0 • decay_beta_1 • rise_alpha_0 • rise_alpha_1
⚠️ Switching peak profile type adds these settings with defaults: • broad_lorentz_gamma_0=0.0 • broad_lorentz_gamma_1=0.0 • broad_lorentz_gamma_2=0.0 • broad_lorentz_size_l=0.0 • broad_lorentz_strain_l=0.0
Peak profile type for experiment 'expt_s2' changed to
pseudo-voigt
In [12]:
Copied!
expt_s2.peak.broad_gauss_sigma_0 = 300
expt_s2.peak.broad_gauss_sigma_1 = 1200
expt_s2.peak.broad_gauss_sigma_2 = 900
expt_s2.peak.broad_gauss_sigma_0 = 300
expt_s2.peak.broad_gauss_sigma_1 = 1200
expt_s2.peak.broad_gauss_sigma_2 = 900
In [13]:
Copied!
expt_n2.peak.type = 'pseudo-voigt'
expt_n2.peak.type = 'pseudo-voigt'
⚠️ Switching peak profile type removes these settings: • decay_beta_0 • decay_beta_1 • rise_alpha_0 • rise_alpha_1
⚠️ Switching peak profile type adds these settings with defaults: • broad_lorentz_gamma_0=0.0 • broad_lorentz_gamma_1=0.0 • broad_lorentz_gamma_2=0.0 • broad_lorentz_size_l=0.0 • broad_lorentz_strain_l=0.0
Peak profile type for experiment 'expt_n2' changed to
pseudo-voigt
In [14]:
Copied!
expt_n2.peak.broad_gauss_sigma_0 = 300
expt_n2.peak.broad_gauss_sigma_1 = 1200
expt_n2.peak.broad_gauss_sigma_2 = 900
expt_n2.peak.broad_gauss_sigma_0 = 300
expt_n2.peak.broad_gauss_sigma_1 = 1200
expt_n2.peak.broad_gauss_sigma_2 = 900
Set Background¶
In [15]:
Copied!
expt_s2.background.show_supported()
expt_s2.background.show_supported()
Background types
| Type | Description | ||
|---|---|---|---|
| 1 | chebyshev | Chebyshev polynomial background | |
| 2 | * | line-segment | Linear interpolation between points |
In [16]:
Copied!
expt_s2.background.auto_estimate()
expt_s2.background.auto_estimate()
In [17]:
Copied!
expt_s2.background.show()
expt_s2.background.show()
Line-segment background points
| Position | Intensity | |
|---|---|---|
| 1 | 40094.52340 | 0.00154 |
| 2 | 48089.84890 | 0.16817 |
| 3 | 51976.02300 | 0.18318 |
| 4 | 54301.35670 | 0.17817 |
| 5 | 58729.04700 | 0.29095 |
| 6 | 62710.78280 | 0.30387 |
| 7 | 67711.84290 | 0.25310 |
| 8 | 73158.85750 | 0.22573 |
| 9 | 76439.80780 | 0.20324 |
| 10 | 81249.74460 | 0.19453 |
| 11 | 85263.33430 | 0.17297 |
| 12 | 96157.36350 | 0.24903 |
| 13 | 98132.30440 | 0.34182 |
| 14 | 102368.87130 | 0.39039 |
| 15 | 104248.25060 | 0.36120 |
| 16 | 108771.50250 | 0.62067 |
| 17 | 111606.49840 | 1.22400 |
| 18 | 112721.38440 | 1.32442 |
| 19 | 115715.64970 | 1.12711 |
| 20 | 135592.47480 | 0.00952 |
In [18]:
Copied!
for point in expt_s2.background:
expt_n2.background.create(
id=point.id.value, position=point.position.value, intensity=point.intensity.value
)
for point in expt_s2.background:
expt_n2.background.create(
id=point.id.value, position=point.position.value, intensity=point.intensity.value
)
Set Linked Structures¶
In [19]:
Copied!
expt_s2.linked_structures.create(structure_id='ferrite', scale=285)
expt_s2.linked_structures.create(structure_id='austenite', scale=68)
expt_s2.linked_structures.create(structure_id='ferrite', scale=285)
expt_s2.linked_structures.create(structure_id='austenite', scale=68)
In [20]:
Copied!
expt_n2.linked_structures.create(structure_id='ferrite', scale=285)
expt_n2.linked_structures.create(structure_id='austenite', scale=68)
expt_n2.linked_structures.create(structure_id='ferrite', scale=285)
expt_n2.linked_structures.create(structure_id='austenite', scale=68)
Set Excluded Regions¶
In [21]:
Copied!
expt_s2.excluded_regions.create(id='1', start=0, end=40500)
expt_s2.excluded_regions.create(id='2', start=130000, end=180000)
expt_s2.excluded_regions.create(id='1', start=0, end=40500)
expt_s2.excluded_regions.create(id='2', start=130000, end=180000)
In [22]:
Copied!
expt_n2.excluded_regions.create(id='1', start=0, end=40500)
expt_n2.excluded_regions.create(id='2', start=130000, end=180000)
expt_n2.excluded_regions.create(id='1', start=0, end=40500)
expt_n2.excluded_regions.create(id='2', start=130000, end=180000)
In [23]:
Copied!
project = Project(name='beer_mcstas')
project.save_as(dir_path='projects/calibrate-beer-ess')
project = Project(name='beer_mcstas')
project.save_as(dir_path='projects/calibrate-beer-ess')
Saving project 📦 'beer_mcstas' to '../../../projects/calibrate-beer-ess'
├── 📄 project.edi
├── 📁 structures/
├── 📁 experiments/
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 beer_mcstas.html
Add Structures¶
In [24]:
Copied!
project.structures.add(ferrite)
project.structures.add(austenite)
project.structures.add(ferrite)
project.structures.add(austenite)
Add Experiments¶
In [25]:
Copied!
project.experiments.add(expt_s2)
project.experiments.add(expt_n2)
project.experiments.add(expt_s2)
project.experiments.add(expt_n2)
Display Structure¶
In [26]:
Copied!
project.display.structure(struct_name='ferrite')
project.display.structure(struct_name='austenite')
project.display.structure(struct_name='ferrite')
project.display.structure(struct_name='austenite')
Structure 🧩 'ferrite' (Atom view type: 'covalent')
Loading plot…
drag = rotate
wheel = zoom
right-drag = pan
wheel = zoom
right-drag = pan
Structure 🧩 'austenite' (Atom view type: 'covalent')
Loading plot…
drag = rotate
wheel = zoom
right-drag = pan
wheel = zoom
right-drag = pan
Display Pattern¶
In [27]:
Copied!
project.display.pattern(expt_name='expt_s2')
project.display.pattern(expt_name='expt_s2')
Loading plot…
In [28]:
Copied!
project.display.pattern(expt_name='expt_n2')
project.display.pattern(expt_name='expt_n2')
Loading plot…
In [29]:
Copied!
project.analysis.fitting_mode.show_supported()
project.analysis.fitting_mode.show_supported()
Fitting Mode types
| Type | Description | ||
|---|---|---|---|
| 1 | joint | Fit several experiments together with shared parameters. |
In [30]:
Copied!
project.analysis.fitting_mode.type = 'joint'
project.analysis.fitting_mode.type = 'joint'
Fitting mode changed to
joint
Set Free Parameters¶
In [31]:
Copied!
project.display.parameters.fittable()
project.display.parameters.fittable()
Fittable parameters for all structures (🧩 data blocks)
Fittable parameters for all experiments (🔬 data blocks)
| datablock | category | entry | parameter | value | uncertainty | units | free | |
|---|---|---|---|---|---|---|---|---|
| 1 | expt_s2 | linked_structure | ferrite | scale | 285.00000 | False | ||
| 2 | expt_s2 | linked_structure | austenite | scale | 68.00000 | False | ||
| 3 | expt_s2 | peak | broad_lorentz_gamma_0 | 0.00000 | μs | False | ||
| 4 | expt_s2 | peak | broad_lorentz_gamma_1 | 0.00000 | μs/Å | False | ||
| 5 | expt_s2 | peak | broad_lorentz_gamma_2 | 0.00000 | μs²/Ų | False | ||
| 6 | expt_s2 | peak | broad_lorentz_size_l | 0.00000 | μs²/Ų | False | ||
| 7 | expt_s2 | peak | broad_lorentz_strain_l | 0.00000 | μs/Å | False | ||
| 8 | expt_s2 | peak | broad_gauss_sigma_0 | 300.00000 | μs² | False | ||
| 9 | expt_s2 | peak | broad_gauss_sigma_1 | 1200.00000 | μs/Å | False | ||
| 10 | expt_s2 | peak | broad_gauss_sigma_2 | 900.00000 | μs²/Ų | False | ||
| 11 | expt_s2 | peak | broad_gauss_size_g | 0.00000 | μs²/Ų | False | ||
| 12 | expt_s2 | peak | broad_gauss_strain_g | 0.00000 | μs/Å | False | ||
| 13 | expt_s2 | instrument | twotheta_bank | 90.00000 | deg | False | ||
| 14 | expt_s2 | instrument | d_to_tof_offset | 0.00000 | μs | False | ||
| 15 | expt_s2 | instrument | d_to_tof_linear | 54902.18695 | μs/Å | False | ||
| 16 | expt_s2 | instrument | d_to_tof_quadratic | 0.00000 | μs/Ų | False | ||
| 17 | expt_s2 | instrument | d_to_tof_reciprocal | 0.00000 | μs·Å | False | ||
| 18 | expt_s2 | background | 1 | intensity | 0.00154 | False | ||
| 19 | expt_s2 | background | 2 | intensity | 0.16817 | False | ||
| 20 | expt_s2 | background | 3 | intensity | 0.18318 | False | ||
| 21 | expt_s2 | background | 4 | intensity | 0.17817 | False | ||
| 22 | expt_s2 | background | 5 | intensity | 0.29095 | False | ||
| 23 | expt_s2 | background | 6 | intensity | 0.30387 | False | ||
| 24 | expt_s2 | background | 7 | intensity | 0.25310 | False | ||
| 25 | expt_s2 | background | 8 | intensity | 0.22573 | False | ||
| 26 | expt_s2 | background | 9 | intensity | 0.20324 | False | ||
| 27 | expt_s2 | background | 10 | intensity | 0.19453 | False | ||
| 28 | expt_s2 | background | 11 | intensity | 0.17297 | False | ||
| 29 | expt_s2 | background | 12 | intensity | 0.24903 | False | ||
| 30 | expt_s2 | background | 13 | intensity | 0.34182 | False | ||
| 31 | expt_s2 | background | 14 | intensity | 0.39039 | False | ||
| 32 | expt_s2 | background | 15 | intensity | 0.36120 | False | ||
| 33 | expt_s2 | background | 16 | intensity | 0.62067 | False | ||
| 34 | expt_s2 | background | 17 | intensity | 1.22400 | False | ||
| 35 | expt_s2 | background | 18 | intensity | 1.32442 | False | ||
| 36 | expt_s2 | background | 19 | intensity | 1.12711 | False | ||
| 37 | expt_s2 | background | 20 | intensity | 0.00952 | False | ||
| 38 | expt_n2 | linked_structure | ferrite | scale | 285.00000 | False | ||
| 39 | expt_n2 | linked_structure | austenite | scale | 68.00000 | False | ||
| 40 | expt_n2 | peak | broad_lorentz_gamma_0 | 0.00000 | μs | False | ||
| 41 | expt_n2 | peak | broad_lorentz_gamma_1 | 0.00000 | μs/Å | False | ||
| 42 | expt_n2 | peak | broad_lorentz_gamma_2 | 0.00000 | μs²/Ų | False | ||
| 43 | expt_n2 | peak | broad_lorentz_size_l | 0.00000 | μs²/Ų | False | ||
| 44 | expt_n2 | peak | broad_lorentz_strain_l | 0.00000 | μs/Å | False | ||
| 45 | expt_n2 | peak | broad_gauss_sigma_0 | 300.00000 | μs² | False | ||
| 46 | expt_n2 | peak | broad_gauss_sigma_1 | 1200.00000 | μs/Å | False | ||
| 47 | expt_n2 | peak | broad_gauss_sigma_2 | 900.00000 | μs²/Ų | False | ||
| 48 | expt_n2 | peak | broad_gauss_size_g | 0.00000 | μs²/Ų | False | ||
| 49 | expt_n2 | peak | broad_gauss_strain_g | 0.00000 | μs/Å | False | ||
| 50 | expt_n2 | instrument | twotheta_bank | 90.00000 | deg | False | ||
| 51 | expt_n2 | instrument | d_to_tof_offset | 0.00000 | μs | False | ||
| 52 | expt_n2 | instrument | d_to_tof_linear | 54902.18695 | μs/Å | False | ||
| 53 | expt_n2 | instrument | d_to_tof_quadratic | 0.00000 | μs/Ų | False | ||
| 54 | expt_n2 | instrument | d_to_tof_reciprocal | 0.00000 | μs·Å | False | ||
| 55 | expt_n2 | background | 1 | intensity | 0.00154 | False | ||
| 56 | expt_n2 | background | 2 | intensity | 0.16817 | False | ||
| 57 | expt_n2 | background | 3 | intensity | 0.18318 | False | ||
| 58 | expt_n2 | background | 4 | intensity | 0.17817 | False | ||
| 59 | expt_n2 | background | 5 | intensity | 0.29095 | False | ||
| 60 | expt_n2 | background | 6 | intensity | 0.30387 | False | ||
| 61 | expt_n2 | background | 7 | intensity | 0.25310 | False | ||
| 62 | expt_n2 | background | 8 | intensity | 0.22573 | False | ||
| 63 | expt_n2 | background | 9 | intensity | 0.20324 | False | ||
| 64 | expt_n2 | background | 10 | intensity | 0.19453 | False | ||
| 65 | expt_n2 | background | 11 | intensity | 0.17297 | False | ||
| 66 | expt_n2 | background | 12 | intensity | 0.24903 | False | ||
| 67 | expt_n2 | background | 13 | intensity | 0.34182 | False | ||
| 68 | expt_n2 | background | 14 | intensity | 0.39039 | False | ||
| 69 | expt_n2 | background | 15 | intensity | 0.36120 | False | ||
| 70 | expt_n2 | background | 16 | intensity | 0.62067 | False | ||
| 71 | expt_n2 | background | 17 | intensity | 1.22400 | False | ||
| 72 | expt_n2 | background | 18 | intensity | 1.32442 | False | ||
| 73 | expt_n2 | background | 19 | intensity | 1.12711 | False | ||
| 74 | expt_n2 | background | 20 | intensity | 0.00952 | False |
In [32]:
Copied!
ferrite.atom_sites['Fe'].adp_iso.free = True
austenite.atom_sites['Fe'].adp_iso.free = True
ferrite.atom_sites['Fe'].adp_iso.free = True
austenite.atom_sites['Fe'].adp_iso.free = True
In [33]:
Copied!
expt_s2.linked_structures['ferrite'].scale.free = True
expt_s2.linked_structures['austenite'].scale.free = True
expt_s2.peak.broad_gauss_sigma_0.free = True
expt_s2.peak.broad_gauss_sigma_1.free = True
expt_s2.peak.broad_gauss_sigma_2.free = True
expt_s2.peak.broad_lorentz_gamma_0.free = True
expt_s2.instrument.calib_d_to_tof_offset.free = True
for segment in expt_s2.background:
segment.intensity.free = True
expt_s2.linked_structures['ferrite'].scale.free = True
expt_s2.linked_structures['austenite'].scale.free = True
expt_s2.peak.broad_gauss_sigma_0.free = True
expt_s2.peak.broad_gauss_sigma_1.free = True
expt_s2.peak.broad_gauss_sigma_2.free = True
expt_s2.peak.broad_lorentz_gamma_0.free = True
expt_s2.instrument.calib_d_to_tof_offset.free = True
for segment in expt_s2.background:
segment.intensity.free = True
In [34]:
Copied!
expt_n2.linked_structures['ferrite'].scale.free = True
expt_n2.linked_structures['austenite'].scale.free = True
expt_n2.peak.broad_gauss_sigma_0.free = True
expt_n2.peak.broad_gauss_sigma_1.free = True
expt_n2.peak.broad_gauss_sigma_2.free = True
expt_n2.peak.broad_lorentz_gamma_0.free = True
expt_n2.instrument.calib_d_to_tof_offset.free = True
for segment in expt_n2.background:
segment.intensity.free = True
expt_n2.linked_structures['ferrite'].scale.free = True
expt_n2.linked_structures['austenite'].scale.free = True
expt_n2.peak.broad_gauss_sigma_0.free = True
expt_n2.peak.broad_gauss_sigma_1.free = True
expt_n2.peak.broad_gauss_sigma_2.free = True
expt_n2.peak.broad_lorentz_gamma_0.free = True
expt_n2.instrument.calib_d_to_tof_offset.free = True
for segment in expt_n2.background:
segment.intensity.free = True
Add Constraints¶
In [35]:
Copied!
project.analysis.aliases.create(
id='s2_ferrite_scale', param=expt_s2.linked_structures['ferrite'].scale
)
project.analysis.aliases.create(
id='s2_austenite_scale', param=expt_s2.linked_structures['austenite'].scale
)
project.analysis.aliases.create(
id='n2_ferrite_scale', param=expt_n2.linked_structures['ferrite'].scale
)
project.analysis.aliases.create(
id='n2_austenite_scale', param=expt_n2.linked_structures['austenite'].scale
)
project.analysis.constraints.create(expression='n2_ferrite_scale = s2_ferrite_scale')
project.analysis.constraints.create(expression='n2_austenite_scale = s2_austenite_scale')
project.analysis.aliases.create(
id='s2_ferrite_scale', param=expt_s2.linked_structures['ferrite'].scale
)
project.analysis.aliases.create(
id='s2_austenite_scale', param=expt_s2.linked_structures['austenite'].scale
)
project.analysis.aliases.create(
id='n2_ferrite_scale', param=expt_n2.linked_structures['ferrite'].scale
)
project.analysis.aliases.create(
id='n2_austenite_scale', param=expt_n2.linked_structures['austenite'].scale
)
project.analysis.constraints.create(expression='n2_ferrite_scale = s2_ferrite_scale')
project.analysis.constraints.create(expression='n2_austenite_scale = s2_austenite_scale')
Run Fitting¶
Run full fitting with all free parameters.
In [36]:
Copied!
project.analysis.fit()
project.analysis.fit()
Using all experiments 🔬 ['expt_s2', 'expt_n2'] for 'joint' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.06 | 589.93 | |
| 2 | 58 | 3.38 | 32.98 | 94.4% ↓ |
| 3 | 113 | 6.86 | 12.96 | 60.7% ↓ |
| 4 | 197 | 11.86 | 12.85 | |
| 5 | 278 | 16.87 | 12.85 | |
| 6 | 334 | 23.53 | 12.85 |
🏆 Best goodness-of-fit (reduced χ²) is 12.85 at iteration 333
✅ Fitting complete.
Saving project 📦 'beer_mcstas' to '../../../projects/calibrate-beer-ess'
├── 📄 project.edi
├── 📁 structures/
│ └── 📄 ferrite.edi
│ └── 📄 austenite.edi
├── 📁 experiments/
│ └── 📄 expt_s2.edi
│ └── 📄 expt_n2.edi
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 beer_mcstas.html
Fix background and run fitting again.
In [37]:
Copied!
for segment in expt_s2.background:
segment.intensity.free = False
for segment in expt_n2.background:
segment.intensity.free = False
for segment in expt_s2.background:
segment.intensity.free = False
for segment in expt_n2.background:
segment.intensity.free = False
In [38]:
Copied!
project.analysis.fit()
project.analysis.fit()
Using all experiments 🔬 ['expt_s2', 'expt_n2'] for 'joint' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit progress:
| iteration | time (s) | χ² | change / status | |
|---|---|---|---|---|
| 1 | 1 | 0.06 | 12.76 | |
| 2 | 19 | 1.14 | 12.76 |
🏆 Best goodness-of-fit (reduced χ²) is 12.76 at iteration 18
✅ Fitting complete.
Saving project 📦 'beer_mcstas' to '../../../projects/calibrate-beer-ess'
├── 📄 project.edi
├── 📁 structures/
│ └── 📄 ferrite.edi
│ └── 📄 austenite.edi
├── 📁 experiments/
│ └── 📄 expt_s2.edi
│ └── 📄 expt_n2.edi
├── 📁 analysis/
│ └── 📄 analysis.edi
└── 📁 reports/
└── 📄 beer_mcstas.html
Show fit results and parameter correlations.
In [39]:
Copied!
project.display.fit.results()
project.display.fit.correlations()
project.display.fit.results()
project.display.fit.correlations()
⚙️ 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) | 1.14 |
| 4 | 🔁 Iterations | 16 |
| 5 | 📏 Goodness-of-fit (reduced χ²) | 12.76 |
| 6 | 📏 R-factor (Rf, %) | 4.97 |
| 7 | 📏 R-factor squared (Rf², %) | 3.89 |
| 8 | 📏 Weighted R-factor (wR, %) | 3.40 |
📈 Refined parameters:
| datablock | category | entry | parameter | units | start | value | s.u. | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | ferrite | atom_site | Fe | adp_iso | Ų | 1.7191 | 1.7191 | 0.0126 | 0.00 % ↑ |
| 2 | austenite | atom_site | Fe | adp_iso | Ų | 1.7126 | 1.7126 | 0.0118 | 0.00 % ↑ |
| 3 | expt_s2 | linked_structure | ferrite | scale | 284.7197 | 284.7201 | 0.8354 | 0.00 % ↑ | |
| 4 | expt_s2 | linked_structure | austenite | scale | 67.9132 | 67.9133 | 0.1683 | 0.00 % ↑ | |
| 5 | expt_s2 | peak | broad_lorentz_gamma_0 | μs | 5.2351 | 5.2351 | 0.1470 | 0.00 % ↑ | |
| 6 | expt_s2 | peak | broad_gauss_sigma_0 | μs² | 884.3308 | 884.3524 | 56.2993 | 0.00 % ↑ | |
| 7 | expt_s2 | peak | broad_gauss_sigma_1 | μs/Å | 1284.1657 | 1284.1455 | 56.2420 | 0.00 % ↓ | |
| 8 | expt_s2 | peak | broad_gauss_sigma_2 | μs²/Ų | 311.1710 | 311.1747 | 11.1945 | 0.00 % ↑ | |
| 9 | expt_s2 | instrument | d_to_tof_offset | μs | -10.4533 | -10.4534 | 0.1176 | 0.00 % ↑ | |
| 10 | expt_n2 | peak | broad_lorentz_gamma_0 | μs | 5.2429 | 5.2429 | 0.1475 | 0.00 % ↑ | |
| 11 | expt_n2 | peak | broad_gauss_sigma_0 | μs² | 921.6972 | 921.7187 | 56.8582 | 0.00 % ↑ | |
| 12 | expt_n2 | peak | broad_gauss_sigma_1 | μs/Å | 1226.5363 | 1226.5159 | 56.8131 | 0.00 % ↓ | |
| 13 | expt_n2 | peak | broad_gauss_sigma_2 | μs²/Ų | 329.0370 | 329.0408 | 11.3113 | 0.00 % ↑ | |
| 14 | expt_n2 | instrument | d_to_tof_offset | μs | -2.2574 | -2.2574 | 0.1178 | 0.00 % ↑ |
• 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
Loading plot…
Display Pattern¶
Show full range in TOF.
In [40]:
Copied!
project.display.pattern(expt_name='expt_s2')
project.display.pattern(expt_name='expt_s2')
Loading plot…
In [41]:
Copied!
project.display.pattern(expt_name='expt_n2')
project.display.pattern(expt_name='expt_n2')
Loading plot…
Show selected peaks in d-spacing.
In [42]:
Copied!
project.display.pattern(
expt_name='expt_s2',
x='d_spacing',
x_min=2.08,
x_max=2.13,
)
project.display.pattern(
expt_name='expt_s2',
x='d_spacing',
x_min=2.08,
x_max=2.13,
)
Loading plot…
In [43]:
Copied!
project.display.pattern(
expt_name='expt_n2',
x='d_spacing',
x_min=2.08,
x_max=2.13,
)
project.display.pattern(
expt_name='expt_n2',
x='d_spacing',
x_min=2.08,
x_max=2.13,
)
Loading plot…