#include <experiment.h>
The main class, where the simulation of an experiment is executed.
The Experiment class owns all data (maybe indirectly) relevant for the execution of the experiment simulation. The experiment can be conducted in different running modi. Since the abstraction of these differences should not incur any overhead, the design is built around the Policy pattern.
The Policy pattern was defined by Andrei Alexandrescu in his book "Modern C++ Design: Generic Programming and Design Patterns Applied". Addison-Wesley:
A policy defines a class interface or a class template interface. The interface consists of one or all of the following: inner type definitions, member functions, and member variables.
The policy pattern can also be understood as a compile-time variant of the strategy pattern.
The Modus
template parameter defines the "policy" of the Experiment class. It determines several aspects of the experiment execution at compile time. The original strategy pattern would select these differences at run time, thus incurring an overhead. This overhead becomes severe in cases where calls to strategy/policy functions are done very frequently. Using the policy pattern, the compiler can fully optimize: It creates a new instance of all functions in Experiment for all different Modus types.
Definition at line 133 of file experiment.h.
Public Member Functions | |
void | run () override |
Runs the experiment. More... | |
Experiment (Configuration config, const bf::path &output_path) | |
Create a new Experiment. More... | |
void | initialize_new_event () |
This is called in the beginning of each event. More... | |
void | run_time_evolution () |
Runs the time evolution of an event with fixed-sized time steps or without timesteps, from action to actions. More... | |
void | do_final_decays () |
Performs the final decays of an event. More... | |
void | final_output (const int evt_num) |
Output at the end of an event. More... | |
Particles * | particles () |
Provides external access to SMASH particles. More... | |
Modus * | modus () |
Provides external access to SMASH calculation modus. More... | |
![]() | |
ExperimentBase ()=default | |
virtual | ~ExperimentBase ()=default |
The virtual destructor avoids undefined behavior when destroying derived objects. More... | |
Private Member Functions | |
template<typename Container > | |
bool | perform_action (Action &action, const Container &particles_before_actions) |
Perform the given action. More... | |
void | create_output (const std::string &format, const std::string &content, const bf::path &output_path, const OutputParameters &par) |
Create a list of output files. More... | |
void | propagate_and_shine (double to_time) |
Propagate all particles until time to_time without any interactions and shine dileptons. More... | |
void | run_time_evolution_timestepless (Actions &actions) |
Performs all the propagations and actions during a certain time interval neglecting the influence of the potentials. More... | |
void | intermediate_output () |
Intermediate output during an event. More... | |
void | update_potentials () |
Recompute potentials on lattices if necessary. More... | |
double | compute_min_cell_length (double dt) const |
Calculate the minimal size for the grid cells such that the ScatterActionsFinder will find all collisions within the maximal transverse distance (which is determined by the maximal cross section). More... | |
double | next_output_time () const |
Shortcut for next output time. More... | |
Private Attributes | |
ExperimentParameters | parameters_ |
Struct of several member variables. More... | |
DensityParameters | density_param_ |
Structure to precalculate and hold parameters for density computations. More... | |
Modus | modus_ |
Instance of the Modus template parameter. More... | |
Particles | particles_ |
Complete particle list. More... | |
std::unique_ptr< Potentials > | potentials_ |
An instance of potentials class, that stores parameters of potentials, calculates them and their gradients. More... | |
std::unique_ptr< PauliBlocker > | pauli_blocker_ |
An instance of PauliBlocker class that stores parameters needed for Pauli blocking calculations and computes phase-space density. More... | |
OutputsList | outputs_ |
A list of output formaters. More... | |
OutputPtr | dilepton_output_ |
The Dilepton output. More... | |
OutputPtr | photon_output_ |
The Photon output. More... | |
std::vector< bool > | nucleon_has_interacted_ = {} |
nucleon_has_interacted_ labels whether the particles in the nuclei have experienced any collisions or not. More... | |
std::vector< FourVector > | beam_momentum_ = {} |
The initial nucleons in the ColliderModus propagate with beam_momentum_, if Fermi motion is frozen. More... | |
std::vector< std::unique_ptr< ActionFinderInterface > > | action_finders_ |
The Action finder objects. More... | |
std::unique_ptr< DecayActionsFinderDilepton > | dilepton_finder_ |
The Dilepton Action Finder. More... | |
std::unique_ptr< ActionFinderInterface > | photon_finder_ |
The (Scatter) Actions Finder for Direct Photons. More... | |
int | n_fractional_photons_ = 100 |
Number of fractional photons produced per single reaction. More... | |
std::unique_ptr< DensityLattice > | jmu_B_lat_ |
Baryon density on the lattices. More... | |
std::unique_ptr< DensityLattice > | jmu_I3_lat_ |
Isospin projection density on the lattices. More... | |
std::unique_ptr< DensityLattice > | jmu_custom_lat_ |
Custom density on the lattices. More... | |
DensityType | dens_type_lattice_printout_ = DensityType::None |
Type of density for lattice printout. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | UB_lat_ = nullptr |
Lattices for Skyrme potentials (evaluated in the local rest frame) times the baryon flow 4-velocity. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | UI3_lat_ = nullptr |
Lattices for symmetry potentials (evaluated in the local rest frame) times the isospin flow 4-velocity. More... | |
std::unique_ptr< RectangularLattice< std::pair< ThreeVector, ThreeVector > > > | FB_lat_ |
Lattices for the electric and magnetic components of the Skyrme force. More... | |
std::unique_ptr< RectangularLattice< std::pair< ThreeVector, ThreeVector > > > | FI3_lat_ |
Lattices for the electric and magnetic component of the symmetry force. More... | |
std::unique_ptr< RectangularLattice< EnergyMomentumTensor > > | Tmn_ |
Lattices of energy-momentum tensors for printout. More... | |
bool | printout_tmn_ = false |
Whether to print the energy-momentum tensor. More... | |
bool | printout_tmn_landau_ = false |
Whether to print the energy-momentum tensor in Landau frame. More... | |
bool | printout_v_landau_ = false |
Whether to print the 4-velocity in Landau fram. More... | |
bool | printout_lattice_td_ = false |
Whether to print the thermodynamics quantities evaluated on the lattices. More... | |
std::unique_ptr< GrandCanThermalizer > | thermalizer_ |
Instance of class used for forced thermalization. More... | |
StringProcess * | process_string_ptr_ |
Pointer to the string process class object, which is used to set the random seed for PYTHIA objects in each event. More... | |
const int | nevents_ |
Number of events. More... | |
const double | end_time_ |
simulation time at which the evolution is stopped. More... | |
const double | delta_time_startup_ |
The clock's timestep size at start up. More... | |
const bool | force_decays_ |
This indicates whether we force all resonances to decay in the last timestep. More... | |
const bool | use_grid_ |
This indicates whether to use the grid. More... | |
const ExpansionProperties | metric_ |
This struct contains information on the metric to be used. More... | |
const bool | dileptons_switch_ |
This indicates whether dileptons are switched on. More... | |
const bool | photons_switch_ |
This indicates whether photons are switched on. More... | |
const TimeStepMode | time_step_mode_ |
This indicates whether to use time steps. More... | |
double | max_transverse_distance_sqr_ = std::numeric_limits<double>::max() |
Maximal distance at which particles can interact, squared. More... | |
QuantumNumbers | conserved_initial_ |
The conserved quantities of the system. More... | |
SystemTimePoint | time_start_ = SystemClock::now() |
system starting time of the simulation More... | |
DensityType | dens_type_ = DensityType::None |
Type of density to be written to collision headers. More... | |
uint64_t | interactions_total_ = 0 |
Total number of interactions for current timestep. More... | |
uint64_t | previous_interactions_total_ = 0 |
Total number of interactions for previous timestep. More... | |
uint64_t | wall_actions_total_ = 0 |
Total number of wall-crossings for current timestep. More... | |
uint64_t | previous_wall_actions_total_ = 0 |
Total number of wall-crossings for previous timestep. More... | |
uint64_t | total_pauli_blocked_ = 0 |
Total number of Pauli-blockings for current timestep. More... | |
int64_t | seed_ = -1 |
random seed for the next event. More... | |
Friends | |
class | ExperimentBase |
std::ostream & | operator<< (std::ostream &out, const Experiment &e) |
Writes the initial state for the Experiment to the output stream. More... | |
Additional Inherited Members | |
![]() | |
static std::unique_ptr< ExperimentBase > | create (Configuration config, const bf::path &output_path) |
Factory method that creates and initializes a new Experiment<Modus>. More... | |
|
explicit |
Create a new Experiment.
This constructor is only called from the ExperimentBase::create factory method.
[in] | config | The Configuration object contains all initial setup of the experiment. It is forwarded to the constructors of member variables as needed. Note that the object is passed by non-const reference. This is only necessary for bookkeeping: Values are not only read, but actually taken out of the object. Thus, all values that remain were not used. |
[in] | output_path | The directory where the output files are written. |
|
overridevirtual |
Runs the experiment.
The constructor does the setup of the experiment. The run function executes the complete experiment.
Implements smash::ExperimentBase.
Definition at line 1788 of file experiment.h.
void smash::Experiment< Modus >::initialize_new_event | ( | ) |
This is called in the beginning of each event.
It initializes particles according to selected modus, resets the clock and saves the initial conserved quantities for subsequent sanity checks.
Definition at line 1200 of file experiment.h.
void smash::Experiment< Modus >::run_time_evolution | ( | ) |
Runs the time evolution of an event with fixed-sized time steps or without timesteps, from action to actions.
Within one timestep (fixed) evolution from action to action is invoked.
Definition at line 1404 of file experiment.h.
void smash::Experiment< Modus >::do_final_decays | ( | ) |
Performs the final decays of an event.
Definition at line 1715 of file experiment.h.
void smash::Experiment< Modus >::final_output | ( | const int | evt_num | ) |
Output at the end of an event.
[in] | evt_num | Number of the event |
Definition at line 1751 of file experiment.h.
|
inline |
Provides external access to SMASH particles.
This is helpful if SMASH is used as a 3rd-party library.
Definition at line 218 of file experiment.h.
|
inline |
Provides external access to SMASH calculation modus.
This is helpful if SMASH is used as a 3rd-party library.
Definition at line 224 of file experiment.h.
|
private |
Perform the given action.
Container | type that holds the particles before the action. |
[in] | action | The action to perform. If it performs, it'll modify the private member particles_. |
[in] | particles_before_actions | A container with the ParticleData from this time step before any actions were performed. |
|
private |
Create a list of output files.
[in] | format | Format of the output file (e.g. Root, Oscar, Vtk) |
[in] | content | Content of the output (e.g. particles, collisions) |
[in] | output_path | Path of the output file |
[in] | par | Output options.(e.g. Extended) |
Definition at line 543 of file experiment.h.
|
private |
Propagate all particles until time to_time without any interactions and shine dileptons.
[in] | to_time | Time at the end of propagation [fm/c] |
Definition at line 1501 of file experiment.h.
|
private |
Performs all the propagations and actions during a certain time interval neglecting the influence of the potentials.
This function is called in either the time stepless cases or the cases with time steps. In a time stepless case, the time interval should be equal to the whole evolution time, while in the case with time step, the intervals are given by the time steps.
[in,out] | actions | Actions occur during a certain time interval. They provide the ending times of the propagations and are updated during the time interval. |
Definition at line 1526 of file experiment.h.
|
private |
Intermediate output during an event.
Definition at line 1607 of file experiment.h.
|
private |
Recompute potentials on lattices if necessary.
Definition at line 1677 of file experiment.h.
|
inlineprivate |
Calculate the minimal size for the grid cells such that the ScatterActionsFinder will find all collisions within the maximal transverse distance (which is determined by the maximal cross section).
[in] | dt | The current time step size [fm/c] |
Definition at line 288 of file experiment.h.
|
inlineprivate |
Shortcut for next output time.
Definition at line 293 of file experiment.h.
|
friend |
Definition at line 163 of file experiment.h.
|
private |
Struct of several member variables.
These variables are combined into a struct for efficient input to functions outside of this class.
Definition at line 302 of file experiment.h.
|
private |
Structure to precalculate and hold parameters for density computations.
Definition at line 305 of file experiment.h.
|
private |
Instance of the Modus template parameter.
May store modus-specific data and contains modus-specific function implementations.
Definition at line 311 of file experiment.h.
|
private |
Complete particle list.
Definition at line 314 of file experiment.h.
|
private |
An instance of potentials class, that stores parameters of potentials, calculates them and their gradients.
Definition at line 320 of file experiment.h.
|
private |
An instance of PauliBlocker class that stores parameters needed for Pauli blocking calculations and computes phase-space density.
Definition at line 326 of file experiment.h.
|
private |
A list of output formaters.
They will be called to write the state of the particles to file.
Definition at line 332 of file experiment.h.
|
private |
The Dilepton output.
Definition at line 335 of file experiment.h.
|
private |
The Photon output.
Definition at line 338 of file experiment.h.
|
private |
nucleon_has_interacted_ labels whether the particles in the nuclei have experienced any collisions or not.
It's only valid in the ColliderModus, so is set as an empty vector by default.
Definition at line 345 of file experiment.h.
|
private |
The initial nucleons in the ColliderModus propagate with beam_momentum_, if Fermi motion is frozen.
It's only valid in the ColliderModus, so is set as an empty vector by default.
Definition at line 352 of file experiment.h.
|
private |
The Action finder objects.
Definition at line 355 of file experiment.h.
|
private |
The Dilepton Action Finder.
Definition at line 358 of file experiment.h.
|
private |
The (Scatter) Actions Finder for Direct Photons.
Definition at line 361 of file experiment.h.
|
private |
Number of fractional photons produced per single reaction.
Definition at line 364 of file experiment.h.
|
private |
Baryon density on the lattices.
Definition at line 367 of file experiment.h.
|
private |
Isospin projection density on the lattices.
Definition at line 370 of file experiment.h.
|
private |
Custom density on the lattices.
In the config user asks for some kind of density for printout. Baryon and isospin projection density are anyway needed for potentials. If user asks for some other density type for printout, it will be handled using jmu_custom variable.
Definition at line 379 of file experiment.h.
|
private |
Type of density for lattice printout.
Definition at line 382 of file experiment.h.
|
private |
Lattices for Skyrme potentials (evaluated in the local rest frame) times the baryon flow 4-velocity.
Definition at line 388 of file experiment.h.
|
private |
Lattices for symmetry potentials (evaluated in the local rest frame) times the isospin flow 4-velocity.
Definition at line 394 of file experiment.h.
|
private |
Lattices for the electric and magnetic components of the Skyrme force.
Definition at line 398 of file experiment.h.
|
private |
Lattices for the electric and magnetic component of the symmetry force.
Definition at line 402 of file experiment.h.
|
private |
Lattices of energy-momentum tensors for printout.
Definition at line 405 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor.
Definition at line 408 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor in Landau frame.
Definition at line 411 of file experiment.h.
|
private |
Whether to print the 4-velocity in Landau fram.
Definition at line 414 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices.
Definition at line 417 of file experiment.h.
|
private |
Instance of class used for forced thermalization.
Definition at line 420 of file experiment.h.
|
private |
Pointer to the string process class object, which is used to set the random seed for PYTHIA objects in each event.
Definition at line 426 of file experiment.h.
|
private |
Number of events.
Event is a single simulation of a physical phenomenon: elementary particle or nucleus-nucleus collision. Result of a single SMASH event is random (by construction) as well as result of one collision in nature. To compare simulation with experiment one has to take ensemble averages, i.e. perform simulation and real experiment many times and compare average results.
nevents_ is number of times single phenomenon (particle or nucleus-nucleus collision) will be simulated.
Definition at line 442 of file experiment.h.
|
private |
simulation time at which the evolution is stopped.
Definition at line 445 of file experiment.h.
|
private |
The clock's timestep size at start up.
Stored here so that the next event will remember this.
Definition at line 452 of file experiment.h.
|
private |
This indicates whether we force all resonances to decay in the last timestep.
Definition at line 458 of file experiment.h.
|
private |
This indicates whether to use the grid.
Definition at line 461 of file experiment.h.
|
private |
This struct contains information on the metric to be used.
Definition at line 464 of file experiment.h.
|
private |
This indicates whether dileptons are switched on.
Definition at line 467 of file experiment.h.
|
private |
This indicates whether photons are switched on.
Definition at line 470 of file experiment.h.
|
private |
This indicates whether to use time steps.
Definition at line 473 of file experiment.h.
|
private |
Maximal distance at which particles can interact, squared.
Definition at line 476 of file experiment.h.
|
private |
The conserved quantities of the system.
This struct carries the sums of the single particle's various quantities as measured at the beginning of the evolution and can be used to regularly check if they are still good.
Definition at line 485 of file experiment.h.
|
private |
system starting time of the simulation
Definition at line 488 of file experiment.h.
|
private |
Type of density to be written to collision headers.
Definition at line 491 of file experiment.h.
|
private |
Total number of interactions for current timestep.
For timestepless mode the whole run time is considered as one timestep.
Definition at line 497 of file experiment.h.
|
private |
Total number of interactions for previous timestep.
For timestepless mode the whole run time is considered as one timestep.
Definition at line 503 of file experiment.h.
|
private |
Total number of wall-crossings for current timestep.
For timestepless mode the whole run time is considered as one timestep.
Definition at line 509 of file experiment.h.
|
private |
Total number of wall-crossings for previous timestep.
For timestepless mode the whole run time is considered as one timestep.
Definition at line 515 of file experiment.h.
|
private |
Total number of Pauli-blockings for current timestep.
For timestepless mode the whole run time is considered as one timestep.
Definition at line 521 of file experiment.h.
|
private |
random seed for the next event.
Definition at line 524 of file experiment.h.