Version: SMASH-2.2
smash::ThermodynamicOutput Class Reference

#include <thermodynamicoutput.h>

Writes the thermodynamic quantities at a specified point versus time.

This class is a temporary solution to write thermodynamic quantities out. Calculations are called directly inside the output functions. In future it should be substituted by some more general output.

Definition at line 39 of file thermodynamicoutput.h.

Inheritance diagram for smash::ThermodynamicOutput:
[legend]
Collaboration diagram for smash::ThermodynamicOutput:
[legend]

Public Member Functions

 ThermodynamicOutput (const bf::path &path, const std::string &name, const OutputParameters &out_par)
 Construct Output param[in] path Path to output param[in] name Filename param[in] out_par Parameters of output. More...
 
 ~ThermodynamicOutput ()
 Default destructor. More...
 
void at_eventstart (const std::vector< Particles > &ensembles, const int event_number) override
 writes the event header More...
 
void at_eventend (const std::vector< Particles > &ensembles, const int event_number) override
 only flushes the output the file More...
 
void at_intermediate_time (const std::vector< Particles > &ensembles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param) override
 Writes thermodynamics every fixed time interval. More...
 
void density_along_line (const char *file_name, const ParticleList &plist, const DensityParameters &param, DensityType dens_type, const ThreeVector &line_start, const ThreeVector &line_end, int n_points)
 Prints density along the specified line. More...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=default
 
virtual void at_eventstart (const Particles &particles, const int event_number, const EventInfo &info)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< DensityOnLattice > lattice)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, RectangularLattice< EnergyMomentumTensor > lattice)
 Output launched atevent start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventend (const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type)
 Output launched at event end. More...
 
virtual void at_eventend (const ThermodynamicQuantity tq)
 Output launched at event end. More...
 
virtual void at_eventend (const Particles &particles, const int event_number, const EventInfo &info)
 Output launched at event end. More...
 
virtual void at_interaction (const Action &action, const double density)
 Called whenever an action modified one or more particles. More...
 
virtual void at_intermediate_time (const Particles &particles, const std::unique_ptr< Clock > &clock, const DensityParameters &dens_param, const EventInfo &info)
 Output launched after every N'th timestep. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< DensityOnLattice > &lattice)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity tq, const DensityType dt, RectangularLattice< EnergyMomentumTensor > &lattice)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &lattice, const double current_time, const std::vector< Particles > &ensembles, const DensityParameters &dens_param)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (const ThermodynamicQuantity tq, RectangularLattice< EnergyMomentumTensor > &lattice, const double current_time)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_output (const GrandCanThermalizer &gct)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. More...
 
virtual void fields_output (const std::string name1, const std::string name2, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &lat)
 Write fields in vtk output. 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...
 

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

◆ ThermodynamicOutput()

smash::ThermodynamicOutput::ThermodynamicOutput ( const bf::path &  path,
const std::string &  name,
const OutputParameters out_par 
)

Construct Output param[in] path Path to output param[in] name Filename param[in] out_par Parameters of output.

Definition at line 116 of file thermodynamicoutput.cc.

