48 using json = nlohmann::json;
50 std::string type_id =
"";
52 if constexpr (std::is_same_v<f32_3, Tvec>) {
54 }
else if constexpr (std::is_same_v<f64_3, Tvec>) {
70 if (
const Isothermal *eos_config = std::get_if<Isothermal>(&p.
config)) {
71 j = json{{
"Tvec", type_id}, {
"eos_type",
"isothermal"}, {
"cs", eos_config->cs}};
72 }
else if (
const Adiabatic *eos_config = std::get_if<Adiabatic>(&p.
config)) {
73 j = json{{
"Tvec", type_id}, {
"eos_type",
"adiabatic"}, {
"gamma", eos_config->gamma}};
74 }
else if (
const Polytropic *eos_config = std::get_if<Polytropic>(&p.
config)) {
77 {
"eos_type",
"polytropic"},
79 {
"gamma", eos_config->gamma}};
80 }
else if (
const LocIsoT *eos_config = std::get_if<LocIsoT>(&p.
config)) {
81 j = json{{
"Tvec", type_id}, {
"eos_type",
"locally_isothermal"}};
82 }
else if (
const LocIsoTLP07 *eos_config = std::get_if<LocIsoTLP07>(&p.
config)) {
85 {
"eos_type",
"locally_isothermal_lp07"},
86 {
"cs0", eos_config->cs0},
88 {
"r0", eos_config->r0}};
89 }
else if (
const LocIsoTFA2014 *eos_config = std::get_if<LocIsoTFA2014>(&p.
config)) {
92 {
"eos_type",
"locally_isothermal_fa2014"},
93 {
"h_over_r", eos_config->h_over_r}};
95 const LocIsoTFA2014Extended *eos_config
96 = std::get_if<LocIsoTFA2014Extended>(&p.
config)) {
99 {
"eos_type",
"locally_isothermal_fa2014_extended"},
100 {
"cs0", eos_config->cs0},
101 {
"q", eos_config->q},
102 {
"r0", eos_config->r0},
103 {
"n_sinks", eos_config->n_sinks}};
104 }
else if (
const Fermi *eos_config = std::get_if<Fermi>(&p.
config)) {
105 j = json{{
"Tvec", type_id}, {
"eos_type",
"fermi"}, {
"mu_e", eos_config->mu_e}};
106 }
else if (
const Barotropic *eos_config = std::get_if<Barotropic>(&p.
config)) {
109 {
"eos_type",
"barotropic"},
110 {
"cs0", eos_config->cs0},
111 {
"rho0", eos_config->rho0},
112 {
"gamma0", eos_config->gamma0}};
133 using Tscal = shambase::VecComponent<Tvec>;
136 j.at(
"Tvec").get_to(type_id);
138 if constexpr (std::is_same_v<f32_3, Tvec>) {
139 if (type_id !=
"f32_3") {
141 "You are trying to create a EOSConfig with the wrong vector type");
143 }
else if constexpr (std::is_same_v<f64_3, Tvec>) {
144 if (type_id !=
"f64_3") {
146 "You are trying to create a EOSConfig with the wrong vector type");
152 if (!j.contains(
"eos_type")) {
156 std::string eos_type;
157 j.at(
"eos_type").get_to(eos_type);
169 if (eos_type ==
"isothermal") {
170 p.
config = Isothermal{j.at(
"cs").get<Tscal>()};
171 }
else if (eos_type ==
"adiabatic") {
172 p.
config = Adiabatic{j.at(
"gamma").get<Tscal>()};
173 }
else if (eos_type ==
"polytropic") {
174 p.
config = Polytropic{j.at(
"K").get<Tscal>(), j.at(
"gamma").get<Tscal>()};
175 }
else if (eos_type ==
"locally_isothermal") {
177 }
else if (eos_type ==
"locally_isothermal_lp07") {
179 j.at(
"cs0").get<Tscal>(), j.at(
"q").get<Tscal>(), j.at(
"r0").get<Tscal>()};
180 }
else if (eos_type ==
"locally_isothermal_fa2014") {
181 p.
config = LocIsoTFA2014{j.at(
"h_over_r").get<Tscal>()};
182 }
else if (eos_type ==
"locally_isothermal_fa2014_extended") {
183 p.
config = LocIsoTFA2014Extended{
184 j.at(
"cs0").get<Tscal>(),
185 j.at(
"q").get<Tscal>(),
186 j.at(
"r0").get<Tscal>(),
187 j.at(
"n_sinks").get<
u32>()};
188 }
else if (eos_type ==
"fermi") {
189 p.
config = Fermi{j.at(
"mu_e").get<Tscal>()};
190 }
else if (eos_type ==
"barotropic") {
192 j.at(
"cs0").get<Tscal>(), j.at(
"rho0").get<Tscal>(), j.at(
"gamma0").get<Tscal>()};
198 template void to_json<f64_3>(nlohmann::json &j,
const EOSConfig<f64_3> &p);
199 template void from_json<f64_3>(
const nlohmann::json &j, EOSConfig<f64_3> &p);
void to_json(nlohmann::json &j, const PatchSchedulerConfig &p)
Converts a PatchSchedulerConfig object to a JSON object.
void from_json(const nlohmann::json &j, PatchSchedulerConfig &p)
Deserializes a PatchSchedulerConfig object from a JSON object.
std::uint32_t u32
32 bit unsigned integer
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
constexpr bool always_false_v
Helper variable template that is always false. Especially useful to perform static asserts based on t...
Locally isothermal equation of state configuration.
Configuration struct for the equation of state used in the hydrodynamic models.
Variant config
Current EOS configuration.
shamphys::EOS_Config_Polytropic< Tscal > Polytropic
Polytropic equation of state configuration.
shamphys::EOS_Config_Isothermal< Tscal > Isothermal
Isothermal equation of state configuration.
shamphys::EOS_Config_LocallyIsothermalDisc_Farris2014< Tscal > LocallyIsothermalFA2014
Locally isothermal equation of state configuration from Lodato Price 2007.
shamphys::EOS_Config_LocallyIsothermal_LP07< Tscal > LocallyIsothermalLP07
Locally isothermal equation of state configuration from Lodato Price 2007.
shamphys::EOS_Config_Fermi< Tscal > Fermi
Fermi equation of state configuration.
shamphys::EOS_Config_LocallyIsothermalDisc_ExtendedFarris2014< Tscal > LocallyIsothermalFA2014Extended
Locally isothermal equation of state configuration from Farris 2014 extended to q !...
shamphys::EOS_Config_Adiabatic< Tscal > Adiabatic
Adiabatic equation of state configuration.
shamphys::EOS_Config_Barotropic< Tscal > Barotropic
Barotropic equation of state configuration.