Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:31

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 #include "FluidDynamics.h"
0017 #include "FluidEvolutionHistory.h"
0018 #include "gtest/gtest.h"
0019 
0020 using namespace Jetscape;
0021 
0022 void test_not_in_range(EvolutionHistory hist, real tau, real x, real y, real eta) {
0023     try {
0024         hist.CheckInRange(tau, x, y, eta);
0025     } catch (InvalidSpaceTimeRange & e) {
0026         auto estr = std::string(e.what());
0027         ASSERT_TRUE(estr.find("not in range") != estr.npos);
0028     }
0029 }
0030 
0031 // test EvolutionHistory Class
0032 TEST(EvolutionHistoryTest, TEST_WRITE){
0033     auto hist = EvolutionHistory();
0034     hist.tau_min = 0.6;
0035     hist.dtau = 0.1;
0036     hist.x_min = -10;
0037     hist.y_min = -10;
0038     hist.eta_min = -10;
0039     hist.dx = 0.5;
0040     hist.dy = 0.5;
0041     hist.deta = 0.5;
0042     hist.ntau = 11;
0043     hist.nx = 41;
0044     hist.ny = 41;
0045     hist.neta = 41;
0046     hist.tau_eta_is_tz = false;
0047 
0048     EXPECT_EQ(hist.TauMax(), static_cast<real>(1.6));
0049     EXPECT_EQ(hist.XMax(), static_cast<real>(10.0));
0050     EXPECT_EQ(hist.YMax(), static_cast<real>(10.0));
0051     EXPECT_EQ(hist.EtaMax(), static_cast<real>(10.0));
0052 
0053     // check range test
0054     test_not_in_range(hist, 0.5, 0.3, 0.3, 0.3);
0055     test_not_in_range(hist, 20.5, 0.3, 0.3, 0.3);
0056     test_not_in_range(hist, 10.5, 10.3, 0.3, 0.3);
0057     test_not_in_range(hist, 10.5, 10., 10.3, 0.3);
0058     test_not_in_range(hist, 10.5, 10., 10., 10.3);
0059 
0060     real const_ed = 0.8;
0061     for (int n=0; n != hist.ntau; n++)
0062         for (int i=0; i != hist.nx; i++)
0063             for (int j=0; j != hist.ny; j++)
0064                 for (int k=0; k != hist.neta; k++) {
0065                     auto cell = FluidCellInfo();
0066                     cell.energy_density = const_ed;
0067                     hist.data.emplace_back(std::move(cell));
0068                 }
0069     // check almost equal for two float numbers
0070     ASSERT_NEAR(hist.get(0.8, 0.0, 0.0, 0.0).energy_density, static_cast<real>(const_ed), 1.0E-6);
0071 }