Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <string> 9 : #include <unordered_map> 10 : #include <vector> 11 : 12 : #include "DataStructures/DataVector.hpp" 13 : 14 : /// \cond 15 : namespace PUP { 16 : class er; 17 : } // namespace PUP 18 : /// \endcond 19 : 20 0 : namespace io { 21 : /*! 22 : * \brief Reader for the CompOSE (https://compose.obspm.fr/home) ASCII tabulated 23 : * equations of state. 24 : * 25 : * The directory from which the data is read must contain the `eos.quantities`, 26 : * `eos.parameters`, and `eos.table`. 27 : */ 28 1 : class ComposeTable { 29 : public: 30 0 : ComposeTable() = default; 31 0 : explicit ComposeTable(std::string directory_to_read_from); 32 : 33 0 : const std::unordered_map<std::string, DataVector>& data() const { 34 : return data_; 35 : } 36 : 37 0 : const DataVector& data(const std::string& quantity_name) const { 38 : return data_.at(quantity_name); 39 : } 40 : 41 0 : const std::vector<std::string>& available_quantities() const { 42 : return available_quantities_; 43 : } 44 : 45 0 : const std::array<double, 2>& number_density_bounds() const { 46 : return number_density_bounds_; 47 : } 48 : 49 0 : const std::array<double, 2>& temperature_bounds() const { 50 : return temperature_bounds_; 51 : } 52 : 53 0 : const std::array<double, 2>& electron_fraction_bounds() const { 54 : return electron_fraction_bounds_; 55 : } 56 : 57 0 : size_t number_density_number_of_points() const { 58 : return number_density_number_of_points_; 59 : } 60 : 61 0 : size_t temperature_number_of_points() const { 62 : return temperature_number_of_points_; 63 : } 64 : 65 0 : size_t electron_fraction_number_of_points() const { 66 : return electron_fraction_number_of_points_; 67 : } 68 : 69 0 : bool beta_equilibrium() const { return beta_equilibrium_; } 70 : 71 0 : bool number_density_log_spacing() const { 72 : return number_density_log_spacing_; 73 : } 74 : 75 0 : bool temperature_log_spacing() const { return temperature_log_spacing_; } 76 : 77 0 : bool electron_fraction_log_spacing() const { 78 : return electron_fraction_log_spacing_; 79 : } 80 : 81 0 : void pup(PUP::er& p); 82 : 83 : private: 84 0 : void parse_eos_quantities(); 85 0 : void parse_eos_parameters(); 86 0 : void parse_eos_table(); 87 : 88 : static const std::vector<std::string> 89 0 : compose_regular_and_additional_index_to_names_; 90 0 : static const std::vector<std::string> compose_derivative_index_to_names_; 91 0 : std::string directory_to_read_from_; 92 0 : std::vector<std::string> available_quantities_; 93 0 : std::array<size_t, 3> interpolation_order_; 94 0 : std::array<double, 2> number_density_bounds_; 95 0 : std::array<double, 2> temperature_bounds_; 96 0 : std::array<double, 2> electron_fraction_bounds_; 97 0 : size_t number_density_number_of_points_; 98 0 : size_t temperature_number_of_points_; 99 0 : size_t electron_fraction_number_of_points_; 100 0 : size_t table_size_; 101 0 : bool beta_equilibrium_; 102 0 : bool number_density_log_spacing_; 103 0 : bool temperature_log_spacing_; 104 0 : bool electron_fraction_log_spacing_; 105 0 : std::unordered_map<std::string, DataVector> data_; 106 : }; 107 : } // namespace io