[CCP14 Home: (Frames | No Frames)]
CCP14 Mirrors: [UK] | [CA] | [US] | [AU]

(This Webpage Page in No Frames Mode)


Tutorials and Examples

LHPM-Rietica Rietveld for Win95/NT by Brett Hunter

An example of automatic mass Rietveld powder diffraction data analysis within Rietica using Rietbasic macros

The CCP14 Homepage is at http://www.ccp14.ac.uk

[Tutorials page] | [LHPM-Rietica Tutorial Index]

The following is used as an example of using the Rietbasic macro languate to perform automatic refinement runs on a large number of near identical data files (preferably in a numeric sequence (any Rietica supported data format is acceptable) - blah01.cpi, blah02.cpi, blah03.cpi, etc).

Click here to download the example script and data files.

In the above example data (Le Bail fitting to perform unit-cell refinement), the initial optimisation found for this data consisted of (Cubic P M 3 M with a=b=c=3.77):

  • Peak profile could be adequately fitted with V W width and the first gamma shape parameter

  • Background was happy by using the Automatic Smoothed mode.

  • An area of the pattern was excluded (use Right Mouse Button, Insert Excluded) (the blue area in the following screen dumps) that had impurity area.

  • 30 cycles was a good number to perform in this case to ensure convergence.

  • It is useful to have as defaults (via File, Preference):
    • automatic assign data file name,
    • DON'T use a temporary directory,
    • Refine at start and update boxes ticked.

Optimising the first pattern in the series

This has probably been done already but optimise the first dataset in your file sequence by slowing releasing parameters; and get the best fit possible. (don't forget to press the Finish Icon so that the newly refined parameters are updated).

For information on setting up the first file, refer to Setting up Rietica for doing Le Bail whole profile unit cell refinement

Initial optimised pattern

The Rietbasic Script

Create a Rietbasic script to provide the automatic control (a PDF file is provided with the Rietica distribution giving the list of Rietbasic options). As Rietbasic is as a pseudo-programming language, it can be easier just to reverse-engineer and modify an existing Rietbasic script.

Thus, modify the following Rietbasic macro script to match the name and number of your data files (the script it is included in the zip file). You would change the following within the script:

filestem = 'dat_'
startnum = 10
endnum = 20

The example data provided performs mass Le Bail fitting to get unit-cell constants. If you were doing normal structure refinement, get rid of the following line (which copies over the HKL file with the Le Bail intensities:


One limitation with this present script is there is no plotting of the data. You should thus note how the fit parameter is varying and also look at the Rietveld plots after to visually make sure everything has gone as intended.

Put the rietbasic RIB file you edited in the same directory where your data exists.

// ----------------------------------------------------------
function NewRefineFile(afile as string) as integer
integer error,i
   i = 1
   error = openrietveld(afile)
   if error == 0 then
      error = startrietveld()
      if error == 0 then
          do while (i < 20) 
               error = steprietveld(1)
               write('Cycle '+Str(i)+' :  '+Str(GetFit(1)))
               i = i + 1
          if error == 0 then
             error = endrietveld()
//  update() is undocumented call to update the inp file with the latest information
//  Lachlan - be careful with this as potentially can corrupt starting input file
//  if refinement goes beserk.  Maintain a copy of you starting input file.
             error = update()
          end if
      end if
   end if
   NewRefineFile = error
end function
// ---------------------------------------------------------

string workdir, filestem, filenumber,filenumberx
integer i,j,k,error,startnum, endnum

//------ run specific info -------------------
// "REM_this_out unless you want to" WorkDir = 'D:\rietica_analysis\dummy\'
filestem = 'dat_'
startnum = 10
endnum = 20

j = 1
for i = startnum to endnum
   filenumber = Str(i)
   if i > 9 then
            j = 2
   elseif i > 99
            j = 3
   end if
   filenumber =  StrCopy(filenumber,1,j)   
   Write('Refining file '+workdir+filestem+filenumber)
   error = NewRefineFile(workdir+filestem+filenumber)
   if error == 0 then
      write('Refined file '+workdir+filestem+filenumber)
      write('Cell = '+Str(GetParameter(1, 1, 0, 6))+ '  '+Str(GetParameter(1, 1, 0, 7))+ ' 
                    '+Str(GetParameter(1, 1, 0, 8))+ '  '+Str(GetParameter(1, 1, 0, 9))+ ' 
                    '+Str(GetParameter(1, 1, 0, 10))+ ' '+Str(GetParameter(1, 1, 0, 11)))
      k= i + 1
      filenumberx = Str(k)
      filenumberx =  StrCopy(filenumberx,1,j)   
      Write('filenumber = '+filenumber)
      Write('filenumberx = '+filenumberx)
   end if
next i

Using Rietbasic in Rietica

Run Rietica and select, Rietveld, Rietveld Basic to bring up the following Rietbasic screen.

Rietbasic screen

To load the Rietbasic script, within the Rietbasic control menu select, File, Open and select the script file (which will then be displayed in the top half of the Rietbasic interface).

Rietbasic screen with Rietbasic script loaded

To run the script, select Run (in this case performing Le Bail fitting/unit-cell refinement on 10 datasets - it could as easily far more datasets); after which all your specified data will be analysed - or you may hit a logic bug in the script (if you hit problems, repair the script and try again).

Running a Rietbasic script

After running a Rietbasic script

After you perform the automatic analysis

Checking through the output produced in the lower Rietbasic screen. Load the inp files for any datasets that have higher fit values than surrounding files. (also, it can be good to check each Rietveld fit) You can see from the following that one of the datasets has extra impurity peaks.

Checking the refined data

[Tutorials page] | [LHPM-Rietica Tutorial Index]

[CCP14 Home: (Frames | No Frames)]
CCP14 Mirrors: [UK] | [CA] | [US] | [AU]

(This Webpage Page in No Frames Mode)

If you have any queries or comments, please feel free to contact the CCP14