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
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
48
49 // EOS types definition usable in the code
50
53
56
59
62
65
69
73
76
78 using Variant = std::variant<
86 Fermi>;
87
90
96 inline void set_isothermal(Tscal cs) { config = Isothermal{cs}; }
97
103 inline void set_adiabatic(Tscal gamma) { config = Adiabatic{gamma}; }
104
110 inline void set_polytropic(Tscal K, Tscal gamma) { config = Polytropic{K, gamma}; }
111
116
128 inline void set_locally_isothermalLP07(Tscal cs0, Tscal q, Tscal r0) {
129 config = LocallyIsothermalLP07{cs0, q, r0};
130 }
131
132 inline void set_locally_isothermalFA2014(Tscal h_over_r) {
134 }
135
136 inline void set_locally_isothermalFA2014_extended(
137 Tscal cs0, Tscal q, Tscal r0, u32 n_sinks) {
138 config = LocallyIsothermalFA2014Extended{cs0, q, r0, n_sinks};
139 }
140
146 inline void set_fermi(Tscal mu_e) { config = Fermi{mu_e}; }
147
151 inline void print_status();
152 };
153
154} // namespace shammodels
155
156template<class Tvec>
158
159 std::string s;
160 if constexpr (std::is_same_v<f32_3, Tvec>) {
161 s = "f32_3";
162 }
163
164 if constexpr (std::is_same_v<f64_3, Tvec>) {
165 s = "f64_3";
166 }
167
168 logger::raw_ln("EOS config", s, ":");
169 if (Isothermal *eos_config = std::get_if<Isothermal>(&config)) {
170 logger::raw_ln("isothermal : ");
171 logger::raw_ln("cs", eos_config->cs);
172 } else if (Adiabatic *eos_config = std::get_if<Adiabatic>(&config)) {
173 logger::raw_ln("adiabatic : ");
174 logger::raw_ln("gamma", eos_config->gamma);
175 } else if (Polytropic *eos_config = std::get_if<Polytropic>(&config)) {
176 logger::raw_ln("polytropic : ");
177 logger::raw_ln("K", eos_config->K);
178 logger::raw_ln("gamma", eos_config->gamma);
179 } else if (LocallyIsothermal *eos_config = std::get_if<LocallyIsothermal>(&config)) {
180 logger::raw_ln("locally isothermal : ");
181 } else if (LocallyIsothermalLP07 *eos_config = std::get_if<LocallyIsothermalLP07>(&config)) {
182 logger::raw_ln("locally isothermal (Lodato Price 2007) : ");
183 } else if (
184 LocallyIsothermalFA2014 *eos_config = std::get_if<LocallyIsothermalFA2014>(&config)) {
185 logger::raw_ln("locally isothermal (Farris 2014) : ");
186 } else if (
188 = std::get_if<LocallyIsothermalFA2014Extended>(&config)) {
189 logger::raw_ln("locally isothermal (Farris 2014 extended) : ");
190 } else if (Fermi *eos_config = std::get_if<Fermi>(&config)) {
191 logger::raw_ln("Fermi : ");
192 logger::raw_ln("mu_e", eos_config->mu_e);
193 } else {
195 }
196}
197
198namespace shammodels {
199
218 template<class Tvec>
219 void to_json(nlohmann::json &j, const EOSConfig<Tvec> &p);
220
233 template<class Tvec>
234 void from_json(const nlohmann::json &j, EOSConfig<Tvec> &p);
235
236} // 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
void to_json(nlohmann::json &j, const EOSConfig< Tvec > &p)
Serialize EOSConfig to json.
Definition EOSConfig.cpp:43
void from_json(const nlohmann::json &j, EOSConfig< Tvec > &p)
Deserializes an EOSConfig<Tvec> from a JSON object.
Traits for C++ types.
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:96
Variant config
Current EOS configuration.
Definition EOSConfig.hpp:89
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:68
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
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:72
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.
std::variant< Isothermal, Adiabatic, Polytropic, LocallyIsothermal, LocallyIsothermalLP07, LocallyIsothermalFA2014, LocallyIsothermalFA2014Extended, Fermi > Variant
Variant type to store the EOS configuration.
Definition EOSConfig.hpp:86
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 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.