Differences

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

Link to this comparison view

Next revision
Previous revision
out_with_suffix [2014/05/07 14:22]
martin_fisch created
out_with_suffix [2014/05/07 15:06]
martin_fisch
Line 1: Line 1:
-====== ​DAC_Abs_Correction ​====== +====== ​Out_with_suffix ​====== 
-Description: ​Absorption correction ​for diamond anvil cell dataCorrects intensity decrease with increasing 2-Theta due to longer beam paths through diamonds.+Description: ​Versatile output macro for multipattern ​.inp files.
  
-Comment: ​Actually not a macro, the structure ​of diamond in included with a scale factor of zero to calculate ​the correct value for u_per_cm_diamond for any given wavelength.+Comment: ​ 
 +In complex input files with many diffraction patterns (e.g. parametric ones), a different output is needed for e.g. each temperature.\\ Assuming there is consistent naming of parameters of interest, this can be done easier by using a macro for the outputin which the suffixes ​of the parameter names can be easily changed.
  
 Contributed by: Martin Fisch Contributed by: Martin Fisch
  
 <code topas> <code topas>
-scale_pks = Exp( - u_per_cm_diamond * ( 1 - 1/Cos(Deg * 2 * Th)));+xdd Scan_100.raw ' measured at 100 °C
 str str
-phase_name "Diamond+phase_name "PhaseX
-Cubic(3.56672) ​   +a lp_a_Phase_X_100 5 
-scale 0 +b lp_b_Phase_X_100 5 
-space_group ​"Fd-3mS+c lp_c_Phase_X_100 5 
-prm u_per_cm_diamond = (Get(phase_MAC* 1.6605402 ​Get(cell_mass/ Get(cell_volume));: 0 +scale scale_PhaseX_100 ​0.00001 
-site C x 0 y 0 z 0 occ C 1 beq 1+..... 
 +out Output.txt append 
 +Out(Get(xdd_path_name, ​"\n%s\t") 
 +Outlp_a_Phase_X_100 , "​%11.5f\t",​ "​%11.5f\t"​) 
 +Outlp_b_Phase_X_100 , "​%11.5f\t",​ "​%11.5f\t"​) 
 +Out( lp_c_Phase_X_100 , "%11.5f\t", "​%11.5f\t"​) 
 +..... 
 + 
 +xdd Scan_200.raw ' measured at 200 °C 
 +str 
 +phase_name "​PhaseX"​ 
 +a lp_a_Phase_X_200 6 
 +b lp_b_Phase_X_200 6 
 +c lp_c_Phase_X_200 6 
 +scale scale_PhaseX_200 0.00001 
 +..... 
 +out Output.txt append 
 +Out(Get(xdd_path_name,​ "​\n%s\t"​) 
 +Outlp_a_Phase_X_200 , "​%11.5f\t",​ "​%11.5f\t"​) 
 +Out( lp_b_Phase_X_200 , "​%11.5f\t",​ "​%11.5f\t"​
 +Out( lp_c_Phase_X_200 , "​%11.5f\t",​ "​%11.5f\t"​) 
 +..... 
 + 
 +xdd .....
 </​code>​ </​code>​
  
 +Is a lot easier by using a macro:
 +
 +<code topas>
 +xdd Scan_100.raw ' measured at 100 °C
 +str
 +phase_name "​PhaseX"​
 +a lp_a_Phase_X_100 5
 +b lp_b_Phase_X_100 5
 +c lp_c_Phase_X_100 5
 +scale scale_PhaseX_100 0.00001
 +.....
 +Out_with_suffix(100)
 +
 +xdd Scan_200.raw ' measured at 200 °C
 +str 
 +phase_name "​PhaseX"​
 +a lp_a_Phase_X_200 6
 +b lp_b_Phase_X_200 6
 +c lp_c_Phase_X_200 6
 +scale scale_PhaseX_200 0.00001
 +.....
 +Out_with_suffix(200)
 +
 +xdd .....
 +</​code>​
 +
 +<code topas>
 +macro Out_with_suffix(suffix) ​
 +   {
 + out Output.txt append
 + Out(Get(xdd_path_name,​ "​\n%s\t"​)
 + Out( lp_a_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 + Out( lp_b_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 + Out( lp_c_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +        '..... add more .....
 +   }
 +</​code>​
 +
 +In case phases appear/​disappear with changing conditions, adding a condition as e.g. 
 +
 +<code topas>
 +macro Out_with_suffix(suffix)
 +   {
 +        out Output.txt append
 +        Out(Get(xdd_path_name,​ "​\n%s\t"​)
 +        if And( (Prm_There(scale_PhaseX_##​suffix),​ scale_PhaseX_##​suffix > 0)
 +          {    ​
 +   ​  ​   Out( lp_a_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +     Out( lp_b_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +     Out( lp_c_Phase_X_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +            '.....
 +          }
 +        else
 +          {
 +            Out_String("​\t\t\t\t\t\t"​)
 +          }
 +        if And( (Prm_There(scale_PhaseY_##​suffix),​ scale_PhaseY_##​suffix > 0)
 +          {    ​
 +   ​  ​   Out( lp_a_Phase_Y_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +     Out( lp_b_Phase_Y_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +     Out( lp_c_Phase_Y_##​suffix , "​%11.5f\t",​ "​%11.5f\t"​)
 +            '.....
 +          }
 +        else
 +          {
 +            Out_String("​\t\t\t\t\t\t"​)
 +          }
 +    }
 +</​code>​
  
 +will only write the values to a file if the phase is actually there (or more precisely, if its scale factor is there and > 0). \\ 
 +If the phase is not there, the empty values will be replaced by tabs in order to allow easy editing of Output.txt in e.g. Excel.
 +   
 +   
 +   

Personal Tools