Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sequential_refinements_-_save_phase_pattern [2020/04/20 12:53]
iangie
sequential_refinements_-_save_phase_pattern [2021/05/13 05:07] (current)
iangie [Extracting the intensity contribution from a certain phase for a batch of dataset]
Line 1: Line 1:
-====== Extracting the intensity contribution from a certain phase from a batch data set ======+====== 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..."​. 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.+However, there were multiple questions asked in the forum concerning how to extract phase contribution through Launch Mode .inp file setup, and how to do this even for a batch dataset.
  
-The solution below has been enlightened by the Alan Coelho'​s 2-step refinement & Matthew Rowles'​s Sequential Refinement method.+The solution below has been enlightened by Alan Coelho'​s 2-step refinement ​solution ​& 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:+TOPAS V6 allows a keyword //​num_runs//​ which instructs the programme to run an .inp file multiple times. This 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 ====== ​
 <code topas> <code topas>
 num_runs 2 num_runs 2
Line 16: Line 17:
  
 #if Run_Number == 0; #if Run_Number == 0;
-system_before_save_OUT { copy INP_File##​.inp INP_File##​.backup }  ​'Backup this .inp file in the first run.  +system_before_save_OUT { copy INP_File##​.inp INP_File##​.backup }  ​/* Backup this .inp file in the first run. */
 #​endif  ​ #​endif  ​
  
-out_file = Concat(String(INP_File),​ "​.INP"​); ​           ' ​This allow the refinement result to be accepted.+out_file = Concat(String(INP_File),​ "​.INP"​); ​          /* This allow the refinement result to be accepted. ​*/
  
 #if Run_Number == 1; #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 +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 ​   #​endif ​  
     ​     ​
- 
 xdd "​somepattern.raw"​ xdd "​somepattern.raw"​
        
Line 33: Line 31:
    bkg @ 713.3525387 332.4034599 -218.0099371    bkg @ 713.3525387 332.4034599 -218.0099371
    ​One_on_X(@,​ 9993.352223)    ​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 ​   #​endif ​  
  
    ​LP_Factor( 0)    ​LP_Factor( 0)
    ​Specimen_Displacement(samp_disp,​ -0.05080112471)    ​Specimen_Displacement(samp_disp,​ -0.05080112471)
-   Mixture_LAC_1_on_cm0) +   Radius(300)
-   ​mixture_MAC 0 +
-   ​mixture_density_g_on_cm3 1.6605402e+22 +
-   Rp 300 +
-   Rs 300+
    ​lpsd_th2_angular_range_degrees ​ 2.29    ​lpsd_th2_angular_range_degrees ​ 2.29
       lpsd_equitorial_divergence_degrees ​ 0.5       lpsd_equitorial_divergence_degrees ​ 0.5
-   ​axial_conv  +      Full_Axial_Model(12202055)
-      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)    ​CuKa(0.0001)
        
Line 56: Line 45:
       xdd_out Output_phase_contribution.xy load out_record out_fmt out_eqn       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 ​ " = 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; ​                                                   /* You can add Ln() in the equation , if you want to plot as the intensity of the 2D plot in logarithm scale. */
-       "​ %11.6f\n ​ " = Ycalc;+
        }        }
 #endif #endif
- 
    
 #if (Run_Number == 0) #if (Run_Number == 0)
- ​xo_Is ​                               ' ​Amorphous Hump + ​xo_Is ​                              /* Amorphous Hump */
       xo @ 14.70505682       xo @ 14.70505682
       peak_type spv       peak_type spv
Line 81: Line 67:
       r_bragg ​ 1.213209076       r_bragg ​ 1.213209076
       phase_MAC 0       phase_MAC 0
-      phase_name "​hkl_Al" ​                ' ​Internal Standard +      phase_name "​hkl_Al" ​               /​*  ​Internal Standard ​ ​*/ ​     
-      +
       MVW( 0, 65.99173092,​ 0)       MVW( 0, 65.99173092,​ 0)
       space_group Fm-3m       space_group Fm-3m
-      Cubic(!a_000040787 4.049) ​          'Fixed to the lattice parameter from a PDF card. +      Cubic(!a_000040787 4.049) ​         /​*  ​Fixed to the lattice parameter from a PDF card. */
  
