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
17
22
23namespace shammodels::common::modules {
24
25 template<class Tvec>
27
29
30 auto edges = get_edges();
31
32 edges.spans_positions.check_sizes(edges.sizes.indexes);
33 edges.spans_accel_ext.ensure_sizes(edges.sizes.indexes);
34
35 Tscal cmass = edges.central_mass.data;
36 Tscal G = edges.constant_G.data;
37 Tscal c = edges.constant_c.data;
38 Tvec cpos = edges.central_pos.data;
39 Tscal rs = 2 * G * cmass / (c * c);
40
42 shamsys::instance::get_compute_scheduler_ptr(),
43 sham::DDMultiRef{edges.spans_positions.get_spans()},
44 sham::DDMultiRef{edges.spans_accel_ext.get_spans()},
45 edges.sizes.indexes,
46 [GM = cmass * G, rs, cpos](u32 gid, const Tvec *xyz, Tvec *axyz_ext) {
47 Tvec r_a = xyz[gid] - cpos;
48 Tscal abs_ra = sycl::length(r_a);
49 Tscal denom = (abs_ra - rs) * (abs_ra - rs) * abs_ra;
50
51 axyz_ext[gid] += -GM * r_a / denom;
52 });
53 }
54
55 template<class Tvec>
57 std::string tex = R"tex(
58 Add force (Paczynski-Wiita potential)
59
60 \begin{align}
61 r_{\text{s}} &= 2 * {constant_G}* {central_mass} / {constant_c}^2\\
62 r_i &= {spans_positions}_i - {central_pos}_i\\
63 r &= \sqrt{\sum r_i^2}\\
64 {spans_accel_ext}_i &= -{constant_G} * {central_mass} * r_i / (r * (r - r_{\text{s}})^2)
65 \end{align}
66 )tex";
67
68 replace_edges_tex_symbols(tex);
69
70 return tex;
71 }
72
74
75} // 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.