Version: SMASH-3.0
smash::anonymous_namespace{smash.cc} Namespace Reference

Classes

struct  OutputDirectoryExists
 Exception class that is thrown, if the requested output directory already exists and -f was not specified on the command line. More...
 
struct  OutputDirectoryOutOfIds
 Exception class that is thrown, if no new output path can be generated (there is a directory name for each positive integer value) More...
 

Functions

void usage (const int rc, const std::string &progname)
 Prints usage information and exits the program. More...
 
void print_disclaimer ()
 Print the disclaimer. More...
 
std::filesystem::path default_output_path ()
 
void ensure_path_is_valid (const std::filesystem::path &path)
 Ensures the output path is valid. More...
 
ScatterActionsFinder actions_finder_for_dump (Configuration &configuration)
 Prepares ActionsFinder for cross-section and reaction dumps. More...
 
void check_for_unused_config_values (const Configuration &configuration)
 Checks if there are unused config values. More...
 
void ignore_simulation_config_values (Configuration &configuration)
 Remove all config values that are only needed for simulations. More...
 

Function Documentation

◆ usage()

void smash::anonymous_namespace{smash.cc}::usage ( const int  rc,
const std::string &  progname 
)

Prints usage information and exits the program.

Parameters
[out]rcExit status to return
[in]prognameName of the program

usage() is called when either the --help or -h command line options are given to the program; in this case, the exit status is EXIT_SUCCESS, or when an unknown option is given; in this case, the exit status is EXIT_FAIL.

Definition at line 131 of file smash.cc.

131  {
132  std::printf("\nUsage: %s [option]\n\n", progname.c_str());
133  std::printf(
134  " -h, --help usage information\n"
135  "\n"
136  " -i, --inputfile <file> path to input configuration file\n"
137  " (default: ./config.yaml)\n"
138  " -d, --decaymodes <file> override default decay modes from file\n"
139  " -p, --particles <file> override default particles from file\n"
140  "\n"
141  " -c, --config <YAML> specify config value overrides\n"
142  " (multiple -c arguments are supported)\n"
143  " -m, --modus <modus> shortcut for -c 'General: { Modus: <modus> "
144  "}'\n"
145  " -e, --endtime <time> shortcut for -c 'General: { End_Time: <time> "
146  "}'"
147  "\n"
148  "\n"
149  " -o, --output <dir> output directory (default: ./data/<runid>)\n"
150  " -l, --list-2-to-n list all possible 2->n reactions (with n>1)\n"
151  " -r, --resonance <pdg> dump width(m) and m*spectral function(m^2)"
152  " for resonance pdg\n"
153  " -s, --cross-sections <pdg1>,<pdg2>[,mass1,mass2[,plab1,...]] \n"
154  " dump all partial cross-sections of "
155  "pdg1 + pdg2 reactions versus sqrt(s).\n"
156  " -S, --cross-sections-fs <pdg1>,<pdg2>[,mass1,mass2[,plab1,...]] \n"
157  " dump an approximation of the final-state"
158  " cross-sections\n"
159  " of pdg1 + pdg2 reactions versus sqrt(s).\n"
160  " Contributions from strings are not considered"
161  " for the final state.\n"
162  " Masses are optional, by default pole masses"
163  " are used.\n"
164  " Note the required comma and no spaces.\n"
165  " -f, --force force overwriting files in the output "
166  "directory"
167  "\n"
168  " -x, --dump_iSS Dump particle table in iSS format\n"
169  " This format is used in MUSIC and CLVisc\n"
170  " relativistic hydro codes\n"
171  " -q, --quiet Supress disclaimer print-out\n"
172  " -n, --no-cache Don't cache integrals on disk\n"
173  " -v, --version\n\n");
174  std::exit(rc);
175 }

◆ print_disclaimer()

void smash::anonymous_namespace{smash.cc}::print_disclaimer ( )

Print the disclaimer.

Definition at line 178 of file smash.cc.

