Fitting pd-neut-tof Si-SEPD¶
This example shows how to refine the crystal structure parameters of Si from neutron diffraction data in a time-of-flight experiment performed on SEPD diffractometer at Argonne.
Import EasyDiffraction¶
In [2]:
Copied!
import easydiffraction as ed
import easydiffraction as ed
Create a job¶
Create a job — the main object to store all the information
In [3]:
Copied!
job = ed.Job(type='tof')
print(job.type)
job = ed.Job(type='tof')
print(job.type)
Job type: pd-tof-unp-1d-neut
Define a model¶
Create a phase object
In [4]:
Copied!
phase = ed.Phase(name='si')
phase = ed.Phase(name='si')
Set space group
In [5]:
Copied!
phase.space_group.name_hm_alt = 'F d -3 m'
phase.space_group.name_hm_alt = 'F d -3 m'
Set cell parameters
In [6]:
Copied!
phase.cell.length_a = 5.43146
phase.cell.length_a = 5.43146
Add atoms
In [7]:
Copied!
phase.atom_sites.append(label='Si',
type_symbol='Si',
fract_x=0,
fract_y=0,
fract_z=0,
occupancy=1,
b_iso_or_equiv=0.529)
phase.atom_sites.append(label='Si',
type_symbol='Si',
fract_x=0,
fract_y=0,
fract_z=0,
occupancy=1,
b_iso_or_equiv=0.529)
Add phase to the job object
In [8]:
Copied!
job.add_phase(phase=phase)
print(job.phases)
job.add_phase(phase=phase)
print(job.phases)
Several values of it_coordinate_system_code have been defined: 2, 1 The default value has been choosen:'2'.
Several values of it_coordinate_system_code have been defined: 2, 1 The default value has been choosen:'2'. Collection of 1 phases: ['si']
Show phase info in CIF format
In [9]:
Copied!
phase = job.phases['si']
print(phase.cif)
phase = job.phases['si']
print(phase.cif)
data_si _cell_length_a 5.43146 _cell_length_b 5.43146 _cell_length_c 5.43146 _cell_angle_alpha 90.00000000 _cell_angle_beta 90.00000000 _cell_angle_gamma 90.00000000 _space_group_name_H-M_ref 'F d -3 m' _space_group_IT_coordinate_system_code 1 loop_ _atom_site_label _atom_site_type_symbol _atom_site_fract_x _atom_site_fract_y _atom_site_fract_z _atom_site_occupancy _atom_site_adp_type _atom_site_B_iso_or_equiv Si Si 0.00000000 0.00000000 0.00000000 1.00000000 Biso 0.529
Display the crystal structure of a given model
In [10]:
Copied!
job.show_crystal_structure(id='si')
job.show_crystal_structure(id='si')
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
Define an experiment¶
Download the data file from the EasyDiffraction repository on GitHub
In [11]:
Copied!
ed.download_from_repository('sepd.xye', destination='data')
ed.download_from_repository('sepd.xye', destination='data')
Show content of the downloaded file (first 5 lines)
In [12]:
Copied!
with open('data/sepd.xye') as f:
print(''.join(f.readlines()[:5]))
with open('data/sepd.xye') as f:
print(''.join(f.readlines()[:5]))
2000.0 213.8 3.3 2005.0 213.8 3.3 2010.0 210.1 3.3 2015.0 213.3 3.3 2020.0 211.9 3.3
Load experimentally measured data from a file in XYE format
In [13]:
Copied!
job.add_experiment_from_file('data/sepd.xye')
job.add_experiment_from_file('data/sepd.xye')
Display the experimentally measured data
In [14]:
Copied!
job.show_experiment_chart(show_legend=False)
job.show_experiment_chart(show_legend=False)