119  : OutputInterface(name),
120  file_{path / "thermodynamics.dat", "w"},
121  out_par_(out_par) {
122  std::fprintf(file_.get(), "# %s thermodynamics output\n", SMASH_VERSION);
123  const ThreeVector r = out_par.td_position;
125  std::fprintf(file_.get(), "# only participants are taken into account\n");
126  }
127  if (out_par_.td_smearing) {
128  std::fprintf(file_.get(), "# @ point (%6.2f, %6.2f, %6.2f) [fm]\n", r.x1(),
129  r.x2(), r.x3());
130  } else {
131  std::fprintf(file_.get(), "# averaged over the entire volume\n");
132  }
133  std::fprintf(file_.get(), "# %s\n", to_string(out_par.td_dens_type));
134  std::fprintf(file_.get(), "# time [fm/c], ");
135  if (out_par_.td_rho_eckart) {
136  std::fprintf(file_.get(), "%s [fm^-3], ",
138  }
139  if (out_par_.td_tmn) {
140  if (out_par_.td_smearing) {
141  std::fprintf(file_.get(), "%s [GeV/fm^3] 00 01 02 03 11 12 13 22 23 33, ",
143  } else {
144  std::fprintf(file_.get(), "%s [GeV] 00 01 02 03 11 12 13 22 23 33, ",
146  }
147  }
148  if (out_par_.td_tmn_landau) {
149  if (out_par_.td_smearing) {
150  std::fprintf(file_.get(), "%s [GeV/fm^3] 00 01 02 03 11 12 13 22 23 33, ",
152  } else {
153  std::fprintf(file_.get(), "%s [GeV] 00 01 02 03 11 12 13 22 23 33, ",
155  }
156  }
157  if (out_par_.td_v_landau) {
158  std::fprintf(file_.get(), "%s x y z, ",
160  }
161  if (out_par_.td_jQBS) {
162  if (out_par_.td_smearing) {
163  std::fprintf(file_.get(), "j_QBS [(Q,B,S)/fm^3] (0 1 2 3)x3");
164  } else {
165  std::fprintf(file_.get(), "j_QBS [(Q,B,S)] (0 1 2 3)x3");
166  }
167  }
168  std::fprintf(file_.get(), "\n");
169 }
OutputInterface(std::string name)
Construct output interface.
const char * to_string(const ThermodynamicQuantity tq)
Convert thermodynamic quantities to strings.
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Pointer to output file.
const OutputParameters out_par_
Structure that holds all the information about what to printout.
bool td_v_landau
Print out Landau velocity of type td_dens_type or not?
bool td_tmn_landau
Print out energy-momentum tensor in Landau rest frame (of type td_dens_type) or not?
bool td_jQBS
Print out QBS 4-currents or not?
bool td_tmn
Print out energy-momentum tensor of type td_dens_type or not?
bool td_smearing
Whether smearing is on or off; WARNING : if smearing is off, then final result is in GeV instead of G...
bool td_rho_eckart
Print out Eckart rest frame density of type td_dens_type or not?
bool td_only_participants
Flag reporting whether only participants are considered (true) or also spectators (false)
Here is the call graph for this function:

◆ ~ThermodynamicOutput()

smash::ThermodynamicOutput::~ThermodynamicOutput ( )

Default destructor.

Definition at line 171 of file thermodynamicoutput.cc.

171 {}

Member Function Documentation

◆ at_eventstart()

void smash::ThermodynamicOutput::at_eventstart ( const std::vector< Particles > &  ensembles,
const int  event_number 
)
overridevirtual

writes the event header

Parameters
[in]ensemblesDummy, is just here to satisfy inheritance
[in]event_numberCurrent event number, that will be written to the header

Reimplemented from smash::OutputInterface.

Definition at line 173 of file thermodynamicoutput.cc.

174  {
175  std::fprintf(file_.get(), "# event %i\n", event_number);
176 }
Here is the call graph for this function:

◆ at_eventend()

void smash::ThermodynamicOutput::at_eventend ( const std::vector< Particles > &  ensembles,
const int  event_number 
)
overridevirtual

only flushes the output the file

Parameters
[in]ensemblesDummy, is just here to satisfy inheritance
[in]event_numberDummy, is just here to satisfy inheritance

Reimplemented from smash::OutputInterface.

Definition at line 178 of file thermodynamicoutput.cc.

179  {
180  std::fflush(file_.get());
181 }
Here is the call graph for this function:

◆ at_intermediate_time()

void smash::ThermodynamicOutput::at_intermediate_time ( const std::vector< Particles > &  ensembles,
const std::unique_ptr< Clock > &  clock,
const DensityParameters dens_param 
)
overridevirtual

Writes thermodynamics every fixed time interval.

For configuring the output see ASCII Thermodynamics Output.

Parameters
[in]ensemblesParticles, from which thermodynamic variables are computed
[in]clockClock, needed to get current time
[in]dens_paramset of parameters, defining smearing. For more info about smearing see ASCII Thermodynamics Output.

Reimplemented from smash::OutputInterface.

Definition at line 183 of file thermodynamicoutput.cc.

185  {
186  std::fprintf(file_.get(), "%6.2f ", clock->current_time());
187  constexpr bool compute_gradient = false;
188  if (out_par_.td_rho_eckart) {
189  FourVector jmu = FourVector();
190  for (const Particles &particles : ensembles) {
191  jmu += std::get<1>(current_eckart(
192  out_par_.td_position, particles, dens_param, out_par_.td_dens_type,
193  compute_gradient, out_par_.td_smearing));
194  }
195  std::fprintf(file_.get(), "%15.12f ", jmu.abs());
196  }
198  EnergyMomentumTensor Tmn;
199  for (const Particles &particles : ensembles) {
200  for (const auto &p : particles) {
201  if (dens_param.only_participants()) {
202  // if this condition holds, the hadron is a spectator and we skip it
203  if (p.get_history().collisions_per_particle == 0) {
204  continue;
205  }
206  }
207  const double dens_factor =
209  if (std::abs(dens_factor) < really_small) {
210  continue;
211  }
212  if (out_par_.td_smearing) {
213  const auto sf =
215  p.position().threevec() - out_par_.td_position, p.momentum(),
216  1.0 / p.momentum().abs(), dens_param, compute_gradient)
217  .first;
218  if (sf < really_small) {
219  continue;
220  }
221  Tmn.add_particle(p, dens_factor * sf * dens_param.norm_factor_sf());
222  } else {
223  Tmn.add_particle(p, dens_factor);
224  }
225  }
226  }
227  const FourVector u = Tmn.landau_frame_4velocity();
228  const EnergyMomentumTensor Tmn_L = Tmn.boosted(u);
229  if (out_par_.td_tmn) {
230  for (int i = 0; i < 10; i++) {
231  std::fprintf(file_.get(), "%15.12f ", Tmn[i]);
232  }
233  }
234  if (out_par_.td_tmn_landau) {
235  for (int i = 0; i < 10; i++) {
236  std::fprintf(file_.get(), "%15.12f ", Tmn_L[i]);
237  }
238  }
239  if (out_par_.td_v_landau) {
240  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f ", -u[1] / u[0],
241  -u[2] / u[0], -u[3] / u[0]);
242  }
243  }
244  if (out_par_.td_jQBS) {
245  FourVector jQ = FourVector(), jB = FourVector(), jS = FourVector();
246  for (const Particles &particles : ensembles) {
247  jQ += std::get<1>(current_eckart(out_par_.td_position, particles,
248  dens_param, DensityType::Charge,
249  compute_gradient, out_par_.td_smearing));
250  jB += std::get<1>(current_eckart(out_par_.td_position, particles,
251  dens_param, DensityType::Baryon,
252  compute_gradient, out_par_.td_smearing));
253  jS += std::get<1>(current_eckart(out_par_.td_position, particles,
254  dens_param, DensityType::Strangeness,
255  compute_gradient, out_par_.td_smearing));
256  }
257  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jQ[0], jQ[1],
258  jQ[2], jQ[3]);
259  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jB[0], jB[1],
260  jB[2], jB[3]);
261  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jS[0], jS[1],
262  jS[2], jS[3]);
263  }
264  std::fprintf(file_.get(), "\n");
265 }
constexpr int p
Proton.
std::tuple< double, FourVector, ThreeVector, ThreeVector, FourVector, FourVector, FourVector, FourVector > current_eckart(const ThreeVector &r, const ParticleList &plist, const DensityParameters &par, DensityType dens_type, bool compute_gradient, bool smearing)
Calculates Eckart rest frame density and 4-current of a given density type and optionally the gradien...
Definition: density.cc:167
std::pair< double, ThreeVector > unnormalized_smearing_factor(const ThreeVector &r, const FourVector &p, const double m_inv, const DensityParameters &dens_par, const bool compute_gradient=false)
Implements gaussian smearing for any quantity.
Definition: density.cc:37
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37
double density_factor(const ParticleType &type, DensityType dens_type)
Get the factor that determines how much a particle contributes to the density type that is computed.
Definition: density.cc:16
DensityType td_dens_type
Type (e.g., baryon/pion/hadron) of thermodynamic quantity.
ThreeVector td_position
Point, where thermodynamic quantities are calculated.
Here is the call graph for this function:

