Version: SMASH-3.1
smash::ICOutput Class Reference

#include <icoutput.h>

SMASH output in ASCII format containing initial conditions for hydrodynamic codes.

Formatted such that it can be directly processed by vHLLE Karpenko:2015xea [29].

Definition at line 31 of file icoutput.h.

Inheritance diagram for smash::ICOutput:
smash::OutputInterface

Public Member Functions

 ICOutput (const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par)
 Create a new IC output. More...
 
 ~ICOutput ()
 
void at_eventstart (const Particles &, const int event_number, const EventInfo &) override
 Write event start line. More...
 
void at_eventend (const Particles &particles, const int event_number, const EventInfo &event) override
 Write event end line. More...
 
void at_intermediate_time (const Particles &, const std::unique_ptr< Clock > &, const DensityParameters &, const EventInfo &) override
 Unused, but needed since virtually declared in mother class. More...
 
void at_interaction (const Action &action, const double) override
 Write particle data at the hypersurface crossing point to the IC output. More...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=0
 Pure virtual destructor to make class abstract and prevent its instantiation. More...
 
virtual void at_eventstart (const std::vector< Particles > &, int)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice >)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor >)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventend (const int, const ThermodynamicQuantity, const DensityType)
 Output launched at event end. More...
 
virtual void at_eventend (const ThermodynamicQuantity)
 Output launched at event end. More...
 
virtual void at_eventend (const std::vector< Particles > &, const int)
 Output launched at event end. More...
 
virtual void at_intermediate_time (const std::vector< Particles > &, const std::unique_ptr< Clock > &, const DensityParameters &)
 Output launched after every N'th timestep. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice > &)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor > &)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double, const std::vector< Particles > &, const DensityParameters &)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (const ThermodynamicQuantity, RectangularLattice< EnergyMomentumTensor > &, const double)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_output (const GrandCanThermalizer &)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. More...
 
virtual void fields_output (const std::string, const std::string, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &)
 Write fields in vtk output Fields are a pair of threevectors for example electric and magnetic field. More...
 
bool is_dilepton_output () const
 Get, whether this is the dilepton output? More...
 
bool is_photon_output () const
 Get, whether this is the photon output? More...
 
bool is_IC_output () const
 Get, whether this is the IC output? More...
 
const char * to_string (const ThermodynamicQuantity tq)
 Convert thermodynamic quantities to strings. More...
 
const char * to_string (const DensityType dens_type)
 Convert density types to strings. More...
 

Private Attributes

RenamingFilePtr file_
 Pointer to output file. More...
 
const OutputParameters out_par_
 Structure that holds all the information about what to printout. More...
 
double IC_proper_time_ = -1.0
 Proper time of the particles removed when extracting initial conditions. More...
 

Additional Inherited Members

- Protected Attributes inherited from smash::OutputInterface
const bool is_dilepton_output_
 Is this the dilepton output? More...
 
const bool is_photon_output_
 Is this the photon output? More...
 
const bool is_IC_output_
 Is this the IC output? More...
 

Constructor & Destructor Documentation

◆ ICOutput()

smash::ICOutput::ICOutput ( const std::filesystem::path &  path,
const std::string &  name,
const OutputParameters out_par 
)

Create a new IC output.

Parameters
[in]pathPath to the output file.
[in]nameName of the output.
[in]out_parAdditional information on the configured output.

Definition at line 101 of file icoutput.cc.

103  : OutputInterface(name),
104  file_{path / "SMASH_IC.dat", "w"},
105  out_par_(out_par) {
106  std::fprintf(
107  file_.get(),
108  "# %s initial conditions: hypersurface of constant proper time\n",
109  SMASH_VERSION);
110  std::fprintf(file_.get(),
111  "# tau x y eta mt px py Rap pdg charge "
112  "baryon_number strangeness\n");
113  std::fprintf(file_.get(),
114  "# fm fm fm none GeV GeV GeV none none e "
115  "none none\n");
116 }
RenamingFilePtr file_
Pointer to output file.
Definition: icoutput.h:75
const OutputParameters out_par_
Structure that holds all the information about what to printout.
Definition: icoutput.h:77
OutputInterface(std::string name)
Construct output interface.
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27

◆ ~ICOutput()

smash::ICOutput::~ICOutput ( )

Definition at line 118 of file icoutput.cc.

118 {}

Member Function Documentation

◆ at_eventstart()

void smash::ICOutput::at_eventstart ( const Particles ,
const int  event_number,
const EventInfo  
)
overridevirtual

Write event start line.

Parameters
[in]event_numberNumber of the current event.

Reimplemented from smash::OutputInterface.

