Version: SMASH-1.7
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 37 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 Particles &particles, const int event_number) override
 writes the event header More...
 
void at_eventend (const Particles &particles, const int event_number, double impact_parameter, bool empty_event) override
 only flushes the output the file More...
 
void at_intermediate_time (const Particles &particles, 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_interaction (const Action &action, const double density)
 Called whenever an action modified one or more particles. 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_output (const GrandCanThermalizer &gct)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. 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

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 109 of file thermodynamicoutput.cc.

112  : OutputInterface(name),
113  file_{path / "thermodynamics.dat", "w"},
114  out_par_(out_par) {
115  std::fprintf(file_.get(), "# %s thermodynamics output\n", VERSION_MAJOR);
116  const ThreeVector r = out_par.td_position;
117  if (out_par_.td_smearing) {
118  std::fprintf(file_.get(), "# @ point (%6.2f, %6.2f, %6.2f) [fm]\n", r.x1(),
119  r.x2(), r.x3());
120  } else {
121  std::fprintf(file_.get(), "# averaged over the entire volume\n");
122  }
123  std::fprintf(file_.get(), "# %s\n", to_string(out_par.td_dens_type));
124  std::fprintf(file_.get(), "# time [fm/c], ");
125  if (out_par_.td_rho_eckart) {
126  std::fprintf(file_.get(), "%s [fm^-3], ",
128  }
129  if (out_par_.td_tmn) {
130  if (out_par_.td_smearing) {
131  std::fprintf(file_.get(), "%s [GeV/fm^3] 00 01 02 03 11 12 13 22 23 33, ",
133  } else {
134  std::fprintf(file_.get(), "%s [GeV] 00 01 02 03 11 12 13 22 23 33, ",
136  }
137  }
138  if (out_par_.td_tmn_landau) {
139  if (out_par_.td_smearing) {
140  std::fprintf(file_.get(), "%s [GeV/fm^3] 00 01 02 03 11 12 13 22 23 33, ",
142  } else {
143  std::fprintf(file_.get(), "%s [GeV] 00 01 02 03 11 12 13 22 23 33, ",
145  }
146  }
147  if (out_par_.td_v_landau) {
148  std::fprintf(file_.get(), "%s x y z, ",
150  }
151  if (out_par_.td_jQBS) {
152  if (out_par_.td_smearing) {
153  std::fprintf(file_.get(), "j_QBS [(Q,B,S)/fm^3] (0 1 2 3)x3");
154  } else {
155  std::fprintf(file_.get(), "j_QBS [(Q,B,S)] (0 1 2 3)x3");
156  }
157  }
158  std::fprintf(file_.get(), "\n");
159 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
ThreeVector td_position
Point, where thermodynamic quantities are calculated.
bool td_jQBS
Print out QBS 4-currents or not?
const OutputParameters out_par_
Structure that holds all the information about what to printout.
bool td_tmn_landau
Print out energy-momentum tensor in Landau rest frame (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_tmn
Print out energy-momentum tensor of type td_dens_type or not?
const char * to_string(const ThermodynamicQuantity tq)
Convert thermodynamic quantities to strings.
bool td_v_landau
Print out Landau velocity of type td_dens_type or not?
OutputInterface(std::string name)
Construct output interface.
RenamingFilePtr file_
Pointer to output file.

Here is the call graph for this function:

smash::ThermodynamicOutput::~ThermodynamicOutput ( )

Default destructor.

Definition at line 161 of file thermodynamicoutput.cc.

161 {}

Member Function Documentation

void smash::ThermodynamicOutput::at_eventstart ( const Particles particles,
const int  event_number 
)
overridevirtual

writes the event header

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

Implements smash::OutputInterface.

Definition at line 163 of file thermodynamicoutput.cc.

164  {
165  std::fprintf(file_.get(), "# event %i\n", event_number);
166 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Pointer to output file.

Here is the call graph for this function:

void smash::ThermodynamicOutput::at_eventend ( const Particles particles,
const int  event_number,
double  impact_parameter,
bool  empty_event 
)
overridevirtual

only flushes the output the file

Parameters
[in]particlesDummy, is just here to satisfy inheritance
[in]event_numberDummy, is just here to satisfy inheritance
[in]impact_parameterDummy, is just here to satisfy inheritance
[in]empty_eventDummy, is just here to satisfy inheritance

Implements smash::OutputInterface.

Definition at line 168 of file thermodynamicoutput.cc.

171  {
172  std::fflush(file_.get());
173 }
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
RenamingFilePtr file_
Pointer to output file.

Here is the call graph for this function:

void smash::ThermodynamicOutput::at_intermediate_time ( const Particles particles,
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]particlesParticles, 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 175 of file thermodynamicoutput.cc.

177  {
178  std::fprintf(file_.get(), "%6.2f ", clock->current_time());
179  constexpr bool compute_gradient = false;
180  if (out_par_.td_rho_eckart) {
181  const double rho = std::get<0>(current_eckart(
182  out_par_.td_position, particles, dens_param, out_par_.td_dens_type,
183  compute_gradient, out_par_.td_smearing));
184  std::fprintf(file_.get(), "%7.4f ", rho);
185  }
187  EnergyMomentumTensor Tmn;
188  for (const auto &p : particles) {
189  const double dens_factor =
191  if (std::abs(dens_factor) < really_small) {
192  continue;
193  }
194  if (out_par_.td_smearing) {
195  const auto sf =
197  p.position().threevec() - out_par_.td_position, p.momentum(),
198  1.0 / p.momentum().abs(), dens_param, compute_gradient)
199  .first;
200  if (sf < really_small) {
201  continue;
202  }
203  Tmn.add_particle(p, dens_factor * sf * dens_param.norm_factor_sf());
204  } else {
205  Tmn.add_particle(p, dens_factor);
206  }
207  }
208  const FourVector u = Tmn.landau_frame_4velocity();
209  const EnergyMomentumTensor Tmn_L = Tmn.boosted(u);
210  if (out_par_.td_tmn) {
211  for (int i = 0; i < 10; i++) {
212  std::fprintf(file_.get(), "%15.12f ", Tmn[i]);
213  }
214  }
215  if (out_par_.td_tmn_landau) {
216  for (int i = 0; i < 10; i++) {
217  std::fprintf(file_.get(), "%7.4f ", Tmn_L[i]);
218  }
219  }
220  if (out_par_.td_v_landau) {
221  std::fprintf(file_.get(), "%7.4f %7.4f %7.4f ", -u[1] / u[0],
222  -u[2] / u[0], -u[3] / u[0]);
223  }
224  }
225  if (out_par_.td_jQBS) {
226  FourVector jQ = std::get<1>(current_eckart(
227  out_par_.td_position, particles, dens_param, DensityType::Charge,
228  compute_gradient, out_par_.td_smearing));
229  FourVector jB = std::get<1>(current_eckart(
230  out_par_.td_position, particles, dens_param, DensityType::Baryon,
231  compute_gradient, out_par_.td_smearing));
232  FourVector jS = std::get<1>(current_eckart(
233  out_par_.td_position, particles, dens_param, DensityType::Strangeness,
234  compute_gradient, out_par_.td_smearing));
235  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jQ[0], jQ[1],
236  jQ[2], jQ[3]);
237  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jB[0], jB[1],
238  jB[2], jB[3]);
239  std::fprintf(file_.get(), "%15.12f %15.12f %15.12f %15.12f ", jS[0], jS[1],
240  jS[2], jS[3]);
241  }
242  std::fprintf(file_.get(), "\n");
243 }
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37
DensityType td_dens_type
Type (e.g., baryon/pion/hadron) of thermodynamic quantity.
FILE * get()
Get the underlying FILE* pointer.
Definition: file.cc:27
ThreeVector td_position
Point, where thermodynamic quantities are calculated.
bool td_jQBS
Print out QBS 4-currents or not?
const OutputParameters out_par_
Structure that holds all the information about what to printout.
bool td_tmn_landau
Print out energy-momentum tensor in Landau rest frame (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?
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:17
std::tuple< double, FourVector, ThreeVector, ThreeVector, ThreeVector > 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:149
constexpr int p
Proton.
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:38
bool td_tmn
Print out energy-momentum tensor of type td_dens_type or not?
bool td_v_landau
Print out Landau velocity of type td_dens_type or not?
RenamingFilePtr file_
Pointer to output file.

Here is the call graph for this function:

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 245 of file thermodynamicoutput.cc.

248  {
249  ThreeVector r;
250  std::ofstream a_file;
251  a_file.open(file_name, std::ios::out);
252  const bool compute_gradient = false;
253  const bool smearing = true;
254 
255  for (int i = 0; i <= n_points; i++) {
256  r = line_start + (line_end - line_start) * (1.0 * i / n_points);
257  double rho_eck = std::get<0>(
258  current_eckart(r, plist, param, dens_type, compute_gradient, smearing));
259  a_file << r.x1() << " " << r.x2() << " " << r.x3() << " " << rho_eck
260  << "\n";
261  }
262 }
std::tuple< double, FourVector, ThreeVector, ThreeVector, ThreeVector > 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:149

Here is the call graph for this function:

Member Data Documentation

RenamingFilePtr smash::ThermodynamicOutput::file_
private

Pointer to output file.

Definition at line 100 of file thermodynamicoutput.h.

const OutputParameters smash::ThermodynamicOutput::out_par_
private

Structure that holds all the information about what to printout.

Definition at line 102 of file thermodynamicoutput.h.


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