36#include <pybind11/complex.h>
42 py::module shamphys_module = m.def_submodule(
"phys",
"Physics Library");
48 &shamphys::hill_radius<f64>,
54 Compute the hill radius of a planet
63 return shamphys::keplerian_speed(G, M, R);
70 Compute the keplerian orbit speed
71 G : Gravitational constant
79 return shamphys::keplerian_speed(M, R, usys);
86 Compute the keplerian orbit speed
95 "schwarzschild_radius",
97 return shamphys::schwarzschild_radius(M, G, c);
104 Compute the schwarzschild radius
106 G : Gravitational constant
111 "schwarzschild_radius",
113 return shamphys::schwarzschild_radius(M, usys);
119 Compute the schwarzschild radius
126 [](
double m1,
double m2,
double a,
double e,
double nu,
double G) {
137 Compute the positions and velocities of two objects in a binary system
138 m1 : Mass of the first object
139 m2 : Mass of the second object
140 a : Semi-major axis of the system
141 e : Eccentricity of the system
142 nu : True anomaly of the system (in radians)
143 G : Gravitational constant
164 Compute the positions and velocities of two objects in a binary system
165 m1 : Mass of the first object
166 m2 : Mass of the second object
167 a : Semi-major axis of the system
168 e : Eccentricity of the system
169 nu : True anomaly of the system (in radians)
175 [](f64_3 point,
double roll,
double pitch,
double yaw) {
176 return shamphys::rotate_point(point, roll, pitch, yaw);
184 Rotate a 3D point using Euler angles.
185 point : 3D point as a f64_3
186 roll : Rotation about the X-axis (in radians)
187 pitch : Rotation about the Y-axis (in radians)
188 yaw : Rotation about the Z-axis (in radians)
192 "get_binary_rotated",
215 Rotate a binary orbit by Euler angles and return the positions and
216 velocities of the two objects.
217 m1 : Mass of the first object
218 m2 : Mass of the second object
219 a : Semi-major axis of the system
220 e : Eccentricity of the system
221 nu : True anomaly of the system (in radians)
222 G : Gravitational constant
223 roll : Rotation about the X-axis (in radians)
224 pitch : Rotation about the Y-axis (in radians)
225 yaw : Rotation about the Z-axis (in radians)
229 "get_binary_rotated",
255 return shamphys::free_fall_time(rho, G);
260 Compute the free fall time
262 G : Gravitational constant
268 return shamphys::free_fall_time(rho, usys);
273 Compute the free fall time
279 "epstein_supersonic_correction",
280 [](
double delta_v,
double cs) {
281 return shamphys::epstein_supersonic_correction<double>(delta_v, cs);
287 Epstein drag supersonic correction factor for spherical dust grains.
289 Corrects the Epstein drag force when the drift speed between dust
290 and gas exceeds the thermal speed.
292 \f$f(\Delta v, c_s) = \sqrt{1 + \frac{9\pi}{128} \frac{\Delta v^2}{c_s^2}}\f$
295 delta_v: Drift speed between dust and gas
299 The supersonic correction factor f(delta_v, cs)
303 "epstein_stopping_time",
304 [](
double rho_grain,
double s_grain,
double rho,
double cs,
double gamma,
double f) {
308 py::arg(
"rho_grain"),
315 Epstein drag stopping time for spherical dust grains.
317 \f[t_s = \frac{\rho_{\rm grain} \, s_{\rm grain}}{\rho \, c_s \, f} \sqrt{\frac{\pi \gamma}{8}}\f]
319 where \f$\rho = \rho_{\rm g} + \rho_{\rm d}\f$ is the total density and \f$f\f$
320 is the supersonic correction factor.
323 rho_grain: Internal density of the dust grain
324 s_grain: Radius of the dust grain
325 rho: Total density (\f$\rho_{\rm g} + \rho_{\rm d}\f$)
327 gamma: Adiabatic index
328 f: Supersonic correction factor (1.0 for subsonic)
335 py::class_<shamphys::HydroSoundwave>(shamphys_module,
"HydroSoundwave")
337 py::init([](
f64 cs,
f64 k, std::complex<f64> rho_tilde, std::complex<f64> v_tilde) {
338 return std::make_unique<shamphys::HydroSoundwave>(
344 py::arg(
"rho_tilde"),
346 .def(
"get_omega", &shamphys::HydroSoundwave::get_omega)
348 auto ret = self.get_value(t, x);
349 return std::pair<f64, f64>{ret.rho, ret.v};
353 py::class_<shamphys::SodTube>(shamphys_module,
"SodTube")
356 return std::make_unique<shamphys::SodTube>(
366 auto ret = self.get_value(t, x);
367 return std::tuple<f64, f64, f64>{ret.rho, ret.vx, ret.P};
371 py::class_<shamphys::SedovTaylor>(shamphys_module,
"SedovTaylor")
377 return std::tuple<f64, f64, f64>{ret.rho, ret.vx, ret.P};
382 "green_func_grav_cartesian_0_5", &shamphys::green_func_grav_cartesian<f64, 0, 5>);
384 "green_func_grav_cartesian_0_4", &shamphys::green_func_grav_cartesian<f64, 0, 4>);
386 "green_func_grav_cartesian_0_3", &shamphys::green_func_grav_cartesian<f64, 0, 3>);
388 "green_func_grav_cartesian_0_2", &shamphys::green_func_grav_cartesian<f64, 0, 2>);
390 "green_func_grav_cartesian_0_1", &shamphys::green_func_grav_cartesian<f64, 0, 1>);
392 "green_func_grav_cartesian_0_0", &shamphys::green_func_grav_cartesian<f64, 0, 0>);
394 "green_func_grav_cartesian_1_5", &shamphys::green_func_grav_cartesian<f64, 1, 5>);
396 "green_func_grav_cartesian_1_4", &shamphys::green_func_grav_cartesian<f64, 1, 4>);
398 "green_func_grav_cartesian_1_3", &shamphys::green_func_grav_cartesian<f64, 1, 3>);
400 "green_func_grav_cartesian_1_2", &shamphys::green_func_grav_cartesian<f64, 1, 2>);
402 "green_func_grav_cartesian_1_1", &shamphys::green_func_grav_cartesian<f64, 1, 1>);
405 shamphys_module.def(
"get_M_mat_5", &shamphys::get_M_mat<f64, 0, 5>);
406 shamphys_module.def(
"get_M_mat_4", &shamphys::get_M_mat<f64, 0, 4>);
407 shamphys_module.def(
"get_M_mat_3", &shamphys::get_M_mat<f64, 0, 3>);
408 shamphys_module.def(
"get_M_mat_2", &shamphys::get_M_mat<f64, 0, 2>);
409 shamphys_module.def(
"get_M_mat_1", &shamphys::get_M_mat<f64, 0, 1>);
410 shamphys_module.def(
"get_M_mat_0", &shamphys::get_M_mat<f64, 0, 0>);
411 shamphys_module.def(
"get_dM_mat_5", &shamphys::get_dM_mat<f64, 4>);
412 shamphys_module.def(
"get_dM_mat_4", &shamphys::get_dM_mat<f64, 3>);
413 shamphys_module.def(
"get_dM_mat_3", &shamphys::get_dM_mat<f64, 2>);
414 shamphys_module.def(
"get_dM_mat_2", &shamphys::get_dM_mat<f64, 1>);
415 shamphys_module.def(
"get_dM_mat_1", &shamphys::get_dM_mat<f64, 0>);
419 "contract_grav_moment_to_force_5", &shamphys::contract_grav_moment_to_force<f64, 5>);
421 "contract_grav_moment_to_force_4", &shamphys::contract_grav_moment_to_force<f64, 4>);
423 "contract_grav_moment_to_force_3", &shamphys::contract_grav_moment_to_force<f64, 3>);
425 "contract_grav_moment_to_force_2", &shamphys::contract_grav_moment_to_force<f64, 2>);
427 "contract_grav_moment_to_force_1", &shamphys::contract_grav_moment_to_force<f64, 1>);
431 "offset_multipole_5",
432 &shamphys::offset_multipole<f64, 0, 5>,
437 "offset_multipole_4",
438 &shamphys::offset_multipole<f64, 0, 4>,
443 "offset_multipole_3",
444 &shamphys::offset_multipole<f64, 0, 3>,
449 "offset_multipole_2",
450 &shamphys::offset_multipole<f64, 0, 2>,
455 "offset_multipole_1",
456 &shamphys::offset_multipole<f64, 0, 1>,
461 "offset_multipole_0",
462 &shamphys::offset_multipole<f64, 0, 0>,
470 &shamphys::offset_dM_mat<f64, 1, 5>,
476 &shamphys::offset_dM_mat<f64, 1, 4>,
482 &shamphys::offset_dM_mat<f64, 1, 3>,
488 &shamphys::offset_dM_mat<f64, 1, 2>,
494 &shamphys::offset_dM_mat<f64, 1, 1>,
501 py::module eos_module = shamphys_module.def_submodule(
"eos");
509 return std::tuple<f64, f64, f64>{P, _cs, T};
525 return std::tuple<f64, f64>{P_cs.pressure, P_cs.soundspeed};
Epstein drag stopping time for spherical dust grains.
T epstein_stopping_time(T rho_grain, T s_grain, T rho, T cs, T gamma, T f=T(1.0)) noexcept
Epstein drag stopping time for spherical dust grains.
double f64
Alias for double.
Represents a Sedov-Taylor solution, a self-similar solution to the hydrodynamic equations describing ...
field_val get_value(f64 x)
Compute field values at radial distance x.
Functions for gravitational collapse calculations.
auto get_binary_pair(double m1, double m2, double a, double e, double nu, double G)
Convert a binary system from Keplerian to Cartesian coordinates.
auto get_binary_rotated(double m1, double m2, double a, double e, double nu, double G, double roll, double pitch, double yaw)
Rotate a binary orbit by Euler angles and return the positions and velocities of the two objects.
Pybind11 include and definitions.
#define Register_pymod(placeholdername)
Register a python module init function using static initialisation.
void debug_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
static constexpr PressureAndCs< T > pressure_and_soundspeed(T mu_e, T rho)
EOS_Fermi::pressure_and_soundspeed Returns pressure and sound speed from the given value of density i...
Piecewise polytropic EOS from Machida et al. (2006)