Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:03

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 
0016 #ifndef MUSICWRAPPER_H
0017 #define MUSICWRAPPER_H
0018 
0019 #include <memory>
0020 
0021 #include "FluidDynamics.h"
0022 #include "music.h"
0023 #include "hydro_source_base.h"
0024 #include "LiquefierBase.h"
0025 #include "data_struct.h"
0026 #include "JetScapeConstants.h"
0027 #include "MakeUniqueHelper.h"
0028 
0029 using namespace Jetscape;
0030 
0031 class HydroSourceJETSCAPE : public HydroSourceBase {
0032 private:
0033   std::weak_ptr<LiquefierBase> liquefier_ptr;
0034 
0035 public:
0036   HydroSourceJETSCAPE() = default;
0037   ~HydroSourceJETSCAPE() {}
0038 
0039   void add_a_liquefier(std::shared_ptr<LiquefierBase> new_liqueifier) {
0040     liquefier_ptr = new_liqueifier;
0041   }
0042 
0043   int get_number_of_sources() const {
0044     if (weak_ptr_is_uninitialized(liquefier_ptr)) {
0045       return (0);
0046     } else {
0047       return (liquefier_ptr.lock()->get_dropletlist_size());
0048     }
0049   }
0050 
0051   double get_total_E_of_sources() const {
0052     if (weak_ptr_is_uninitialized(liquefier_ptr)) {
0053       return (0.0);
0054     } else {
0055       return (liquefier_ptr.lock()->get_dropletlist_total_energy());
0056     }
0057   }
0058 
0059   //! this function returns the energy source term J^\mu at a given point
0060   //! (tau, x, y, eta_s)
0061   void get_hydro_energy_source(const double tau, const double x, const double y,
0062                                const double eta_s, const FlowVec &u_mu,
0063                                EnergyFlowVec &j_mu) const {
0064     j_mu = {0.0};
0065     if (weak_ptr_is_uninitialized(liquefier_ptr))
0066       return;
0067 
0068     std::array<Jetscape::real, 4> jmu_tmp = {0.0};
0069     liquefier_ptr.lock()->get_source(tau, x, y, eta_s, jmu_tmp);
0070     for (int i = 0; i < 4; i++) {
0071       j_mu[i] = jmu_tmp[i]/hbarC;  // convert the unit from GeV/fm^4 to 1/fm^5
0072     }
0073   }
0074 };
0075 
0076 //! this is wrapper class for MUSIC so that it can be used as a external
0077 //! library for the JETSCAPE integrated framework
0078 class MpiMusic : public FluidDynamics {
0079 private:
0080   // int mode;            //!< records running mode
0081   std::unique_ptr<MUSIC> music_hydro_ptr;
0082 
0083   Jetscape::real freezeout_temperature; //!< [GeV]
0084   int doCooperFrye;                     //!< flag to run Cooper-Frye freeze-out
0085                                         //!< for soft particles
0086   int flag_output_evo_to_file;
0087   bool has_source_terms;
0088   std::shared_ptr<HydroSourceJETSCAPE> hydro_source_terms_ptr;
0089 
0090   // Allows the registration of the module so that it is available to be
0091   // used by the Jetscape framework.
0092   static RegisterJetScapeModule<MpiMusic> reg;
0093 
0094 public:
0095   MpiMusic();
0096   ~MpiMusic();
0097 
0098   void InitializeHydro(Parameter parameter_list);
0099 
0100   void EvolveHydro();
0101   void GetHydroInfo(Jetscape::real t, Jetscape::real x, Jetscape::real y,
0102                     Jetscape::real z,
0103                     std::unique_ptr<FluidCellInfo> &fluid_cell_info_ptr);
0104 
0105   void
0106   GetHydroInfo_JETSCAPE(Jetscape::real t, Jetscape::real x, Jetscape::real y,
0107                         Jetscape::real z,
0108                         std::unique_ptr<FluidCellInfo> &fluid_cell_info_ptr);
0109   void GetHydroInfo_MUSIC(Jetscape::real t, Jetscape::real x, Jetscape::real y,
0110                           Jetscape::real z,
0111                           std::unique_ptr<FluidCellInfo> &fluid_cell_info_ptr);
0112 
0113   void SetHydroGridInfo();
0114   void PassHydroEvolutionHistoryToFramework();
0115 
0116   void add_a_liquefier(std::shared_ptr<LiquefierBase> new_liqueifier) {
0117     liquefier_ptr = new_liqueifier;
0118     hydro_source_terms_ptr->add_a_liquefier(liquefier_ptr.lock());
0119   }
0120 
0121   void GetHyperSurface(Jetscape::real T_cut,
0122                        SurfaceCellInfo *surface_list_ptr){};
0123   void collect_freeze_out_surface();
0124 };
0125 
0126 #endif // MUSICWRAPPER_H