◆ density_along_line()

void smash::ThermodynamicOutput::density_along_line ( const char *  file_name,
const ParticleList &  plist,
const DensityParameters param,
DensityType  dens_type,
const ThreeVector line_start,
const ThreeVector line_end,
int  n_points 
)

Prints density along the specified line.

Useful to make 1D plots of density profiles.

Parameters
[in]file_namename of the file to print out
[in]paramParameters for density calculation
[in]plistparticles, from which density is computed
[in]dens_typetype of density
[in]line_startstarting point of the line
[in]line_endending point of the line
[in]n_pointsnumber of points along the line, where density is printed out

Definition at line 267 of file thermodynamicoutput.cc.

270  {
271  ThreeVector r;
272  std::ofstream a_file;
273  a_file.open(file_name, std::ios::out);
274  const bool compute_gradient = false;
275  const bool smearing = true;
276 
277  for (int i = 0; i <= n_points; i++) {
278  r = line_start + (line_end - line_start) * (1.0 * i / n_points);
279  double rho_eck = std::get<0>(
280  current_eckart(r, plist, param, dens_type, compute_gradient, smearing));
281  a_file << r.x1() << " " << r.x2() << " " << r.x3() << " " << rho_eck
282  << "\n";
283  }
284 }
Here is the call graph for this function:

Member Data Documentation

◆ file_

RenamingFilePtr smash::ThermodynamicOutput::file_
private

Pointer to output file.

Definition at line 103 of file thermodynamicoutput.h.

◆ out_par_

const OutputParameters smash::ThermodynamicOutput::out_par_
private

Structure that holds all the information about what to printout.

Definition at line 105 of file thermodynamicoutput.h.


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