optional_sections
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
optional_sections [2019/12/21 15:12] – johnsoevans | optional_sections [2022/11/03 15:08] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== #define and #prm (hash prm or hash parameter)====== | ||
+ | It's often useful to have optional sections in an INP file to test different models. | ||
+ | |||
+ | Often it's easier to use the #define command: | ||
+ | |||
+ | <code topas> | ||
+ | #define fit_xray | ||
+ | #define fit_neutron | ||
+ | |||
+ | #ifdef fit_xray | ||
+ | ..xray stuff | ||
+ | #endif | ||
+ | |||
+ | #ifdef fit_neutron | ||
+ | ..neutron stuff | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | You can get more flexibility with #prm. For example the code below does the same as #define: | ||
+ | |||
+ | <code topas> | ||
+ | #prm x_ray = 1; ' | ||
+ | #prm neutron = 1; 'or set to 0 to not include | ||
+ | |||
+ | #if (x_ray) | ||
+ | ..xray stuff | ||
+ | #endif | ||
+ | #if (neutron) | ||
+ | ..neutron stuff | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | But you can also do a lot more and combine conditions. For example: | ||
+ | |||
+ | <code topas> | ||
+ | #if (x_ray == 0) | ||
+ | ..xray stuff | ||
+ | # | ||
+ | ... | ||
+ | #elseif (Or (Run_Number == 18, x_ray)) | ||
+ | #else | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | With variable temperature or pressure refinements you often want to include different phases for different data sets. Some of the tricks are in Section 12.2 of the Topas text book. The snippets below are from an INP file which uses the #list language and includes different phases for different datasets. | ||
+ | |||
+ | <code topas> | ||
+ | /*series of refinments for mono to ortho with mixed phase region between*/ | ||
+ | num_runs 54 | ||
+ | #list Filename Temperature Time Range_Num | ||
+ | filename.raw 103.66 | ||
+ | filename.raw 111.33 | ||
+ | filename.raw 119 | ||
+ | ...etc | ||
+ | } | ||
+ | #prm tempcon = Temperature(Run_Number); | ||
+ | #prm range = Range_Num(Run_Number); | ||
+ | |||
+ | #if (range <= 33) | ||
+ | #prm mono = 1; | ||
+ | #prm orth = 0; | ||
+ | #elseif ( And(range >= 34, range <= 41) ) | ||
+ | #prm mono = 1; | ||
+ | #prm orth = 1; | ||
+ | #else | ||
+ | #prm mono = 0; | ||
+ | #prm orth = 1; | ||
+ | #endif | ||
+ | |||
+ | xdd Filename(Run_Number) | ||
+ | range Range_Num(Run_Number) | ||
+ | #if (mono) | ||
+ | (str info for mono) | ||
+ | #else | ||
+ | (alternative instructions) | ||
+ | #endif | ||
+ | #if (ortho) | ||
+ | (str info for ortho) | ||
+ | #else | ||
+ | (alternative instructions) | ||
+ | #endif | ||
+ | </ | ||
+ | |||
+ | The forum has a thread on removing phases when their phase fraction falls to low values, including tricks to e.g. set the scale factor to zero if peaks become too broad. |
optional_sections.txt · Last modified: 2024/02/22 16:32 by 127.0.0.1