Changeset 3094

Ignore:
Timestamp:
Sep 21, 2017 2:36:00 PM (5 years ago)
Message:

revise & update to 2 frame

Location:
Tutorials/SeqParametric
Files:
46 deleted
22 edited

Unmodified
Removed
• Tutorials/SeqParametric/ParametricFitting.htm

 r2324 B Toby Von Dreele 3 986 vondreele 6 1765 2014-07-22T21:21:00Z 2015-03-20T13:49:00Z 1 1645 9379 2017-09-21T19:33:00Z 21 1721 9814 Argonne National Laboratory 78 22 11002 15.00 81 23 11512 16.00

If you look through the table, you will see how each variable changed through the temperature series. In particular the CuCrO4 b & c lattice parameters become nearly identical above ~120K (PWDR OH_24.fxye Bank 1). Select these two columns (0::b & 0::c) and do Columns/Plot selected

Select the plot & press the s key; the popup will show

Select Temperature and press OK; do Columns/Plot selected again. The x-axis will be temperature

It would seem that there is a phase transition where the orthorhombic low temperature phase is transformed to a miss-indexed tetragonal phase where b=c. This phase transition has been previously explored by Suchomel, Shoemaker & Ribaud (Phys. Rev. B86, 054406, 2012) and the data used in that study is used here in this tutorial. We will be investigating this transition with the parametric fitting tools in GSAS-II

Step 2. Create a Pseudo Variable

Pseudo-variables allow computation of an arbitrarily defined function of combinations of the variables that are displayed in the sequential refinement table. Any valid Python language expression can be used to define this. While one can plot a, While one can plot a, b and c axis lengths by clicking on the appropriate column of the table; it will be more useful to have some mathematical relationship among them. We can define pseudo-variables that allow computation of an arbitrarily defined function of combinations of parameters that are displayed in the sequential refinement table. Any valid Python language expression can be used to define them. For this phase transition it is most useful to view the ratio of b and c axis lengths by clicking on the appropriate column of the table, to compare them one might want to scale them. Alternately, as will be done here, we will plot the ratio of b and c.

normal'>c.

Click on the Pseudo Vars/Add Formula menu item to create a new pseudo-variable.

major-latin;mso-hansi-theme-font:major-latin'>Pseudo Vars/Add Formula menu item to create a new pseudo-variable. A window opens to define a formula

2.      A window opens to define a formula

mso-no-proof:yes'>

In src="ParametricFitting_files/image031.jpg" align=right hspace=12 v:shapes="Picture_x0020_4">In this window, type a Python expression, "b/c", but note that the variables c and b here are arbitrary labels. After entering the formula, press the Validate button or wait a few seconds and the validation will be tested automatically. Note that if you pause too long, while typing, an error message may be displayed as the incomplete formula is found to be invalid. If so, make corrections or keep typing until the entire expression is entered. The error message will sometimes show where error is encountered, though not in this case.

the variables b and c are arbitrary labels. After entering the formula, press the Validate button or wait a few seconds and the validation will be tested automatically. Note that if you pause too long, while typing, an error message may be displayed as the incomplete formula is found to be invalid. If so, make corrections or keep typing until the entire expression is entered.

table appears where the arbitrary c and b and b labels will be major-latin;mso-hansi-theme-font:major-latin'>c labels will be assigned.

3.      style='mso-list:Ignore'>2.      Assign src="ParametricFitting_files/image035.jpg" align=right hspace=12 v:shapes="Picture_x0020_6">Assign the label for the numerator by clicking on the menu button next to label Phase to bring up a list of phase variables, from that list select variable lattice as a filter and from that list select variable 0::b, which is the b lattice parameter for phase 0 (CuCr2O4). Press OK. Repeat this process to select assign to label 0::b, which is the b lattice parameter for phase 0 (CuCr2O4). Repeat this process to select assign to label c variable 0::b.

mso-ascii-theme-font:major-latin;mso-hansi-theme-font:major-latin'>0::c.

As each variable is set, the window shows the value for each variable from the first refinement and when the expression can be evaluated, the value for the expression, evaluated for that first the value for each variable from the first refinement and when the expression can be evaluated, the value for the expression, evaluated for that first refinement. Only when the expression can be evaluated can the

OK to close the window and add the pseudo-variable. Note that a new column appears at the end of the sequential refinement data table.