Definition at line 120 of file icoutput.cc.

121  {
122  std::fprintf(file_.get(), "# event %i start\n", event_number);
123 }

◆ at_eventend()

void smash::ICOutput::at_eventend ( const Particles particles,
const int  event_number,
const EventInfo event 
)
overridevirtual

Write event end line.

Parameters
[in]particlesParticles at end of event, expected to be empty
[in]event_numberNumber of the current event.
[in]eventEvent info, see event_info

Reimplemented from smash::OutputInterface.

Definition at line 125 of file icoutput.cc.

126  {
127  std::fprintf(file_.get(), "# event %i end\n", event_number);
128 
129  // If the runtime is too short some particles might not yet have
130  // reached the hypersurface. Warning is printed.
131  if (particles.size() != 0 && !event.impose_kinematic_cut_for_SMASH_IC) {
133  "End time might be too small for initial conditions output. "
134  "Hypersurface has not yet been crossed by ",
135  particles.size(), " particle(s).");
136  }
137 }
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
static constexpr int LHyperSurfaceCrossing
Definition: binaryoutput.cc:22

◆ at_intermediate_time()

void smash::ICOutput::at_intermediate_time ( const Particles ,
const std::unique_ptr< Clock > &  ,
const DensityParameters ,
const EventInfo  
)
overridevirtual

Unused, but needed since virtually declared in mother class.

Reimplemented from smash::OutputInterface.

Definition at line 139 of file icoutput.cc.

142  {
143  // Dummy, but virtual function needs to be declared.
144 }

◆ at_interaction()

void smash::ICOutput::at_interaction ( const Action action,
const double   
)
overridevirtual

Write particle data at the hypersurface crossing point to the IC output.

Parameters
[in]actionDetails about the action

Reimplemented from smash::OutputInterface.

Definition at line 146 of file icoutput.cc.

146  {
147  assert(action.get_type() == ProcessType::HyperSurfaceCrossing);
148  assert(action.incoming_particles().size() == 1);
149 
150  ParticleData particle = action.incoming_particles()[0];
151 
152  // transverse mass
153  const double m_trans =
154  std::sqrt(particle.effective_mass() * particle.effective_mass() +
155  particle.momentum()[1] * particle.momentum()[1] +
156  particle.momentum()[2] * particle.momentum()[2]);
157  // momentum space rapidity
158  const double rapidity =
159  0.5 * std::log((particle.momentum()[0] + particle.momentum()[3]) /
160  (particle.momentum()[0] - particle.momentum()[3]));
161 
162  // Determine if particle is spectator:
163  // Fulfilled if particle is initial nucleon, aka has no prior interactions
164  bool is_spectator = particle.get_history().collisions_per_particle == 0;
165 
166  // write particle data excluding spectators
167  if (!is_spectator) {
168  std::fprintf(file_.get(), "%g %g %g %g %g %g %g %g %s %i %i %i \n",
169  particle.position().tau(), particle.position()[1],
170  particle.position()[2], particle.position().eta(), m_trans,
171  particle.momentum()[1], particle.momentum()[2], rapidity,
172  particle.pdgcode().string().c_str(), particle.type().charge(),
173  particle.type().baryon_number(),
174  particle.type().strangeness());
175  }
176 
177  if (IC_proper_time_ < 0.0) {
178  // First particle that is removed, overwrite negative default
179  IC_proper_time_ = particle.position().tau();
180  } else {
181  // Verify that all other particles have the same proper time
182  const double next_proper_time = particle.position().tau();
183  if (!((next_proper_time - IC_proper_time_) < really_small))
184  throw std::runtime_error(
185  "Hypersurface proper time changed during evolution.");
186  }
187 }
double IC_proper_time_
Proper time of the particles removed when extracting initial conditions.
Definition: icoutput.h:88
@ HyperSurfaceCrossing
See here for a short description.
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37

Member Data Documentation

◆ file_

RenamingFilePtr smash::ICOutput::file_
private

Pointer to output file.

Definition at line 75 of file icoutput.h.

◆ out_par_

const OutputParameters smash::ICOutput::out_par_
private

Structure that holds all the information about what to printout.

Definition at line 77 of file icoutput.h.

◆ IC_proper_time_

double smash::ICOutput::IC_proper_time_ = -1.0
private

Proper time of the particles removed when extracting initial conditions.

Parameter used for testing purposes only. Used to verify that the initial proper time remains unchanged during the evolution. Determined from the actually removed particles. By construction, tau > 0. Nevertheless it is initialized with a negative number to easily find the first particle that is removed from the evolution in at_interaction().

Definition at line 88 of file icoutput.h.


The documentation for this class was generated from the following files: