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
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 .....
Is a lot easier by using a macro:
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 .....
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 ..... }
In case phases appear/disappear with changing conditions, adding a condition as e.g.
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") } }
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.