to close the window and add the pseudo-variable. Note that a new column (b/c) appears at the end of the sequential refinement data table.

Also note that positioning the mouse above any cell in the table and waiting for a few seconds causes the s.u. to be shown as a tooltip.

mso-no-proof:yes'>

Also note that positioning the mouse above any cell in the table and waiting for a few seconds causes the s.u. to be shown as a tooltip.

The main feature is the b/c ratio falls to ~1 at ~120K and is then essentially constant at higher temperatures. It looks like a second order phase transition since the lattice parameter change isnt confined to a single temperature. Notice that the b/c ratio shows some instability above the transition. This is because the refinement is somewhat ill conditioned after the phase transition because of parameter degeneracies. This can be improved by modifying the Singular Value Decomposition (SVD) zero tolerance. Go to the Controls main tree item and change this parameter to 0.0001.

Press the "s" key inside the plot to select Temperature as the x-axis.

Then repeat the sequential refinement (perhaps twice); the new b/c plot is now much cleaner after the phase transition.

The plot will then appear as below:

Step 3: Fitting a simple parametric equation to the unit cell volume

Step 3: Fitting a simple parametric equation to the unit cell volume

normal'>0::Vol, to plot the unit volume for the first phase vs. T, and fit this to a straight line.

unit volume for the first phase vs. T, and fit this to a straight line (even though it obviously isnt straight)

mso-no-proof:yes'>

1.      Click src="ParametricFitting_files/image077.jpg" align=right hspace=12 v:shapes="Picture_x0020_16">Click on the Parametric

mso-bidi-font-family:"Times New Roman"'>2.
Click the emptybutton to select a dependent variable for "y". From the phase list, select the unit cell volume for the CuCr2O4 phase, select 0::Vol and then press OK.

major-latin;mso-hansi-theme-font:major-latin'> button in the upper left corner to select a dependent variable for "y". From the phase list (use vol as a filter), select the unit cell volume for the CuCr2O4 phase, select 0::Vol and then press OK.

The Expression Editor will be updated to show the new y parameter

mso-no-proof:yes'>

style='mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman"'>4.      Assign b and m as refinable free parameters: Click on the b and button next to b and selectm as refinable free parameters: Click on the button next to b and select Free. Then repeat this for Free. Then repeat this for m.

mso-hansi-theme-font:major-latin'>m
.

To src="ParametricFitting_files/image085.jpg" align=right hspace=12 v:shapes="Picture_x0020_24">To set x as the temperature, click on the button next to x, select Global, and then select Temperature from the list and click on OK.

as the temperature, click on the button next to x, select Global, and then select Temperature from the list and click on OK.

id="Picture_x0020_17" o:spid="_x0000_i1036" type="#_x0000_t75" style='width:6in; height:172.5pt;visibility:visible;mso-wrap-style:square'>

The window then changes, showing the values of the dependent variable and the expression for the first refinement, as below.  Optionally, the values for   Optionally, the values for m

6.      values are then refined and the console shows the results:

7.

Fit Results

0::Vol = m*x +b

x  = Temperature

b  = 561.7722(26)

m  = 0.014833(14)

Also, the plot shows the actual values and the fit. Note that while the values are close to a straight line, the deviations are huge compared to the estimated uncertainty values for the unit cell volume (shown as very small error bars, unless the plot is magnified).  If a linear relationship had been defined as a constraint (as can be done with other software packages) the

Also, the plot shows lines for the data values and the fit. Note that while the values are close to a straight line, the deviations are huge compared to the estimated uncertainty values for the unit cell volume (shown as very small error bars, unless the plot is magnified).  NB: If a linear relationship had been defined as a constraint (as can be done with other software packages) the unit cell parameters would have been forced onto this line with no obvious indication that this was not a correct result.

Step 4: Examples of more complex fitting equations

Step 4: Fitting to a Pseudovariable

Here we will look at how more sophisticated Python capabilities can be used to fit more complex behavior.

capabilities can be used to fit more complex behavior and use a pseudovariable

1.      Optionally Double-click on the 0::c column. Note the changes in the c unit cell parameter as a function of temperature, as shown below.

Double-click on the b/c column. We will be trying to extract the critical exponent for this 2nd order phase transition from this data.

