|
5 | 5 | # structure using time-of-flight neutron powder diffraction data from WISH at
|
6 | 6 | # ISIS.
|
7 | 7 | #
|
8 |
| -# Temporarily, only a single dataset from detector banks 5 & 6 is used here. |
| 8 | +# Two datasets from detector banks 5_6 and 4_7 are used for joint fitting. |
9 | 9 |
|
10 | 10 | # %% [markdown]
|
11 | 11 | # ## Import Library
|
|
45 | 45 | # ### Set Atom Sites
|
46 | 46 |
|
47 | 47 | # %%
|
48 |
| -model.atom_sites.add('Ca', 'Ca', 0.4661, 0.0, 0.25, wyckoff_letter="b", b_iso=0.9) |
49 |
| -model.atom_sites.add('Al', 'Al', 0.25171, 0.25171, 0.25171, wyckoff_letter="a", b_iso=0.66) |
50 |
| -model.atom_sites.add('Na', 'Na', 0.08481, 0.08481, 0.08481, wyckoff_letter="a", b_iso=1.9) |
51 |
| -model.atom_sites.add('F1', 'F', 0.1375, 0.3053, 0.1195, wyckoff_letter="c", b_iso=0.9) |
52 |
| -model.atom_sites.add('F2', 'F', 0.3626, 0.3634, 0.1867, wyckoff_letter="c", b_iso=1.28) |
53 |
| -model.atom_sites.add('F3', 'F', 0.4612, 0.4612, 0.4612, wyckoff_letter="a", b_iso=0.79) |
| 48 | +model.atom_sites.add('Ca', 'Ca', |
| 49 | + 0.4665, 0.0, 0.25, |
| 50 | + wyckoff_letter="b", b_iso=0.92) |
| 51 | +model.atom_sites.add('Al', 'Al', |
| 52 | + 0.2520, 0.2520, 0.2520, |
| 53 | + wyckoff_letter="a", b_iso=0.73) |
| 54 | +model.atom_sites.add('Na', 'Na', |
| 55 | + 0.0852, 0.0852, 0.0852, |
| 56 | + wyckoff_letter="a", b_iso=2.08) |
| 57 | +model.atom_sites.add('F1', 'F', |
| 58 | + 0.1376, 0.3055, 0.1196, |
| 59 | + wyckoff_letter="c", b_iso=0.90) |
| 60 | +model.atom_sites.add('F2', 'F', |
| 61 | + 0.3623, 0.3631, 0.1870, |
| 62 | + wyckoff_letter="c", b_iso=1.37) |
| 63 | +model.atom_sites.add('F3', 'F', |
| 64 | + 0.4611, 0.4611, 0.4611, |
| 65 | + wyckoff_letter="a", b_iso=0.88) |
54 | 66 |
|
55 | 67 | # %% [markdown]
|
56 | 68 | # ## Define Experiment
|
|
61 | 73 | # ### Download Measured Data
|
62 | 74 |
|
63 | 75 | # %%
|
64 |
| -download_from_repository('wish_ncaf.xye', |
| 76 | +download_from_repository('wish_ncaf_5_6.xye', |
| 77 | + branch='docs', |
| 78 | + destination='data') |
| 79 | + |
| 80 | +# %% |
| 81 | +download_from_repository('wish_ncaf_4_7.xye', |
65 | 82 | branch='docs',
|
66 | 83 | destination='data')
|
67 | 84 |
|
68 | 85 | # %% [markdown]
|
69 | 86 | # ### Create Experiment
|
70 | 87 |
|
71 | 88 | # %%
|
72 |
| -expt = Experiment('wish', |
73 |
| - beam_mode='time-of-flight', |
74 |
| - data_path='data/wish_ncaf.xye') |
| 89 | +expt1 = Experiment('wish_5_6', |
| 90 | + beam_mode='time-of-flight', |
| 91 | + data_path='data/wish_ncaf_5_6.xye') |
| 92 | + |
| 93 | +# %% |
| 94 | +expt2 = Experiment('wish_4_7', |
| 95 | + beam_mode='time-of-flight', |
| 96 | + data_path='data/wish_ncaf_4_7.xye') |
75 | 97 |
|
76 | 98 | # %% [markdown]
|
77 | 99 | # ### Set Instrument
|
78 | 100 |
|
79 | 101 | # %%
|
80 |
| -expt.instrument.setup_twotheta_bank = 152.827 |
81 |
| -expt.instrument.calib_d_to_tof_offset = 0.0 |
82 |
| -expt.instrument.calib_d_to_tof_linear = 20770 |
83 |
| -expt.instrument.calib_d_to_tof_quad = -1.08308 |
| 102 | +expt1.instrument.setup_twotheta_bank = 152.827 |
| 103 | +expt1.instrument.calib_d_to_tof_offset = -13.0 |
| 104 | +expt1.instrument.calib_d_to_tof_linear = 20752.1 |
| 105 | +expt1.instrument.calib_d_to_tof_quad = -1.08308 |
| 106 | + |
| 107 | +# %% |
| 108 | +expt2.instrument.setup_twotheta_bank = 121.660 |
| 109 | +expt2.instrument.calib_d_to_tof_offset = -15.0 |
| 110 | +expt2.instrument.calib_d_to_tof_linear = 18640.7 |
| 111 | +expt2.instrument.calib_d_to_tof_quad = -0.47488 |
84 | 112 |
|
85 | 113 | # %% [markdown]
|
86 | 114 | # ### Set Peak Profile
|
87 | 115 |
|
88 | 116 | # %%
|
89 |
| -expt.peak_profile_type = 'pseudo-voigt * ikeda-carpenter' |
90 |
| -expt.peak.broad_gauss_sigma_0 = 0.0 |
91 |
| -expt.peak.broad_gauss_sigma_1 = 0.0 |
92 |
| -expt.peak.broad_gauss_sigma_2 = 5.0 |
93 |
| -expt.peak.broad_mix_beta_0 = 0.01 |
94 |
| -expt.peak.broad_mix_beta_1 = 0.01 |
95 |
| - |
96 |
| -# %% [markdown] |
97 |
| -# ### Set Peak Asymmetry |
| 117 | +expt1.peak_profile_type = 'pseudo-voigt * ikeda-carpenter' |
| 118 | +expt1.peak.broad_gauss_sigma_0 = 0.0 |
| 119 | +expt1.peak.broad_gauss_sigma_1 = 0.0 |
| 120 | +expt1.peak.broad_gauss_sigma_2 = 15.0 |
| 121 | +expt1.peak.broad_mix_beta_0 = 0.01 |
| 122 | +expt1.peak.broad_mix_beta_1 = 0.01 |
| 123 | +expt1.peak.asym_alpha_0 = -0.01 |
| 124 | +expt1.peak.asym_alpha_1 = 0.10 |
98 | 125 |
|
99 | 126 | # %%
|
100 |
| -expt.peak.asym_alpha_0 = 0.0 |
101 |
| -expt.peak.asym_alpha_1 = 0.1 |
| 127 | +expt2.peak_profile_type = 'pseudo-voigt * ikeda-carpenter' |
| 128 | +expt2.peak.broad_gauss_sigma_0 = 0.0 |
| 129 | +expt2.peak.broad_gauss_sigma_1 = 30.0 |
| 130 | +expt2.peak.broad_gauss_sigma_2 = 20.0 |
| 131 | +expt2.peak.broad_mix_beta_0 = 0.01 |
| 132 | +expt2.peak.broad_mix_beta_1 = 0.01 |
| 133 | +expt2.peak.asym_alpha_0 = -0.01 |
| 134 | +expt2.peak.asym_alpha_1 = 0.10 |
102 | 135 |
|
103 | 136 | # %% [markdown]
|
104 | 137 | # ### Set Background
|
105 | 138 |
|
106 | 139 | # %%
|
107 |
| -expt.background_type = 'line-segment' |
| 140 | +expt1.background_type = 'line-segment' |
108 | 141 | for x, y in [
|
109 | 142 | (9162, 465),
|
110 | 143 | (11136, 593),
|
|
135 | 168 | (91958, 268),
|
136 | 169 | (102712, 262)
|
137 | 170 | ]:
|
138 |
| - expt.background.add(x, y) |
| 171 | + expt1.background.add(x, y) |
| 172 | + |
| 173 | +# %% |
| 174 | +expt2.background_type = 'line-segment' |
| 175 | +for x, y in [ |
| 176 | + (9090, 488), |
| 177 | + (10672, 566), |
| 178 | + (12287, 494), |
| 179 | + (14037, 559), |
| 180 | + (15451, 529), |
| 181 | + (16764, 445), |
| 182 | + (18076, 460), |
| 183 | + (19456, 413), |
| 184 | + (20466, 511), |
| 185 | + (21880, 396), |
| 186 | + (23798, 391), |
| 187 | + (25447, 385), |
| 188 | + (28073, 349), |
| 189 | + (30058, 332), |
| 190 | + (32583, 309), |
| 191 | + (34804, 355), |
| 192 | + (37160, 318), |
| 193 | + (40324, 290), |
| 194 | + (46895, 260), |
| 195 | + (50631, 256), |
| 196 | + (54602, 246), |
| 197 | + (58439, 264), |
| 198 | + (66520, 250), |
| 199 | + (75002, 258), |
| 200 | + (83649, 257), |
| 201 | + (92770, 255), |
| 202 | + (101524, 260) |
| 203 | +]: |
| 204 | + expt2.background.add(x, y) |
139 | 205 |
|
140 | 206 | # %% [markdown]
|
141 | 207 | # ### Set Linked Phases
|
142 | 208 |
|
143 | 209 | # %%
|
144 |
| -expt.linked_phases.add('ncaf', scale=0.5) |
| 210 | +expt1.linked_phases.add('ncaf', scale=1.0) |
| 211 | + |
| 212 | +# %% |
| 213 | +expt2.linked_phases.add('ncaf', scale=2.0) |
145 | 214 |
|
146 | 215 | # %% [markdown]
|
147 | 216 | # ## Define Project
|
|
170 | 239 | # ### Add Experiment
|
171 | 240 |
|
172 | 241 | # %%
|
173 |
| -project.experiments.add(expt) |
| 242 | +project.experiments.add(expt1) |
| 243 | +project.experiments.add(expt2) |
174 | 244 |
|
175 | 245 | # %% [markdown]
|
176 | 246 | # ## Analysis
|
|
190 | 260 | project.analysis.current_minimizer = 'lmfit (leastsq)'
|
191 | 261 |
|
192 | 262 | # %% [markdown]
|
193 |
| -# ### Plot Measured vs Calculated |
194 |
| - |
195 |
| -# %% |
196 |
| -project.plot_meas_vs_calc(expt_name='wish', |
197 |
| - show_residual=True) |
| 263 | +# ### Set Fit Mode |
198 | 264 |
|
199 | 265 | # %%
|
200 |
| -project.plot_meas_vs_calc(expt_name='wish', |
201 |
| - x_min=37000, x_max=40000, |
202 |
| - show_residual=True) |
203 |
| - |
204 |
| -# %% [markdown] |
205 |
| -# ### Perform Fit 1/5 |
206 |
| -# |
207 |
| -# Set parameters to be refined. |
208 |
| - |
209 |
| -# %% |
210 |
| -model.cell.length_a.free = True |
211 |
| - |
212 |
| -expt.instrument.calib_d_to_tof_offset.free = True |
213 |
| -expt.linked_phases['ncaf'].scale.free = True |
214 |
| - |
215 |
| -# %% [markdown] |
216 |
| -# Show free parameters after selection. |
217 |
| - |
218 |
| -# %% |
219 |
| -project.analysis.show_free_params() |
220 |
| - |
221 |
| -# %% [markdown] |
222 |
| -# #### Run Fit |
223 |
| - |
224 |
| -# %% |
225 |
| -project.analysis.fit() |
| 266 | +project.analysis.fit_mode = 'joint' |
226 | 267 |
|
227 | 268 | # %% [markdown]
|
228 | 269 | # ### Plot Measured vs Calculated
|
229 | 270 |
|
230 | 271 | # %%
|
231 |
| -project.plot_meas_vs_calc(expt_name='wish', |
| 272 | +project.plot_meas_vs_calc(expt_name='wish_5_6', |
232 | 273 | show_residual=True)
|
233 | 274 |
|
234 | 275 | # %%
|
235 |
| -project.plot_meas_vs_calc(expt_name='wish', |
236 |
| - x_min=37000, x_max=40000, |
| 276 | +project.plot_meas_vs_calc(expt_name='wish_4_7', |
237 | 277 | show_residual=True)
|
238 | 278 |
|
239 | 279 | # %% [markdown]
|
240 |
| -# ### Perform Fit 2/5 |
| 280 | +# ### Perform Fit |
241 | 281 | #
|
242 |
| -# Set more parameters to be refined. |
243 |
| - |
244 |
| -# %% |
245 |
| -expt.peak.broad_gauss_sigma_2.free = True |
246 |
| -expt.peak.broad_mix_beta_0.free = True |
247 |
| -expt.peak.broad_mix_beta_1.free = True |
248 |
| -expt.peak.asym_alpha_0.free = True |
249 |
| -expt.peak.asym_alpha_1.free = True |
250 |
| - |
251 |
| -# %% [markdown] |
252 |
| -# Show free parameters after selection. |
253 |
| - |
254 |
| -# %% |
255 |
| -project.analysis.show_free_params() |
256 |
| - |
257 |
| -# %% [markdown] |
258 |
| -# #### Run Fit |
259 |
| - |
260 |
| -# %% |
261 |
| -project.analysis.fit() |
262 |
| - |
263 |
| -# %% [markdown] |
264 |
| -# #### Plot Measured vs Calculated |
265 |
| - |
266 |
| -# %% |
267 |
| -project.plot_meas_vs_calc(expt_name='wish', |
268 |
| - show_residual=True) |
269 |
| - |
270 |
| -# %% |
271 |
| -project.plot_meas_vs_calc(expt_name='wish', |
272 |
| - x_min=37000, x_max=40000, |
273 |
| - show_residual=True) |
274 |
| - |
275 |
| - |
276 |
| -# %% [markdown] |
277 |
| -# ### Perform Fit 3/5 |
278 |
| -# |
279 |
| -# Set more parameters to be refined. |
| 282 | +# Set parameters to be refined. |
280 | 283 |
|
281 | 284 | # %%
|
282 | 285 | model.atom_sites['Ca'].fract_x.free = True
|
|
290 | 293 | model.atom_sites['F2'].fract_z.free = True
|
291 | 294 | model.atom_sites['F3'].fract_x.free = True
|
292 | 295 |
|
293 |
| -# %% [markdown] |
294 |
| -# Show free parameters after selection. |
295 |
| - |
296 |
| -# %% |
297 |
| -project.analysis.show_free_params() |
298 |
| - |
299 |
| -# %% [markdown] |
300 |
| -# #### Run Fit |
301 |
| - |
302 |
| -# %% |
303 |
| -project.analysis.fit() |
304 |
| - |
305 |
| -# %% [markdown] |
306 |
| -# #### Plot Measured vs Calculated |
307 |
| - |
308 |
| -# %% |
309 |
| -project.plot_meas_vs_calc(expt_name='wish', |
310 |
| - show_residual=True) |
311 |
| - |
312 |
| -# %% |
313 |
| -project.plot_meas_vs_calc(expt_name='wish', |
314 |
| - x_min=37000, x_max=40000, |
315 |
| - show_residual=True) |
316 |
| - |
317 |
| -# %% [markdown] |
318 |
| -# ### Perform Fit 4/5 |
319 |
| -# |
320 |
| -# Set more parameters to be refined. |
321 |
| - |
322 |
| -# %% |
323 |
| -expt.instrument.calib_d_to_tof_linear.free = True |
324 |
| - |
325 | 296 | model.atom_sites['Ca'].b_iso.free = True
|
326 | 297 | model.atom_sites['Al'].b_iso.free = True
|
327 | 298 | model.atom_sites['Na'].b_iso.free = True
|
328 | 299 | model.atom_sites['F1'].b_iso.free = True
|
329 | 300 | model.atom_sites['F2'].b_iso.free = True
|
330 | 301 | model.atom_sites['F3'].b_iso.free = True
|
331 | 302 |
|
| 303 | +# %% |
| 304 | +expt1.linked_phases['ncaf'].scale.free = True |
| 305 | +expt1.instrument.calib_d_to_tof_offset.free = True |
| 306 | +expt1.instrument.calib_d_to_tof_linear.free = True |
| 307 | +expt1.peak.broad_gauss_sigma_2.free = True |
| 308 | +expt1.peak.broad_mix_beta_0.free = True |
| 309 | +expt1.peak.broad_mix_beta_1.free = True |
| 310 | +expt1.peak.asym_alpha_0.free = True |
| 311 | +expt1.peak.asym_alpha_1.free = True |
| 312 | + |
| 313 | +expt2.linked_phases['ncaf'].scale.free = True |
| 314 | +expt2.instrument.calib_d_to_tof_linear.free = True |
| 315 | +expt2.instrument.calib_d_to_tof_offset.free = True |
| 316 | +expt2.peak.broad_gauss_sigma_1.free = True |
| 317 | +expt2.peak.broad_gauss_sigma_2.free = True |
| 318 | +expt2.peak.broad_mix_beta_0.free = True |
| 319 | +expt2.peak.broad_mix_beta_1.free = True |
| 320 | +expt2.peak.asym_alpha_0.free = True |
| 321 | +expt2.peak.asym_alpha_1.free = True |
| 322 | + |
332 | 323 | # %% [markdown]
|
333 | 324 | # Show free parameters after selection.
|
334 | 325 |
|
|
345 | 336 | # #### Plot Measured vs Calculated
|
346 | 337 |
|
347 | 338 | # %%
|
348 |
| -project.plot_meas_vs_calc(expt_name='wish', |
| 339 | +project.plot_meas_vs_calc(expt_name='wish_5_6', |
349 | 340 | show_residual=True)
|
350 | 341 |
|
351 | 342 | # %%
|
352 |
| -project.plot_meas_vs_calc(expt_name='wish', |
353 |
| - x_min=37000, x_max=40000, |
| 343 | +project.plot_meas_vs_calc(expt_name='wish_4_7', |
354 | 344 | show_residual=True)
|
355 | 345 |
|
356 | 346 | # %% [markdown]
|
|
0 commit comments