Warning: Trying to access array offset on value of type null in /home/site/wwwroot/lib/plugins/move/action/rename.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/site/wwwroot/lib/plugins/move/action/rename.php:42) in /home/site/wwwroot/inc/actions.php on line 38
out_with_suffix [topas wiki]

User Tools

Site Tools


out_with_suffix

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 13:22] – created martin_fischout_with_suffix [2022/11/03 15:08] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Out_with_suffix ======
 +Description: Versatile output macro for multipattern .inp files.
  
 +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 output, in which the suffixes of the parameter names can be easily changed.
 +
 +Contributed by: Martin Fisch
 +
 +<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 Output.txt append
 +Out(Get(xdd_path_name, "\n%s\t")
 +Out( lp_a_Phase_X_100 , "%11.5f\t", "%11.5f\t")
 +Out( lp_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")
 +Out( lp_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>
 +
 +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.
 +   
 +   
 +