Structure Refinement: Tb2TiO7, HEiDi¶
Crystal structure refinement of Tb2TiO7 using single crystal neutron diffraction data from HEiDi at FRM II.
Import Library¶
In [2]:
Copied!
import easydiffraction as ed
import easydiffraction as ed
Step 1: Define Project¶
In [3]:
Copied!
# Create minimal project without name and description
project = ed.Project()
# Create minimal project without name and description
project = ed.Project()
Step 2: Define Structure¶
In [4]:
Copied!
# Download CIF file from repository
structure_path = ed.download_data(id=20, destination='data')
# Download CIF file from repository
structure_path = ed.download_data(id=20, destination='data')
Getting data...
Data #20: Tb2Ti2O7 (crystal structure)
✅ Data #20 downloaded to 'data/ed-20.cif'
In [5]:
Copied!
project.structures.add_from_cif_path(structure_path)
project.structures.add_from_cif_path(structure_path)
In [6]:
Copied!
project.structures.show_names()
project.structures.show_names()
Defined structures 🧩
['tbti']
In [7]:
Copied!
structure = project.structures['tbti']
structure = project.structures['tbti']
In [8]:
Copied!
structure.show_as_cif()
structure.show_as_cif()
Structure 🧩 'tbti' as cif
| CIF | |
|---|---|
| 1 | data_tbti |
| 2 | |
| 3 | _cell.length_a 10.13000000 |
| 4 | _cell.length_b 10.13000000 |
| 5 | _cell.length_c 10.13000000 |
| 6 | _cell.angle_alpha 90.00000000 |
| 7 | _cell.angle_beta 90.00000000 |
| 8 | _cell.angle_gamma 90.00000000 |
| 9 | |
| 10 | _space_group.name_H-M_alt "F d -3 m" |
| 11 | _space_group.IT_coordinate_system_code 2 |
| 12 | |
| 13 | loop_ |
| 14 | _atom_site.label |
| 15 | _atom_site.type_symbol |
| 16 | _atom_site.fract_x |
| 17 | _atom_site.fract_y |
| 18 | _atom_site.fract_z |
| 19 | _atom_site.Wyckoff_letter |
| 20 | _atom_site.occupancy |
| 21 | _atom_site.B_iso_or_equiv |
| 22 | _atom_site.adp_type |
| 23 | Tb Tb 0.50000000 0.50000000 0.50000000 d 1.00000000 0.53000000(2000000) Biso |
| 24 | Ti Ti 0.00000000 0.00000000 0.00000000 c 1.00000000 0.48000000(3000000) Biso |
| 25 | O1 O 0.32804000(9000) 0.12500000 0.12500000 f 1.00000000(1000000) 0.45000000(2000000) Biso |
| 26 | O2 O 0.37500000 0.37500000 0.37500000 b 0.97000000(2000000) 0.23000000(4000000) Biso |
| 27 |
In [9]:
Copied!
structure.atom_sites['Tb'].adp_type = 'Uiso'
structure.atom_sites['Ti'].adp_type = 'Uiso'
structure.atom_sites['O1'].adp_type = 'Uiso'
structure.atom_sites['O2'].adp_type = 'Uiso'
structure.atom_sites['Tb'].adp_type = 'Uiso'
structure.atom_sites['Ti'].adp_type = 'Uiso'
structure.atom_sites['O1'].adp_type = 'Uiso'
structure.atom_sites['O2'].adp_type = 'Uiso'
In [10]:
Copied!
print(structure.atom_sites.as_cif)
print(structure.atom_sites.as_cif)
loop_ _atom_site.label _atom_site.type_symbol _atom_site.fract_x _atom_site.fract_y _atom_site.fract_z _atom_site.Wyckoff_letter _atom_site.occupancy _atom_site.U_iso_or_equiv _atom_site.adp_type Tb Tb 0.50000000 0.50000000 0.50000000 d 1.00000000 0.00671253(2000000) Uiso Ti Ti 0.00000000 0.00000000 0.00000000 c 1.00000000 0.00607927(3000000) Uiso O1 O 0.32804000(9000) 0.12500000 0.12500000 f 1.00000000(1000000) 0.00569932(2000000) Uiso O2 O 0.37500000 0.37500000 0.37500000 b 0.97000000(2000000) 0.00291298(4000000) Uiso
In [11]:
Copied!
structure.atom_sites['Tb'].adp_iso = 0.0
structure.atom_sites['Ti'].adp_iso = 0.0
structure.atom_sites['O1'].adp_iso = 0.0
structure.atom_sites['O2'].adp_iso = 0.0
structure.atom_sites['Tb'].adp_iso = 0.0
structure.atom_sites['Ti'].adp_iso = 0.0
structure.atom_sites['O1'].adp_iso = 0.0
structure.atom_sites['O2'].adp_iso = 0.0
Step 3: Define Experiment¶
In [12]:
Copied!
# Download data file from repository
data_path = ed.download_data(id=19, destination='data')
# Download data file from repository
data_path = ed.download_data(id=19, destination='data')
Getting data...
Data #19: Tb2Ti2O7, HEiDi (MLZ)
✅ Data #19 downloaded to 'data/ed-19.xye'
In [13]:
Copied!
project.experiments.add_from_data_path(
name='heidi',
data_path=data_path,
sample_form='single crystal',
beam_mode='constant wavelength',
radiation_probe='neutron',
)
project.experiments.add_from_data_path(
name='heidi',
data_path=data_path,
sample_form='single crystal',
beam_mode='constant wavelength',
radiation_probe='neutron',
)
Data loaded successfully
Experiment 🔬 'heidi'. Number of data points: 220.
In [14]:
Copied!
experiment = project.experiments['heidi']
experiment = project.experiments['heidi']
In [15]:
Copied!
experiment.linked_crystal.id = 'tbti'
experiment.linked_crystal.scale = 1.0
experiment.linked_crystal.id = 'tbti'
experiment.linked_crystal.scale = 1.0
In [16]:
Copied!
experiment.instrument.setup_wavelength = 0.793
experiment.instrument.setup_wavelength = 0.793
In [17]:
Copied!
experiment.extinction.mosaicity = 35000
experiment.extinction.radius = 10
experiment.extinction.mosaicity = 35000
experiment.extinction.radius = 10
Step 4: Perform Analysis I (ADP iso)¶
In [18]:
Copied!
project.plotter.plot_meas_vs_calc(expt_name='heidi')
project.plotter.plot_meas_vs_calc(expt_name='heidi')
In [19]:
Copied!
structure.atom_sites['O1'].fract_x.free = True
structure.atom_sites['Ti'].occupancy.free = True
structure.atom_sites['O1'].occupancy.free = True
structure.atom_sites['O2'].occupancy.free = True
structure.atom_sites['Tb'].adp_iso.free = True
structure.atom_sites['Ti'].adp_iso.free = True
structure.atom_sites['O1'].adp_iso.free = True
structure.atom_sites['O2'].adp_iso.free = True
structure.atom_sites['O1'].fract_x.free = True
structure.atom_sites['Ti'].occupancy.free = True
structure.atom_sites['O1'].occupancy.free = True
structure.atom_sites['O2'].occupancy.free = True
structure.atom_sites['Tb'].adp_iso.free = True
structure.atom_sites['Ti'].adp_iso.free = True
structure.atom_sites['O1'].adp_iso.free = True
structure.atom_sites['O2'].adp_iso.free = True
In [20]:
Copied!
experiment.linked_crystal.scale.free = True
experiment.extinction.radius.free = True
experiment.linked_crystal.scale.free = True
experiment.extinction.radius.free = True
In [21]:
Copied!
# Start refinement. All parameters, which have standard uncertainties
# in the input CIF files, are refined by default.
project.analysis.fit()
# Start refinement. All parameters, which have standard uncertainties
# in the input CIF files, are refined by default.
project.analysis.fit()
Standard fitting
📋 Using experiment 🔬 'heidi' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit (reduced χ²) change:
| iteration | χ² | improvement [%] | |
|---|---|---|---|
| 1 | 1 | 355.79 | |
| 2 | 14 | 186.41 | 47.6% ↓ |
| 3 | 25 | 42.28 | 77.3% ↓ |
| 4 | 36 | 12.97 | 69.3% ↓ |
| 5 | 47 | 12.75 | 1.6% ↓ |
| 6 | 81 | 12.75 |
🏆 Best goodness-of-fit (reduced χ²) is 12.75 at iteration 80
✅ Fitting complete.
In [22]:
Copied!
# Show fit results summary
project.analysis.display.fit_results()
# Show fit results summary
project.analysis.display.fit_results()
Fit results
✅ Success: True
⏱️ Fitting time: 2.03 seconds
📏 Goodness-of-fit (reduced χ²): 12.75
📏 R-factor (Rf): 7.65%
📏 R-factor squared (Rf²): 8.10%
📏 Weighted R-factor (wR): 8.59%
📈 Fitted parameters:
| datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | tbti | atom_site | Tb | adp_iso | 0.0000 | 0.0068 | 0.0003 | Ų | N/A |
| 2 | tbti | atom_site | Ti | occupancy | 1.0000 | 0.9730 | 0.0178 | 2.70 % ↓ | |
| 3 | tbti | atom_site | Ti | adp_iso | 0.0000 | 0.0054 | 0.0006 | Ų | N/A |
| 4 | tbti | atom_site | O1 | fract_x | 0.3280 | 0.3280 | 0.0001 | 0.00 % ↑ | |
| 5 | tbti | atom_site | O1 | occupancy | 1.0000 | 0.9989 | 0.0104 | 0.11 % ↓ | |
| 6 | tbti | atom_site | O1 | adp_iso | 0.0000 | 0.0057 | 0.0002 | Ų | N/A |
| 7 | tbti | atom_site | O2 | occupancy | 0.9700 | 0.9688 | 0.0183 | 0.12 % ↓ | |
| 8 | tbti | atom_site | O2 | adp_iso | 0.0000 | 0.0030 | 0.0005 | Ų | N/A |
| 9 | heidi | extinction | radius | 10.0000 | 26.4348 | 1.0122 | μm | 164.35 % ↑ | |
| 10 | heidi | linked_crystal | scale | 1.0000 | 2.9329 | 0.0586 | 193.29 % ↑ |
In [23]:
Copied!
structure.show_as_cif()
structure.show_as_cif()
Structure 🧩 'tbti' as cif
| CIF | |
|---|---|
| 1 | data_tbti |
| 2 | |
| 3 | _cell.length_a 10.13000000 |
| 4 | _cell.length_b 10.13000000 |
| 5 | _cell.length_c 10.13000000 |
| 6 | _cell.angle_alpha 90.00000000 |
| 7 | _cell.angle_beta 90.00000000 |
| 8 | _cell.angle_gamma 90.00000000 |
| 9 | |
| 10 | _space_group.name_H-M_alt "F d -3 m" |
| 11 | _space_group.IT_coordinate_system_code 2 |
| 12 | |
| 13 | loop_ |
| 14 | _atom_site.label |
| 15 | _atom_site.type_symbol |
| 16 | _atom_site.fract_x |
| 17 | _atom_site.fract_y |
| 18 | _atom_site.fract_z |
| 19 | _atom_site.Wyckoff_letter |
| 20 | _atom_site.occupancy |
| 21 | _atom_site.U_iso_or_equiv |
| 22 | _atom_site.adp_type |
| 23 | Tb Tb 0.50000000 0.50000000 0.50000000 d 1.00000000 0.00681683(28758) Uiso |
| 24 | Ti Ti 0.00000000 0.00000000 0.00000000 c 0.97299648(1780992) 0.00539742(59789) Uiso |
| 25 | O1 O 0.32804378(9395) 0.12500000 0.12500000 f 0.99893142(1039031) 0.00572628(24749) Uiso |
| 26 | O2 O 0.37500000 0.37500000 0.37500000 b 0.96880340(1827132) 0.00302999(48336) Uiso |
| 27 |
In [24]:
Copied!
project.experiments.show_names()
project.experiments.show_names()
Defined experiments 🔬
['heidi']
In [25]:
Copied!
project.plotter.plot_meas_vs_calc(expt_name='heidi')
project.plotter.plot_meas_vs_calc(expt_name='heidi')
Step 5: Perform Analysis (ADP aniso)¶
In [26]:
Copied!
structure.atom_sites['Tb'].adp_type = 'Uani'
structure.atom_sites['Ti'].adp_type = 'Uani'
structure.atom_sites['O1'].adp_type = 'Uani'
# structure.atom_sites['O2'].adp_type = 'Uani'
structure.atom_sites['Tb'].adp_type = 'Uani'
structure.atom_sites['Ti'].adp_type = 'Uani'
structure.atom_sites['O1'].adp_type = 'Uani'
# structure.atom_sites['O2'].adp_type = 'Uani'
In [27]:
Copied!
print(structure.atom_site_aniso.as_cif)
print(structure.atom_site_aniso.as_cif)
loop_ _atom_site_aniso.label _atom_site_aniso.U_11 _atom_site_aniso.U_22 _atom_site_aniso.U_33 _atom_site_aniso.U_12 _atom_site_aniso.U_13 _atom_site_aniso.U_23 Tb 0.00681683 0.00681683 0.00681683 0.00000000 0.00000000 0.00000000 Ti 0.00539742 0.00539742 0.00539742 0.00000000 0.00000000 0.00000000 O1 0.00572628 0.00572628 0.00572628 0.00000000 0.00000000 0.00000000 O2 ? ? ? ? ? ?
In [28]:
Copied!
structure.atom_site_aniso['Tb'].adp_11.free = True
structure.atom_site_aniso['Tb'].adp_12.free = True
structure.atom_site_aniso['Ti'].adp_11.free = True
structure.atom_site_aniso['Ti'].adp_12.free = True
structure.atom_site_aniso['O1'].adp_11.free = True
structure.atom_site_aniso['O1'].adp_22.free = True
structure.atom_site_aniso['O1'].adp_23.free = True
# structure.atom_site_aniso['O2'].adp_11.free = True
structure.atom_site_aniso['Tb'].adp_11.free = True
structure.atom_site_aniso['Tb'].adp_12.free = True
structure.atom_site_aniso['Ti'].adp_11.free = True
structure.atom_site_aniso['Ti'].adp_12.free = True
structure.atom_site_aniso['O1'].adp_11.free = True
structure.atom_site_aniso['O1'].adp_22.free = True
structure.atom_site_aniso['O1'].adp_23.free = True
# structure.atom_site_aniso['O2'].adp_11.free = True
In [29]:
Copied!
project.analysis.fit()
project.analysis.fit()
Standard fitting
📋 Using experiment 🔬 'heidi' for 'single' fitting
🚀 Starting fit process with 'lmfit (leastsq)'...
📈 Goodness-of-fit (reduced χ²) change:
| iteration | χ² | improvement [%] | |
|---|---|---|---|
| 1 | 1 | 13.00 | |
| 2 | 18 | 3.02 | 76.8% ↓ |
| 3 | 33 | 2.94 | 2.5% ↓ |
| 4 | 79 | 2.94 |
🏆 Best goodness-of-fit (reduced χ²) is 2.94 at iteration 78
✅ Fitting complete.
In [30]:
Copied!
project.analysis.display.fit_results()
project.analysis.display.fit_results()
Fit results
✅ Success: True
⏱️ Fitting time: 2.57 seconds
📏 Goodness-of-fit (reduced χ²): 2.94
📏 R-factor (Rf): 4.21%
📏 R-factor squared (Rf²): 6.61%
📏 Weighted R-factor (wR): 13.29%
📈 Fitted parameters:
| datablock | category | entry | parameter | start | fitted | uncertainty | units | change | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | tbti | atom_site | Ti | occupancy | 0.9730 | 0.9661 | 0.0085 | 0.71 % ↓ | |
| 2 | tbti | atom_site | O1 | fract_x | 0.3280 | 0.3280 | 0.0000 | 0.01 % ↓ | |
| 3 | tbti | atom_site | O1 | occupancy | 0.9989 | 0.9940 | 0.0050 | 0.50 % ↓ | |
| 4 | tbti | atom_site | O2 | occupancy | 0.9688 | 0.9718 | 0.0088 | 0.31 % ↑ | |
| 5 | tbti | atom_site | O2 | adp_iso | 0.0030 | 0.0033 | 0.0002 | Ų | 7.87 % ↑ |
| 6 | tbti | atom_site_aniso | Tb | adp_11 | 0.0068 | 0.0066 | 0.0001 | Ų | 3.45 % ↓ |
| 7 | tbti | atom_site_aniso | Tb | adp_12 | 0.0000 | -0.0023 | 0.0001 | Ų | N/A |
| 8 | tbti | atom_site_aniso | Ti | adp_11 | 0.0054 | 0.0049 | 0.0003 | Ų | 9.56 % ↓ |
| 9 | tbti | atom_site_aniso | Ti | adp_12 | 0.0000 | -0.0005 | 0.0002 | Ų | N/A |
| 10 | tbti | atom_site_aniso | O1 | adp_11 | 0.0057 | 0.0067 | 0.0002 | Ų | 17.67 % ↑ |
| 11 | tbti | atom_site_aniso | O1 | adp_22 | 0.0057 | 0.0049 | 0.0001 | Ų | 14.61 % ↓ |
| 12 | tbti | atom_site_aniso | O1 | adp_23 | 0.0000 | 0.0019 | 0.0001 | Ų | N/A |
| 13 | heidi | extinction | radius | 26.4348 | 24.8317 | 0.4931 | μm | 6.06 % ↓ | |
| 14 | heidi | linked_crystal | scale | 2.9329 | 2.8744 | 0.0274 | 1.99 % ↓ |
In [31]:
Copied!
project.plotter.plot_param_correlations()
project.plotter.plot_param_correlations()
In [32]:
Copied!
project.plotter.plot_meas_vs_calc(expt_name='heidi')
project.plotter.plot_meas_vs_calc(expt_name='heidi')
In [33]:
Copied!
structure.show_as_cif()
structure.show_as_cif()
Structure 🧩 'tbti' as cif
| CIF | |
|---|---|
| 1 | data_tbti |
| 2 | |
| 3 | _cell.length_a 10.13000000 |
| 4 | _cell.length_b 10.13000000 |
| 5 | _cell.length_c 10.13000000 |
| 6 | _cell.angle_alpha 90.00000000 |
| 7 | _cell.angle_beta 90.00000000 |
| 8 | _cell.angle_gamma 90.00000000 |
| 9 | |
| 10 | _space_group.name_H-M_alt "F d -3 m" |
| 11 | _space_group.IT_coordinate_system_code 2 |
| 12 | |
| 13 | loop_ |
| 14 | _atom_site.label |
| 15 | _atom_site.type_symbol |
| 16 | _atom_site.fract_x |
| 17 | _atom_site.fract_y |
| 18 | _atom_site.fract_z |
| 19 | _atom_site.Wyckoff_letter |
| 20 | _atom_site.occupancy |
| 21 | _atom_site.U_iso_or_equiv |
| 22 | _atom_site.adp_type |
| 23 | Tb Tb 0.50000000 0.50000000 0.50000000 d 1.00000000 0.00658189 Uani |
| 24 | Ti Ti 0.00000000 0.00000000 0.00000000 c 0.96606424(850635) 0.00488144 Uani |
| 25 | O1 O 0.32799582(4713) 0.12500000 0.12500000 f 0.99395914(497554) 0.00550586 Uani |
| 26 | O2 O 0.37500000 0.37500000 0.37500000 b 0.97182102(883817) 0.00326851(23641) Uiso |
| 27 | |
| 28 | loop_ |
| 29 | _atom_site_aniso.label |
| 30 | _atom_site_aniso.U_11 |
| 31 | _atom_site_aniso.U_22 |
| 32 | _atom_site_aniso.U_33 |
| 33 | _atom_site_aniso.U_12 |
| 34 | _atom_site_aniso.U_13 |
| 35 | _atom_site_aniso.U_23 |
| 36 | Tb 0.00658189(13905) 0.00658189 0.00658189 -0.00228459(11215) -0.00228459 -0.00228459 |
| 37 | Ti 0.00488144(28692) 0.00488144 0.00488144 -0.00048176(24537) -0.00048176 -0.00048176 |
| 38 | O1 0.00673797(18380) 0.00488980(13460) 0.00488980 0.00000000 0.00000000 0.00188994(12724) |
| 39 | O2 ? ? ? ? ? ? |