#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 177 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 () |
Output at the end of an event. More... | |
Particles * | first_ensemble () |
Provides external access to SMASH particles. More... | |
std::vector< Particles > * | all_ensembles () |
Getter for all ensembles. 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 | |
bool | perform_action (Action &action, int i_ensemble) |
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, Particles &particles) |
Propagate all particles until time to_time without any interactions and shine dileptons. More... | |
void | run_time_evolution_timestepless (Actions &actions, int i_ensemble, double end_time_propagation) |
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... | |
std::vector< Particles > | ensembles_ |
Complete particle list, all ensembles in one vector. 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 > | projectile_target_interact_ |
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 > | j_QBS_lat_ |
4-current for j_QBS lattice output More... | |
std::unique_ptr< DensityLattice > | jmu_B_lat_ |
Baryon density on the lattice. More... | |
std::unique_ptr< DensityLattice > | jmu_I3_lat_ |
Isospin projection density on the lattice. More... | |
std::unique_ptr< DensityLattice > | jmu_el_lat_ |
Electric charge density on the lattice. More... | |
std::unique_ptr< FieldsLattice > | fields_lat_ |
Mean-field A^mu on the lattice. 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 or VDF 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 or VDF 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< std::pair< ThreeVector, ThreeVector > > > | EM_lat_ |
Lattices for electric and magnetic field in fm^-2. More... | |
std::unique_ptr< RectangularLattice< EnergyMomentumTensor > > | Tmn_ |
Lattices of energy-momentum tensors for printout. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | old_jmu_auxiliary_ |
Auxiliary lattice for values of jmu at a time step t0. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | new_jmu_auxiliary_ |
Auxiliary lattice for values of jmu at a time step t0 + dt. More... | |
std::unique_ptr< RectangularLattice< std::array< FourVector, 4 > > > | four_gradient_auxiliary_ |
Auxiliary lattice for calculating the four-gradient of jmu. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | old_fields_auxiliary_ |
Auxiliary lattice for values of Amu at a time step t0. More... | |
std::unique_ptr< RectangularLattice< FourVector > > | new_fields_auxiliary_ |
Auxiliary lattice for values of Amu at a time step t0 + dt. More... | |
std::unique_ptr< RectangularLattice< std::array< FourVector, 4 > > > | fields_four_gradient_auxiliary_ |
Auxiliary lattice for calculating the four-gradient of Amu. 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 frame. More... | |
bool | printout_j_QBS_ = false |
Whether to print the Q, B, S 4-currents. More... | |
bool | printout_lattice_td_ = false |
Whether to print the thermodynamics quantities evaluated on the lattices. More... | |
bool | printout_full_lattice_ascii_td_ = false |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in ASCII format. More... | |
bool | printout_full_lattice_binary_td_ = false |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in Binary format. More... | |
bool | printout_full_lattice_any_td_ = false |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in any format. 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... | |
int | event_ = 0 |
Current event. 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 in case of the geometric criterion, 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) |
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 2823 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 1840 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 2186 of file experiment.h.
void smash::Experiment< Modus >::do_final_decays |
Performs the final decays of an event.
Definition at line 2648 of file experiment.h.
void smash::Experiment< Modus >::final_output |
Output at the end of an event.
Definition at line 2687 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 231 of file experiment.h.
|
inline |
|
inline |
Provides external access to SMASH calculation modus.
This is helpful if SMASH is used as a 3rd-party library.
Definition at line 239 of file experiment.h.
|
private |
Perform the given action.
[in] | action | The action to perform |
[in] | i_ensemble | index of ensemble in which action is 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 641 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] |
[in,out] | particles | Particles to be propagated |
Definition at line 2310 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,out] | actions | Actions occur during a certain time interval. They provide the ending times of the propagations and are updated during the time interval. |
[in] | i_ensemble | index of ensemble to be evolved |
[in] | end_time_propagation | time until propagation should be performed |
Definition at line 2336 of file experiment.h.
|
private |
Intermediate output during an event.
Auxiliary variable to communicate the time in the computational frame at the functions printing the thermodynamics lattice output
Definition at line 2402 of file experiment.h.
|
private |
Recompute potentials on lattices if necessary.
Definition at line 2548 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 301 of file experiment.h.
|
inlineprivate |
Shortcut for next output time.
Definition at line 309 of file experiment.h.
|
friend |
Definition at line 178 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 318 of file experiment.h.
|
private |
Structure to precalculate and hold parameters for density computations.
Definition at line 321 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 327 of file experiment.h.
|
private |
Complete particle list, all ensembles in one vector.
Definition at line 330 of file experiment.h.
|
private |
An instance of potentials class, that stores parameters of potentials, calculates them and their gradients.
Definition at line 336 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 342 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 348 of file experiment.h.
|
private |
The Dilepton output.
Definition at line 351 of file experiment.h.
|
private |
The Photon output.
Definition at line 354 of file experiment.h.
|
private |
Whether the projectile and the target collided.
One value for each ensemble.
Definition at line 360 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 367 of file experiment.h.
|
private |
The Action finder objects.
Definition at line 370 of file experiment.h.
|
private |
The Dilepton Action Finder.
Definition at line 373 of file experiment.h.
|
private |
The (Scatter) Actions Finder for Direct Photons.
Definition at line 376 of file experiment.h.
|
private |
Number of fractional photons produced per single reaction.
Definition at line 379 of file experiment.h.
|
private |
4-current for j_QBS lattice output
Definition at line 382 of file experiment.h.
|
private |
Baryon density on the lattice.
Definition at line 385 of file experiment.h.
|
private |
Isospin projection density on the lattice.
Definition at line 388 of file experiment.h.
|
private |
Electric charge density on the lattice.
Definition at line 391 of file experiment.h.
|
private |
Mean-field A^mu on the lattice.
Definition at line 394 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 403 of file experiment.h.
|
private |
Type of density for lattice printout.
Definition at line 406 of file experiment.h.
|
private |
Lattices for Skyrme or VDF potentials (evaluated in the local rest frame) times the baryon flow 4-velocity.
Definition at line 412 of file experiment.h.
|
private |
Lattices for symmetry potentials (evaluated in the local rest frame) times the isospin flow 4-velocity.
Definition at line 418 of file experiment.h.
|
private |
Lattices for the electric and magnetic components of the Skyrme or VDF force.
Definition at line 425 of file experiment.h.
|
private |
Lattices for the electric and magnetic component of the symmetry force.
Definition at line 429 of file experiment.h.
|
private |
Lattices for electric and magnetic field in fm^-2.
Definition at line 433 of file experiment.h.
|
private |
Lattices of energy-momentum tensors for printout.
Definition at line 436 of file experiment.h.
|
private |
Auxiliary lattice for values of jmu at a time step t0.
Definition at line 439 of file experiment.h.
|
private |
Auxiliary lattice for values of jmu at a time step t0 + dt.
Definition at line 441 of file experiment.h.
|
private |
Auxiliary lattice for calculating the four-gradient of jmu.
Definition at line 444 of file experiment.h.
|
private |
Auxiliary lattice for values of Amu at a time step t0.
Definition at line 447 of file experiment.h.
|
private |
Auxiliary lattice for values of Amu at a time step t0 + dt.
Definition at line 449 of file experiment.h.
|
private |
Auxiliary lattice for calculating the four-gradient of Amu.
Definition at line 452 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor.
Definition at line 455 of file experiment.h.
|
private |
Whether to print the energy-momentum tensor in Landau frame.
Definition at line 458 of file experiment.h.
|
private |
Whether to print the 4-velocity in Landau frame.
Definition at line 461 of file experiment.h.
|
private |
Whether to print the Q, B, S 4-currents.
Definition at line 464 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices.
Definition at line 467 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in ASCII format.
Definition at line 471 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in Binary format.
Definition at line 475 of file experiment.h.
|
private |
Whether to print the thermodynamics quantities evaluated on the lattices, point by point, in any format.
Definition at line 479 of file experiment.h.
|
private |
Instance of class used for forced thermalization.
Definition at line 482 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 488 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 504 of file experiment.h.
|
private |
Current event.
Definition at line 507 of file experiment.h.
|
private |
simulation time at which the evolution is stopped.
Definition at line 510 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 517 of file experiment.h.
|
private |
This indicates whether we force all resonances to decay in the last timestep.
Definition at line 523 of file experiment.h.
|
private |
This indicates whether to use the grid.
Definition at line 526 of file experiment.h.
|
private |
This struct contains information on the metric to be used.
Definition at line 529 of file experiment.h.
|
private |
This indicates whether dileptons are switched on.
Definition at line 532 of file experiment.h.
|
private |
This indicates whether photons are switched on.
Definition at line 535 of file experiment.h.
|
private |
This indicates whether bremsstrahlung is switched on.
Definition at line 538 of file experiment.h.
|
private |
This indicates whether the IC output is enabled.
Definition at line 541 of file experiment.h.
|
private |
This indicates whether to use time steps.
Definition at line 544 of file experiment.h.
|
private |
Maximal distance at which particles can interact in case of the geometric criterion, squared.
Definition at line 550 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 559 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 565 of file experiment.h.
|
private |
system starting time of the simulation
Definition at line 568 of file experiment.h.
|
private |
Type of density to be written to collision headers.
Definition at line 571 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 577 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 583 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 589 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 595 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 601 of file experiment.h.
|
private |
Total number of particles removed from the evolution in hypersurface crossing actions.
Definition at line 607 of file experiment.h.
|
private |
Total number of discarded interactions, because they were invalidated before they could be performed.
Definition at line 613 of file experiment.h.
|
private |
Total energy removed from the system in hypersurface crossing actions.
Definition at line 619 of file experiment.h.
|
private |
random seed for the next event.
Definition at line 622 of file experiment.h.