32 shamlog_debug_ln(
"PhantomDump",
"read ieos :", ieos);
36 phdump::eos1_load(phdump, cs);
37 cfg.set_isothermal(cs);
38 }
else if (ieos == 2) {
40 phdump::eos2_load(phdump, gamma);
41 cfg.set_adiabatic(gamma);
42 }
else if (ieos == 3) {
44 phdump::eos3_load(phdump, cs0, q, r0);
45 cfg.set_locally_isothermalLP07(cs0, q, r0);
46 }
else if (ieos == 13) {
48 phdump::eos13_load(phdump, cs0, q, r0);
50 cfg.set_locally_isothermalFA2014_extended(cs0, q, r0,
u32_max);
51 }
else if (ieos == 14) {
53 phdump::eos14_load(phdump, cs0, q, r0);
54 cfg.set_locally_isothermalFA2014_extended(cs0, q, r0, 2);
56 const std::string msg =
"loading phantom ieos=" + std::to_string(ieos)
57 +
" is not implemented in shamrock";
59 logger::warn_ln(
"SPH", msg);
77 using EOS_LocallyIsothermalFA2014Extended =
80 if (EOS_Isothermal *eos_config = std::get_if<EOS_Isothermal>(&cfg.
config)) {
81 phdump::eos1_write(dump, eos_config->cs);
82 }
else if (EOS_Adiabatic *eos_config = std::get_if<EOS_Adiabatic>(&cfg.
config)) {
83 phdump::eos2_write(dump, eos_config->gamma);
85 EOS_LocallyIsothermalLP07 *eos_config
86 = std::get_if<EOS_LocallyIsothermalLP07>(&cfg.
config)) {
87 phdump::eos3_write(dump, eos_config->cs0, eos_config->q, eos_config->r0);
89 EOS_LocallyIsothermalFA2014Extended *eos_config
90 = std::get_if<EOS_LocallyIsothermalFA2014Extended>(&cfg.
config)) {
92 if (eos_config->n_sinks ==
u32_max) {
93 phdump::eos13_write(dump, eos_config->cs0, eos_config->q, eos_config->r0);
94 }
else if (eos_config->n_sinks == 2) {
95 phdump::eos14_write(dump, eos_config->cs0, eos_config->q, eos_config->r0);
98 =
"Phantom only support all or 2 sinks for this EOS configuration";
100 logger::warn_ln(
"SPH", msg);
106 const std::string msg
107 =
"The current shamrock EOS is not implemented in phantom dump conversion";
109 logger::warn_ln(
"SPH", msg);
146 template<
class Tscal>
163 template<
class Tscal>
172 f64 umass = units->template to<shamunits::units::kg>();
173 f64 utime = units->template to<shamunits::units::s>();
174 f64 udist = units->template to<shamunits::units::m>();
178 f64 ucharge = sqrt(umass * udist / (4. * shambase::constants::pi<f64> ));
180 f64 umagfd = umass / (utime * ucharge);
184 logger::warn_ln(
"SPH",
"no units are set, defaulting to SI");
198 template void write_shamrock_units_in_phantom_dump<f64>(
208 logger::raw_ln(
"Setting periodic boundaries from phantmdump");
211 logger::raw_ln(
"Setting free boundaries from phantmdump");
218 void write_shamrock_boundaries_in_phantom_dump(
220 std::tuple<Tvec, Tvec> box_size,
224 auto [bmin, bmax] = box_size;
225 using SolverConfigBC = BCConfig<Tvec>;
226 using SolverBCFree =
typename SolverConfigBC::Free;
227 using SolverBCPeriodic =
typename SolverConfigBC::Periodic;
228 using SolverBCShearingPeriodic =
typename SolverConfigBC::ShearingPeriodic;
231 if (SolverBCFree *c = std::get_if<SolverBCFree>(&cfg.config)) {
233 }
else if (SolverBCPeriodic *c = std::get_if<SolverBCPeriodic>(&cfg.config)) {
234 dump.table_header_fort_real.add(
"xmin", bmin.x());
235 dump.table_header_fort_real.add(
"xmax", bmax.x());
236 dump.table_header_fort_real.add(
"ymin", bmin.y());
237 dump.table_header_fort_real.add(
"ymax", bmax.x());
238 dump.table_header_fort_real.add(
"zmin", bmin.z());
239 dump.table_header_fort_real.add(
"zmax", bmax.x());
241 SolverBCShearingPeriodic *c = std::get_if<SolverBCShearingPeriodic>(&cfg.config)) {
243 =
"Phantom does not support shearing periodic boundaries but your are "
244 "making a phantom dump with them, set bypass_error_check=True to ignore";
247 throw std::runtime_error(err_msg);
249 logger::warn_ln(
"PhantomDump", err_msg);
260 template void write_shamrock_boundaries_in_phantom_dump<f32_3>(
262 std::tuple<f32_3, f32_3> box_size,
266 template void write_shamrock_boundaries_in_phantom_dump<f64_3>(
268 std::tuple<f64_3, f64_3> box_size,
double f64
Alias for double.
std::int64_t i64
64 bit integer
Class holding the value of numerous constants generated from the following source.
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
Locally isothermal equation of state configuration.
Configuration struct for the equation of state used in the hydrodynamic models.
Variant config
Current EOS 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.
T read_header_float(std::string s) const
Retrieves a floating-point value from the table headers.
bool has_header_entry(std::string s) const
Checks if a given string is present in any of the table headers.
T read_header_int(std::string s) const
Retrieves an integer value from the table headers.
PhantomDumpTableHeader< f64 > table_header_f64
Table header for 64-bit floating-point data.
Configuration struct for adiabatic 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.
constexpr T c()
get c in the current unit system units (m.s-1)