11#include "../global/global.h"
14static inline __device__ Real pow2(
const Real x) {
return x * x; }
16inline __device__
void calc_g_1D(
int xid,
int x_off,
int n_ghost,
int custom_grav, Real dx, Real xbound, Real *gx)
18 Real x_pos, r_disk, r_halo;
19 x_pos = (x_off + xid - n_ghost + 0.5) * dx + xbound;
21 switch (custom_grav) {
27 r_disk = 13.9211647546;
30 r_halo = sqrt(x_pos * x_pos + r_disk * r_disk);
33 Real a_disk_z, a_halo, M_vir, M_d, R_vir, R_d, z_d, R_h, M_h, c_vir, phi_0_h, x;
42 phi_0_h = GN * M_h / (log(1.0 + c_vir) - c_vir / (1.0 + c_vir));
46 a_halo = -phi_0_h * (log(1 + x) - x / (1 + x)) / (r_halo * r_halo);
48 -GN * M_d * x_pos * (R_d + sqrt(x_pos * x_pos + z_d * z_d)) /
49 (pow(r_disk * r_disk + pow2(R_d + sqrt(x_pos * x_pos + z_d * z_d)), 1.5) * sqrt(x_pos * x_pos + z_d * z_d));
52 *gx = (x_pos / r_halo) * a_halo + a_disk_z;
60inline __device__
void calc_g_2D(
int xid,
int yid,
int x_off,
int y_off,
int n_ghost,
int custom_grav, Real dx, Real dy,
61 Real xbound, Real ybound, Real *gx, Real *gy)
63 Real x_pos, y_pos, r, phi;
66 x_pos = (x_off + xid - n_ghost + 0.5) * dx + xbound;
67 y_pos = (y_off + yid - n_ghost + 0.5) * dy + ybound;
69 r = sqrt(x_pos * x_pos + y_pos * y_pos);
70 phi = atan2(y_pos, x_pos);
71 switch (custom_grav) {
76 *gx = -cos(phi) * 25.0 * r;
77 *gy = -sin(phi) * 25.0 * r;
78 }
else if (r >= 0.2 && r < 0.4) {
79 *gx = -cos(phi) * (4.0 - 20.0 * r + 25.0 * r * r) / r;
80 *gy = -sin(phi) * (4.0 - 20.0 * r + 25.0 * r * r) / r;
95 *gx = -cos(phi) * GN * M / (r * r);
96 *gy = -sin(phi) * GN * M / (r * r);
100 Real a_d, a_h, a, M_vir, M_d, R_vir, R_d, R_s, M_h, c_vir, x;
111 a_d = GN * M_d * r * pow(r * r + R_d * R_d, -1.5);
112 a_h = GN * M_h * (log(1 + x) - x / (1 + x)) / ((log(1 + c_vir) - c_vir / (1 + c_vir)) * r * r);
126inline __device__
void calc_g_3D(
int xid,
int yid,
int zid,
int x_off,
int y_off,
int z_off,
int n_ghost,
127 int custom_grav, Real dx, Real dy, Real dz, Real xbound, Real ybound, Real zbound,
128 Real *gx, Real *gy, Real *gz)
130 Real x_pos, y_pos, z_pos, r_disk, r_halo;
133 x_pos = (x_off + xid - n_ghost + 0.5) * dx + xbound;
134 y_pos = (y_off + yid - n_ghost + 0.5) * dy + ybound;
135 z_pos = (z_off + zid - n_ghost + 0.5) * dz + zbound;
138 r_disk = sqrt(x_pos * x_pos + y_pos * y_pos);
140 r_halo = sqrt(x_pos * x_pos + y_pos * y_pos + z_pos * z_pos);
141 Real a_disk_r, a_disk_z, a_halo, a_halo_r, a_halo_z;
142 Real M_vir, M_d, R_vir, R_d, z_d, R_h, M_h, c_vir, phi_0_h, x;
143 switch (custom_grav) {
157 phi_0_h = GN * M_h / (log(1.0 + c_vir) - c_vir / (1.0 + c_vir));
161 a_halo = -phi_0_h * (log(1 + x) - x / (1 + x)) / (r_halo * r_halo);
162 a_halo_r = a_halo * (r_disk / r_halo);
163 a_halo_z = a_halo * (z_pos / r_halo);
164 a_disk_r = -GN * M_d * r_disk * pow(r_disk * r_disk + pow2(R_d + sqrt(z_pos * z_pos + z_d * z_d)), -1.5);
166 -GN * M_d * z_pos * (R_d + sqrt(z_pos * z_pos + z_d * z_d)) /
167 (pow(r_disk * r_disk + pow2(R_d + sqrt(z_pos * z_pos + z_d * z_d)), 1.5) * sqrt(z_pos * z_pos + z_d * z_d));
170 *gx = (x_pos / r_disk) * (a_disk_r + a_halo_r);
171 *gy = (y_pos / r_disk) * (a_disk_r + a_halo_r);
172 *gz = a_disk_z + a_halo_z;
187 phi_0_h = GN * M_h / (log(1.0 + c_vir) - c_vir / (1.0 + c_vir));
191 a_halo = -phi_0_h * (log(1 + x) - x / (1 + x)) / (r_halo * r_halo);
192 a_halo_r = a_halo * (r_disk / r_halo);
193 a_halo_z = a_halo * (z_pos / r_halo);
194 a_disk_r = -GN * M_d * r_disk * pow(r_disk * r_disk + pow2(R_d + sqrt(z_pos * z_pos + z_d * z_d)), -1.5);
196 -GN * M_d * z_pos * (R_d + sqrt(z_pos * z_pos + z_d * z_d)) /
197 (pow(r_disk * r_disk + pow2(R_d + sqrt(z_pos * z_pos + z_d * z_d)), 1.5) * sqrt(z_pos * z_pos + z_d * z_d));
200 *gx = (x_pos / r_disk) * (a_disk_r + a_halo_r);
201 *gy = (y_pos / r_disk) * (a_disk_r + a_halo_r);
202 *gz = a_disk_z + a_halo_z;