12 double a0_, a1_, a2_, a3_, a4_;
14 SolveVelocity(
double a0,
double a1,
double a2,
double a3,
double a4) :a0_(a0), a1_(a1), a2_(a2), a3_(a3), a4_(a4) {}
18 return v * v*(a4_*v*v + a3_ * v + a2_) +v*a1_ +a0_;
22 double Deriv(
const double v)
const 24 return v * v*(4 * a4_*v + a3_ * 3) + 2 * a2_*v + a1_;
29 double DoNewtonRapshon(SolveVelocity
const& solve,
double val)
32 double f0 = solve(val);
33 double new_val = val - f0 / solve.Deriv(val);
34 while (
std::abs(new_val - val) > 1e-12 && (
std::abs(f0) > (1e-12*solve.a0_)))
39 new_val =
std::min(1.0, val - f0 / solve.Deriv(val));
42 std::cout <<
"Bad convergence in simple cell updater, too mant iterations in finding velocity";
56 SolveVelocity tosolve(M*M, -2 * G*M*E, G*G*E*E + 2 * (G - 1)*M*M - (G - 1)*(G - 1)*cell.
mass*cell.
mass, -2 * G*(G - 1)*M*E, (G - 1)*(G - 1)*(cell.
mass*cell.
mass + M * M));
58 double vmin = (1e6*M < cell.
mass) ? 0 : (G*E - std::sqrt((G*E)*(G*E) - 4 * (G - 1)*M*M)) / (2 * M*(G - 1));
59 if((G*E)*(G*E) - 4 * (G - 1)*M*M < 0)
61 double vmax =
std::min(1.0, M / E + 1e-6);
62 return DoNewtonRapshon(tosolve, 0.5*(vmin + vmax));
Vector2D momentum
momentum, in relativity it is = rho*h*gamma*v
double mass
rest mass times gamma
double energy
energy, in relativity it is = rho*h*gamma^2-P-rho
double GetVelocity(Extensive const &cell, double G)
Calculates velocity from extensive in SR.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
Base class for cell update scheme.
virtual ~CellUpdater(void)
Class destructor.
double min(vector< double > const &v)
Returns the minimal term in a vector.
virtual vector< ComputationalCell > operator()(const Tessellation &tess, const PhysicalGeometry &pg, const EquationOfState &eos, vector< Extensive > &extensives, const vector< ComputationalCell > &old, const CacheData &cd, const TracerStickerNames &tracerstickername, double time) const =0
Calculates the computational cells.
double abs(Vector3D const &v)
Norm of a vector.