-   ​hkl_Is ​ 
-      hkl_m_d_th2 1 0 0 6 3.72346902 23.8787327 I @ 0.0001220703125_LIMIT_MIN_1e-15 
-      hkl_m_d_th2 0 0 1 2 3.66351223 24.2754326 I @ 4.043069301 
-      ... 
-      e0_from_Strain( 0.0004851245559,​@,​ 0.2223647167_LIMIT_MIN_0.0001,,​) 
-      r_bragg ​ 0.1279653452 
-      phase_MAC 0 
-      phase_name "​hkl_LiC6" ​                                        '​ Some other irrelevant phases ​ 
-      ​ 
-      MVW( 0, 58.64925299,​ 0) 
-      space_group P6/mmm 
-      Hexagonal(a_010834148 4.299491625,​c_010834148 3.66351217) 
 #endif #endif
  
Line 109: Line 82:
       r_bragg ​ 0.2228689481       r_bragg ​ 0.2228689481
       phase_MAC 0       phase_MAC 0
-      phase_name "​hkl_Na0.53MnO2" ​        ' ​This is the phase of interest, which you want its intensity contributions saved out  +      phase_name "​hkl_Na0.53MnO2" ​       /​* ​This is the phase of interest, which you want its intensity contributions saved out */      
-      +
       MVW( 0, 78.20697387,​ 0)       MVW( 0, 78.20697387,​ 0)
       space_group P63/mmc       space_group P63/mmc
Line 116: Line 88:
    
 </​code> ​     </​code> ​    
-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). ​+It can be seen that, in the first run (Run_Number = 0), the #if switches ​allow 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.+In the second run (Run_Number = 1), the #if switches only turn on the phase of interest with "iters 0" and get the intensity saved out.
  
-To apply this method for a batch of data set (e.g. in-situ data set), which contains, say 100 patterns, ​.inp file with "​num_run ​2 * 100;" can be set as below:+====== 2Extracting phase contribution from batch dataset ======
  
-The below setup has an restriction ​that, 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. +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. 
  
 <code topas> <code topas>
  
-num_runs =2*100; ​    'This set the Reserved Keywords "​Run_Number"​ goes from 0 to 199 +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 ​+
  
 +#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. Refinements goes on like tik-tok tik-tok … */
 iters 0 iters 0
 #endif #endif
Line 137: Line 110:
 #​endif  ​ #​endif  ​
  
-out_file = Concat(String(INP_File),​ "​.INP"​); ​          'This accepts the refinement result, especially the sample displacement ​ +out_file = Concat(String(INP_File),​ "​.INP"​); ​          /* This accepts the refinement result, especially the sample displacement ​*/
  
 #if Run_Number == 2*100-1; #if Run_Number == 2*100-1;
Line 144: Line 116:
 #​endif ​   #​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! +#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+xdd Somepattern_#​out filenum##​.raw ​        /* This allow TOPAS to find the corresponding pattern ​ */
  
 #if (Mod(Run_Number,​2) == 0) #if (Mod(Run_Number,​2) == 0)
    bkg @ 713.3525387 332.4034599 -218.0099371    bkg @ 713.3525387 332.4034599 -218.0099371
    ​One_on_X(@,​ 9993.352223)    ​One_on_X(@,​ 9993.352223)
-#else bkg 100                              ' ​A arbitrary ​bkg 100 is added to the phase contribution in case some plotting software ​don'​t ​like 0 intensity.+#else bkg 1                             /​* ​A arbitrary ​1 count is added to the phase contribution in case some plotting software ​does not like 0 intensity. ​ */ 
 +#​endif ​  
  
-#​endif ​   
    ​LP_Factor( 0)    ​LP_Factor( 0)
    ​Specimen_Displacement(samp_disp,​ -0.05080112471)    ​Specimen_Displacement(samp_disp,​ -0.05080112471)
