17 #include "smash/config.h"
186 const std::filesystem::path &path,
const std::string &name,
188 const bool enable_binary)
191 base_path_(std::move(path)),
192 enable_ascii_(enable_ascii),
193 enable_binary_(enable_binary) {
202 std::make_shared<std::ofstream>(
nullptr);
206 std::make_shared<std::ofstream>(
nullptr);
210 std::make_shared<std::ofstream>(
nullptr);
214 std::make_shared<std::ofstream>(
nullptr);
218 std::make_shared<std::ofstream>(
nullptr);
224 std::make_shared<std::ofstream>(
nullptr);
228 std::make_shared<std::ofstream>(
nullptr);
232 std::make_shared<std::ofstream>(
nullptr);
236 std::make_shared<std::ofstream>(
nullptr);
240 std::make_shared<std::ofstream>(
nullptr);
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++) {
265 std::shared_ptr<std::ofstream> fp(
nullptr);
267 std::string filename;
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.");
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.");
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.");
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.");
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++) {
349 std::shared_ptr<std::ofstream> fp(
nullptr);
351 std::string filename;
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.");
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.");
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.");
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.");
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.");
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.");
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.");
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.");
513 const auto dim =
lattice.n_cells();
514 std::shared_ptr<std::ofstream> fp(
nullptr);
517 *fp << std::setprecision(14);
518 *fp << std::scientific;
519 *fp << ctime << std::endl;
523 assert(
sizeof(ctime) ==
sizeof(
double));
524 fp->write(
reinterpret_cast<char *
>(&ctime),
sizeof(ctime));
529 *fp << node.rho() <<
" ";
530 if (ix == dim[0] - 1) {
536 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
543 const std::vector<Particles> &ensembles,
549 const auto dim =
lattice.n_cells();
550 std::shared_ptr<std::ofstream> fp(
nullptr);
552 constexpr
bool compute_gradient =
false;
555 *fp << std::setprecision(14);
556 *fp << std::scientific;
557 *fp << ctime << std::endl;
561 assert(
sizeof(ctime) ==
sizeof(
double));
562 fp->write(
reinterpret_cast<char *
>(&ctime),
sizeof(ctime));
570 for (
const Particles &particles : ensembles) {
583 for (
int l = 1; l < 4; l++) {
586 for (
int l = 0; l < 4; l++) {
589 for (
int l = 0; l < 4; l++) {
595 for (
int l = 0; l < 4; l++) {
597 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
599 for (
int l = 0; l < 4; l++) {
601 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
603 for (
int l = 0; l < 4; l++) {
605 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
618 const auto dim =
lattice.n_cells();
619 std::shared_ptr<std::ofstream> fp(
nullptr);
634 *fp << std::setprecision(14);
635 *fp << std::scientific;
636 *fp << ctime << std::endl;
652 assert(
sizeof(ctime) ==
sizeof(
double));
653 fp->write(
reinterpret_cast<char *
>(&ctime),
sizeof(
double));
657 for (
int i = 0; i < 4; i++) {
658 for (
int j = i; j < 4; j++) {
664 if (ix == dim[0] - 1) {
670 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
677 for (
int i = 0; i < 4; i++) {
678 for (
int j = i; j < 4; j++) {
683 const FourVector u = node.landau_frame_4velocity();
686 if (ix == dim[0] - 1) {
691 const FourVector u = node.landau_frame_4velocity();
694 fp->write(
reinterpret_cast<char *
>(&result),
sizeof(
double));
704 const FourVector u = node.landau_frame_4velocity();
706 *fp << v.
x1() <<
" " << v.
x2() <<
" " << v.
x3() <<
"\n";
709 const FourVector u = node.landau_frame_4velocity();
711 fp->write(
reinterpret_cast<char *
>(&v), 3 *
sizeof(double));
733 throw std::runtime_error(
734 "Error when converting a thermodynamic quantity "
735 "to an int, unknown quantity.");
740 const int event_number,
743 assert((type ==
'a') || (type ==
'b'));
745 snprintf(suffix,
sizeof(suffix),
"_%07i.dat", event_number);
747 snprintf(suffix,
sizeof(suffix),
"_%07i.bin", event_number);
749 return base_path_.string() + std::string(
"/") + descr + std::string(suffix);
754 return std::string(
to_string(dens_type)) + std::string(
"_") +
760 *fp << std::setprecision(2);
762 *fp <<
"#Thermodynamic Lattice Output version: "
764 *fp << std::setprecision(6);
766 <<
" " << std::string(
to_string(tq)) << std::endl;
767 *fp <<
"#Grid dimensions: " <<
nodes_[0] <<
" " <<
nodes_[1] <<
" "
768 <<
nodes_[2] << std::endl;
777 auto variable_id =
to_int(tq);
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_));
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
A class to pre-calculate and store parameters relevant for density calculation.
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.
void reset()
Set all the 4-vector components to 0.
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
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.
A container class to hold all the arrays on the lattice and access them.
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.
~ThermodynamicLatticeOutput()
Default destructor.
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 .
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.
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...
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?