Structure Refinement: LBCO, HRPT¶
This example demonstrates how to use the EasyDiffraction API in a simplified, user-friendly manner that closely follows the GUI workflow for a Rietveld refinement of La0.5Ba0.5CoO3 crystal structure using constant wavelength neutron powder diffraction data from HRPT at PSI.
It is intended for users with minimal programming experience who want to learn how to perform standard crystal structure fitting using diffraction data. This script covers creating a project, adding sample models and experiments, performing analysis, and refining parameters.
Only a single import of easydiffraction
is required, and all operations are
performed through high-level components of the project
object, such as
project.sample_models
, project.experiments
, and project.analysis
.
The project
object is the main container for all information.
Import Library¶
import easydiffraction as ed
⚠️ 'pycrysfml' module not found. This calculation engine will not be available. ✅ 'cryspy' calculation engine is successfully imported. ✅ 'pdffit' calculation engine is successfully imported.
Step 1: Create a Project¶
This section explains how to create a project and define its metadata.
Create Project¶
project = ed.Project(name='lbco_hrpt')
Set Project Metadata¶
project.info.title = 'La0.5Ba0.5CoO3 at HRPT@PSI'
project.info.description = """This project demonstrates a standard
refinement of La0.5Ba0.5CoO3, which crystallizes in a perovskite-type
structure, using neutron powder diffraction data collected in constant
wavelength mode at the HRPT diffractometer (PSI)."""
Show Project Metadata as CIF¶
project.info.show_as_cif()
Project 📦 'lbco_hrpt' info as cif
_project.id lbco_hrpt |
_project.title 'La0.5Ba0.5CoO3 at HRPT@PSI' |
_project.description 'This project demonstrates a standard |
refinement of La0.5Ba0.5CoO3, which |
crystallizes in a perovskite-type structure, |
using neutron powder diffraction data |
collected in constant wavelength mode at the |
HRPT diffractometer (PSI).' |
_project.created '14 Aug 2025 13:26:19' |
_project.last_modified '14 Aug 2025 13:26:19' |
Save Project¶
When saving the project for the first time, you need to specify the directory path. In the example below, the project is saved to a temporary location defined by the system.
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ analysis.cif ✅ summary.cif
Set Up Data Plotter¶
Show supported plotting engines.
project.plotter.show_supported_engines()
Supported plotter engines
Engine | Description |
---|---|
asciichartpy |
Console ASCII line charts |
plotly |
Interactive browser-based graphing library |
Show current plotting configuration.
project.plotter.show_config()
Current plotter configuration
Parameter | Value |
---|---|
Plotting engine |
plotly |
x-axis limits |
[-inf, inf] |
Chart height |
9 |
Set plotting engine.
project.plotter.engine = 'plotly'
Current plotter changed to
plotly
Step 2: Define Sample Model¶
This section shows how to add sample models and modify their parameters.
Add Sample Model¶
project.sample_models.add(name='lbco')
Show Defined Sample Models¶
Show the names of the models added. These names are used to access the
model using the syntax: project.sample_models['model_name']
. All model
parameters can be accessed via the project
object.
project.sample_models.show_names()
Defined sample models 🧩
['lbco']
Set Space Group¶
Modify the default space group parameters.
project.sample_models['lbco'].space_group.name_h_m = 'P m -3 m'
project.sample_models['lbco'].space_group.it_coordinate_system_code = '1'
Set Unit Cell¶
Modify the default unit cell parameters.
project.sample_models['lbco'].cell.length_a = 3.88
Set Atom Sites¶
Add atom sites to the sample model.
project.sample_models['lbco'].atom_sites.add(
label='La',
type_symbol='La',
fract_x=0,
fract_y=0,
fract_z=0,
wyckoff_letter='a',
b_iso=0.5,
occupancy=0.5,
)
project.sample_models['lbco'].atom_sites.add(
label='Ba',
type_symbol='Ba',
fract_x=0,
fract_y=0,
fract_z=0,
wyckoff_letter='a',
b_iso=0.5,
occupancy=0.5,
)
project.sample_models['lbco'].atom_sites.add(
label='Co',
type_symbol='Co',
fract_x=0.5,
fract_y=0.5,
fract_z=0.5,
wyckoff_letter='b',
b_iso=0.5,
)
project.sample_models['lbco'].atom_sites.add(
label='O',
type_symbol='O',
fract_x=0,
fract_y=0.5,
fract_z=0.5,
wyckoff_letter='c',
b_iso=0.5,
)
Apply Symmetry Constraints¶
project.sample_models['lbco'].apply_symmetry_constraints()
Show Sample Model as CIF¶
project.sample_models['lbco'].show_as_cif()
Sample model 🧩 'lbco' as cif
data_lbco |
_space_group.IT_coordinate_system_code 1 |
_space_group.name_H-M_alt "P m -3 m" |
_cell.angle_alpha 90 |
_cell.angle_beta 90 |
_cell.angle_gamma 90 |
_cell.length_a 3.88 |
_cell.length_b 3.88 |
_cell.length_c 3.88 |
loop_ |
_atom_site.ADP_type |
_atom_site.B_iso_or_equiv |
_atom_site.fract_x |
_atom_site.fract_y |
_atom_site.fract_z |
_atom_site.label |
_atom_site.occupancy |
_atom_site.type_symbol |
_atom_site.Wyckoff_letter |
Biso 0.5 0.0 0.0 0.0 La 0.5 La a |
Biso 0.5 0.0 0.0 0.0 Ba 0.5 Ba a |
Biso 0.5 0.5 0.5 0.5 Co 1.0 Co b |
Biso 0.5 0.0 0.5 0.5 O 1.0 O c |
Show Sample Model Structure¶
project.sample_models['lbco'].show_structure()
Sample model 🧩 'lbco' structure view Not implemented yet.
Save Project State¶
Save the project state after adding the sample model. This ensures that all changes are stored and can be accessed later. The project state is saved in the directory specified during project creation.
project.save()
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ analysis.cif ✅ summary.cif
Step 3: Define Experiment¶
This section shows how to add experiments, configure their parameters, and link the sample models defined in the previous step.
Download Measured Data¶
Download the data file from the EasyDiffraction repository on GitHub.
ed.download_from_repository('hrpt_lbco.xye', destination='data')
⚠️ Warning
File 'data/hrpt_lbco.xye' already exists and will not be overwritten.
Add Diffraction Experiment¶
project.experiments.add(
name='hrpt',
sample_form='powder',
beam_mode='constant wavelength',
radiation_probe='neutron',
data_path='data/hrpt_lbco.xye',
)
Loading measured data from ASCII file /Users/runner/work/diffraction-lib/diffraction-lib/docs/tutorials/data/hrpt_lbco.xye Data loaded successfully Experiment 🔬 'hrpt'. Number of data points: 3098
Show Defined Experiments¶
project.experiments.show_names()
Defined experiments 🔬
['hrpt']
Show Measured Data¶
project.plot_meas(expt_name='hrpt')
Set Instrument¶
Modify the default instrument parameters.
project.experiments['hrpt'].instrument.setup_wavelength = 1.494
project.experiments['hrpt'].instrument.calib_twotheta_offset = 0.6
Set Peak Profile¶
Show supported peak profile types.
project.experiments['hrpt'].show_supported_peak_profile_types()
Supported peak profile types
Peak profile type | Description |
---|---|
pseudo-voigt |
Pseudo-Voigt profile |
split pseudo-voigt |
Split pseudo-Voigt profile |
thompson-cox-hastings |
Thompson-Cox-Hastings profile |
Show the current peak profile type.
project.experiments['hrpt'].show_current_peak_profile_type()
Current peak profile type
pseudo-voigt
Select the desired peak profile type.
project.experiments['hrpt'].peak_profile_type = 'pseudo-voigt'
Peak profile type for experiment 'hrpt' changed to pseudo-voigt
Modify default peak profile parameters.
project.experiments['hrpt'].peak.broad_gauss_u = 0.1
project.experiments['hrpt'].peak.broad_gauss_v = -0.1
project.experiments['hrpt'].peak.broad_gauss_w = 0.1
project.experiments['hrpt'].peak.broad_lorentz_x = 0
project.experiments['hrpt'].peak.broad_lorentz_y = 0.1
Set Background¶
Show supported background types.
project.experiments['hrpt'].show_supported_background_types()
Supported background types
Background type | Description |
---|---|
line-segment |
Linear interpolation between points |
chebyshev polynomial |
Chebyshev polynomial background |
Show current background type.
project.experiments['hrpt'].show_current_background_type()
Current background type
line-segment
Select the desired background type.
project.experiments['hrpt'].background_type = 'line-segment'
Background type for experiment 'hrpt' changed to line-segment
Add background points.
project.experiments['hrpt'].background.add(x=10, y=170)
project.experiments['hrpt'].background.add(x=30, y=170)
project.experiments['hrpt'].background.add(x=50, y=170)
project.experiments['hrpt'].background.add(x=110, y=170)
project.experiments['hrpt'].background.add(x=165, y=170)
Show current background points.
project.experiments['hrpt'].background.show()
Line-segment background points
X | Intensity |
---|---|
10 |
170 |
30 |
170 |
50 |
170 |
110 |
170 |
165 |
170 |
Set Linked Phases¶
Link the sample model defined in the previous step to the experiment.
project.experiments['hrpt'].linked_phases.add(id='lbco', scale=10.0)
Show Experiment as CIF¶
project.experiments['hrpt'].show_as_cif()
Experiment 🔬 'hrpt' as cif
data_hrpt |
_expt_type.beam_mode "constant wavelength" |
_expt_type.radiation_probe neutron |
_expt_type.sample_form powder |
_expt_type.scattering_type bragg |
_instr.2theta_offset 0.6 |
_instr.wavelength 1.494 |
_peak.broad_gauss_u 0.1 |
_peak.broad_gauss_v -0.1 |
_peak.broad_gauss_w 0.1 |
_peak.broad_lorentz_x 0 |
_peak.broad_lorentz_y 0.1 |
loop_ |
_pd_phase_block.id |
_pd_phase_block.scale |
lbco 10.0 |
loop_ |
_pd_background.line_segment_X |
_pd_background.line_segment_intensity |
10 170 |
30 170 |
50 170 |
110 170 |
165 170 |
loop_ |
_pd_meas.2theta_scan |
_pd_meas.intensity_total |
_pd_meas.intensity_total_su |
10.0 167.0 12.6 |
10.05 157.0 12.5 |
10.1 187.0 13.3 |
10.15 197.0 14.0 |
10.2 164.0 12.5 |
... |
164.65 173.0 30.1 |
164.7 187.0 27.9 |
164.75 175.0 38.2 |
164.8 168.0 30.9 |
164.85 109.0 41.2 |
Save Project State¶
project.save()
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt
✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
project.analysis.show_supported_calculators()
Supported calculators
Calculator | Description |
---|---|
cryspy |
CrysPy library for crystallographic calculations |
pdffit |
PDFfit2 library for pair distribution function calculations |
Show current calculation engine.
project.analysis.show_current_calculator()
Current calculator
cryspy
Select the desired calculation engine.
project.analysis.current_calculator = 'cryspy'
Current calculator changed to
cryspy
Show Calculated Data¶
project.plot_calc(expt_name='hrpt')
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Show Parameters¶
Show all parameters of the project.
project.analysis.show_all_params()
All parameters for all sample models (🧩 data blocks)
datablock | category | entry | parameter | value | fittable | |
---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
adp_type |
Biso |
False |
2 | lbco |
atom_sites |
La |
b_iso |
0.5000 |
True |
3 | lbco |
atom_sites |
La |
fract_x |
0.0000 |
True |
4 | lbco |
atom_sites |
La |
fract_y |
0.0000 |
True |
5 | lbco |
atom_sites |
La |
fract_z |
0.0000 |
True |
6 | lbco |
atom_sites |
La |
label |
La |
False |
7 | lbco |
atom_sites |
La |
occupancy |
0.5000 |
True |
8 | lbco |
atom_sites |
La |
type_symbol |
La |
False |
9 | lbco |
atom_sites |
La |
wyckoff_letter |
a |
False |
10 | lbco |
atom_sites |
Ba |
adp_type |
Biso |
False |
11 | lbco |
atom_sites |
Ba |
b_iso |
0.5000 |
True |
12 | lbco |
atom_sites |
Ba |
fract_x |
0.0000 |
True |
13 | lbco |
atom_sites |
Ba |
fract_y |
0.0000 |
True |
14 | lbco |
atom_sites |
Ba |
fract_z |
0.0000 |
True |
15 | lbco |
atom_sites |
Ba |
label |
Ba |
False |
16 | lbco |
atom_sites |
Ba |
occupancy |
0.5000 |
True |
17 | lbco |
atom_sites |
Ba |
type_symbol |
Ba |
False |
18 | lbco |
atom_sites |
Ba |
wyckoff_letter |
a |
False |
19 | lbco |
atom_sites |
Co |
adp_type |
Biso |
False |
20 | lbco |
atom_sites |
Co |
b_iso |
0.5000 |
True |
21 | lbco |
atom_sites |
Co |
fract_x |
0.5000 |
True |
22 | lbco |
atom_sites |
Co |
fract_y |
0.5000 |
True |
23 | lbco |
atom_sites |
Co |
fract_z |
0.5000 |
True |
24 | lbco |
atom_sites |
Co |
label |
Co |
False |
25 | lbco |
atom_sites |
Co |
occupancy |
1.0000 |
True |
26 | lbco |
atom_sites |
Co |
type_symbol |
Co |
False |
27 | lbco |
atom_sites |
Co |
wyckoff_letter |
b |
False |
28 | lbco |
atom_sites |
O |
adp_type |
Biso |
False |
29 | lbco |
atom_sites |
O |
b_iso |
0.5000 |
True |
30 | lbco |
atom_sites |
O |
fract_x |
0.0000 |
True |
31 | lbco |
atom_sites |
O |
fract_y |
0.5000 |
True |
32 | lbco |
atom_sites |
O |
fract_z |
0.5000 |
True |
33 | lbco |
atom_sites |
O |
label |
O |
False |
34 | lbco |
atom_sites |
O |
occupancy |
1.0000 |
True |
35 | lbco |
atom_sites |
O |
type_symbol |
O |
False |
36 | lbco |
atom_sites |
O |
wyckoff_letter |
c |
False |
37 | lbco |
cell |
angle_alpha |
90.0000 |
True |
|
38 | lbco |
cell |
angle_beta |
90.0000 |
True |
|
39 | lbco |
cell |
angle_gamma |
90.0000 |
True |
|
40 | lbco |
cell |
length_a |
3.8800 |
True |
|
41 | lbco |
cell |
length_b |
3.8800 |
True |
|
42 | lbco |
cell |
length_c |
3.8800 |
True |
|
43 | lbco |
space_group |
it_coordinate_system_code |
1 |
False |
|
44 | lbco |
space_group |
name_h_m |
P m -3 m |
False |
All parameters for all experiments (🔬 data blocks)
datablock | category | entry | parameter | value | fittable | |
---|---|---|---|---|---|---|
1 | hrpt |
background |
10 |
x |
10 |
False |
2 | hrpt |
background |
10 |
y |
170.0000 |
True |
3 | hrpt |
background |
30 |
x |
30 |
False |
4 | hrpt |
background |
30 |
y |
170.0000 |
True |
5 | hrpt |
background |
50 |
x |
50 |
False |
6 | hrpt |
background |
50 |
y |
170.0000 |
True |
7 | hrpt |
background |
110 |
x |
110 |
False |
8 | hrpt |
background |
110 |
y |
170.0000 |
True |
9 | hrpt |
background |
165 |
x |
165 |
False |
10 | hrpt |
background |
165 |
y |
170.0000 |
True |
11 | hrpt |
instrument |
twotheta_offset |
0.6000 |
True |
|
12 | hrpt |
instrument |
wavelength |
1.4940 |
True |
|
13 | hrpt |
linked_phases |
lbco |
id |
lbco |
False |
14 | hrpt |
linked_phases |
lbco |
scale |
10.0000 |
True |
15 | hrpt |
peak |
broad_gauss_u |
0.1000 |
True |
|
16 | hrpt |
peak |
broad_gauss_v |
-0.1000 |
True |
|
17 | hrpt |
peak |
broad_gauss_w |
0.1000 |
True |
|
18 | hrpt |
peak |
broad_lorentz_x |
0.0000 |
True |
|
19 | hrpt |
peak |
broad_lorentz_y |
0.1000 |
True |
|
20 | hrpt |
expt_type |
beam_mode |
constant wavelength |
False |
|
21 | hrpt |
expt_type |
radiation_probe |
neutron |
False |
|
22 | hrpt |
expt_type |
sample_form |
powder |
False |
|
23 | hrpt |
expt_type |
scattering_type |
bragg |
False |
Show all fittable parameters.
project.analysis.show_fittable_params()
Fittable parameters for all sample models (🧩 data blocks)
datablock | category | entry | parameter | value | uncertainty | units | free | |
---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5000 |
Ų |
False |
|
2 | lbco |
atom_sites |
La |
fract_x |
0.0000 |
False |
||
3 | lbco |
atom_sites |
La |
fract_y |
0.0000 |
False |
||
4 | lbco |
atom_sites |
La |
fract_z |
0.0000 |
False |
||
5 | lbco |
atom_sites |
La |
occupancy |
0.5000 |
False |
||
6 | lbco |
atom_sites |
Ba |
b_iso |
0.5000 |
Ų |
False |
|
7 | lbco |
atom_sites |
Ba |
fract_x |
0.0000 |
False |
||
8 | lbco |
atom_sites |
Ba |
fract_y |
0.0000 |
False |
||
9 | lbco |
atom_sites |
Ba |
fract_z |
0.0000 |
False |
||
10 | lbco |
atom_sites |
Ba |
occupancy |
0.5000 |
False |
||
11 | lbco |
atom_sites |
Co |
b_iso |
0.5000 |
Ų |
False |
|
12 | lbco |
atom_sites |
Co |
fract_x |
0.5000 |
False |
||
13 | lbco |
atom_sites |
Co |
fract_y |
0.5000 |
False |
||
14 | lbco |
atom_sites |
Co |
fract_z |
0.5000 |
False |
||
15 | lbco |
atom_sites |
Co |
occupancy |
1.0000 |
False |
||
16 | lbco |
atom_sites |
O |
b_iso |
0.5000 |
Ų |
False |
|
17 | lbco |
atom_sites |
O |
fract_x |
0.0000 |
False |
||
18 | lbco |
atom_sites |
O |
fract_y |
0.5000 |
False |
||
19 | lbco |
atom_sites |
O |
fract_z |
0.5000 |
False |
||
20 | lbco |
atom_sites |
O |
occupancy |
1.0000 |
False |
||
21 | lbco |
cell |
angle_alpha |
90.0000 |
deg |
False |
||
22 | lbco |
cell |
angle_beta |
90.0000 |
deg |
False |
||
23 | lbco |
cell |
angle_gamma |
90.0000 |
deg |
False |
||
24 | lbco |
cell |
length_a |
3.8800 |
Å |
False |
||
25 | lbco |
cell |
length_b |
3.8800 |
Å |
False |
||
26 | lbco |
cell |
length_c |
3.8800 |
Å |
False |
Fittable parameters for all experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | units | free | |
---|---|---|---|---|---|---|---|---|
1 | hrpt |
background |
10 |
y |
170.0000 |
False |
||
2 | hrpt |
background |
30 |
y |
170.0000 |
False |
||
3 | hrpt |
background |
50 |
y |
170.0000 |
False |
||
4 | hrpt |
background |
110 |
y |
170.0000 |
False |
||
5 | hrpt |
background |
165 |
y |
170.0000 |
False |
||
6 | hrpt |
instrument |
twotheta_offset |
0.6000 |
deg |
False |
||
7 | hrpt |
instrument |
wavelength |
1.4940 |
Å |
False |
||
8 | hrpt |
linked_phases |
lbco |
scale |
10.0000 |
False |
||
9 | hrpt |
peak |
broad_gauss_u |
0.1000 |
deg² |
False |
||
10 | hrpt |
peak |
broad_gauss_v |
-0.1000 |
deg² |
False |
||
11 | hrpt |
peak |
broad_gauss_w |
0.1000 |
deg² |
False |
||
12 | hrpt |
peak |
broad_lorentz_x |
0.0000 |
deg |
False |
||
13 | hrpt |
peak |
broad_lorentz_y |
0.1000 |
deg |
False |
Show only free parameters.
project.analysis.show_free_params()
⚠️ Warning
No free parameters found.
Show how to access parameters in the code.
project.analysis.how_to_access_parameters()
How to access parameters
datablock | category | entry | parameter | How to Access in Python Code | Unique Identifier for CIF Constraints | |
---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
adp_type |
project.sample_models['lbco'].atom_sites['La'].adp_type |
lbco.atom_site.La.ADP_type |
2 | lbco |
atom_sites |
La |
b_iso |
project.sample_models['lbco'].atom_sites['La'].b_iso |
lbco.atom_site.La.B_iso_or_equiv |
3 | lbco |
atom_sites |
La |
fract_x |
project.sample_models['lbco'].atom_sites['La'].fract_x |
lbco.atom_site.La.fract_x |
4 | lbco |
atom_sites |
La |
fract_y |
project.sample_models['lbco'].atom_sites['La'].fract_y |
lbco.atom_site.La.fract_y |
5 | lbco |
atom_sites |
La |
fract_z |
project.sample_models['lbco'].atom_sites['La'].fract_z |
lbco.atom_site.La.fract_z |
6 | lbco |
atom_sites |
La |
label |
project.sample_models['lbco'].atom_sites['La'].label |
lbco.atom_site.La.label |
7 | lbco |
atom_sites |
La |
occupancy |
project.sample_models['lbco'].atom_sites['La'].occupancy |
lbco.atom_site.La.occupancy |
8 | lbco |
atom_sites |
La |
type_symbol |
project.sample_models['lbco'].atom_sites['La'].type_symbol |
lbco.atom_site.La.type_symbol |
9 | lbco |
atom_sites |
La |
wyckoff_letter |
project.sample_models['lbco'].atom_sites['La'].wyckoff_letter |
lbco.atom_site.La.Wyckoff_letter |
10 | lbco |
atom_sites |
Ba |
adp_type |
project.sample_models['lbco'].atom_sites['Ba'].adp_type |
lbco.atom_site.Ba.ADP_type |
11 | lbco |
atom_sites |
Ba |
b_iso |
project.sample_models['lbco'].atom_sites['Ba'].b_iso |
lbco.atom_site.Ba.B_iso_or_equiv |
12 | lbco |
atom_sites |
Ba |
fract_x |
project.sample_models['lbco'].atom_sites['Ba'].fract_x |
lbco.atom_site.Ba.fract_x |
13 | lbco |
atom_sites |
Ba |
fract_y |
project.sample_models['lbco'].atom_sites['Ba'].fract_y |
lbco.atom_site.Ba.fract_y |
14 | lbco |
atom_sites |
Ba |
fract_z |
project.sample_models['lbco'].atom_sites['Ba'].fract_z |
lbco.atom_site.Ba.fract_z |
15 | lbco |
atom_sites |
Ba |
label |
project.sample_models['lbco'].atom_sites['Ba'].label |
lbco.atom_site.Ba.label |
16 | lbco |
atom_sites |
Ba |
occupancy |
project.sample_models['lbco'].atom_sites['Ba'].occupancy |
lbco.atom_site.Ba.occupancy |
17 | lbco |
atom_sites |
Ba |
type_symbol |
project.sample_models['lbco'].atom_sites['Ba'].type_symbol |
lbco.atom_site.Ba.type_symbol |
18 | lbco |
atom_sites |
Ba |
wyckoff_letter |
project.sample_models['lbco'].atom_sites['Ba'].wyckoff_letter |
lbco.atom_site.Ba.Wyckoff_letter |
19 | lbco |
atom_sites |
Co |
adp_type |
project.sample_models['lbco'].atom_sites['Co'].adp_type |
lbco.atom_site.Co.ADP_type |
20 | lbco |
atom_sites |
Co |
b_iso |
project.sample_models['lbco'].atom_sites['Co'].b_iso |
lbco.atom_site.Co.B_iso_or_equiv |
21 | lbco |
atom_sites |
Co |
fract_x |
project.sample_models['lbco'].atom_sites['Co'].fract_x |
lbco.atom_site.Co.fract_x |
22 | lbco |
atom_sites |
Co |
fract_y |
project.sample_models['lbco'].atom_sites['Co'].fract_y |
lbco.atom_site.Co.fract_y |
23 | lbco |
atom_sites |
Co |
fract_z |
project.sample_models['lbco'].atom_sites['Co'].fract_z |
lbco.atom_site.Co.fract_z |
24 | lbco |
atom_sites |
Co |
label |
project.sample_models['lbco'].atom_sites['Co'].label |
lbco.atom_site.Co.label |
25 | lbco |
atom_sites |
Co |
occupancy |
project.sample_models['lbco'].atom_sites['Co'].occupancy |
lbco.atom_site.Co.occupancy |
26 | lbco |
atom_sites |
Co |
type_symbol |
project.sample_models['lbco'].atom_sites['Co'].type_symbol |
lbco.atom_site.Co.type_symbol |
27 | lbco |
atom_sites |
Co |
wyckoff_letter |
project.sample_models['lbco'].atom_sites['Co'].wyckoff_letter |
lbco.atom_site.Co.Wyckoff_letter |
28 | lbco |
atom_sites |
O |
adp_type |
project.sample_models['lbco'].atom_sites['O'].adp_type |
lbco.atom_site.O.ADP_type |
29 | lbco |
atom_sites |
O |
b_iso |
project.sample_models['lbco'].atom_sites['O'].b_iso |
lbco.atom_site.O.B_iso_or_equiv |
30 | lbco |
atom_sites |
O |
fract_x |
project.sample_models['lbco'].atom_sites['O'].fract_x |
lbco.atom_site.O.fract_x |
31 | lbco |
atom_sites |
O |
fract_y |
project.sample_models['lbco'].atom_sites['O'].fract_y |
lbco.atom_site.O.fract_y |
32 | lbco |
atom_sites |
O |
fract_z |
project.sample_models['lbco'].atom_sites['O'].fract_z |
lbco.atom_site.O.fract_z |
33 | lbco |
atom_sites |
O |
label |
project.sample_models['lbco'].atom_sites['O'].label |
lbco.atom_site.O.label |
34 | lbco |
atom_sites |
O |
occupancy |
project.sample_models['lbco'].atom_sites['O'].occupancy |
lbco.atom_site.O.occupancy |
35 | lbco |
atom_sites |
O |
type_symbol |
project.sample_models['lbco'].atom_sites['O'].type_symbol |
lbco.atom_site.O.type_symbol |
36 | lbco |
atom_sites |
O |
wyckoff_letter |
project.sample_models['lbco'].atom_sites['O'].wyckoff_letter |
lbco.atom_site.O.Wyckoff_letter |
37 | lbco |
cell |
angle_alpha |
project.sample_models['lbco'].cell.angle_alpha |
lbco.cell.angle_alpha |
|
38 | lbco |
cell |
angle_beta |
project.sample_models['lbco'].cell.angle_beta |
lbco.cell.angle_beta |
|
39 | lbco |
cell |
angle_gamma |
project.sample_models['lbco'].cell.angle_gamma |
lbco.cell.angle_gamma |
|
40 | lbco |
cell |
length_a |
project.sample_models['lbco'].cell.length_a |
lbco.cell.length_a |
|
41 | lbco |
cell |
length_b |
project.sample_models['lbco'].cell.length_b |
lbco.cell.length_b |
|
42 | lbco |
cell |
length_c |
project.sample_models['lbco'].cell.length_c |
lbco.cell.length_c |
|
43 | lbco |
space_group |
it_coordinate_system_code |
project.sample_models['lbco'].space_group.it_coordinate_system_code |
lbco.space_group.IT_coordinate_system_code |
|
44 | lbco |
space_group |
name_h_m |
project.sample_models['lbco'].space_group.name_h_m |
lbco.space_group.name_H-M_alt |
|
45 | hrpt |
background |
10 |
x |
project.experiments['hrpt'].background['10'].x |
hrpt.pd_background.10.line_segment_X |
46 | hrpt |
background |
10 |
y |
project.experiments['hrpt'].background['10'].y |
hrpt.pd_background.10.line_segment_intensity |
47 | hrpt |
background |
30 |
x |
project.experiments['hrpt'].background['30'].x |
hrpt.pd_background.30.line_segment_X |
48 | hrpt |
background |
30 |
y |
project.experiments['hrpt'].background['30'].y |
hrpt.pd_background.30.line_segment_intensity |
49 | hrpt |
background |
50 |
x |
project.experiments['hrpt'].background['50'].x |
hrpt.pd_background.50.line_segment_X |
50 | hrpt |
background |
50 |
y |
project.experiments['hrpt'].background['50'].y |
hrpt.pd_background.50.line_segment_intensity |
51 | hrpt |
background |
110 |
x |
project.experiments['hrpt'].background['110'].x |
hrpt.pd_background.110.line_segment_X |
52 | hrpt |
background |
110 |
y |
project.experiments['hrpt'].background['110'].y |
hrpt.pd_background.110.line_segment_intensity |
53 | hrpt |
background |
165 |
x |
project.experiments['hrpt'].background['165'].x |
hrpt.pd_background.165.line_segment_X |
54 | hrpt |
background |
165 |
y |
project.experiments['hrpt'].background['165'].y |
hrpt.pd_background.165.line_segment_intensity |
55 | hrpt |
instrument |
twotheta_offset |
project.experiments['hrpt'].instrument.twotheta_offset |
hrpt.instr.2theta_offset |
|
56 | hrpt |
instrument |
wavelength |
project.experiments['hrpt'].instrument.wavelength |
hrpt.instr.wavelength |
|
57 | hrpt |
linked_phases |
lbco |
id |
project.experiments['hrpt'].linked_phases['lbco'].id |
hrpt.pd_phase_block.lbco.id |
58 | hrpt |
linked_phases |
lbco |
scale |
project.experiments['hrpt'].linked_phases['lbco'].scale |
hrpt.pd_phase_block.lbco.scale |
59 | hrpt |
peak |
broad_gauss_u |
project.experiments['hrpt'].peak.broad_gauss_u |
hrpt.peak.broad_gauss_u |
|
60 | hrpt |
peak |
broad_gauss_v |
project.experiments['hrpt'].peak.broad_gauss_v |
hrpt.peak.broad_gauss_v |
|
61 | hrpt |
peak |
broad_gauss_w |
project.experiments['hrpt'].peak.broad_gauss_w |
hrpt.peak.broad_gauss_w |
|
62 | hrpt |
peak |
broad_lorentz_x |
project.experiments['hrpt'].peak.broad_lorentz_x |
hrpt.peak.broad_lorentz_x |
|
63 | hrpt |
peak |
broad_lorentz_y |
project.experiments['hrpt'].peak.broad_lorentz_y |
hrpt.peak.broad_lorentz_y |
|
64 | hrpt |
expt_type |
beam_mode |
project.experiments['hrpt'].expt_type.beam_mode |
hrpt.expt_type.beam_mode |
|
65 | hrpt |
expt_type |
radiation_probe |
project.experiments['hrpt'].expt_type.radiation_probe |
hrpt.expt_type.radiation_probe |
|
66 | hrpt |
expt_type |
sample_form |
project.experiments['hrpt'].expt_type.sample_form |
hrpt.expt_type.sample_form |
|
67 | hrpt |
expt_type |
scattering_type |
project.experiments['hrpt'].expt_type.scattering_type |
hrpt.expt_type.scattering_type |
Set Fit Mode¶
Show supported fit modes.
project.analysis.show_available_fit_modes()
Available fit modes
Strategy | Description |
---|---|
single |
Independent fitting of each experiment; no shared parameters |
joint |
Simultaneous fitting of all experiments; some parameters are shared |
Show current fit mode.
project.analysis.show_current_fit_mode()
Current fit mode
single
Select desired fit mode.
project.analysis.fit_mode = 'single'
Current fit mode changed to
single
Set Minimizer¶
Show supported fitting engines.
project.analysis.show_available_minimizers()
Supported minimizers
Minimizer | Description |
---|---|
lmfit |
LMFIT library using the default Levenberg-Marquardt least squares method |
lmfit (leastsq) |
LMFIT library with Levenberg-Marquardt least squares method |
lmfit (least_squares) |
LMFIT library with SciPy’s trust region reflective algorithm |
dfols |
DFO-LS library for derivative-free least-squares optimization |
Show current fitting engine.
project.analysis.show_current_minimizer()
Current minimizer
lmfit (leastsq)
Select desired fitting engine.
project.analysis.current_minimizer = 'lmfit (leastsq)'
Current minimizer changed to
lmfit (leastsq)
Perform Fit 1/5¶
Set sample model parameters to be refined.
project.sample_models['lbco'].cell.length_a.free = True
Set experiment parameters to be refined.
project.experiments['hrpt'].linked_phases['lbco'].scale.free = True
project.experiments['hrpt'].instrument.calib_twotheta_offset.free = True
project.experiments['hrpt'].background['10'].y.free = True
project.experiments['hrpt'].background['30'].y.free = True
project.experiments['hrpt'].background['50'].y.free = True
project.experiments['hrpt'].background['110'].y.free = True
project.experiments['hrpt'].background['165'].y.free = True
Show free parameters after selection.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
cell |
length_a |
3.8800 |
Å |
||||
2 | hrpt |
background |
10 |
y |
170.0000 |
||||
3 | hrpt |
background |
30 |
y |
170.0000 |
||||
4 | hrpt |
background |
50 |
y |
170.0000 |
||||
5 | hrpt |
background |
110 |
y |
170.0000 |
||||
6 | hrpt |
background |
165 |
y |
170.0000 |
||||
7 | hrpt |
instrument |
twotheta_offset |
0.6000 |
deg |
||||
8 | hrpt |
linked_phases |
lbco |
scale |
10.0000 |
Run Fitting¶
project.analysis.fit()
Using experiment 🔬 'hrpt' for 'single' fitting 🚀 Starting fit process with 'lmfit (leastsq)'... 📈 Goodness-of-fit (reduced χ²) change:
iteration | χ² | improvement [%] |
---|---|---|
1 |
164.59 |
|
12 |
33.43 |
79.7% ↓ |
21 |
13.22 |
60.4% ↓ |
30 |
5.78 |
56.3% ↓ |
39 |
3.15 |
45.6% ↓ |
77 |
3.14 |
🏆 Best goodness-of-fit (reduced χ²) is 3.14 at iteration 73
✅ Fitting complete.
Fit results
✅ Success: True
⏱️ Fitting time: 0.68 seconds
📏 Goodness-of-fit (reduced χ²): 3.14
📏 R-factor (Rf): 8.42%
📏 R-factor squared (Rf²): 11.79%
📏 Weighted R-factor (wR): 11.62%
📈 Fitted parameters:
datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
cell |
length_a |
3.8800 |
3.8910 |
0.0001 |
Å |
0.28 % ↑ |
|
2 | hrpt |
background |
10 |
y |
170.0000 |
167.7066 |
2.1300 |
1.35 % ↓ |
|
3 | hrpt |
background |
30 |
y |
170.0000 |
166.0338 |
1.5404 |
2.33 % ↓ |
|
4 | hrpt |
background |
50 |
y |
170.0000 |
169.9495 |
1.1025 |
0.03 % ↓ |
|
5 | hrpt |
background |
110 |
y |
170.0000 |
170.0802 |
0.9788 |
0.05 % ↑ |
|
6 | hrpt |
background |
165 |
y |
170.0000 |
179.6656 |
1.3289 |
5.69 % ↑ |
|
7 | hrpt |
instrument |
twotheta_offset |
0.6000 |
0.6243 |
0.0018 |
deg |
4.05 % ↑ |
|
8 | hrpt |
linked_phases |
lbco |
scale |
10.0000 |
7.3409 |
0.0350 |
26.59 % ↓ |
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Save Project State¶
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
Perform Fit 2/5¶
Set more parameters to be refined.
project.experiments['hrpt'].peak.broad_gauss_u.free = True
project.experiments['hrpt'].peak.broad_gauss_v.free = True
project.experiments['hrpt'].peak.broad_gauss_w.free = True
project.experiments['hrpt'].peak.broad_lorentz_y.free = True
Show free parameters after selection.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
cell |
length_a |
3.8910 |
0.0001 |
Å |
|||
2 | hrpt |
background |
10 |
y |
167.7066 |
2.1300 |
|||
3 | hrpt |
background |
30 |
y |
166.0338 |
1.5404 |
|||
4 | hrpt |
background |
50 |
y |
169.9495 |
1.1025 |
|||
5 | hrpt |
background |
110 |
y |
170.0802 |
0.9788 |
|||
6 | hrpt |
background |
165 |
y |
179.6656 |
1.3289 |
|||
7 | hrpt |
instrument |
twotheta_offset |
0.6243 |
0.0018 |
deg |
|||
8 | hrpt |
linked_phases |
lbco |
scale |
7.3409 |
0.0350 |
|||
9 | hrpt |
peak |
broad_gauss_u |
0.1000 |
deg² |
||||
10 | hrpt |
peak |
broad_gauss_v |
-0.1000 |
deg² |
||||
11 | hrpt |
peak |
broad_gauss_w |
0.1000 |
deg² |
||||
12 | hrpt |
peak |
broad_lorentz_y |
0.1000 |
deg |
Run Fitting¶
project.analysis.fit()
Using experiment 🔬 'hrpt' for 'single' fitting 🚀 Starting fit process with 'lmfit (leastsq)'... 📈 Goodness-of-fit (reduced χ²) change:
iteration | χ² | improvement [%] |
---|---|---|
1 |
3.14 |
|
16 |
2.85 |
9.1% ↓ |
69 |
2.85 |
🏆 Best goodness-of-fit (reduced χ²) is 2.85 at iteration 68
✅ Fitting complete.
Fit results
✅ Success: True
⏱️ Fitting time: 0.58 seconds
📏 Goodness-of-fit (reduced χ²): 2.85
📏 R-factor (Rf): 8.30%
📏 R-factor squared (Rf²): 11.85%
📏 Weighted R-factor (wR): 11.91%
📈 Fitted parameters:
datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
cell |
length_a |
3.8910 |
3.8909 |
0.0001 |
Å |
0.00 % ↓ |
|
2 | hrpt |
background |
10 |
y |
167.7066 |
167.5167 |
2.0311 |
0.11 % ↓ |
|
3 | hrpt |
background |
30 |
y |
166.0338 |
166.7627 |
1.4794 |
0.44 % ↑ |
|
4 | hrpt |
background |
50 |
y |
169.9495 |
170.8330 |
1.0808 |
0.52 % ↑ |
|
5 | hrpt |
background |
110 |
y |
170.0802 |
172.2546 |
0.9660 |
1.28 % ↑ |
|
6 | hrpt |
background |
165 |
y |
179.6656 |
180.6405 |
1.2737 |
0.54 % ↑ |
|
7 | hrpt |
instrument |
twotheta_offset |
0.6243 |
0.6231 |
0.0017 |
deg |
0.19 % ↓ |
|
8 | hrpt |
linked_phases |
lbco |
scale |
7.3409 |
7.2120 |
0.0406 |
1.76 % ↓ |
|
9 | hrpt |
peak |
broad_gauss_u |
0.1000 |
0.0803 |
0.0047 |
deg² |
19.74 % ↓ |
|
10 | hrpt |
peak |
broad_gauss_v |
-0.1000 |
-0.1029 |
0.0104 |
deg² |
2.93 % ↑ |
|
11 | hrpt |
peak |
broad_gauss_w |
0.1000 |
0.1077 |
0.0051 |
deg² |
7.66 % ↑ |
|
12 | hrpt |
peak |
broad_lorentz_y |
0.1000 |
0.0893 |
0.0032 |
deg |
10.67 % ↓ |
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Save Project State¶
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
Perform Fit 3/5¶
Set more parameters to be refined.
project.sample_models['lbco'].atom_sites['La'].b_iso.free = True
project.sample_models['lbco'].atom_sites['Ba'].b_iso.free = True
project.sample_models['lbco'].atom_sites['Co'].b_iso.free = True
project.sample_models['lbco'].atom_sites['O'].b_iso.free = True
Show free parameters after selection.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5000 |
Ų |
|||
2 | lbco |
atom_sites |
Ba |
b_iso |
0.5000 |
Ų |
|||
3 | lbco |
atom_sites |
Co |
b_iso |
0.5000 |
Ų |
|||
4 | lbco |
atom_sites |
O |
b_iso |
0.5000 |
Ų |
|||
5 | lbco |
cell |
length_a |
3.8909 |
0.0001 |
Å |
|||
6 | hrpt |
background |
10 |
y |
167.5167 |
2.0311 |
|||
7 | hrpt |
background |
30 |
y |
166.7627 |
1.4794 |
|||
8 | hrpt |
background |
50 |
y |
170.8330 |
1.0808 |
|||
9 | hrpt |
background |
110 |
y |
172.2546 |
0.9660 |
|||
10 | hrpt |
background |
165 |
y |
180.6405 |
1.2737 |
|||
11 | hrpt |
instrument |
twotheta_offset |
0.6231 |
0.0017 |
deg |
|||
12 | hrpt |
linked_phases |
lbco |
scale |
7.2120 |
0.0406 |
|||
13 | hrpt |
peak |
broad_gauss_u |
0.0803 |
0.0047 |
deg² |
|||
14 | hrpt |
peak |
broad_gauss_v |
-0.1029 |
0.0104 |
deg² |
|||
15 | hrpt |
peak |
broad_gauss_w |
0.1077 |
0.0051 |
deg² |
|||
16 | hrpt |
peak |
broad_lorentz_y |
0.0893 |
0.0032 |
deg |
Run Fitting¶
project.analysis.fit()
Using experiment 🔬 'hrpt' for 'single' fitting 🚀 Starting fit process with 'lmfit (leastsq)'... 📈 Goodness-of-fit (reduced χ²) change:
iteration | χ² | improvement [%] |
---|---|---|
1 |
2.85 |
|
28 |
2.28 |
19.9% ↓ |
45 |
1.62 |
28.9% ↓ |
62 |
1.47 |
9.6% ↓ |
79 |
1.36 |
7.0% ↓ |
97 |
1.29 |
5.4% ↓ |
204 |
1.29 |
🏆 Best goodness-of-fit (reduced χ²) is 1.29 at iteration 186
✅ Fitting complete.
Fit results
✅ Success: True
⏱️ Fitting time: 1.69 seconds
📏 Goodness-of-fit (reduced χ²): 1.29
📏 R-factor (Rf): 5.63%
📏 R-factor squared (Rf²): 5.27%
📏 Weighted R-factor (wR): 4.41%
📈 Fitted parameters:
datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5000 |
0.5051 |
1216.0297 |
Ų |
1.02 % ↑ |
2 | lbco |
atom_sites |
Ba |
b_iso |
0.5000 |
0.5048 |
1976.1470 |
Ų |
0.96 % ↑ |
3 | lbco |
atom_sites |
Co |
b_iso |
0.5000 |
0.2371 |
0.0612 |
Ų |
52.59 % ↓ |
4 | lbco |
atom_sites |
O |
b_iso |
0.5000 |
1.3935 |
0.0167 |
Ų |
178.71 % ↑ |
5 | lbco |
cell |
length_a |
3.8909 |
3.8909 |
0.0000 |
Å |
0.00 % ↓ |
|
6 | hrpt |
background |
10 |
y |
167.5167 |
168.5585 |
1.3671 |
0.62 % ↑ |
|
7 | hrpt |
background |
30 |
y |
166.7627 |
164.3357 |
0.9992 |
1.46 % ↓ |
|
8 | hrpt |
background |
50 |
y |
170.8330 |
166.8881 |
0.7388 |
2.31 % ↓ |
|
9 | hrpt |
background |
110 |
y |
172.2546 |
175.4004 |
0.6571 |
1.83 % ↑ |
|
10 | hrpt |
background |
165 |
y |
180.6405 |
174.2811 |
0.9113 |
3.52 % ↓ |
|
11 | hrpt |
instrument |
twotheta_offset |
0.6231 |
0.6226 |
0.0010 |
deg |
0.09 % ↓ |
|
12 | hrpt |
linked_phases |
lbco |
scale |
7.2120 |
9.1350 |
0.0641 |
26.66 % ↑ |
|
13 | hrpt |
peak |
broad_gauss_u |
0.0803 |
0.0816 |
0.0031 |
deg² |
1.63 % ↑ |
|
14 | hrpt |
peak |
broad_gauss_v |
-0.1029 |
-0.1159 |
0.0067 |
deg² |
12.62 % ↑ |
|
15 | hrpt |
peak |
broad_gauss_w |
0.1077 |
0.1204 |
0.0033 |
deg² |
11.88 % ↑ |
|
16 | hrpt |
peak |
broad_lorentz_y |
0.0893 |
0.0844 |
0.0021 |
deg |
5.47 % ↓ |
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Save Project State¶
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
project.analysis.aliases.add(label='biso_La', param_uid=project.sample_models['lbco'].atom_sites['La'].b_iso.uid)
project.analysis.aliases.add(label='biso_Ba', param_uid=project.sample_models['lbco'].atom_sites['Ba'].b_iso.uid)
Set constraints.
project.analysis.constraints.add(lhs_alias='biso_Ba', rhs_expr='biso_La')
Show defined constraints.
project.analysis.show_constraints()
User defined constraints
lhs_alias | rhs_expr | full expression |
---|---|---|
biso_Ba |
biso_La |
biso_Ba = biso_La |
Show free parameters before applying constraints.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5051 |
1216.0297 |
Ų |
||
2 | lbco |
atom_sites |
Ba |
b_iso |
0.5048 |
1976.1470 |
Ų |
||
3 | lbco |
atom_sites |
Co |
b_iso |
0.2371 |
0.0612 |
Ų |
||
4 | lbco |
atom_sites |
O |
b_iso |
1.3935 |
0.0167 |
Ų |
||
5 | lbco |
cell |
length_a |
3.8909 |
0.0000 |
Å |
|||
6 | hrpt |
background |
10 |
y |
168.5585 |
1.3671 |
|||
7 | hrpt |
background |
30 |
y |
164.3357 |
0.9992 |
|||
8 | hrpt |
background |
50 |
y |
166.8881 |
0.7388 |
|||
9 | hrpt |
background |
110 |
y |
175.4004 |
0.6571 |
|||
10 | hrpt |
background |
165 |
y |
174.2811 |
0.9113 |
|||
11 | hrpt |
instrument |
twotheta_offset |
0.6226 |
0.0010 |
deg |
|||
12 | hrpt |
linked_phases |
lbco |
scale |
9.1350 |
0.0641 |
|||
13 | hrpt |
peak |
broad_gauss_u |
0.0816 |
0.0031 |
deg² |
|||
14 | hrpt |
peak |
broad_gauss_v |
-0.1159 |
0.0067 |
deg² |
|||
15 | hrpt |
peak |
broad_gauss_w |
0.1204 |
0.0033 |
deg² |
|||
16 | hrpt |
peak |
broad_lorentz_y |
0.0844 |
0.0021 |
deg |
Apply constraints.
project.analysis.apply_constraints()
Show free parameters after applying constraints.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5051 |
1216.0297 |
Ų |
||
2 | lbco |
atom_sites |
Co |
b_iso |
0.2371 |
0.0612 |
Ų |
||
3 | lbco |
atom_sites |
O |
b_iso |
1.3935 |
0.0167 |
Ų |
||
4 | lbco |
cell |
length_a |
3.8909 |
0.0000 |
Å |
|||
5 | hrpt |
background |
10 |
y |
168.5585 |
1.3671 |
|||
6 | hrpt |
background |
30 |
y |
164.3357 |
0.9992 |
|||
7 | hrpt |
background |
50 |
y |
166.8881 |
0.7388 |
|||
8 | hrpt |
background |
110 |
y |
175.4004 |
0.6571 |
|||
9 | hrpt |
background |
165 |
y |
174.2811 |
0.9113 |
|||
10 | hrpt |
instrument |
twotheta_offset |
0.6226 |
0.0010 |
deg |
|||
11 | hrpt |
linked_phases |
lbco |
scale |
9.1350 |
0.0641 |
|||
12 | hrpt |
peak |
broad_gauss_u |
0.0816 |
0.0031 |
deg² |
|||
13 | hrpt |
peak |
broad_gauss_v |
-0.1159 |
0.0067 |
deg² |
|||
14 | hrpt |
peak |
broad_gauss_w |
0.1204 |
0.0033 |
deg² |
|||
15 | hrpt |
peak |
broad_lorentz_y |
0.0844 |
0.0021 |
deg |
Run Fitting¶
project.analysis.fit()
Using experiment 🔬 'hrpt' for 'single' fitting 🚀 Starting fit process with 'lmfit (leastsq)'... 📈 Goodness-of-fit (reduced χ²) change:
iteration | χ² | improvement [%] |
---|---|---|
1 |
1.29 |
|
20 |
1.29 |
🏆 Best goodness-of-fit (reduced χ²) is 1.29 at iteration 19 ✅ Fitting complete.
Fit results
✅ Success: True
⏱️ Fitting time: 0.17 seconds
📏 Goodness-of-fit (reduced χ²): 1.29
📏 R-factor (Rf): 5.63%
📏 R-factor squared (Rf²): 5.27%
📏 Weighted R-factor (wR): 4.41%
📈 Fitted parameters:
datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5051 |
0.5051 |
0.0278 |
Ų |
0.00 % ↓ |
2 | lbco |
atom_sites |
Co |
b_iso |
0.2371 |
0.2370 |
0.0564 |
Ų |
0.03 % ↓ |
3 | lbco |
atom_sites |
O |
b_iso |
1.3935 |
1.3935 |
0.0160 |
Ų |
0.00 % ↑ |
4 | lbco |
cell |
length_a |
3.8909 |
3.8909 |
0.0000 |
Å |
0.00 % ↑ |
|
5 | hrpt |
background |
10 |
y |
168.5585 |
168.5585 |
1.3669 |
0.00 % ↓ |
|
6 | hrpt |
background |
30 |
y |
164.3357 |
164.3357 |
0.9990 |
0.00 % ↓ |
|
7 | hrpt |
background |
50 |
y |
166.8881 |
166.8881 |
0.7386 |
0.00 % ↓ |
|
8 | hrpt |
background |
110 |
y |
175.4004 |
175.4006 |
0.6488 |
0.00 % ↑ |
|
9 | hrpt |
background |
165 |
y |
174.2811 |
174.2812 |
0.8944 |
0.00 % ↑ |
|
10 | hrpt |
instrument |
twotheta_offset |
0.6226 |
0.6226 |
0.0010 |
deg |
0.00 % ↑ |
|
11 | hrpt |
linked_phases |
lbco |
scale |
9.1350 |
9.1351 |
0.0538 |
0.00 % ↑ |
|
12 | hrpt |
peak |
broad_gauss_u |
0.0816 |
0.0816 |
0.0031 |
deg² |
0.00 % ↑ |
|
13 | hrpt |
peak |
broad_gauss_v |
-0.1159 |
-0.1159 |
0.0066 |
deg² |
0.00 % ↑ |
|
14 | hrpt |
peak |
broad_gauss_w |
0.1204 |
0.1204 |
0.0032 |
deg² |
0.00 % ↑ |
|
15 | hrpt |
peak |
broad_lorentz_y |
0.0844 |
0.0844 |
0.0021 |
deg |
0.00 % ↓ |
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Save Project State¶
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
project.analysis.aliases.add(
label='occ_La',
param_uid=project.sample_models['lbco'].atom_sites['La'].occupancy.uid,
)
project.analysis.aliases.add(
label='occ_Ba',
param_uid=project.sample_models['lbco'].atom_sites['Ba'].occupancy.uid,
)
Set more constraints.
project.analysis.constraints.add(
lhs_alias='occ_Ba',
rhs_expr='1 - occ_La',
)
Show defined constraints.
project.analysis.show_constraints()
User defined constraints
lhs_alias | rhs_expr | full expression |
---|---|---|
biso_Ba |
biso_La |
biso_Ba = biso_La |
occ_Ba |
1 - occ_La |
occ_Ba = 1 - occ_La |
Apply constraints.
project.analysis.apply_constraints()
Set sample model parameters to be refined.
project.sample_models['lbco'].atom_sites['La'].occupancy.free = True
Show free parameters after selection.
project.analysis.show_free_params()
Free parameters for both sample models (🧩 data blocks) and experiments (🔬 data blocks)
datablock | category | entry | parameter | value | uncertainty | min | max | units | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5051 |
0.0278 |
Ų |
||
2 | lbco |
atom_sites |
La |
occupancy |
0.5000 |
||||
3 | lbco |
atom_sites |
Co |
b_iso |
0.2370 |
0.0564 |
Ų |
||
4 | lbco |
atom_sites |
O |
b_iso |
1.3935 |
0.0160 |
Ų |
||
5 | lbco |
cell |
length_a |
3.8909 |
0.0000 |
Å |
|||
6 | hrpt |
background |
10 |
y |
168.5585 |
1.3669 |
|||
7 | hrpt |
background |
30 |
y |
164.3357 |
0.9990 |
|||
8 | hrpt |
background |
50 |
y |
166.8881 |
0.7386 |
|||
9 | hrpt |
background |
110 |
y |
175.4006 |
0.6488 |
|||
10 | hrpt |
background |
165 |
y |
174.2812 |
0.8944 |
|||
11 | hrpt |
instrument |
twotheta_offset |
0.6226 |
0.0010 |
deg |
|||
12 | hrpt |
linked_phases |
lbco |
scale |
9.1351 |
0.0538 |
|||
13 | hrpt |
peak |
broad_gauss_u |
0.0816 |
0.0031 |
deg² |
|||
14 | hrpt |
peak |
broad_gauss_v |
-0.1159 |
0.0066 |
deg² |
|||
15 | hrpt |
peak |
broad_gauss_w |
0.1204 |
0.0032 |
deg² |
|||
16 | hrpt |
peak |
broad_lorentz_y |
0.0844 |
0.0021 |
deg |
Run Fitting¶
project.analysis.fit()
Using experiment 🔬 'hrpt' for 'single' fitting 🚀 Starting fit process with 'lmfit (leastsq)'... 📈 Goodness-of-fit (reduced χ²) change:
iteration | χ² | improvement [%] |
---|---|---|
1 |
1.29 |
|
55 |
1.28 |
🏆 Best goodness-of-fit (reduced χ²) is 1.28 at iteration 54
✅ Fitting complete.
Fit results
✅ Success: True
⏱️ Fitting time: 0.47 seconds
📏 Goodness-of-fit (reduced χ²): 1.28
📏 R-factor (Rf): 5.61%
📏 R-factor squared (Rf²): 5.25%
📏 Weighted R-factor (wR): 4.39%
📈 Fitted parameters:
datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
---|---|---|---|---|---|---|---|---|---|
1 | lbco |
atom_sites |
La |
b_iso |
0.5051 |
0.5983 |
0.0355 |
Ų |
18.46 % ↑ |
2 | lbco |
atom_sites |
La |
occupancy |
0.5000 |
0.5840 |
0.0203 |
16.81 % ↑ |
|
3 | lbco |
atom_sites |
Co |
b_iso |
0.2370 |
0.1665 |
0.0580 |
Ų |
29.74 % ↓ |
4 | lbco |
atom_sites |
O |
b_iso |
1.3935 |
1.3491 |
0.0192 |
Ų |
3.19 % ↓ |
5 | lbco |
cell |
length_a |
3.8909 |
3.8909 |
0.0000 |
Å |
0.00 % ↑ |
|
6 | hrpt |
background |
10 |
y |
168.5585 |
168.9780 |
1.3666 |
0.25 % ↑ |
|
7 | hrpt |
background |
30 |
y |
164.3357 |
164.0535 |
0.9992 |
0.17 % ↓ |
|
8 | hrpt |
background |
50 |
y |
166.8881 |
166.9125 |
0.7364 |
0.01 % ↑ |
|
9 | hrpt |
background |
110 |
y |
175.4006 |
175.2699 |
0.6479 |
0.07 % ↓ |
|
10 | hrpt |
background |
165 |
y |
174.2812 |
174.5580 |
0.8935 |
0.16 % ↑ |
|
11 | hrpt |
instrument |
twotheta_offset |
0.6226 |
0.6226 |
0.0010 |
deg |
0.00 % ↑ |
|
12 | hrpt |
linked_phases |
lbco |
scale |
9.1351 |
8.9057 |
0.0761 |
2.51 % ↓ |
|
13 | hrpt |
peak |
broad_gauss_u |
0.0816 |
0.0812 |
0.0031 |
deg² |
0.43 % ↓ |
|
14 | hrpt |
peak |
broad_gauss_v |
-0.1159 |
-0.1154 |
0.0066 |
deg² |
0.48 % ↓ |
|
15 | hrpt |
peak |
broad_gauss_w |
0.1204 |
0.1203 |
0.0032 |
deg² |
0.14 % ↓ |
|
16 | hrpt |
peak |
broad_lorentz_y |
0.0844 |
0.0846 |
0.0021 |
deg |
0.18 % ↑ |
Plot Measured vs Calculated¶
project.plot_meas_vs_calc(expt_name='hrpt', show_residual=True)
project.plot_meas_vs_calc(expt_name='hrpt', x_min=38, x_max=41, show_residual=True)
Save Project State¶
project.save_as(dir_path='lbco_hrpt', temporary=True)
Saving project 📦 'lbco_hrpt' to /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/lbco_hrpt ✅ project.cif ✅ sample_models/lbco.cif ✅ experiments/hrpt.cif ✅ analysis.cif ✅ summary.cif
Step 5: Summary¶
This final section shows how to review the results of the analysis.
Show Project Summary¶
project.summary.show_report()
*** PROJECT INFO *** Title La0.5Ba0.5CoO3 at HRPT@PSI Description This project demonstrates a standard refinement of La0.5Ba0.5CoO3, which crystallizes in a perovskite-type structure, using neutron powder diffraction data collected in constant wavelength mode at the HRPT diffractometer (PSI). *** CRYSTALLOGRAPHIC DATA *** Phase datablock 🧩 lbco Space group P m -3 m Cell parameters
alpha |
90.00000 |
beta |
90.00000 |
gamma |
90.00000 |
a |
3.89087 |
b |
3.89087 |
c |
3.89087 |
Atom sites
Label | Type | fract_x | fract_y | fract_z | Occupancy | B_iso |
---|---|---|---|---|---|---|
La |
La |
0.00000 |
0.00000 |
0.00000 |
0.58403 |
0.59832 |
Ba |
Ba |
0.00000 |
0.00000 |
0.00000 |
0.41597 |
0.59832 |
Co |
Co |
0.50000 |
0.50000 |
0.50000 |
1.00000 |
0.16651 |
O |
O |
0.00000 |
0.50000 |
0.50000 |
1.00000 |
1.34914 |
*** EXPERIMENTS *** Experiment datablock 🔬 hrpt Experiment type powder, neutron, constant wavelength Wavelength 1.49400 2θ offset 0.62261 Profile type pseudo-voigt Peak broadening (Gaussian)
U |
0.08122 |
V |
-0.11537 |
W |
0.12028 |
Peak broadening (Lorentzian)
X |
0.00000 |
Y |
0.08460 |
*** FITTING *** Calculation engine cryspy Minimization engine lmfit (leastsq) Fit quality
Goodness-of-fit (reduced χ²) |
1.28 |