1 | # Load data |
---|
2 | LoadAscii(Filename=r'PG3_11485-1.dat',OutputWorkspace='PG3_11485',Unit='TOF') |
---|
3 | |
---|
4 | # Create input workspaces for Le Bail fit |
---|
5 | CreateLeBailFitInput(ReflectionsFile=r'LB4844b1.hkl', |
---|
6 | FullprofParameterFile=r'2011B_HR60b1.irf', |
---|
7 | LatticeConstant='4.1568899999999998', |
---|
8 | InstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
---|
9 | BraggPeakParameterWorkspace='BraggPeakParameterTable1') |
---|
10 | |
---|
11 | # Initial Le Bail fit in calculation mode to see how far the starting parameters are off |
---|
12 | LeBailFit(InputWorkspace='PG3_11485', |
---|
13 | OutputWorkspace='PG3_11485_Calculated_0', |
---|
14 | InputParameterWorkspace='Bank1InstrumentParameterTable1', |
---|
15 | OutputParameterWorkspace='TempTable', |
---|
16 | InputHKLWorkspace='BraggPeakParameterTable1', |
---|
17 | OutputPeaksWorkspace='BraggPeakParameterTable2', |
---|
18 | Function='Calculation', |
---|
19 | BackgroundType='Chebyshev', |
---|
20 | BackgroundParameters='0,0,0', # No background at first |
---|
21 | UseInputPeakHeights='0', |
---|
22 | PeakRadius='8', |
---|
23 | Minimizer='Levenberg-Marquardt') |
---|
24 | |
---|
25 | # Fit the instrumental geometry-related parameters. Dtt1, Dtt1t, Dtt2, Zero, Zerot, |
---|
26 | # Step 1: Fit single diffraction peaks |
---|
27 | FitPowderDiffPeaks(InputWorkspace='PG3_11485', |
---|
28 | OutputWorkspace='Bank1FittedPeaks', |
---|
29 | BraggPeakParameterWorkspace='BraggPeakParameterTable2', |
---|
30 | InstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
---|
31 | OutputBraggPeakParameterWorkspace='BraggPeakParameterTable2_0', |
---|
32 | OutputBraggPeakParameterDataWorkspace='BraggPeakParameterTable2_P', |
---|
33 | OutputZscoreWorkspace='BraggPeakParameterTable2_Zscore', |
---|
34 | MinTOF='15000',MaxTOF='49387',UseGivenPeakCentreTOF='0', |
---|
35 | MinimumPeakHeight='0.29999999999999999', |
---|
36 | PeaksCorrelated='1', |
---|
37 | MinimumHKL='12,12,12', |
---|
38 | RightMostPeakHKL='2,0,0', |
---|
39 | RightMostPeakLeftBound='46000', |
---|
40 | RightMostPeakRightBound='48000') |
---|
41 | |
---|
42 | # Step 2: Refine geometry-related parameters. Dtt1, Dtt1t, Dtt2, Zero, Zerot, |
---|
43 | RefinePowderInstrumentParameters(InputPeakPositionWorkspace='BraggPeakParameterTable2_P', |
---|
44 | OutputPeakPositionWorkspace='PG3_11485_PeakPositions', |
---|
45 | InputInstrumentParameterWorkspace='Bank1InstrumentParameterTable1', |
---|
46 | OutputInstrumentParameterWorkspace='Bank1InstrumentParameterTable1_01', |
---|
47 | RefinementAlgorithm='OneStepFit') |
---|
48 | |
---|
49 | # Create a workspace containing background of diffraction data to fit background polynomial |
---|
50 | ProcessBackground(InputWorkspace='PG3_11485', |
---|
51 | OutputWorkspace='PG3_11485_Background', |
---|
52 | Options='SelectBackgroundPoints', |
---|
53 | LowerBound='5053', |
---|
54 | UpperBound='49387', |
---|
55 | BackgroundPoints='5243,8910,11165,12153,13731,15060,16511,17767,19650,21874,23167,24519,36000,44282,49000', |
---|
56 | NoiseTolerance='0.10000000000000001') |
---|
57 | |
---|
58 | # Fit background function |
---|
59 | Fit(Function='name=Polynomial,n=6,A0=0.558765,A1=-3.36699e-05,A2=-9.89997e-10,A3=2.29598e-13,A4=-1.07727e-17,A5=2.10058e-22,A6=-1.49446e-27', |
---|
60 | InputWorkspace='PG3_11485_Background', |
---|
61 | MaxIterations='1000', |
---|
62 | Minimizer='Levenberg-MarquardtMD', |
---|
63 | CreateOutput='1', |
---|
64 | Output='PG3_11485_Background', |
---|
65 | StartX='5053',EndX='49387') |
---|
66 | |
---|
67 | # Use LeBailFit to calculate the diffraction pattern to see whether the refined geometry-related parameters are good as starting value |
---|
68 | LeBailFit(InputWorkspace='PG3_11485', |
---|
69 | OutputWorkspace='CalculatedPattern0', |
---|
70 | InputParameterWorkspace='Bank1InstrumentParameterTable1_01', |
---|
71 | OutputParameterWorkspace='Bank1InstrumentParameterTable1_0', |
---|
72 | InputHKLWorkspace='BraggPeakParameterTable1', |
---|
73 | OutputPeaksWorkspace='BraggPeakParameterTable2_0', |
---|
74 | Function='Calculation', |
---|
75 | BackgroundParametersWorkspace='PG3_11485_Background_Parameters', |
---|
76 | UseInputPeakHeights='0',PeakRadius='8',Minimizer='Levenberg-Marquardt') |
---|
77 | |
---|
78 | # Use LeBailFit to refine POWGEN's instrument profile parameters by Monte Carlo algorithm |
---|
79 | LeBailFit(InputWorkspace='PG3_11485', |
---|
80 | OutputWorkspace='PG3_11485_MC_1000', |
---|
81 | InputParameterWorkspace='Bank1InstrumentParameterTable1_0', |
---|
82 | OutputParameterWorkspace='Bank1InstrumentParameterTable_MC', |
---|
83 | InputHKLWorkspace='BraggPeakParameterTable1', |
---|
84 | OutputPeaksWorkspace='BraggPeakParameterTable3', |
---|
85 | FitRegion='5053,49387', |
---|
86 | Function='MonteCarlo', |
---|
87 | BackgroundParametersWorkspace='PG3_11485_Background_Parameters', |
---|
88 | UseInputPeakHeights='0', |
---|
89 | PeakRadius='8', |
---|
90 | Minimizer='Levenberg-Marquardt', |
---|
91 | Damping='0.90000000000000002', |
---|
92 | NumberMinimizeSteps='1000', |
---|
93 | FitGeometryParameter='1', |
---|
94 | RandomSeed='1000', |
---|
95 | AnnealingTemperature='10', |
---|
96 | DrunkenWalk='1') |
---|