46 using json = nlohmann::json;
48 std::string type_id =
"";
50 if constexpr (std::is_same_v<f32_3, Tvec>) {
52 }
else if constexpr (std::is_same_v<f64_3, Tvec>) {
67 if (
const Isothermal *eos_config = std::get_if<Isothermal>(&p.config)) {
68 j = json{{
"Tvec", type_id}, {
"eos_type",
"isothermal"}, {
"cs", eos_config->cs}};
69 }
else if (
const Adiabatic *eos_config = std::get_if<Adiabatic>(&p.config)) {
70 j = json{{
"Tvec", type_id}, {
"eos_type",
"adiabatic"}, {
"gamma", eos_config->gamma}};
71 }
else if (
const Polytropic *eos_config = std::get_if<Polytropic>(&p.config)) {
74 {
"eos_type",
"polytropic"},
76 {
"gamma", eos_config->gamma}};
77 }
else if (
const LocIsoT *eos_config = std::get_if<LocIsoT>(&p.config)) {
78 j = json{{
"Tvec", type_id}, {
"eos_type",
"locally_isothermal"}};
79 }
else if (
const LocIsoTLP07 *eos_config = std::get_if<LocIsoTLP07>(&p.config)) {
82 {
"eos_type",
"locally_isothermal_lp07"},
83 {
"cs0", eos_config->cs0},
85 {
"r0", eos_config->r0}};
86 }
else if (
const LocIsoTFA2014 *eos_config = std::get_if<LocIsoTFA2014>(&p.config)) {
89 {
"eos_type",
"locally_isothermal_fa2014"},
90 {
"h_over_r", eos_config->h_over_r}};
92 const LocIsoTFA2014Extended *eos_config
93 = std::get_if<LocIsoTFA2014Extended>(&p.config)) {
96 {
"eos_type",
"locally_isothermal_fa2014_extended"},
97 {
"cs0", eos_config->cs0},
99 {
"r0", eos_config->r0},
100 {
"n_sinks", eos_config->n_sinks}};
101 }
else if (
const Fermi *eos_config = std::get_if<Fermi>(&p.config)) {
102 j = json{{
"Tvec", type_id}, {
"eos_type",
"fermi"}, {
"mu_e", eos_config->mu_e}};
123 using Tscal = shambase::VecComponent<Tvec>;
126 j.at(
"Tvec").get_to(type_id);
128 if constexpr (std::is_same_v<f32_3, Tvec>) {
129 if (type_id !=
"f32_3") {
131 "You are trying to create a EOSConfig with the wrong vector type");
133 }
else if constexpr (std::is_same_v<f64_3, Tvec>) {
134 if (type_id !=
"f64_3") {
136 "You are trying to create a EOSConfig with the wrong vector type");
142 if (!j.contains(
"eos_type")) {
146 std::string eos_type;
147 j.at(
"eos_type").get_to(eos_type);
158 if (eos_type ==
"isothermal") {
159 p.config = Isothermal{j.at(
"cs").get<Tscal>()};
160 }
else if (eos_type ==
"adiabatic") {
161 p.config = Adiabatic{j.at(
"gamma").get<Tscal>()};
162 }
else if (eos_type ==
"polytropic") {
163 p.config = Polytropic{j.at(
"K").get<Tscal>(), j.at(
"gamma").get<Tscal>()};
164 }
else if (eos_type ==
"locally_isothermal") {
165 p.config = LocIsoT{};
166 }
else if (eos_type ==
"locally_isothermal_lp07") {
167 p.config = LocIsoTLP07{
168 j.at(
"cs0").get<Tscal>(), j.at(
"q").get<Tscal>(), j.at(
"r0").get<Tscal>()};
169 }
else if (eos_type ==
"locally_isothermal_fa2014") {
170 p.config = LocIsoTFA2014{j.at(
"h_over_r").get<Tscal>()};
171 }
else if (eos_type ==
"locally_isothermal_fa2014_extended") {
172 p.config = LocIsoTFA2014Extended{
173 j.at(
"cs0").get<Tscal>(),
174 j.at(
"q").get<Tscal>(),
175 j.at(
"r0").get<Tscal>(),
176 j.at(
"n_sinks").get<
u32>()};
177 }
else if (eos_type ==
"fermi") {
178 p.config = Fermi{j.at(
"mu_e").get<Tscal>()};
184 template void to_json<f64_3>(nlohmann::json &j,
const EOSConfig<f64_3> &p);
185 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...
void to_json(nlohmann::json &j, const EOSConfig< Tvec > &p)
Serialize EOSConfig to json.
void from_json(const nlohmann::json &j, EOSConfig< Tvec > &p)
Deserializes an EOSConfig<Tvec> from a JSON object.
Locally isothermal equation of state configuration.
Configuration struct for the equation of state used in the hydrodynamic models.
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.