void initialize(GridNode* g) { State::turn_fluid_on(); State U = Vector<Real, STATE_NF>(0.0); Real r, d, r1, d0, alpha; alpha = 1.0 / 15.0; d0 = pow(alpha * alpha / POLY_K / 5.0, -3.0); State::d_floor = d0 / 1.0e+10; for (int k = 0; k < GNX; k++) { for (int j = 0; j < GNX; j++) { for (int i = 0; i < GNX; i++) { U = Vector<Real, STATE_NF>(0.0); r = sqrt(g->xc(i) * g->xc(i) + g->yc(j) * g->yc(j) + g->zc(k) * g->zc(k)); r1 = r / alpha; if (r1 < 3.7) { d = lane_emden(r1); U.d() = max(d0 * d, State::d_floor); } else { U.d() = State::d_floor; } U.tau() = POLY_K * pow(U.d(), State::fgamma) / (State::fgamma - 1.0); _3Vec X; X[0] = g->xc(i); X[1] = g->yc(j); X[2] = g->xc(k); U.floor(X); (*g)(i, j, k) = U; } } } State::turn_fluid_off(); }
std::vector<real> star(real x, real y, real z) { x -= x0; y -= y0_; z -= z0; real theta; const real n = real(1) / (fgamma - real(1)); const real rho_min = 1.0e-3; std::vector < real > u(NF, real(0)); const real r = std::sqrt(x * x + y * y + z * z) / alpha; const real theta_min = std::pow(rho_min, real(1) / n); const auto c0 = real(4) * real(M_PI) * alpha * alpha / (n + real(1)); if (r <= rmax) { theta = lane_emden(r, dr); theta = std::max(theta, theta_min); } else { theta = theta_min; } u[rho_i] = std::pow(theta, n); u[egas_i] = std::pow(theta, fgamma * n) * c0 / (fgamma - real(1)); //if (theta <= theta_min) { // u[egas_i] *= real(100); //} u[tau_i] = std::pow(u[egas_i], (real(1) / real(fgamma))); return u; }
void star_force(real x, real y, real z, real& fx, real& fy, real& fz) { x -= x0; y -= y0_; z -= z0; constexpr real mtot = 3.410854709920873e+01; real m; const real r = std::sqrt(x * x + y * y + z * z) / alpha; if (r < rmax) { lane_emden(r, dr, &m); } else { m = mtot; } fx = -m * x / (r * r * r); fy = -m * y / (r * r * r); fz = -m * z / (r * r * r); }