Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddForcePaczynskiWiita.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
16
21
22namespace shammodels::common::modules {
23
24 template<class Tvec>
26
28
29 auto edges = get_edges();
30
31 edges.spans_positions.check_sizes(edges.sizes.indexes);
32 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
33
34 Tscal cmass = edges.central_mass.data;
35 Tscal G = edges.constant_G.data;
36 Tscal c = edges.constant_c.data;
37 Tvec cpos = edges.central_pos.data;
38 Tscal rs = 2 * G * cmass / (c * c);
39
41 shamsys::instance::get_compute_scheduler_ptr(),
42 sham::DDMultiRef{edges.spans_positions.get_spans()},
43 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
44 edges.sizes.indexes,
45 [GM = cmass * G, rs, cpos](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
46 Tvec r_a = xyz[gid] - cpos;
47 Tscal abs_ra = sycl::length(r_a);
48 Tscal denom = (abs_ra - rs) * (abs_ra - rs) * abs_ra;
49
50 axyz_ext[gid] += -GM * r_a / denom;
51 });
52 }
53
54 template<class Tvec>
56 std::string tex = R"tex(
57 Add force (Paczynski-Wiita potential)
58
59 \begin{align}
60 r_{\text{s}} &= 2 * {constant_G}* {central_mass} / {constant_c}^2\\
61 r_i &= {spans_positions}_i - {central_pos}_i\\
62 r &= \sqrt{\sum r_i^2}\\
63 {spans_accel_ext}_i &= -{constant_G} * {central_mass} * r_i / (r * (r - r_{\text{s}})^2)
64 \end{align}
65 )tex";
66
67 replace_edges_tex_symbols(tex);
68
69 return tex;
70 }
71
73
74} // namespace shammodels::common::modules
Adds the acceleration from a Paczynski Wiita (1980) pseudo-newtonian potential.
Header file describing a Node Instance.
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.
#define __shamrock_stack_entry()
Macro to create a stack entry.
A variant of sham::MultiRef for distributed data.