Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
EOSConfig.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20
23#include "nlohmann/json_fwd.hpp"
24#include "shambackends/vec.hpp"
27#include <nlohmann/json.hpp>
28#include <type_traits>
29#include <stdexcept>
30#include <string>
31#include <variant>
32
33namespace shammodels {
34
41 template<class Tvec>
42 struct EOSConfig {
44 using Tscal = shambase::VecComponent<Tvec>;
45
47 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
48
49 // EOS types definition usable in the code
50
53
56
59
62
65
69
81 using Variant = std::variant<
89 Fermi,
94
100 inline void set_isothermal(Tscal cs) { config = Isothermal{cs}; }
101
107 inline void set_adiabatic(Tscal gamma) { config = Adiabatic{gamma}; }
108
114 inline void set_polytropic(Tscal K, Tscal gamma) { config = Polytropic{K, gamma}; }
115
119 inline void set_locally_isothermal() { config = LocallyIsothermal{}; }
120
130 * @param r0 Reference radius
131 */
132 inline void set_locally_isothermalLP07(Tscal cs0, Tscal q, Tscal r0) {
133 config = LocallyIsothermalLP07{cs0, q, r0};
134 }
135
136 inline void set_locally_isothermalFA2014(Tscal h_over_r) {
138 }
139
140 inline void set_locally_isothermalFA2014_extended(
141 Tscal cs0, Tscal q, Tscal r0, u32 n_sinks) {
142 config = LocallyIsothermalFA2014Extended{cs0, q, r0, n_sinks};
143 }
144
150 inline void set_fermi(Tscal mu_e) { config = Fermi{mu_e}; }
151
160 * @param gamma0 Adiabatic index of the high density regime
161 */
162 inline void set_barotropic(Tscal cs0, Tscal rho0, Tscal gamma0) {
163 config = Barotropic{cs0, rho0, gamma0};
164 }
165
169 inline void print_status();
170 };
171
172} // namespace shammodels
173
174template<class Tvec>
176
177 std::string s;
178 if constexpr (std::is_same_v<f32_3, Tvec>) {
179 s = "f32_3";
180 }
181
182 if constexpr (std::is_same_v<f64_3, Tvec>) {
183 s = "f64_3";
184 }
185
186 logger::raw_ln("EOS config", s, ":");
187 if (Isothermal *eos_config = std::get_if<Isothermal>(&config)) {
188 logger::raw_ln("isothermal : ");
189 logger::raw_ln("cs", eos_config->cs);
190 } else if (Adiabatic *eos_config = std::get_if<Adiabatic>(&config)) {
191 logger::raw_ln("adiabatic : ");
192 logger::raw_ln("gamma", eos_config->gamma);
193 } else if (Polytropic *eos_config = std::get_if<Polytropic>(&config)) {
194 logger::raw_ln("polytropic : ");
195 logger::raw_ln("K", eos_config->K);
196 logger::raw_ln("gamma", eos_config->gamma);
197 } else if (LocallyIsothermal *eos_config = std::get_if<LocallyIsothermal>(&config)) {
198 logger::raw_ln("locally isothermal : ");
199 } else if (LocallyIsothermalLP07 *eos_config = std::get_if<LocallyIsothermalLP07>(&config)) {
200 logger::raw_ln("locally isothermal (Lodato Price 2007) : ");
201 } else if (
202 LocallyIsothermalFA2014 *eos_config = std::get_if<LocallyIsothermalFA2014>(&config)) {
203 logger::raw_ln("locally isothermal (Farris 2014) : ");
204 } else if (
206 = std::get_if<LocallyIsothermalFA2014Extended>(&config)) {
207 logger::raw_ln("locally isothermal (Farris 2014 extended) : ");
208 } else if (Fermi *eos_config = std::get_if<Fermi>(&config)) {
209 logger::raw_ln("Fermi : ");
210 logger::raw_ln("mu_e", eos_config->mu_e);
211 } else if (Barotropic *eos_config = std::get_if<Barotropic>(&config)) {
212 logger::raw_ln("barotropic : ");
213 logger::raw_ln("cs0", eos_config->cs0);
214 logger::raw_ln("rho0", eos_config->rho0);
215 logger::raw_ln("gamma0", eos_config->gamma0);
216 } else {
218 }
219}
220
221namespace shammodels {
222
241 template<class Tvec>
242 void to_json(nlohmann::json &j, const EOSConfig<Tvec> &p);
243
256 template<class Tvec>
257 void from_json(const nlohmann::json &j, EOSConfig<Tvec> &p);
258
259} // namespace shammodels
std::uint32_t u32
32 bit unsigned integer
This header file contains utility functions related to exception handling in the code.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
namespace for models
Definition AMRBlock.hpp:26
Traits for C++ types.
void raw_ln(Types... var2)
Prints a log message with multiple arguments followed by a newline.
Definition logs.hpp:89
Locally isothermal equation of state configuration.
Definition EOSConfig.hpp:61
Configuration struct for the equation of state used in the hydrodynamic models.
Definition EOSConfig.hpp:42
void set_isothermal(Tscal cs)
Set the EOS configuration to an isothermal equation of state.
Definition EOSConfig.hpp:98
std::variant< Isothermal, Adiabatic, Polytropic, LocallyIsothermal, LocallyIsothermalLP07, LocallyIsothermalFA2014, LocallyIsothermalFA2014Extended, Fermi, Barotropic > Variant
Variant type to store the EOS configuration.
Definition EOSConfig.hpp:79
Variant config
Current EOS configuration.
Definition EOSConfig.hpp:91
shamphys::EOS_Config_Polytropic< Tscal > Polytropic
Polytropic equation of state configuration.
Definition EOSConfig.hpp:55
shamphys::EOS_Config_Isothermal< Tscal > Isothermal
Isothermal equation of state configuration.
Definition EOSConfig.hpp:58
void print_status()
Print current status of the EOSConfig.
shamphys::EOS_Config_LocallyIsothermalDisc_Farris2014< Tscal > LocallyIsothermalFA2014
Locally isothermal equation of state configuration from Lodato Price 2007.
Definition EOSConfig.hpp:67
void set_adiabatic(Tscal gamma)
Set the EOS configuration to an adiabatic equation of state.
shamphys::EOS_Config_LocallyIsothermal_LP07< Tscal > LocallyIsothermalLP07
Locally isothermal equation of state configuration from Lodato Price 2007.
Definition EOSConfig.hpp:64
shamphys::EOS_Config_Fermi< Tscal > Fermi
Fermi equation of state configuration.
Definition EOSConfig.hpp:73
void set_polytropic(Tscal K, Tscal gamma)
Set the EOS configuration to an polytropic equation of state.
shamphys::EOS_Config_LocallyIsothermalDisc_ExtendedFarris2014< Tscal > LocallyIsothermalFA2014Extended
Locally isothermal equation of state configuration from Farris 2014 extended to q !...
Definition EOSConfig.hpp:70
void set_barotropic(Tscal cs0, Tscal rho0, Tscal gamma0)
Set the EOS configuration to a barotropic equation of state.
void set_fermi(Tscal mu_e)
Set the EOS configuration to a Fermi equation of state.
void set_locally_isothermalLP07(Tscal cs0, Tscal q, Tscal r0)
Set the EOS configuration to a locally isothermal equation of state (Lodato Price 2007).
static constexpr u32 dim
Dimension of the vector quantities.
Definition EOSConfig.hpp:47
shamphys::EOS_Config_Adiabatic< Tscal > Adiabatic
Adiabatic equation of state configuration.
Definition EOSConfig.hpp:52
void set_locally_isothermal()
Set the EOS configuration to a locally isothermal equation of state.
shamphys::EOS_Config_Barotropic< Tscal > Barotropic
Barotropic equation of state configuration.
Definition EOSConfig.hpp:76
shambase::VecComponent< Tvec > Tscal
Scalar type associated to the vector template type.
Definition EOSConfig.hpp:44
Configuration struct for adiabatic equation of state.
Configuration struct for the barotropic equation of state.
Configuration struct for Fermi equation of state.
Configuration struct for isothermal equation of state.
Configuration struct for the locally isothermal equation of state extended from Farris 2014 to includ...
Configuration struct for the locally isothermal equation of state from Farris 2014.
Configuration struct for the locally isothermal equation of state from Lodato Price 2007.
Configuration struct for polytropic equation of state.