#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 143 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 (int event_number) |
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... | |
bool | projectile_target_interact_ = false |
Whether the projectile and the target collided. 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_ |
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 bool | bremsstrahlung_switch_ |
This indicates whether bremsstrahlung is switched on. More... | |
const bool | IC_output_switch_ |
This indicates whether the IC output is enabled. 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... | |
double | initial_mean_field_energy_ |
The initial total mean field energy in 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... | |
uint64_t | total_hypersurface_crossing_actions_ = 0 |
Total number of particles removed from the evolution in hypersurface crossing actions. More... | |
uint64_t | discarded_interactions_total_ = 0 |
Total number of discarded interactions, because they were invalidated before they could be performed. More... | |
double | total_energy_removed_ = 0.0 |
Total energy removed from the system in hypersurface crossing actions. More... | |
int64_t | seed_ = -1 |
random seed for the next event. More... | |
Friends | |
class | ExperimentBase |
std::ostream & | operator<< (std::ostream &out, const Experiment &e) |
Creates a verbose textual description of the setup of the Experiment. 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 2221 of file experiment.h.
void smash::Experiment< Modus >::initialize_new_event | ( | int | event_number | ) |
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 1451 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 1714 of file experiment.h.
void smash::Experiment< Modus >::do_final_decays | ( | ) |
Performs the final decays of an event.
Definition at line 2085 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 2121 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 228 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 234 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 587 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 1812 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 1837 of file experiment.h.
|
private |
Intermediate output during an event.
Definition at line 1923 of file experiment.h.
|
private |
Recompute potentials on lattices if necessary.
Definition at line 2039 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 298 of file experiment.h.
|
inlineprivate |
Shortcut for next output time.
Definition at line 303 of file experiment.h.
|
friend |
Definition at line 173 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 312 of file experiment.h.
|
private |
Structure to precalculate and hold parameters for density computations.
Definition at line 315 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 321 of file experiment.h.
|
private |
Complete particle list.
Definition at line 324 of file experiment.h.
|
private |
An instance of potentials class, that stores parameters of potentials, calculates them and their gradients.
Definition at line 330 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 336 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 342 of file experiment.h.
|
private |
The Dilepton output.
Definition at line 345 of file experiment.h.
|
private |
The Photon output.
Definition at line 348 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 355 of file experiment.h.
|
private |
Whether the projectile and the target collided.
Definition at line 359 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 366 of file experiment.h.
|
private |
The Action finder objects.
Definition at line 369 of file experiment.h.
|
private |
The Dilepton Action Finder.
Definition at line 372 of file experiment.h.
|
private |
The (Scatter) Actions Finder for Direct Photons.
Definition at line 375 of file experiment.h.
|
private |
Number of fractional photons produced per single reaction.
Definition at line 378 of file experiment.h.
|
private |
Baryon density on the lattices.
Definition at line 381 of file experiment.h.
|
private |
Isospin projection density on the lattices.
Definition at line 384 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 393 of file experiment.h.
|
private |
Type of density for lattice printout.
Definition at line 396 of file experiment.h.
|
private |
Lattices for Skyrme potentials (evaluated in the local rest frame) times the baryon flow 4-velocity.
Definition at line 402 of file experiment.h.
|
private |
Lattices for symmetry potentials (evaluated in the local rest frame) times the isospin flow 4-velocity.
Definition at line 408 of file experiment.h.
|
private |
Lattices for the electric and magnetic components of the Skyrme force.
Definition at line 412 of file experiment.h.
|
private |
Lattices for the electric and magnetic component of the symmetry force.
Definition at line 416 of file experiment.h.
|
private |
Lattices of energy-momentum tensors for printout.
Definition at line 419 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor.
Definition at line 422 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor in Landau frame.
Definition at line 425 of file experiment.h.
|
private |
Whether to print the 4-velocity in Landau fram.
Definition at line 428 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices.
Definition at line 431 of file experiment.h.
|
private |
Instance of class used for forced thermalization.
Definition at line 434 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 440 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 456 of file experiment.h.
|
private |
simulation time at which the evolution is stopped.
Definition at line 459 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 466 of file experiment.h.
|
private |
This indicates whether we force all resonances to decay in the last timestep.
Definition at line 472 of file experiment.h.
|
private |
This indicates whether to use the grid.
Definition at line 475 of file experiment.h.
|
private |
This struct contains information on the metric to be used.
Definition at line 478 of file experiment.h.
|
private |
This indicates whether dileptons are switched on.
Definition at line 481 of file experiment.h.
|
private |
This indicates whether photons are switched on.
Definition at line 484 of file experiment.h.
|
private |
This indicates whether bremsstrahlung is switched on.
Definition at line 487 of file experiment.h.
|
private |
This indicates whether the IC output is enabled.
Definition at line 490 of file experiment.h.
|
private |
This indicates whether to use time steps.
Definition at line 493 of file experiment.h.
|
private |
Maximal distance at which particles can interact, squared.
Definition at line 496 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 505 of file experiment.h.
|
private |
The initial total mean field energy in the system.
Note: will only be calculated if lattice is on.
Definition at line 511 of file experiment.h.
|
private |
system starting time of the simulation
Definition at line 514 of file experiment.h.
|
private |
Type of density to be written to collision headers.
Definition at line 517 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 523 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 529 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 535 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 541 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 547 of file experiment.h.
|
private |
Total number of particles removed from the evolution in hypersurface crossing actions.
Definition at line 553 of file experiment.h.
|
private |
Total number of discarded interactions, because they were invalidated before they could be performed.
Definition at line 559 of file experiment.h.
|
private |
Total energy removed from the system in hypersurface crossing actions.
Definition at line 565 of file experiment.h.
|
private |
random seed for the next event.
Definition at line 568 of file experiment.h.