Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ComputeLuminosity.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
17
19#include "shambase/string.hpp"
26
27template<class Tvec, template<class> class SPHKernel>
29
31
32 auto edges = get_edges();
33
34 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
35
36 auto &part_counts_with_ghosts = edges.part_counts_with_ghosts.indexes;
37 auto &part_counts = edges.part_counts.indexes;
38
39 edges.luminosity.ensure_sizes(edges.part_counts.indexes);
40 edges.omega.check_sizes(part_counts_with_ghosts);
41
43 dev_sched,
45 edges.xyz.get_spans(),
46 edges.hpart.get_spans(),
47 edges.omega.get_spans(),
48 edges.u.get_spans(),
49 edges.pressure.get_spans(),
50 edges.neigh_cache.neigh_cache},
51 sham::DDMultiRef{edges.luminosity.get_spans()},
52 edges.part_counts.indexes,
53 [part_mass = this->part_mass, alpha_u = this->alpha_u](
54 u32 id_a,
55 const Tvec *r,
56 const Tscal *hpart,
57 const Tscal *omega,
58 const Tscal *u,
59 const Tscal *pressure,
60 const auto ploop_ptrs,
61 Tscal *luminosity) {
62 shamrock::tree::ObjectCacheIterator particle_looper(ploop_ptrs);
63
64 using namespace shamrock::sph;
65
66 Tscal h_a = hpart[id_a];
67 Tvec xyz_a = r[id_a];
68 const Tscal u_a = u[id_a];
69 const Tscal omega_a = omega[id_a];
70 const Tscal rho_a = rho_h(part_mass, h_a, SPHKernel<Tscal>::hfactd);
71 const Tscal P_a = pressure[id_a];
72 Tscal omega_a_rho_a_inv = 1 / (omega_a * rho_a);
73 Tscal tmp_luminosity = 0;
74
75 particle_looper.for_each_object(id_a, [&](u32 id_b) {
76 const Tscal u_b = u[id_b];
77 const Tscal h_b = hpart[id_b];
78 const Tscal omega_b = omega[id_b];
79 const Tscal P_b = pressure[id_b];
80 const Tscal rho_b = rho_h(part_mass, h_b, SPHKernel<Tscal>::hfactd);
81 Tvec dr = xyz_a - r[id_b];
82 Tscal rab2 = sycl::dot(dr, dr);
83 Tscal rab = sycl::sqrt(rab2);
84
85 Tscal vsigu = vsig_u(P_a, P_b, rho_a, rho_b);
86 Tscal Fab_a = SPHKernel<Tscal>::dW_3d(rab, h_a);
87 Tscal Fab_b = SPHKernel<Tscal>::dW_3d(rab, h_b);
88
89 tmp_luminosity += lambda_shock_conductivity(
90 part_mass,
91 alpha_u,
92 vsigu,
93 u_a - u_b,
94 Fab_a * omega_a_rho_a_inv,
95 Fab_b / (rho_b * omega_b));
96 });
97
98 luminosity[id_a] = tmp_luminosity;
99 });
100}
101
102template<class Tvec, template<class> class SPHKernel>
104 const {
105 std::string tex = R"tex(
106 Compute idealized luminosity from shocks only: energy dissipated immidiately emitted
107 \begin{align}
108 {luminosity}_i &= pmass * alpha_u * vsigu * u_ab * \frac{1}{2}
109 * (Fab_inv_omega_a_rho_a + Fab_inv_omega_b_rho_b)\\
110 &= pmass * alpha_u * \sqrt(\frac{\abs({pressure}_a - {pressure}_b)}{2 (rho_a + rho_b)}); * ({u}_a - {u}_b) * \frac{1}{2}
111 * (\frac{Fab_a}{{omega}_a * rho_a} + \frac{Fab_b}{{omega}_b * rho_b})
112 \end{align}
113 )tex";
114
115 replace_edges_tex_symbols(tex);
116
117 return tex;
118}
119
120using namespace shammath;
124
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_tex() const
get the tex of the node
void distributed_data_kernel_call(sham::DeviceScheduler_ptr dev_sched, RefIn in, RefOut in_out, const shambase::DistributedData< index_t > &thread_counts, Functor &&func)
A variant of sham::kernel_call for distributed data.
namespace for math utility
Definition AABB.hpp:26
file containing formulas for sph forces
Tscal lambda_shock_conductivity(const Tscal &pmass, const Tscal &alpha_u, const Tscal &vsig_u, const Tscal &u_ab, const Tscal &Fab_inv_omega_a_rho_a, const Tscal &Fab_inv_omega_b_rho_b)
phantom_2018 eq.42
Definition forces.hpp:161
sph kernels
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
A variant of sham::MultiRef for distributed data.