This is an old revision of the document!


Extracting the intensity contribution from a certain phase for a batch of dataset

Intensity contribution from individual phase can be saved out from GUI interface “right-click → save if displayed…”.

However, there were multiple questions asked in the forum concerning how to extract phase contribution through Launch Mode .inp file setup, and even do this for in-situ data set.

The solution below has been enlightened by the Alan Coelho's 2-step refinement & Matthew Rowles's Sequential Refinement method.

TOPAS V6 allows a keyword num_runs which instructs the programme to run an .inp file multiple times, which means above 2-step solution can be devised in one .inp file with “num_runs 2” and several #if switches:

1. Extracting phase contribution from a single data

num_runs 2
 
#if (Run_Number == 1)
iters 0
#endif
 
#if Run_Number == 0;
system_before_save_OUT { copy INP_File##.inp INP_File##.backup }  /* Backup this .inp file in the first run. */
#endif  
 
out_file = Concat(String(INP_File), ".INP");           /* This allow the refinement result to be accepted. */
 
#if Run_Number == 1;
system_after_save_OUT { copy INP_File##.backup INP_File##.inp }    /* Restore this .inp file to its initial status from the backup in the final run */
#endif   
 
xdd "somepattern.raw"
 
#if (Run_Number == 0)
   bkg @ 713.3525387 332.4034599 -218.0099371
   One_on_X(@, 9993.352223)
#else bkg 1                             /* A arbitrary 1 count is added to the phase contribution in case some plotting software does not like 0 intensity.  */
#endif   
 
   LP_Factor( 0)
   Specimen_Displacement(samp_disp, -0.05080112471)
   Mixture_LAC_1_on_cm( 0)
   mixture_MAC 0
   mixture_density_g_on_cm3 1.6605402e+22
   Rp 300
   Rs 300
   lpsd_th2_angular_range_degrees  2.29
      lpsd_equitorial_divergence_degrees  0.5
   axial_conv 
      filament_length  12
      sample_length  20
      receiving_slit_length  20
      primary_soller_angle  5
      secondary_soller_angle  5
      axial_n_beta  30
   CuKa(0.0001)
 
#if (Run_Number == 1)
      xdd_out Output_phase_contribution.xy load out_record out_fmt out_eqn
      {
       " %11.6f  " = X + 2 samp_disp Cos(X Deg_on_2)/Rp Rad;                     /* Correct sample displacement from an internal standard, hkl_Al in this case */       
       " %11.6f\n  " = Ycalc;
       }
#endif
 
 
#if (Run_Number == 0)
 xo_Is                               /* Amorphous Hump */
      xo @ 14.70505682
      peak_type spv
         spv_h1 @ 0.9845624876
         spv_h2 @ 1.396576759
         spv_l1  0.0040801296_LIMIT_MIN_0
         spv_l2  0.9958599408_LIMIT_MAX_1
      I  97.34548273
 
   hkl_Is 
      hkl_m_d_th2 1 1 1 8 2.33311367 38.5568314 I @ 74.14699402
      hkl_m_d_th2 2 0 0 6 2.02053571 44.8203506 I @ 96.76241314
      LVol_FWHM_CS_G_L( 1, 113.2882082, 0.89, 158.3779042,,,@, 177.9527013_LIMIT_MAX_115.908746)
      Stephens_cubic(@, 0.2634600653_LIMIT_MIN_0,@, -2072.424113,@, -5379.345555)
      r_bragg  1.213209076
      phase_MAC 0
      phase_name "hkl_Al"                /*  Internal Standard  */      
      MVW( 0, 65.99173092, 0)
      space_group Fm-3m
      Cubic(!a_000040787 4.049)          /*  Fixed to the lattice parameter from a PDF card. */
 
#endif
 
   hkl_Is 
      hkl_m_d_th2 0 0 2 2 5.54676771 15.9653101 I @ 2.664253279
      hkl_m_d_th2 0 0 4 2 2.77338386 32.2515259 I @ 10.48756371
      ...
      LVol_FWHM_CS_G_L( 1, 173.7971979, 0.89, 242.97,,,, 273_LIMIT_MIN_200 min =200;)
      e0_from_Strain( 0.001701696021,, 0.78,,)
      r_bragg  0.2228689481
      phase_MAC 0
      phase_name "hkl_Na0.53MnO2"        /* This is the phase of interest, which you want its intensity contributions saved out */      
      MVW( 0, 78.20697387, 0)
      space_group P63/mmc
      Hexagonal(a_040201752 2.853135761,c_040201752 11.09353545)
 

It can be seen that, in the first run (Run_Number = 0), the #if switches allows a normal Pawley refinement which refines the sample displacement according to an internal standard (hkl_Al in this case).

In the second run (Run_Number = 1), the #if switches only turned on the phase of interest with “iters 0” and get the intensity saved out.

2. Extracting phase contribution from a batch dataset

To apply this method for a batch of data set (e.g. in-situ data set), which contains, say 100 patterns, an .inp file with “num_run = 2 * 100;” can be set as below:

(The restriction of this setup is, the file names of the dataset must contain an increasing run number: e.g. *_1.raw, *_2.raw, ***_3.raw, ….. A simple windows/DOS batch rename can achieve this. )

num_runs =2*100;                /* This set the Reserved Keywords "Run_Number" goes from 0 to 199 */
 
#if (Mod(Run_Number,2) == 1)    /* Normal Pawley refinement when Run_Number is an even number; Save the phase intensity when Run_Number is an odd number */
iters 0
#endif
 
#if Run_Number == 0;
system_before_save_OUT { copy INP_File##.inp INP_File##.backup }
#endif  
 
out_file = Concat(String(INP_File), ".INP");           /* This accepts the refinement result, especially the sample displacement */
 
#if Run_Number == 2*100-1;
system_after_save_OUT { copy INP_File##.backup INP_File##.inp }
#endif   
 
#prm filenum = Round((Run_Number+1)/2);    /* This calculates the run number of the file, NOTE Round(0.5) evaluates to 0 in TOPAS V5, but evaluates to 1 in TOPAS V6! */
 
xdd Somepattern_#out filenum##.raw         /* This allow TOPAS to find the corresponding pattern  */
 
#if (Mod(Run_Number,2) == 0)
   bkg @ 713.3525387 332.4034599 -218.0099371
   One_on_X(@, 9993.352223)
#else bkg 1                             /* A arbitrary 1 count is added to the phase contribution in case some plotting software does not like 0 intensity.  */
#endif   
 
   LP_Factor( 0)
   Specimen_Displacement(samp_disp, -0.05080112471)
   Mixture_LAC_1_on_cm( 0)
   mixture_MAC 0
   mixture_density_g_on_cm3 1.6605402e+22
   Rp 300
   Rs 300
   lpsd_th2_angular_range_degrees  2.29
      lpsd_equitorial_divergence_degrees  0.5
   axial_conv 
      filament_length  12
      sample_length  20
      receiving_slit_length  20
      primary_soller_angle  5
      secondary_soller_angle  5
      axial_n_beta  30
 
   CuKa(0.0001)
 
#if (Mod(Run_Number,2) == 1)            /* When Run_Number is an odd number, save the phase contribution to a file with the run number of its raw data  */
      xdd_out OUTPUT_NMO_#out filenum##.xy load out_record out_fmt out_eqn
      {
       " %11.6f  " = X + 2 samp_disp Cos(X Deg_on_2)/Rp Rad;   /* Correct sample displacement of the phase  */       
       " %11.6f\n  " = Ycalc;
       }
      #endif
 
#if (Mod(Run_Number,2) == 0)
 xo_Is                              /*  Amorphous hump */
      xo @ 14.70505682
      peak_type spv
         spv_h1 @ 0.9845624876
         spv_h2 @ 1.396576759
         spv_l1  0.0040801296_LIMIT_MIN_0
         spv_l2  0.9958599408_LIMIT_MAX_1
      I  97.34548273
 
   hkl_Is 
      hkl_m_d_th2 1 1 1 8 2.33311367 38.5568314 I @ 74.14699402
      hkl_m_d_th2 2 0 0 6 2.02053571 44.8203506 I @ 96.76241314
      LVol_FWHM_CS_G_L( 1, 113.2882082, 0.89, 158.3779042,,,@, 177.9527013_LIMIT_MAX_115.908746)
      Stephens_cubic(@, 0.2634600653_LIMIT_MIN_0,@, -2072.424113,@, -5379.345555)
      r_bragg  1.213209076
      phase_MAC 0
      phase_name "hkl_Al"                   /*  Internal Standard with fixed lattice parameter  */      
      MVW( 0, 65.99173092, 0)
      space_group Fm-3m
      Cubic(!a_000040787 4.049)
 
#endif
 
   hkl_Is 
      hkl_m_d_th2 0 0 2 2 5.54676771 15.9653101 I @ 2.664253279
      hkl_m_d_th2 0 0 4 2 2.77338386 32.2515259 I @ 10.48756371
      ...
      LVol_FWHM_CS_G_L( 1, 173.7971979, 0.89, 242.97,,,, 273_LIMIT_MIN_200 min =200;)
      e0_from_Strain( 0.001701696021,, 0.78,,)
      r_bragg  0.2228689481
      phase_MAC 0
      phase_name "hkl_Na0.53MnO2"    /* The phase of interest, the intensity of which needs be saved out */      
      MVW( 0, 78.20697387, 0)
      space_group P63/mmc
      Hexagonal(a_040201752 2.853135761,c_040201752 11.09353545)
 

Personal Tools