17 __host__ __device__
static Real log_func(Real y) {
return log(1 + y) - y / (1 + y); };
20 Real gr_halo_D3D(Real R, Real z)
const noexcept
22 Real r = sqrt(R * R + z * z);
27 Real B = 1.0 / (r * r);
30 return -C * A * B * r_comp;
34 Real gz_halo_D3D(Real R, Real z)
36 Real r = sqrt(R * R + z * z);
41 Real B = 1.0 / (r * r);
44 return -C * A * B * z_comp;
48 __host__ __device__ Real rho_halo_D3D(Real R, Real z)
const noexcept
55 Real rdivRh = sqrt(R * R + z * z) /
R_h;
57 Real rdivRh_p_1 = rdivRh + 1;
60 return rho0 / (rdivRh * (rdivRh_p_1 * rdivRh_p_1));
64 __host__ __device__ Real phi_halo_D3D(Real R, Real z)
const noexcept
66 Real r = sqrt(R * R + z * z);
75 return -C * log(1 + x) / x;
91 Real gr_disk_D3D(Real R, Real z)
const noexcept
94 Real B = pow(A * A + R * R, 1.5);
96 return -GN *
M_d * R / B;
100 Real gz_disk_D3D(Real R, Real z)
const noexcept
104 Real A = sqrt(b * b + z * z);
106 Real C = pow(B * B + R * R, 1.5);
109 return -GN *
M_d * z * B / (A * C);
113 __host__ __device__ Real phi_disk_D3D(Real R, Real z)
const noexcept
115 Real A = sqrt(z * z +
Z_d *
Z_d);
117 Real C = sqrt(R * R + B * B);
120 return -GN *
M_d / C;
124 __host__ __device__ Real rho_disk_D3D(
const Real r,
const Real z)
const noexcept
128 const Real b = sqrt(z * z + c * c);
129 const Real d = a + b;
130 const Real s = r * r + d * d;
131 return M_d * c * c * (a * (d * d + r * r) + 3.0 * b * d * d) / (4.0 * M_PI * b * b * b * pow(s, 2.5));
168 static ApproxExponentialDisk3MN create(Real mass, Real scale_length, Real scale_height,
bool exponential_scaleheight)
170 if ((mass <= 0) or (scale_length <= 0)) CHOLLA_ERROR(
"invalid args");
173 Real b_div_scale_length;
174 if (scale_height < 0.0) {
175 CHOLLA_ERROR(
"scale_height must be positive");
176 }
else if (scale_height == 0.0) {
177 b_div_scale_length = 0.0;
178 }
else if (exponential_scaleheight) {
179 Real x = scale_height / scale_length;
180 b_div_scale_length = (-0.269 * x + 1.080) * x + 1.092 * x;
182 Real x = scale_height / scale_length;
183 b_div_scale_length = (-0.033 * x + 0.262) * x + 0.659 * x;
185 Real b = b_div_scale_length * scale_length;
187 if (b_div_scale_length > 3.0) CHOLLA_ERROR(
"The disk is too thick for this approx");
193 const Real k[6][5] = {{-0.0090, 0.0640, -0.1653, 0.1164, 1.9487},
194 {0.0173, -0.0903, 0.0877, 0.2029, -1.3077},
195 {-0.0051, 0.0287, -0.0361, -0.0544, 0.2242},
196 {-0.0358, 0.2610, -0.6987, -0.1193, 2.0074},
197 {-0.0830, 0.4992, -0.7967, -1.2966, 4.4441},
198 {-0.0247, 0.1718, -0.4124, -0.5944, 0.7333}};
199 auto param = [&k, b_div_scale_length](
int i) {
200 Real x = b_div_scale_length;
201 return ((((k[i][0] * x + k[i][1]) * x + k[i][2]) * x) + k[i][3]) * x + k[i][4];
205 for (
int j = 0; j < 3; j++) {
212 Real gr_disk_D3D(Real R, Real z)
const noexcept
214 return (comps[0].gr_disk_D3D(R, z) + comps[1].gr_disk_D3D(R, z) + comps[2].gr_disk_D3D(R, z));
218 Real gz_disk_D3D(Real R, Real z)
const noexcept
220 return (comps[0].gz_disk_D3D(R, z) + comps[1].gz_disk_D3D(R, z) + comps[2].gz_disk_D3D(R, z));
224 __host__ __device__ Real phi_disk_D3D(Real R, Real z)
const noexcept
226 return (comps[0].phi_disk_D3D(R, z) + comps[1].phi_disk_D3D(R, z) + comps[2].phi_disk_D3D(R, z));
236 __host__ __device__ Real rho_disk_D3D(Real R, Real z)
const noexcept
238 return (comps[0].rho_disk_D3D(R, z) + comps[1].rho_disk_D3D(R, z) + comps[2].rho_disk_D3D(R, z));