-   Mixture_LAC_1_on_cm0) +   Radius(300)
-   ​mixture_MAC 0 +
-   ​mixture_density_g_on_cm3 1.6605402e+22 +
-   Rp 300 +
-   Rs 300+
    ​lpsd_th2_angular_range_degrees ​ 2.29    ​lpsd_th2_angular_range_degrees ​ 2.29
       lpsd_equitorial_divergence_degrees ​ 0.5       lpsd_equitorial_divergence_degrees ​ 0.5
-   ​axial_conv  +      Full_Axial_Model(12202055)
-      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)    ​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 +#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       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 ​ " = X + 2 samp_disp Cos(X Deg_on_2)/​Rp Rad;   /* Correct sample displacement of the phase, because the in-situ cell pops up */        
-        +       "​ %11.6f\n ​ " = Ycalc; ​                                 /* You can add Ln() in the equation , if you want to plot as the intensity of the 2D plot in logarithm scale. */
-       "​ %11.6f\n ​ " = Ycalc;+
        }        }
-      ​#endif+#endif
  
 #if (Mod(Run_Number,​2) == 0) #if (Mod(Run_Number,​2) == 0)
- ​xo_Is ​                              'Amorphous hump + ​xo_Is ​                             /​*  ​Amorphous hump */
       xo @ 14.70505682       xo @ 14.70505682
       peak_type spv       peak_type spv
Line 201: Line 159:
       r_bragg ​ 1.213209076       r_bragg ​ 1.213209076
       phase_MAC 0       phase_MAC 0
-      phase_name "​hkl_Al" ​                  'Internal Standard with fixed lattice parameter +      phase_name "​hkl_Al" ​                  /​*  ​Internal Standard with fixed lattice parameter ​ ​*/ ​     
-      +
       MVW( 0, 65.99173092,​ 0)       MVW( 0, 65.99173092,​ 0)
       space_group Fm-3m       space_group Fm-3m
       Cubic(!a_000040787 4.049)       Cubic(!a_000040787 4.049)
  
-   ​hkl_Is ​ 
-      hkl_m_d_th2 1 0 0 6 3.72346902 23.8787327 I @ 0.0001220703125_LIMIT_MIN_1e-15 
-      hkl_m_d_th2 0 0 1 2 3.66351223 24.2754326 I @ 4.043069301 
-      ... 
-      LVol_FWHM_CS_G_L( 1, 689.7614989,​ 0.89, 964.2925977,,,​@,​ 1083.474829_LIMIT_MIN_0.3) 
-      e0_from_Strain( 0.0004851245559,​@,​ 0.2223647167_LIMIT_MIN_0.0001,,​) 
-      r_bragg ​ 0.1279653452 
-      phase_MAC 0 
-      phase_name "​hkl_LiC6" ​                 'Other irrelevant phases ​ 
-      ​ 
-      MVW( 0, 58.64925299,​ 0) 
-      space_group P6/mmm 
-      Hexagonal(a_010834148 4.299491625,​c_010834148 3.66351217) 
 #endif #endif
  
Line 230: Line 174:
       r_bragg ​ 0.2228689481       r_bragg ​ 0.2228689481
       phase_MAC 0       phase_MAC 0
-      phase_name "​hkl_Na0.53MnO2" ​   ​' ​The phase of interest, the intensity of which needs be saved out  +      phase_name "​hkl_Na0.53MnO2" ​   ​/* The phase of interest, the intensity of which needs be saved out */      
-      +
       MVW( 0, 78.20697387,​ 0)       MVW( 0, 78.20697387,​ 0)
       space_group P63/mmc       space_group P63/mmc
Line 237: Line 180:
       ​       ​
 </​code> ​     ​ </​code> ​     ​
-   + 
 +====== 3. Plot the extracted phase intensity as 2D plot using TOPAS V6 ====== 
 +Note the saved phase intensities .xy files will be in different X step positions.  
 + 
 +Some algorithms require long time to create 2D plot when the data are not in an uniform mesh.  
 + 
 +Surprisingly the 2D plot function in TOPAS v6 can create below 2D plot from 100 .xy data of non-uniform data step very quickly, which persuaded me no need to turn to other plotting software: 
 + 
 +The example of the plot is like [[https://​cloudstor.aarnet.edu.au/​plus/​s/​3sjimyTzfPse30L | this]]. 

Personal Tools