Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:54

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 FLUIDDYNAMICS_H
0018 #define FLUIDDYNAMICS_H
0019 
0020 #include <memory>
0021 #include <vector>
0022 #include <array>
0023 #include <cstring>
0024 #include <stdexcept>
0025 #include <cmath>
0026 #include <iostream>
0027 #include <map>
0028 
0029 #include "InitialState.h"
0030 #include "JetScapeModuleBase.h"
0031 #include "PreequilibriumDynamics.h"
0032 #include "RealType.h"
0033 #include "FluidCellInfo.h"
0034 #include "FluidEvolutionHistory.h"
0035 #include "LiquefierBase.h"
0036 #include "SurfaceCellInfo.h"
0037 
0038 namespace Jetscape {
0039 
0040 /// Flags for hydrodynamics status.
0041 enum HydroStatus { NOT_START, INITIALIZED, EVOLVING, FINISHED, ERROR };
0042 
0043 /** A helper class for hydro parameters file name.*/
0044 class Parameter {
0045 public:
0046   char *hydro_input_filename;
0047 };
0048 
0049 class FluidDynamics : public JetScapeModuleBase {
0050 protected:
0051   // record hydro start and end proper time [fm/c]
0052   Jetscape::real hydro_tau_0, hydro_tau_max;
0053   // record hydro freeze out temperature [GeV]
0054   Jetscape::real hydro_freeze_out_temperature;
0055   // record hydro running status
0056   HydroStatus hydro_status;
0057 
0058   // add initial state shared pointer
0059   /** A pointer of type InitialState class.
0060      */
0061   std::shared_ptr<InitialState> ini;
0062   std::shared_ptr<PreequilibriumDynamics> pre_eq_ptr;
0063 
0064   double eta;
0065   bool boost_invariant_;
0066   Parameter parameter_list;
0067 
0068   // How to store this data? In memory or hard disk?
0069   // 3D hydro may eat out the memory,
0070   // for large dataset, std::deque is better than std::vector.
0071   /** Stores the evolution history. */
0072   EvolutionHistory bulk_info;
0073 
0074   std::weak_ptr<LiquefierBase> liquefier_ptr;
0075 
0076 public:
0077   /** Default constructor. task ID as "FluidDynamics",
0078         eta is initialized to -99.99.
0079     */
0080   FluidDynamics();
0081 
0082   /** Default destructor. */
0083   virtual ~FluidDynamics();
0084 
0085   /** Reads the input parameters from the XML file under the tag <Hydro>. Uses JetScapeSingnalManager Instance to retrive the Initial State Physics information. Calls InitializeHydro(parameter_list) and InitTask(); This explicit call can be used for actual initialization of modules such as @a Brick, @a MpiMusic, or @a OSU-HYDRO if attached as a @a polymorphic class. It also initializes the tasks within the current module.
0086     @sa Read about @a polymorphism in C++.
0087     */
0088   virtual void Init();
0089 
0090   /** Calls EvolveHydro(); This explicit call can be used for actual execution of hydrodynamic evolution defined in the modules such as @a Brick, @a MpiMusic, or @a OSU-HYDRO if attached as a @a polymorphic class. It also execute the tasks within the current module.
0091     @sa Read about @a polymorphism in C++.
0092     */
0093   virtual void Exec();
0094 
0095   virtual void Clear();
0096 
0097   /** @return parameter_list A pointer to the class Parameter which contains a file name for the fluid dynamics task.
0098     @sa Implementation of the class Parameter.
0099     */
0100   Parameter &GetParameterList() { return (parameter_list); }
0101 
0102   /** Collect header information for writer modules
0103     @param w is a pointer of type JetScapeWrite class.
0104     */
0105   virtual void CollectHeader(weak_ptr<JetScapeWriter> w);
0106 
0107   /** Generated event plane angle
0108     To be overwritten by implementations that have such information.
0109     */
0110   virtual double GetEventPlaneAngle() { return (-999); }
0111 
0112   /** It stores the temperature of the fluid cell at location (t or tau,x,y,z or eta) into an input variable "mT". It can be overridden by modules attached to the FluidDynamics class.
0113     @param t  tau or t coordinate.
0114     @param x  space x coordinate.
0115     @param y  space y coordinate.
0116     @param z  rapidity eta or space z coordinate.
0117     @param mT temperature.
0118     */
0119   virtual void GetTemperature(double t, double x, double y, double z,
0120                               double &mT) {
0121     mT = GetTemperature(t, x, y, z);
0122   }
0123 
0124   /** It calls GetHydroInfo(t,x,y,z,fCell) to retrieve the properties of the fluid cell at location (t or tau,x,y,z or eta). It can be overridden by modules attached to the FluidDynamics class.
0125     @param t  tau or t coordinate.
0126     @param x  space x coordinate.
0127     @param y  space y coordinate.
0128     @param z  rapidity eta or space z coordinate.
0129     @param fCell A pointer of type FluidCellInfo class.
0130     */
0131   virtual void GetHydroCell(double t, double x, double y, double z,
0132                             std::unique_ptr<FluidCellInfo> &fCell) {
0133     GetHydroInfo(t, x, y, z, fCell);
0134   }
0135 
0136   // currently we have no standard for passing configurations
0137   // pure virtual function; to be implemented by users
0138   // should make it easy to save evolution history to bulk_info
0139   /** Default function to initialize the hydrodynamics. It can be overridden by different modules.
0140     @param parameter_list An object of the class Parameter. */
0141   virtual void InitializeHydro(Parameter parameter_list){};
0142 
0143   /** Default function to evolve the hydrodynamics. It can be overridden by different modules. */
0144   virtual void EvolveHydro(){};
0145 
0146   /** @return Status of the hydrodynamics (NOT_START, INITIALIZED, EVOLVING, FINISHED, ERROR). */
0147   int GetHydroStatus() const { return (hydro_status); }
0148 
0149   void StoreHydroEvolutionHistory(
0150       std::unique_ptr<FluidCellInfo> &fluid_cell_info_ptr) {
0151     bulk_info.data.push_back(*fluid_cell_info_ptr);
0152   }
0153 
0154   void clear_up_evolution_data() { bulk_info.clear_up_evolution_data(); }
0155 
0156   /** @return Start time (or tau) for hydrodynamic evolution.
0157      */
0158   void GetHydroStartTime(double &tau0) { tau0 = hydro_tau_0; }
0159 
0160   /** @return End time (or tau) for hydrodynamic evolution.
0161      */
0162   Jetscape::real GetHydroEndTime() const { return (hydro_tau_max); }
0163   /** @return Freeze-out temperature.
0164      */
0165   Jetscape::real GetHydroFreezeOutTemperature() const {
0166     return (hydro_freeze_out_temperature);
0167   }
0168 
0169   /** Retrieves the hydro information at a given space-time point.
0170      * It throws a InvalidSpaceTimeRange message when
0171      * (t or tau, x, y, z or eta) is out of the evolution history range.
0172      @param time Time or tau coordinate.
0173      @param x Space coordinate.
0174      @param y Space coordinate.
0175      @param z Space or eta coordinate.
0176      @param fluid_cell_info_ptr A pointer to the FluidCellInfo class.
0177     */
0178   virtual void
0179   GetHydroInfo(Jetscape::real t, Jetscape::real x, Jetscape::real y,
0180                Jetscape::real z,
0181                std::unique_ptr<FluidCellInfo> &fluid_cell_info_ptr) {
0182     if (hydro_status != FINISHED || bulk_info.data.size() == 0) {
0183       throw std::runtime_error("Hydro evolution is not finished "
0184                                "or EvolutionHistory is empty");
0185     }
0186     // judge whether to use 2D interpolation or 3D interpolation
0187     if (!bulk_info.tau_eta_is_tz) {
0188       Jetscape::real tau = std::sqrt(t * t - z * z);
0189       Jetscape::real eta = 0.5 * (std::log(t + z) - std::log(t - z));
0190       bulk_info.CheckInRange(tau, x, y, eta);
0191       //return bulk_info.get(tau, x, y, eta);
0192     } else {
0193       bulk_info.CheckInRange(t, x, y, z);
0194       //return bulk_info.get(t, x, y, z);
0195     }
0196   }
0197 
0198   // this function print out the information of the fluid cell to the screen
0199   /** It prints out the information of the fluid cell.
0200     @param fluid_cell_info_ptr A pointer to FluidCellInfor class.
0201     */
0202   void PrintFluidCellInformation(FluidCellInfo *fluid_cell_info_ptr);
0203 
0204   // this function returns hypersurface for Cooper-Frye or recombination
0205   // the detailed implementation is left to the hydro developper
0206   /** @return Default function to get the hypersurface for Cooper-Frye or recombination model. It can overridden by different modules.
0207      */
0208   void FindAConstantTemperatureSurface(
0209           Jetscape::real T_sw, std::vector<SurfaceCellInfo> &surface_cells);
0210 
0211   // all the following functions will call function GetHydroInfo()
0212   // to get thermaldynamic and dynamical information at a space-time point
0213   // (time, x, y, z)
0214 
0215   /** @return Energy density at point (t or tau, x, y, z or eta)
0216         @param time Time or tau coordinate.
0217         @param x Space coordinate.
0218         @param y Space coordinate.
0219         @param z Space or eta coordinate.
0220     */
0221   virtual Jetscape::real GetEnergyDensity(Jetscape::real time, Jetscape::real x,
0222                                           Jetscape::real y, Jetscape::real z);
0223 
0224   /** @return Entropy density at point (t or tau, x, y, z or eta)
0225         @param time Time or tau coordinate.
0226         @param x Space coordinate.
0227         @param y Space coordinate.
0228         @param z Space or eta coordinate.
0229     */
0230   virtual Jetscape::real GetEntropyDensity(Jetscape::real time,
0231                                            Jetscape::real x, Jetscape::real y,
0232                                            Jetscape::real z);
0233 
0234   /** @return Temperature at point (t or tau, x, y, z or eta)
0235     @param time Time or tau coordinate.
0236         @param x Space coordinate.
0237         @param y Space coordinate.
0238         @param z Space or eta coordinate.
0239     */
0240   virtual Jetscape::real GetTemperature(Jetscape::real time, Jetscape::real x,
0241                                         Jetscape::real y, Jetscape::real z);
0242 
0243   /** @return Fraction of quark gluon plasma assuming medium is in QGP+HRG phase at point (t or tau, x, y, z or eta).
0244     @param time Time or tau coordinate.
0245         @param x Space coordinate.
0246         @param y Space coordinate.
0247         @param z Space or eta coordinate.
0248     */
0249   virtual Jetscape::real GetQgpFraction(Jetscape::real time, Jetscape::real x,
0250                                         Jetscape::real y, Jetscape::real z);
0251 
0252   // These have no default implementation
0253   // /** @return 3-component (vx,vy,vz) fluid velocity at point (t or tau, x, y, z or eta).
0254   //     @param time Time or tau coordinate.
0255   //     @param x Space coordinate.
0256   //     @param y Space coordinate.
0257   //     @param z Space or eta coordinate.
0258   // */
0259   // virtual real3 Get3FluidVelocity(Jetscape::real time, Jetscape::real x, Jetscape::real y, Jetscape::real z)=0;
0260 
0261   // /** @return 4-component fluid velocity at point (t or tau, x, y, zor eta).
0262   //     @param time Time or tau coordinate.
0263   //     @param x Space coordinate.
0264   //     @param y Space coordinate.
0265   //     @param z Space or eta coordinate.
0266   // */
0267   // virtual real4 Get4FluidVelocity(Jetscape::real time, Jetscape::real x, Jetscape::real y, Jetscape::real z);
0268 
0269   // /** @return Net baryon density at point (t or tau, x, y, z or eta).
0270   //     @param time Time or tau coordinate.
0271   //     @param x Space coordinate.
0272   //     @param y Space coordinate.
0273   //     @param z Space or eta coordinate.
0274   // */
0275   // virtual Jetscape::real GetNetBaryonDensity(Jetscape::real time, Jetscape::real x, Jetscape::real y, Jetscape::real z);
0276 
0277   // /** @return Net charge density at point (t or tau, x, y, z or eta).
0278   //    @param time Time or tau coordinate.
0279   //    @param x Space coordinate.
0280   //    @param y Space coordinate.
0281   //    @param z Space or eta coordinate.
0282   // */
0283   // virtual Jetscape::real GetNetChargeDensity(Jetscape::real time, Jetscape::real x, Jetscape::real y, Jetscape::real z);
0284 
0285   virtual void add_a_liquefier(std::shared_ptr<LiquefierBase> new_liquefier) {
0286     liquefier_ptr = new_liquefier;
0287   }
0288 
0289   void get_source_term(Jetscape::real tau, Jetscape::real x, Jetscape::real y,
0290                        Jetscape::real eta,
0291                        std::array<Jetscape::real, 4> jmu) const;
0292 
0293   /// slots for "jet" signals (future)
0294   virtual void UpdateEnergyDeposit(int t, double edop);
0295   /// slots for "jet" signals (future)
0296   virtual void GetEnergyDensity(int t, double &edensity) { edensity = 0.0; }
0297 
0298   // get a reference to the bulk_info object
0299   const EvolutionHistory& get_bulk_info() const { return bulk_info; }
0300 
0301 }; // end class FluidDynamics
0302 
0303 } // end namespace Jetscape
0304 
0305 #endif // FLUIDDYNAMICS_H