style='mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman"'>2.      We will now fit c as a function of form 1/(1 + exp[k(t-t0)]). Select theb/c
as a function of form 1/(1 + exp[k(t-t0)]). Select the Parametric Fit/Add equation menu item (as before). For the dependent variable, click on Parametric Fit/Add equation menu item (as before). For the dependent variable, click on Phase and then select 0::c.

major-latin'>Global
and then select b/c.

b + c / (1+math.exp(k*(t-t0)))

mso-ascii-theme-font:major-latin;mso-hansi-theme-font:major-latin'>a + b / (1+np.exp(k*(t-t0)))

b, c, a, b, k andb_1. If the same variable name (b_1 because the symbol b) was used again here, the same value would be used to fit both equations, which is certainly not what we want here. Finally, since this equation is too complex to fit without some reasonable starting values, specify an approximate value, 120, for the vicinity of where the c lattice parameter starts to change (t0) and non-zero values for variables c and k.

mso-ascii-theme-font:major-latin;mso-hansi-theme-font:major-latin;mso-bidi-theme-font: major-latin'>b was used in the previous equation for fitting the volume. If the same variable name (b) was used again here, the same value would be used to fit both equations, which is certainly not what we want here.  Finally, since this equation is too complex to fit without some reasonable starting values, specify an approximate value, 120, for the vicinity of where the c lattice parameter starts to change (t0) and non-zero values for variables c and k.

normal'>Fit button to see if the equation can be refined with starting values of zero for the other three parameters.  A fit is obtained and is plotted.

the equation can be refined with starting values of zero for the other three parameters.  A fit is obtained and is plotted; the fit is quite poor.

To give it more reasonable starting values, set a=1.0, b=0.1,k=0.1 and t0=120. Press Fit again; the plot shows a better (but not right) fit.

OK to add this equation to the parametric fits and both equations are refit (and if the label for b had not been changed, applying the constraint that b must be the same for both equations.)

7.      We will now try a more complex equation for the same data, where we set the value to b for temperatures less than t0 and a critical phenomenon formulism [(t-t0)-a] for temperatures above t0. To do this we use the Python syntax "x1 if testexp else x2" which is x1 where the test expression (testexp here) is True and x2 otherwise. Thus we can use an expression such as:

b if t <= t0 else b + c * (1-(t-t0)**d)

This may be easier to read with the inclusion of extra parentheses (that have no effect on the execution):

b if (t <= t0) else (b + c * (1-(t-t0)**d))

As before, add an equation (or edit an existing one), set the dependent variable to 0::c, enter the expression and assign the free and fixed variables, as before. Set the exponent and the t0 values to initial values of -0.025 and 120, respectively, and turn off their refinement flags. Then press Fit.

Then turn refinement of t0 back on and press OK. The resulting fit shows the trends quite well:

parametric fits and both equations are refit. The fit is ok but this is not the correct expression for critical phenomena.

Step 5: Fitting to a Pseudo Variable

One can fit a function to a pseudo variable, just as to a direct variable. If we look at the plot shown in Step 2, it appears there are two regions. We can treat the lower range as a power-law growth, Tk, and the upper region as linear (m*T + b).

If we look at the above plot, it appears there are two regions. We can treat the lower range as a power-law decay, Tk, and the upper region as linear (m*T + b).

auto'>(o1 + (a1*T)**k) if T < 120 else (o2 + a2*T)

"Lucida Grande";color:black'>a+((T0-T)/T0)**k if T < T0 else d+e*T

k) and scaling factor (a1), cannot start as zero.

mso-ascii-theme-font:major-latin;mso-hansi-theme-font:major-latin'>a), cannot start as zero; T0 should be set to 120..

# file fittest.py
def fitfxn(T,o1,o2,a1,a2,k):
if T < 120:
return o1 + (a1*T)**k
else:
return o2 + a2*T

The function fittest.fitfxn can then be used to duplicate the previous example:

#file fittest.py

def fitfxn(T,T0,a,k,d,e):

if T < T0:

return a+((T0-T)/T0)**k

else:

return d+e*T

The function fittest.fitfxn can then be used to duplicate the previous example:

id="Picture_x0020_44" o:spid="_x0000_i1025" type="#_x0000_t75" style='width:6in; height:289.5pt;visibility:visible;mso-wrap-style:square'>

• Tutorials/SeqParametric/ParametricFitting_files/filelist.xml

 r1745
Note: See TracChangeset for help on using the changeset viewer.