29 i64 ieos = phdump.read_header_int<
i64>(
"ieos");
31 shamlog_debug_ln(
"PhantomDump",
"read ieos :", ieos);
37 }
else if (ieos == 2) {
41 }
else if (ieos == 3) {
45 }
else if (ieos == 6) {
52 "phantom ieos=6 (locally isothermal centred on sink",
54 ") is not implemented in shamrock, falling back to ieos=3 (locally isothermal "
55 "centred on the origin). This is only correct if the sink stays at the origin.");
57 }
else if (ieos == 13) {
61 cfg.set_locally_isothermalFA2014_extended(cs0, q, r0,
u32_max);
62 }
else if (ieos == 14) {
65 cfg.set_locally_isothermalFA2014_extended(cs0, q, r0, 2);
67 const std::string msg =
"loading phantom ieos=" + std::to_string(ieos)
68 +
" is not implemented in shamrock";
88 using EOS_LocallyIsothermalFA2014Extended =
91 if (EOS_Isothermal *eos_config = std::get_if<EOS_Isothermal>(&cfg.
config)) {
93 }
else if (EOS_Adiabatic *eos_config = std::get_if<EOS_Adiabatic>(&cfg.
config)) {
96 EOS_LocallyIsothermalLP07 *eos_config
97 = std::get_if<EOS_LocallyIsothermalLP07>(&cfg.
config)) {
100 EOS_LocallyIsothermalFA2014Extended *eos_config
101 = std::get_if<EOS_LocallyIsothermalFA2014Extended>(&cfg.
config)) {
103 if (eos_config->n_sinks ==
u32_max) {
105 }
else if (eos_config->n_sinks == 2) {
108 const std::string msg
109 =
"Phantom only support all or 2 sinks for this EOS configuration";
117 const std::string msg
118 =
"The current shamrock EOS is not implemented in phantom dump conversion";
160 constexpr f64 m_to_cm = 1e2;
161 constexpr f64 kg_to_g = 1e3;
165 constexpr f64 phantom_pi = 3.1415926536;
168 f64 get_phantom_umagfd(
f64 udist,
f64 umass,
f64 utime) {
169 f64 ucharge = sycl::sqrt(umass * udist / (4. * phantom_pi));
170 return umass / (utime * ucharge);
174 template<
class Tscal>
177 f64 udist = phdump.read_header_float<
f64>(
"udist");
178 f64 umass = phdump.read_header_float<
f64>(
"umass");
179 f64 utime = phdump.read_header_float<
f64>(
"utime");
180 f64 umagfd = phdump.read_header_float<
f64>(
"umagfd");
183 utime, udist / m_to_cm, umass / kg_to_g
191 template<
class Tscal>
201 utime_si = units->s_inv;
202 udist_si = units->m_inv;
203 umass_si = units->kg_inv;
208 f64 udist = udist_si * m_to_cm;
209 f64 umass = umass_si * kg_to_g;
210 f64 utime = utime_si;
232 if (phdump.has_header_entry(
"xmin")) {
243 void write_shamrock_boundaries_in_phantom_dump(
245 std::tuple<Tvec, Tvec> box_size,
249 auto [bmin, bmax] = box_size;
250 using SolverConfigBC = BCConfig<Tvec>;
251 using SolverBCFree =
typename SolverConfigBC::Free;
252 using SolverBCPeriodic =
typename SolverConfigBC::Periodic;
253 using SolverBCShearingPeriodic =
typename SolverConfigBC::ShearingPeriodic;
256 if (SolverBCFree *c = std::get_if<SolverBCFree>(&cfg.config)) {
258 }
else if (SolverBCPeriodic *c = std::get_if<SolverBCPeriodic>(&cfg.config)) {
259 dump.table_header_fort_real.add(
"xmin", bmin.x());
260 dump.table_header_fort_real.add(
"xmax", bmax.x());
261 dump.table_header_fort_real.add(
"ymin", bmin.y());
262 dump.table_header_fort_real.add(
"ymax", bmax.y());
263 dump.table_header_fort_real.add(
"zmin", bmin.z());
264 dump.table_header_fort_real.add(
"zmax", bmax.z());
266 SolverBCShearingPeriodic *c = std::get_if<SolverBCShearingPeriodic>(&cfg.config)) {
268 =
"Phantom does not support shearing periodic boundaries but your are "
269 "making a phantom dump with them, set bypass_error_check=True to ignore";
272 throw std::runtime_error(err_msg);
285 template void write_shamrock_boundaries_in_phantom_dump<f32_3>(
287 std::tuple<f32_3, f32_3> box_size,
291 template void write_shamrock_boundaries_in_phantom_dump<f64_3>(
293 std::tuple<f64_3, f64_3> box_size,
void eos2_write(PhantomDump &dump, const f64 &gamma)
Write the EOS2 to the phantom dump.
void eos1_write(PhantomDump &dump, const f64 &cs)
Write the EOS1 to the phantom dump.
void eos2_load(const PhantomDump &dump, f64 &gamma)
Load the EOS2 from the phantom dump.
void eos13_write(PhantomDump &dump, const f64 &cs0, const f64 &q, const f64 &r0)
Write the EOS13 to the phantom dump.
void eos3_load(const PhantomDump &dump, f64 &cs0, f64 &q, f64 &r0)
Load the EOS3 from the phantom dump.
void eos13_load(const PhantomDump &dump, f64 &cs0, f64 &q, f64 &r0)
Load the EOS13 from the phantom dump.
void eos14_write(PhantomDump &dump, const f64 &cs0, const f64 &q, const f64 &r0)
Write the EOS14 to the phantom dump.
void eos14_load(const PhantomDump &dump, f64 &cs0, f64 &q, f64 &r0)
Load the EOS14 from the phantom dump.
void eos3_write(PhantomDump &dump, const f64 &cs0, const f64 &q, const f64 &r0)
Write the EOS3 to the phantom dump.
void eos1_load(const PhantomDump &dump, f64 &cs)
Load the EOS1 from the phantom dump.
void eos6_load(const PhantomDump &dump, f64 &cs0, f64 &q, f64 &r0, i32 &isink)
Load the EOS6 from the phantom dump.
double f64
Alias for double.
std::int64_t i64
64 bit integer
std::int32_t i32
32 bit integer
A unit system, defined by the SI value of its base units.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
namespace for the sph model
BCConfig< Tvec > get_shamrock_boundary_config(PhantomDump &phdump)
Generate an Shamrock boundary configuration from a PhantomDump object.
AVConfig< Tvec > get_shamrock_avconfig(PhantomDump &phdump)
Generate an Shamrock artificial viscosity configuration from a PhantomDump object.
template EOSConfig< f64_3 > get_shamrock_eosconfig< f64_3 >(PhantomDump &phdump, bool bypass_error)
explicit instanciation for f64_3
EOSConfig< Tvec > get_shamrock_eosconfig(PhantomDump &phdump, bool bypass_error)
Generate a Shamrock EOS configuration from a PhantomDump object.
template void write_shamrock_eos_in_phantom_dump< f64_3 >(EOSConfig< f64_3 > &cfg, PhantomDump &dump, bool bypass_error)
explicit instanciation for f64_3
void write_shamrock_units_in_phantom_dump(std::optional< shamunits::UnitSystem< Tscal > > &units, PhantomDump &dump, bool bypass_error)
Write shamrock units config into the phantom dump.
template EOSConfig< f32_3 > get_shamrock_eosconfig< f32_3 >(PhantomDump &phdump, bool bypass_error)
explicit instanciation for f32_3
shamunits::UnitSystem< Tscal > get_shamrock_units(PhantomDump &phdump)
Get the shamrock units object.
void write_shamrock_eos_in_phantom_dump(EOSConfig< Tvec > &cfg, PhantomDump &dump, bool bypass_error)
Write the eos config to th phantom dump header.
template void write_shamrock_eos_in_phantom_dump< f32_3 >(EOSConfig< f32_3 > &cfg, PhantomDump &dump, bool bypass_error)
explicit instanciation for f32_3
constexpr u32 u32_max
u32 max value
void raw_ln(Types... var2)
Prints a log message with multiple arguments followed by a newline.
void warn_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
Locally isothermal equation of state configuration.
Configuration struct for the equation of state used in the hydrodynamic models.
void set_isothermal(Tscal cs)
Set the EOS configuration to an isothermal equation of state.
Variant config
Current EOS 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.
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.
shamphys::EOS_Config_LocallyIsothermalDisc_ExtendedFarris2014< Tscal > LocallyIsothermalFA2014Extended
Locally isothermal equation of state configuration from Farris 2014 extended to q !...
void set_locally_isothermalLP07(Tscal cs0, Tscal q, Tscal r0)
Set the EOS configuration to a locally isothermal equation of state (Lodato Price 2007).
shamphys::EOS_Config_Adiabatic< Tscal > Adiabatic
Adiabatic equation of state configuration.
Configuration for the Artificial Viscosity (AV).
void set_varying_cd10(Tscal alpha_min, Tscal alpha_max, Tscal sigma_decay, Tscal alpha_u, Tscal beta_AV)
Sets the configuration to use a varying Cullen & Dehnen 2010 artificial viscosity.
Boundary conditions configuration.
void set_periodic()
Set the boundary condition to periodic boundaries.
void set_free()
Set the boundary condition to free boundaries.
Class representing a Phantom dump file.
PhantomDumpTableHeader< f64 > table_header_f64
Table header for 64-bit floating-point data.