Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:17

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  *
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 // This is a general basic class for hydrodynamics
0016 
0017 #ifndef EVOLUTIONHISTORY_H
0018 #define EVOLUTIONHISTORY_H
0019 
0020 #include <vector>
0021 #include <stdexcept>
0022 #include "FluidCellInfo.h"
0023 #include "RealType.h"
0024 
0025 namespace Jetscape {
0026 
0027 // The simplest way for 3rd party hydro to provide evolution history is to
0028 // send 2 vectors to the framework. One is a 1D float vector stores all
0029 // the evolution history to data_vector.
0030 // The other is the description of the content of the data to data_info.
0031 // E.g., data_info should store a vector of 3 strings ['energy_density', 'vx, 'vy']
0032 // if data_vector = [ed0, vx0, vy0, ed1, vx1, vy1, ..., edN, vxN, vyN, vzN],
0033 // where N = ntau * nx * ny * netas is the number of total cells.
0034 // One can pass these 3 data or more data to the framework, by storing them in any order,
0035 // as long as the description matches the data content.
0036 // The following is a list possible valid data names.
0037 // ValidNames = [ "energy_density", "entropy_density", "temperature",
0038 //                "pressure", "qgp_fraction", "mu_b", "mu_c", "mu_s",
0039 //                "vx", "vy", "vz", "pi00", "pi01", "pi02", "pi03",
0040 //                "pi11", "pi12", "pi13", "pi22", "pi23", "pi33", "bulk_pi"];
0041 //
0042 
0043 enum EntryName {
0044   ENTRY_ENERGY_DENSITY,
0045   ENTRY_ENTROPY_DENSITY,
0046   ENTRY_TEMPERATURE,
0047   ENTRY_PRESSURE,
0048   ENTRY_QGP_FRACTION,
0049   ENTRY_MU_B,
0050   ENTRY_MU_C,
0051   ENTRY_MU_S,
0052   ENTRY_VX,
0053   ENTRY_VY,
0054   ENTRY_VZ,
0055   ENTRY_PI00,
0056   ENTRY_PI01,
0057   ENTRY_PI02,
0058   ENTRY_PI03,
0059   ENTRY_PI11,
0060   ENTRY_PI12,
0061   ENTRY_PI13,
0062   ENTRY_PI22,
0063   ENTRY_PI23,
0064   ENTRY_PI33,
0065   ENTRY_BULK_PI,
0066   ENTRY_INVALID
0067 };
0068 
0069 EntryName ResolveEntryName(std::string input);
0070 
0071 class InvalidSpaceTimeRange : public std::invalid_argument {
0072   using std::invalid_argument::invalid_argument;
0073 };
0074 
0075 class EvolutionHistory {
0076 public:
0077   /** @param tau_min Minimum value of tau.*/
0078   Jetscape::real tau_min, dtau; //!< @param dtau Step-size for tau.
0079   /** @param x_min Minimum value of x. */
0080   Jetscape::real x_min, dx; //!< @param dx Step-size for x.
0081   /** @param y_min Minimum value of y. */
0082   Jetscape::real y_min, dy; //!< @param dy Step-size for y.
0083   /** @param eta_min Minimum value of eta. */
0084   Jetscape::real eta_min, deta; //!< @param deta Step-size for eta.
0085   int ntau; //!< @param ntau Number of grid points in tau-axis.
0086   int nx;   //!< @param nx Number of grid points in x-axis.
0087   int ny;   //!< @param ny Number of grid points in y-axis.
0088   int neta; //!< @param neta Number of grid points in eta-axis.
0089 
0090   /** Default is set to false. Set flag tau_eta_is_tz to true if hydro dynamics is setup in (t,x,y,z) coordinate. */
0091   bool tau_eta_is_tz;
0092 
0093   bool boost_invariant;
0094 
0095   /** The bulk information of hydro dynamics, in the form of
0096      * vector of FluidCellInfo objects. */
0097   std::vector<FluidCellInfo> data;
0098 
0099   /** The bulk information of hydro dynamics, in the form of 1D float vector.
0100      * It is easy to pass vector of float from 3rd party hydro module
0101      * to Jetscape Fluid Evolution History, where bulk info should be stored
0102      * in orders of ed0, sd0, temp0, ..., ed1, sd1, temp1, ..., edn, sdn, tempn.
0103      * The content and order of data entres are given by data_info */
0104   std::vector<float> data_vector;
0105 
0106   /** Store the entry names of one record in the data array*/
0107   std::vector<std::string> data_info;
0108 
0109   /** Default constructor. */
0110   EvolutionHistory() = default;
0111 
0112   /** Auxiliary function that helps to read hydro evolution history from external fluid dynamic module.
0113      * The history from 3rd party hydro should be stored in a std::vector<float> container.
0114      * The size of the vector should equal ntau * nx * ny * neta * data_info_.size();
0115      * For each piece with length data_info_.size(), the vector should store the corresponding float number
0116      * whose name is written in std::vector<string> data_info_.
0117      * E.g., data_info_ can be a vector of ['
0118      * */
0119   void FromVector(const std::vector<float> &data_,
0120                   const std::vector<std::string> &data_info_, float tau_min,
0121                   float dtau, float x_min, float dx, int nx, float y_min,
0122                   float dy, int ny, float eta_min, float deta, int neta,
0123                   bool tau_eta_is_tz);
0124 
0125   /** Default destructor. */
0126   ~EvolutionHistory() {
0127     data.clear();
0128     data_vector.clear();
0129     data_info.clear();
0130   }
0131 
0132   void clear_up_evolution_data() { data.clear(); }
0133 
0134   int get_data_size() const { return (data.size()); }
0135   bool is_boost_invariant() const { return (boost_invariant); }
0136   bool is_Cartesian() const { return (tau_eta_is_tz); }
0137 
0138   Jetscape::real Tau0() const { return (tau_min); }
0139   Jetscape::real XMin() const { return (x_min); }
0140   Jetscape::real YMin() const { return (y_min); }
0141   Jetscape::real EtaMin() const { return (eta_min); }
0142 
0143   /** Maximum value of tau. */
0144   inline Jetscape::real TauMax() const { return (tau_min + (ntau - 1) * dtau); }
0145 
0146   /** Maximum value of x. */
0147   inline Jetscape::real XMax() const { return (x_min + (nx - 1) * dx); }
0148 
0149   /** Maximum value of y. */
0150   inline Jetscape::real YMax() const { return (y_min + (ny - 1) * dy); }
0151 
0152   /** Maximum value of eta. */
0153   inline Jetscape::real EtaMax() const { return (eta_min + (neta - 1) * deta); }
0154 
0155   /** It checks whether a space-time point (tau, x, y, eta) is inside evolution history or outside.
0156     @param tau Light-cone coordinate.
0157     @param x  Space coordinate.
0158     @param y  Space coordinate.
0159     @param eta Light-cone coordinate.
0160     */
0161   int CheckInRange(Jetscape::real tau, Jetscape::real x, Jetscape::real y,
0162                    Jetscape::real eta) const;
0163 
0164   // get the lower bound of the fluid cell along tau
0165   /** @return Fluid cell number along the tau-grid.
0166     @param tau Light-cone coordinate.
0167     */
0168   inline int GetIdTau(Jetscape::real tau) const {
0169     return (static_cast<int>((tau - tau_min) / dtau));
0170   }
0171 
0172   // get the lower bound of the fluid cell along x
0173   /** @return Fluid cell number along the x-grid.
0174         @param x Space coordinate.
0175     */
0176   inline int GetIdX(Jetscape::real x) const {
0177     return (static_cast<int>((x - x_min) / dx));
0178   }
0179 
0180   // get the lower bound of the fluid cell along y
0181   /** @return Fluid cell number along the y-grid.
0182         @param y Space coordinate.
0183     */
0184   inline int GetIdY(Jetscape::real y) const {
0185     return (static_cast<int>((y - y_min) / dy));
0186   }
0187 
0188   // get the lower bound of the fluid cell along eta
0189   /** @return Fluid cell number along the eta-grid.
0190         @param eta Light-cone coordinate.
0191     */
0192   inline int GetIdEta(Jetscape::real eta) const {
0193     return (static_cast<int>((eta - eta_min) / deta));
0194   }
0195 
0196   // get the coordinate of tau, x, y, eta on grid
0197   /** @param id_tau Fluid cell number along tau-grid.
0198     @return The tau coordinate for fluid cell number.
0199     */
0200   inline Jetscape::real TauCoord(int id_tau) const {
0201     return (tau_min + id_tau * dtau);
0202   }
0203 
0204   /** @param id_x Fluid cell number along x-grid.
0205         @return The x coordinate for fluid cell number.
0206     */
0207   inline Jetscape::real XCoord(int id_x) const { return (x_min + id_x * dx); }
0208 
0209   /** @param id_y Fluid cell number along y-grid.
0210         @return The y coordinate for fluid cell number.
0211     */
0212   inline Jetscape::real YCoord(int id_y) const { return (y_min + id_y * dy); }
0213 
0214   /** @param id_eta Fluid cell number along eta-grid.
0215         @return The eta coordinate for fluid cell number.
0216     */
0217   inline Jetscape::real EtaCoord(int id_eta) const {
0218     return (eta_min + id_eta * deta);
0219   }
0220 
0221   // get the FluidCellInfo index in data
0222   /** @return FluidCellInfo index in the data.
0223     @param id_tau Fluid cell number along tau-grid.
0224     @param id_x Fluid cell number along x-grid.
0225     @param id_y Fluid cell number along y-grid.
0226     @param id_eta Fluid cell number along eta-grid.
0227     */
0228   inline int CellIndex(int id_tau, int id_x, int id_y, int id_eta) const {
0229     id_tau = std::min(ntau - 1, std::max(0, id_tau));
0230     id_x = std::min(nx - 1, std::max(0, id_x));
0231     id_y = std::min(ny - 1, std::max(0, id_y));
0232     id_eta = std::min(neta - 1, std::max(0, id_eta));
0233     return (id_tau * nx * ny * neta + id_x * ny * neta + id_y * neta + id_eta);
0234   }
0235 
0236   /* Read fluid cell info for a given lattice cell*/
0237   FluidCellInfo GetFluidCell(int id_tau, int id_x, int id_y, int id_eta) const;
0238 
0239   // get the FluidCellInfo at space point given time step
0240   /** @return FluidCellInfo at a point (x,y,eta) and time-step id_tau.
0241     @param id_tau tau-step number.
0242     @param x Space coordinate.
0243     @param y Space coordinate.
0244     @param eta Light-cone coordinate.
0245     */
0246   FluidCellInfo GetAtTimeStep(int id_tau, Jetscape::real x, Jetscape::real y,
0247                               Jetscape::real etas) const;
0248 
0249   // get the FluidCellInfo at given space time point
0250   /** @return FluidCellInfo at a point (tau, x, y, eta).
0251         @param tau Light-cone coordinate.
0252         @param x Space coordinate.
0253         @param y Space coordinate.
0254         @param eta Light-cone coordinate.
0255     */
0256   FluidCellInfo get(Jetscape::real tau, Jetscape::real x, Jetscape::real y,
0257                     Jetscape::real etas) const;
0258   FluidCellInfo get_tz(Jetscape::real t, Jetscape::real x, Jetscape::real y,
0259                        Jetscape::real z) const;
0260 };
0261 
0262 } // namespace Jetscape
0263 
0264 #endif // EVOLUTIONHISTORY_H