Version: SMASH-3.4
thermodynamiclatticeoutput.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2022,2026
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
11 
12 #include <filesystem>
13 #include <fstream>
14 #include <memory>
15 
16 #include "smash/clock.h"
17 #include "smash/config.h"
18 #include "smash/density.h"
22 #include "smash/vtkoutput.h"
23 
24 namespace smash {
25 
26 /*!\Userguide
27  * \page doxypage_output_thermodyn_lattice
28  *
29  * The thermodynamics lattice output prints "smeared" thermodynamic quantities
30  * evaluated at the nodes of a Lattice, defined as defined in
31  * \ref doxypage_input_conf_lattice.
32  *
33  * The calculated quantities can include: the Eckart density, the
34  * energy-momentum tensor in the lab and/or Landau frame, the Landau
35  * velocity and the electric/baryonic/strange currents.
36  * Which of these quantities are outputted needs to be specified in the config
37  * file. They will be calculated using **one** of the following density types:
38  * hadron, baryon, baryonic isospin, pion, or none.
39  *
40  * A separate output file is printed for each quantity and each event.
41  *
42  * It is possible to print the output in:
43  * - ASCII format (option "Lattice_ASCII")
44  * - Binary format (option "Lattice_Binary")
45  *
46  * For example:
47  *\verbatim
48  Output:
49  Output_Interval: 4.0
50  Thermodynamics:
51  Format: ["Lattice_ASCII","Lattice_Binary"]
52  Type: "baryon"
53  Quantities: ["rho_eckart", "tmn", "tmn_landau","landau_velocity","j_QBS"]
54  \endverbatim
55  *
56  * Please, note that the Thermodynamic output is not printed at the end of an
57  event, even if the end time of the simulation is a multiple of
58  Output_Interval (if this final output is important, just increase a little
59  the parameter End_Time).
60  *
61  * **Output files**
62  * Each file has a header and a payload. The content is the same both in
63  * Lattice_ASCII and Lattice_Binary formats, but, of course, the details are a
64  * bit different.
65  *
66  *
67  * **Header of the output files**
68  *
69  * - version of the output (ASCII: fixed 2 digits float, Binary: double)
70  * - thermodynamic quantity (ASCII: string, Binary: int)
71  * - nx, ny, nz: cells of the lattice along x, y, z, respectively
72  * (set in: Lattice->Cell_Number, see \ref doxypage_input_conf_lattice)
73  * (3 ints)
74  * - x0, y0, z0: coordinates of the origin of the lattice
75  * (set in Lattice->Origin)
76  * (ASCII: 3 fixed 6 digits precision floats, Binary: 3 doubles)
77  * - dx, dy, dz: size of the lattice (set in Lattice->Sizes)
78  * (ASCII: 3 fixed 6 digits precision floats, Binary: 3 doubles)
79  *
80  * In "Lattice_ASCII" the data entries are separated by 1 space and each line of
81  * the header starts with "#", followed by the description of the entry.
82  *
83  * The numbers corresponding to the various thermodynamic quantities are:
84  * -0 EckartDensity
85  * -1 Tmn (energy momentum tensor in the lab frame)
86  * -2 TmnLandau (energy momentum tensor in Landau's frame)
87  * -3 LandauVelocity
88  * -4 j_QBS (electric charge, baryon and strangeness four currents)
89  * -99 Unknown quantity
90  *
91  * **Payload of the output files**
92  *
93  * All the data in the payload are represented as:
94  * - ASCII files: scientific format, 14 precision digits
95  * - Binary files: double type
96  *
97  * In the case of the energy-momentum tensor, the data payload consists
98  * in the values of the quantity in the following order:
99  *
100  \code
101  for (h=0;h<{number of timesteps};h++) {
102  output time
103  for (l=0;l<{number of components};l++) {
104  for (k=0;k<nz;k++) {
105  for (j=0;j<ny;j++) {
106  for (i=0;i<nx;i++) {
107  energy momentum tensor component T[l]
108  }
109  \newline (only in ASCII files)
110  }
111  }
112  }
113  }
114  \endcode
115  * (see SMASH documentation of the function tmn_index for more details about the
116  * components)
117  *
118  *
119  * In the case of densities, the data payload consists
120  * in the values of the quantity in the following order:
121  *
122  \code
123  for (h=0;h<{number of timesteps};h++) {
124  output time
125  for (k=0;k<nz;k++) {
126  for (j=0;j<ny;j++) {
127  for (i=0;i<nx;i++) {
128  density value
129  }
130  \newline (only in ASCII files)
131  }
132  }
133  }
134  \endcode
135  *
136  * In the case of Landau velocity the data payload
137  * consists in the values of the components
138  * Vx, Vy, Vz in the following order:
139 
140 \code
141  for (h=0;h<{number of timesteps};h++) {
142  output time
143  for (k=0;k<nz;k++) {
144  for (j=0;j<ny;j++) {
145  for (i=0;i<nx;i++) {
146  Vx Vy Vz (+ \newline in ASCII files)
147  }
148  }
149  }
150  }
151  \endcode
152  *
153  * In the case of the electric charge, baryon and strangeness currents
154  * jQ, jB and jS the data payload consists in the values of their components
155  * in following order:
156 
157 \code
158  for (h=0;h<{number of timesteps};h++) {
159  output time
160  for (k=0;k<nz;k++) {
161  for (j=0;j<ny;j++) {
162  for (i=0;i<nx;i++) {
163  jQ[0] jQ[1] jQ[2] jQ[3] jB[0] jB[1] jB[2] jB[3] jS[0] jS[1] jS[2] jS[3]
164  (+ \newline in ASCII files)
165  }
166  }
167  }
168  }
169  \endcode
170  * (see SMASH documentation of the function current_eckart for more details
171  * about
172  * the definition of the currents)
173  * Please, note that note that all currents are given in units of
174  "number of charges"; multiply the electric current by the
175  elementary charge \f$\sqrt{4 \pi \alpha_{EM}} \f$ for charge units.
176  *
177  * Please visit the \ref input_output_thermodynamics_ "Thermodynamics" section
178  * of the \ref input_output_content_specific_ "content-specific output options"
179  * for additional information about the thermodynamic quantities.
180  */
181 
182 /* initialization of the static member version */
183 const double_t ThermodynamicLatticeOutput::version = 1.0;
184 
186  const std::filesystem::path &path, const std::string &name,
187  const OutputParameters &out_par, const bool enable_ascii,
188  const bool enable_binary)
189  : OutputInterface(name),
190  out_par_(out_par),
191  base_path_(std::move(path)),
192  enable_ascii_(enable_ascii),
193  enable_binary_(enable_binary) {
194  if (enable_ascii_ || enable_binary_) {
195  enable_output_ = true;
196  } else {
197  enable_output_ = false;
198  }
199  if (enable_ascii_) {
200  if (out_par_.td_rho_eckart) {
202  std::make_shared<std::ofstream>(nullptr);
203  }
204  if (out_par_.td_tmn_landau) {
206  std::make_shared<std::ofstream>(nullptr);
207  }
208  if (out_par_.td_tmn) {
210  std::make_shared<std::ofstream>(nullptr);
211  }
212  if (out_par_.td_v_landau) {
214  std::make_shared<std::ofstream>(nullptr);
215  }
216  if (out_par_.td_jQBS) {
218  std::make_shared<std::ofstream>(nullptr);
219  }
220  }
221  if (enable_binary_) {
222  if (out_par_.td_rho_eckart) {
224  std::make_shared<std::ofstream>(nullptr);
225  }
226  if (out_par_.td_tmn_landau) {
228  std::make_shared<std::ofstream>(nullptr);
229  }
230  if (out_par_.td_tmn) {
232  std::make_shared<std::ofstream>(nullptr);
233  }
234  if (out_par_.td_v_landau) {
236  std::make_shared<std::ofstream>(nullptr);
237  }
238  if (out_par_.td_jQBS) {
240  std::make_shared<std::ofstream>(nullptr);
241  }
242  }
243 }
244 
246 
248  const int event_number, const ThermodynamicQuantity tq,
250  if (!enable_output_) {
251  return;
252  }
253  assert((tq == ThermodynamicQuantity::EckartDensity) ||
255  // at the next refactoring of the code,
256  // this piece should go in the constructor
257  const auto dim = lattice.n_cells();
258  const auto cs = lattice.cell_sizes();
259  const auto orig = lattice.origin();
260  for (int l = 0; l < 3; l++) {
261  nodes_[l] = dim[l];
262  sizes_[l] = cs[l];
263  origin_[l] = orig[l];
264  }
265  std::shared_ptr<std::ofstream> fp(nullptr);
266  std::string varname;
267  std::string filename;
268  varname = make_varname(tq, dens_type);
270  if (enable_ascii_) {
271  filename = make_filename(varname, event_number, 'a');
272  try {
274  filename, std::ios::out);
275  } catch (std::ofstream::failure &e) {
276  logg[LogArea::Main::id].fatal()
277  << "Error in opening " << filename << std::endl;
278  throw std::runtime_error(
279  "Not possible to write thermodynamic "
280  "lattice output to file.");
281  }
284  }
285  if (enable_binary_) {
286  filename = make_filename(varname, event_number, 'b');
287  try {
289  filename, std::ios::out | std::ios::binary);
290  } catch (std::ofstream::failure &e) {
291  logg[LogArea::Main::id].fatal()
292  << "Error in opening " << filename << std::endl;
293  throw std::runtime_error(
294  "Not possible to write thermodynamic "
295  "lattice output to file.");
296  }
299  }
300  } else {
301  if (enable_ascii_) {
302  filename = make_filename(varname, event_number, 'a');
303  try {
305  std::ios::out);
306  } catch (std::ofstream::failure &e) {
307  logg[LogArea::Main::id].fatal()
308  << "Error in opening " << filename << std::endl;
309  throw std::runtime_error(
310  "Not possible to write thermodynamic "
311  "lattice output to file.");
312  }
315  }
316  if (enable_binary_) {
317  filename = make_filename(varname, event_number, 'b');
318  try {
320  filename, std::ios::out | std::ios::binary);
321  } catch (std::ofstream::failure &e) {
322  logg[LogArea::Main::id].fatal()
323  << "Error in opening " << filename << std::endl;
324  throw std::runtime_error(
325  "Not possible to write thermodynamic "
326  "lattice output to file.");
327  }
330  }
331  }
332 }
333 
335  const int event_number, const ThermodynamicQuantity tq,
336  const DensityType dens_type,
338  if (!enable_output_) {
339  return;
340  }
341  const auto dim = lattice.n_cells();
342  const auto cs = lattice.cell_sizes();
343  const auto orig = lattice.origin();
344  for (int l = 0; l < 3; l++) {
345  nodes_[l] = dim[l];
346  sizes_[l] = cs[l];
347  origin_[l] = orig[l];
348  }
349  std::shared_ptr<std::ofstream> fp(nullptr);
350  std::string varname;
351  std::string filename;
352  varname = make_varname(tq, dens_type);
353  if (enable_ascii_) {
354  filename = make_filename(varname, event_number, 'a');
356  try {
358  filename, std::ios::out);
359  } catch (std::ofstream::failure &e) {
360  logg[LogArea::Main::id].fatal()
361  << "Error in opening " << filename << std::endl;
362  throw std::runtime_error(
363  "Not possible to write thermodynamic "
364  "lattice output to file.");
365  }
367  } else if (tq == ThermodynamicQuantity::Tmn) {
368  try {
370  std::ios::out);
371  } catch (std::ofstream::failure &e) {
372  logg[LogArea::Main::id].fatal()
373  << "Error in opening " << filename << std::endl;
374  throw std::runtime_error(
375  "Not possible to write thermodynamic "
376  "lattice output to file.");
377  }
379  } else if (tq == ThermodynamicQuantity::LandauVelocity) {
380  try {
382  filename, std::ios::out);
383  } catch (std::ofstream::failure &e) {
384  logg[LogArea::Main::id].fatal()
385  << "Error in opening " << filename << std::endl;
386  throw std::runtime_error(
387  "Not possible to write thermodynamic "
388  "lattice output to file.");
389  }
391  } else {
392  try {
394  std::ios::out);
395  } catch (std::ofstream::failure &e) {
396  logg[LogArea::Main::id].fatal()
397  << "Error in opening " << filename << std::endl;
398  throw std::runtime_error(
399  "Not possible to write thermodynamic "
400  "lattice output to file.");
401  }
402  }
404  }
405  if (enable_binary_) {
406  filename = make_filename(varname, event_number, 'b');
408  try {
410  filename, std::ios::out | std::ios::binary);
411  } catch (std::ofstream::failure &e) {
412  logg[LogArea::Main::id].fatal()
413  << "Error in opening " << filename << std::endl;
414  throw std::runtime_error(
415  "Not possible to write thermodynamic "
416  "lattice output to file.");
417  }
419  } else if (tq == ThermodynamicQuantity::Tmn) {
420  try {
422  filename, std::ios::out | std::ios::binary);
423  } catch (std::ofstream::failure &e) {
424  logg[LogArea::Main::id].fatal()
425  << "Error in opening " << filename << std::endl;
426  throw std::runtime_error(
427  "Not possible to write thermodynamic "
428  "lattice output to file.");
429  }
431  } else if (tq == ThermodynamicQuantity::LandauVelocity) {
432  try {
434  filename, std::ios::out | std::ios::binary);
435  } catch (std::ofstream::failure &e) {
436  logg[LogArea::Main::id].fatal()
437  << "Error in opening " << filename << std::endl;
438  throw std::runtime_error(
439  "Not possible to write thermodynamic "
440  "lattice output to file.");
441  }
443  } else {
444  try {
446  std::ios::out);
447  } catch (std::ofstream::failure &e) {
448  logg[LogArea::Main::id].fatal()
449  << "Error in opening " << filename << std::endl;
450  throw std::runtime_error(
451  "Not possible to write thermodynamic "
452  "lattice output to file.");
453  }
454  }
456  }
457 }
458 
460  if (!enable_output_) {
461  return;
462  }
464  if (enable_ascii_) {
466  }
467  if (enable_binary_) {
469  }
470  return;
471  }
472  if (tq == ThermodynamicQuantity::Tmn) {
473  if (enable_ascii_) {
475  }
476  if (enable_binary_) {
478  }
479  return;
480  }
482  if (enable_ascii_) {
484  }
485  if (enable_binary_) {
487  }
488  return;
489  }
491  if (enable_ascii_) {
493  }
494  if (enable_binary_) {
496  }
497  return;
498  }
499  if (tq == ThermodynamicQuantity::j_QBS) {
500  if (enable_ascii_) {
502  }
503  if (enable_binary_) {
505  }
506  return;
507  }
508 }
509 
512  double result;
513  const auto dim = lattice.n_cells();
514  std::shared_ptr<std::ofstream> fp(nullptr);
515  if (enable_ascii_) {
517  *fp << std::setprecision(14);
518  *fp << std::scientific;
519  *fp << ctime << std::endl;
520  }
521  if (enable_binary_) {
523  assert(sizeof(ctime) == sizeof(double));
524  fp->write(reinterpret_cast<char *>(&ctime), sizeof(ctime));
525  }
526  lattice.iterate_sublattice(
527  {0, 0, 0}, dim, [&](DensityOnLattice &node, int ix, int, int) {
528  if (enable_ascii_) {
529  *fp << node.rho() << " ";
530  if (ix == dim[0] - 1) {
531  *fp << "\n";
532  }
533  }
534  if (enable_binary_) {
535  result = node.rho();
536  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
537  }
538  });
539 }
540 
543  const std::vector<Particles> &ensembles,
544  const DensityParameters &dens_param) {
545  if (!enable_output_) {
546  return;
547  }
548  double result;
549  const auto dim = lattice.n_cells();
550  std::shared_ptr<std::ofstream> fp(nullptr);
551  FourVector jQ = FourVector(), jB = FourVector(), jS = FourVector();
552  constexpr bool compute_gradient = false;
553  if (enable_ascii_) {
555  *fp << std::setprecision(14);
556  *fp << std::scientific;
557  *fp << ctime << std::endl;
558  }
559  if (enable_binary_) {
561  assert(sizeof(ctime) == sizeof(double));
562  fp->write(reinterpret_cast<char *>(&ctime), sizeof(ctime));
563  }
564  lattice.iterate_sublattice(
565  {0, 0, 0}, dim, [&](DensityOnLattice &, int ix, int iy, int iz) {
566  const ThreeVector position = lattice.cell_center(ix, iy, iz);
567  jQ.reset();
568  jB.reset();
569  jS.reset();
570  for (const Particles &particles : ensembles) {
571  jQ += std::get<1>(current_eckart(
572  position, particles, dens_param, DensityType::Charge,
573  compute_gradient, out_par_.td_smearing));
574  jB += std::get<1>(current_eckart(
575  position, particles, dens_param, DensityType::Baryon,
576  compute_gradient, out_par_.td_smearing));
577  jS += std::get<1>(current_eckart(
578  position, particles, dens_param, DensityType::Strangeness,
579  compute_gradient, out_par_.td_smearing));
580  }
581  if (enable_ascii_) {
582  *fp << jQ[0];
583  for (int l = 1; l < 4; l++) {
584  *fp << " " << jQ[l];
585  }
586  for (int l = 0; l < 4; l++) {
587  *fp << " " << jB[l];
588  }
589  for (int l = 0; l < 4; l++) {
590  *fp << " " << jS[l];
591  }
592  *fp << "\n";
593  }
594  if (enable_binary_) {
595  for (int l = 0; l < 4; l++) {
596  result = jQ[l];
597  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
598  }
599  for (int l = 0; l < 4; l++) {
600  result = jB[l];
601  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
602  }
603  for (int l = 0; l < 4; l++) {
604  result = jS[l];
605  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
606  }
607  }
608  });
609 }
610 
612  const ThermodynamicQuantity tq,
614  if (!enable_output_) {
615  return;
616  }
617  double result;
618  const auto dim = lattice.n_cells();
619  std::shared_ptr<std::ofstream> fp(nullptr);
620  if (enable_ascii_) {
621  switch (tq) {
624  break;
627  break;
630  break;
631  default:
632  return;
633  }
634  *fp << std::setprecision(14);
635  *fp << std::scientific;
636  *fp << ctime << std::endl;
637  }
638  if (enable_binary_) {
639  switch (tq) {
642  break;
645  break;
648  break;
649  default:
650  return;
651  }
652  assert(sizeof(ctime) == sizeof(double));
653  fp->write(reinterpret_cast<char *>(&ctime), sizeof(double));
654  }
655  switch (tq) {
657  for (int i = 0; i < 4; i++) {
658  for (int j = i; j < 4; j++) {
659  lattice.iterate_sublattice(
660  {0, 0, 0}, dim,
661  [&](EnergyMomentumTensor &node, int ix, int, int) {
662  if (enable_ascii_) {
663  *fp << node[EnergyMomentumTensor::tmn_index(i, j)] << " ";
664  if (ix == dim[0] - 1) {
665  *fp << "\n";
666  }
667  }
668  if (enable_binary_) {
669  result = node[EnergyMomentumTensor::tmn_index(i, j)];
670  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
671  }
672  });
673  }
674  }
675  break;
677  for (int i = 0; i < 4; i++) {
678  for (int j = i; j < 4; j++) {
679  lattice.iterate_sublattice(
680  {0, 0, 0}, dim,
681  [&](EnergyMomentumTensor &node, int ix, int, int) {
682  if (enable_ascii_) {
683  const FourVector u = node.landau_frame_4velocity();
684  const EnergyMomentumTensor Tmn_L = node.boosted(u);
685  *fp << Tmn_L[EnergyMomentumTensor::tmn_index(i, j)] << " ";
686  if (ix == dim[0] - 1) {
687  *fp << "\n";
688  }
689  }
690  if (enable_binary_) {
691  const FourVector u = node.landau_frame_4velocity();
692  const EnergyMomentumTensor Tmn_L = node.boosted(u);
693  result = Tmn_L[EnergyMomentumTensor::tmn_index(i, j)];
694  fp->write(reinterpret_cast<char *>(&result), sizeof(double));
695  }
696  });
697  }
698  }
699  break;
701  lattice.iterate_sublattice(
702  {0, 0, 0}, dim, [&](EnergyMomentumTensor &node, int, int, int) {
703  if (enable_ascii_) {
704  const FourVector u = node.landau_frame_4velocity();
705  const ThreeVector v = -u.velocity();
706  *fp << v.x1() << " " << v.x2() << " " << v.x3() << "\n";
707  }
708  if (enable_binary_) {
709  const FourVector u = node.landau_frame_4velocity();
710  ThreeVector v = -u.velocity();
711  fp->write(reinterpret_cast<char *>(&v), 3 * sizeof(double));
712  }
713  });
714  break;
715  default:
716  return;
717  }
718 }
719 
721  switch (tq) {
723  return 0;
725  return 1;
727  return 2;
729  return 3;
731  return 4;
732  default:
733  throw std::runtime_error(
734  "Error when converting a thermodynamic quantity "
735  "to an int, unknown quantity.");
736  }
737 }
738 
739 std::string ThermodynamicLatticeOutput::make_filename(const std::string &descr,
740  const int event_number,
741  const char type) {
742  char suffix[13];
743  assert((type == 'a') || (type == 'b'));
744  if (type == 'a') {
745  snprintf(suffix, sizeof(suffix), "_%07i.dat", event_number);
746  } else {
747  snprintf(suffix, sizeof(suffix), "_%07i.bin", event_number);
748  }
749  return base_path_.string() + std::string("/") + descr + std::string(suffix);
750 }
751 
753  const ThermodynamicQuantity tq, const DensityType dens_type) {
754  return std::string(to_string(dens_type)) + std::string("_") +
755  std::string(to_string(tq));
756 }
757 
759  std::shared_ptr<std::ofstream> fp, const ThermodynamicQuantity &tq) {
760  *fp << std::setprecision(2);
761  *fp << std::fixed;
762  *fp << "#Thermodynamic Lattice Output version: "
763  << ThermodynamicLatticeOutput::version << std::endl;
764  *fp << std::setprecision(6);
765  *fp << "#Quantity:"
766  << " " << std::string(to_string(tq)) << std::endl;
767  *fp << "#Grid dimensions: " << nodes_[0] << " " << nodes_[1] << " "
768  << nodes_[2] << std::endl;
769  *fp << "#Grid spacing: " << sizes_[0] << " " << sizes_[1] << " " << sizes_[2]
770  << std::endl;
771  *fp << "#Grid origin: " << origin_[0] << " " << origin_[1] << " "
772  << origin_[2] << std::endl;
773 }
774 
776  std::shared_ptr<std::ofstream> fp, const ThermodynamicQuantity &tq) {
777  auto variable_id = to_int(tq);
778  fp->write(
779  reinterpret_cast<const char *>(&ThermodynamicLatticeOutput::version),
780  sizeof(double));
781  fp->write(reinterpret_cast<char *>(&variable_id), sizeof(int));
782  fp->write(reinterpret_cast<char *>(&nodes_), sizeof(nodes_));
783  fp->write(reinterpret_cast<char *>(&sizes_), sizeof(sizes_));
784  fp->write(reinterpret_cast<char *>(&origin_), sizeof(origin_));
785 }
786 } // namespace smash
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
Definition: density.h:304
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:92
The EnergyMomentumTensor class represents a symmetric positive semi-definite energy-momentum tensor .
EnergyMomentumTensor boosted(const FourVector &u) const
Boost to a given 4-velocity.
static std::int8_t tmn_index(std::int8_t mu, std::int8_t nu)
Access the index of component .
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
void reset()
Set all the 4-vector components to 0.
Definition: fourvector.h:486
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
Definition: fourvector.h:333
Abstraction of generic output.
const char * to_string(const ThermodynamicQuantity tq)
Convert thermodynamic quantities to strings.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
A container class to hold all the arrays on the lattice and access them.
Definition: lattice.h:49
std::array< int, 3 > nodes_
number of nodes in the lattice along the three axes
std::map< ThermodynamicQuantity, std::shared_ptr< std::ofstream > > output_ascii_files_
map of output file handlers for ASCII format
bool enable_binary_
enable output type Binary
void at_eventstart(const int event_number, const ThermodynamicQuantity tq, const DensityType dens_type, const RectangularLattice< DensityOnLattice > lattice) override
Output launched at event start after initialization, when particles are generated but not yet propaga...
std::string make_filename(const std::string &description, const int event_number, const char type)
Makes a file name given a description and a counter.
static const double_t version
Version of the thermodynamic lattice output.
std::map< ThermodynamicQuantity, std::shared_ptr< std::ofstream > > output_binary_files_
map of output file handlers for binary format
int to_int(const ThermodynamicQuantity &tq)
Convert a ThermodynamicQuantity into an int.
void write_therm_lattice_binary_header(std::shared_ptr< std::ofstream > file, const ThermodynamicQuantity &tq)
Writes the header for the binary output files.
void write_therm_lattice_ascii_header(std::shared_ptr< std::ofstream > file, const ThermodynamicQuantity &tq)
Writes the header for the ASCII output files.
const std::filesystem::path base_path_
filesystem path for output
void thermodynamics_lattice_output(RectangularLattice< DensityOnLattice > &lattice, double current_time) override
Prints the density lattice on a grid.
void at_eventend(const ThermodynamicQuantity tq) override
Final actions at the end of each event (it closes the output files).
const OutputParameters out_par_
Structure that holds all the information about what to printout.
bool enable_output_
enable output, of any kind (if False, the object does nothing)
std::string make_varname(const ThermodynamicQuantity tq, const DensityType dens_type)
Makes a variable name given quantity and density type.
bool enable_ascii_
enable output type ASCII
std::array< double, 3 > sizes_
lattice resolution along the three axes
ThermodynamicLatticeOutput(const std::filesystem::path &path, const std::string &name, const OutputParameters &out_par, const bool enable_ascii, const bool enable_binary)
Construct Output.
std::array< double, 3 > origin_
lattice origin orientation: if 0,0,0 is the origin of a cube with face widths 10, the center is at 5,...
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
double x3() const
Definition: threevector.h:194
double x2() const
Definition: threevector.h:190
double x1() const
Definition: threevector.h:186
ThermodynamicQuantity
Represents thermodynamic quantities that can be printed out See user guide description for more infor...
@ EckartDensity
Density in the Eckart frame.
@ Tmn
Energy-momentum tensor in lab frame.
@ LandauVelocity
Velocity of the Landau rest frame.
@ j_QBS
Electric (Q), baryonic (B) and strange (S) currents.
@ TmnLandau
Energy-momentum tensor in Landau rest frame.
DensityType
Allows to choose which kind of density to calculate.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > & logg
An array that stores all pre-configured Logger objects.
Definition: logging.h:245
constexpr Section lattice
Section for the lattice.
Definition: input_keys.h:149
Definition: action.h:24
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:176
Helper structure for Experiment to hold output options and parameters.
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?