178  {
179  std::cout
180  << "###################################################################"
181  << "############"
182  << "\n"
183  << "\n"
184  << " :::s.\n"
185  << " .... ''ss:: "
186  "ah:\n"
187  << " a::''. ..:sss "
188  ".HH.\n"
189  << " mss'.. ...s'm. sSA##As mAhh##hsh##s. .hA##ASa sS###As "
190  "hMAh##h.\n"
191  << " :a':'. .'':as sM#' .HHm''HMS''AMs mMA' .AMs aMA. "
192  "'HHa..HM:\n"
193  << " .a:s'. ..''ss 'h#H#S. mMm 'M#' .HH. 'MH. :MA 'h#H#S. "
194  "hMm :M#\n"
195  << " .::ss'. .... 'SMm .HH. SMa hMm sM#..mHMs 'AMa "
196  "'MH. SMa\n"
197  << " .s::' #SMASHh aMS .MH: HM: #MMMmMM. #SMASHh "
198  "aMS .MM.\n"
199  << "\n"
200  << "###################################################################"
201  << "############"
202  << "\n"
203  << " This is SMASH version: " << SMASH_VERSION << "\n"
204  << " Simulating Many Accelerated Strongly-interacting Hadrons"
205  << "\n"
206  << "\n"
207  << " Distributed under the GNU General Public License 3.0"
208  << " (GPLv3 or later)."
209  << "\n"
210  << " See LICENSE for details."
211  << "\n"
212  << " For the full list of contributors see the AUTHORS.md file."
213  << "\n"
214  << "\n"
215  << " When using SMASH, please cite"
216  << "\n"
217  << " J. Weil et al., Phys.Rev. C94 (2016) no.5, 054905"
218  << "\n"
219  << " together with the software DOI for the specific code version "
220  << "employed:"
221  << "\n"
222  << " https://doi.org/10.5281/zenodo.3484711."
223  << "\n"
224  << " In addition, if Pythia is used please cite"
225  << "\n"
226  << " C. Bierlich et al, SciPost Phys. Codebases 8 (2022)"
227  << "\n"
228  << " together with the Codebase release you used:"
229  << "\n"
230  << " https://doi.org/10.21468/SciPostPhysCodeb.8-r8.3."
231  << "\n"
232  << "\n"
233  << " Webpage: https://smash-transport.github.io"
234  << "\n"
235  << "\n"
236  << " Report issues at https://github.com/smash-transport/smash"
237  << "\n"
238  << " or contact us by email at elfner@itp.uni-frankfurt.de"
239  << "\n"
240  << "\n"
241  << "###################################################################"
242  << "############"
243  << "\n"
244  << "\n";
245 }

◆ default_output_path()

std::filesystem::path smash::anonymous_namespace{smash.cc}::default_output_path ( )
Returns
the default path for output.

Definition at line 266 of file smash.cc.

266  {
267  const std::filesystem::path p = std::filesystem::absolute("data");
268  if (!std::filesystem::exists(p)) {
269  return p / "0";
270  }
271  std::filesystem::path p2;
272  for (int id = 0; id < std::numeric_limits<int>::max(); ++id) {
273  p2 = p / std::to_string(id);
274  if (!std::filesystem::exists(p2)) {
275  break;
276  }
277  }
278  if (p == p2) {
279  throw OutputDirectoryOutOfIds("no unique data subdir ID left");
280  }
281  return p2;
282 }
constexpr int p
Proton.

◆ ensure_path_is_valid()

void smash::anonymous_namespace{smash.cc}::ensure_path_is_valid ( const std::filesystem::path &  path)

Ensures the output path is valid.

Exceptions
OutputDirectoryExistsif the Output directory already exists.
Parameters
[in]pathThe output path to be written to

Definition at line 290 of file smash.cc.

290  {
291  if (std::filesystem::exists(path)) {
292  if (!std::filesystem::is_directory(path)) {
293  throw OutputDirectoryExists("The given path (" + path.native() +
294  ") exists, but it is not a directory.");
295  }
296  } else {
297  if (!std::filesystem::create_directories(path)) {
298  throw OutputDirectoryExists(
299  "Race condition detected: The directory " + path.native() +
300  " did not exist a few cycles ago, but was created in the meantime by "
301  "a different process.");
302  }
303  }
304 }

◆ actions_finder_for_dump()

ScatterActionsFinder smash::anonymous_namespace{smash.cc}::actions_finder_for_dump ( Configuration configuration)

Prepares ActionsFinder for cross-section and reaction dumps.

Parameters
[in,out]configurationNecessary parameters to switch reactions on/off
Returns
The constructed ScatterActionsFinder .

Definition at line 312 of file smash.cc.

312  {
313  ExperimentParameters params = create_experiment_parameters(configuration);
314  params.use_monash_tune_default = false;
315  return ScatterActionsFinder(configuration, params);
316 }
A simple scatter finder: Just loops through all particles and checks each pair for a collision.
ExperimentParameters create_experiment_parameters(Configuration &config)
Gathers all general Experiment parameters.
Definition: experiment.cc:132
Helper structure for Experiment.
std::optional< bool > use_monash_tune_default
Bool for the default usage of the monash tune in the collider modus.

◆ check_for_unused_config_values()

void smash::anonymous_namespace{smash.cc}::check_for_unused_config_values ( const Configuration configuration)

Checks if there are unused config values.

Definition at line 321 of file smash.cc.

321  {
322  if (!configuration.is_empty()) {
323  throw std::runtime_error(
324  "The following configuration values were not used:\n" +
325  configuration.to_string());
326  }
327 }
std::string to_string() const
Return a string of the current YAML tree.

◆ ignore_simulation_config_values()

void smash::anonymous_namespace{smash.cc}::ignore_simulation_config_values ( Configuration configuration)

Remove all config values that are only needed for simulations.

This is useful when checking for unused config value when SMASH only outputs cross sections, resonance properties or possible reactions.

Definition at line 335 of file smash.cc.

335  {
336  for (const std::string s :
337  {"particles", "decaymodes", "Modi", "General", "Output", "Lattice",
338  "Potentials", "Forced_Thermalization"}) {
339  if (configuration.has_value({s.c_str()})) {
340  configuration.take({s.c_str()});
341  }
342  }
343 }
bool has_value(std::initializer_list< const char * > keys) const
Return whether there is a non-empty value behind the requested keys.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.