Version: SMASH-3.1
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 139 of file smash.cc.

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

◆ print_disclaimer()

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

Print the disclaimer.

Definition at line 186 of file smash.cc.

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

◆ default_output_path()

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

Definition at line 274 of file smash.cc.

274  {
275  const std::filesystem::path p = std::filesystem::absolute("data");
276  if (!std::filesystem::exists(p)) {
277  return p / "0";
278  }
279  std::filesystem::path p2;
280  for (int id = 0; id < std::numeric_limits<int>::max(); ++id) {
281  p2 = p / std::to_string(id);
282  if (!std::filesystem::exists(p2)) {
283  break;
284  }
285  }
286  if (p == p2) {
287  throw OutputDirectoryOutOfIds("no unique data subdir ID left");
288  }
289  return p2;
290 }
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 298 of file smash.cc.

298  {
299  if (std::filesystem::exists(path)) {
300  if (!std::filesystem::is_directory(path)) {
301  throw OutputDirectoryExists("The given path (" + path.native() +
302  ") exists, but it is not a directory.");
303  }
304  } else {
305  if (!std::filesystem::create_directories(path)) {
306  throw OutputDirectoryExists(
307  "Race condition detected: The directory " + path.native() +
308  " did not exist a few cycles ago, but was created in the meantime by "
309  "a different process.");
310  }
311  }
312 }

◆ 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 320 of file smash.cc.

320  {
321  ExperimentParameters params = create_experiment_parameters(configuration);
322  params.use_monash_tune_default = false;
323  return ScatterActionsFinder(configuration, params);
324 }
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 329 of file smash.cc.

329  {
330  if (!configuration.is_empty()) {
331  throw std::runtime_error(
332  "The following configuration values were not used:\n" +
333  configuration.to_string());
334  }
335 }
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 343 of file smash.cc.

343  {
344  for (const std::string s :
345  {"particles", "decaymodes", "Modi", "General", "Output", "Lattice",
346  "Potentials", "Forced_Thermalization"}) {
347  if (configuration.has_value({s.c_str()})) {
348  configuration.take({s.c_str()});
349  }
350  }
351 }
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.