hydrodynamics.cpp
1 #include <cmath>
2 #include "hydrodynamics.hpp"
3 
4 Primitive CalcPrimitive(double density, double pressure,
5  Vector2D const& velocity,
6  EquationOfState const& eos)
7 {
8  return Primitive(density,
9  pressure,
10  velocity,
11  eos.dp2e(density, pressure),
12  eos.dp2c(density, pressure));
13 }
14 
16 (Conserved const& c, EquationOfState const& eos)
17 {
18  const double density = c.Mass;
19  const Vector2D velocity = c.Momentum / c.Mass;
20  const double energy = c.Energy/c.Mass -
21  0.5*pow(abs(velocity),2);
22  assert(energy>=0 &&
23  "Thermal energy is negative");
24  /*
25  if(energy<0)
26  {
27  UniversalError eo("Negative thermal energy");
28  eo.AddEntry("x velocity",velocity.x);
29  eo.AddEntry("y velocity",velocity.y);
30  eo.AddEntry("density",density);
31  eo.AddEntry("Energy per volume",c.Energy);
32  throw eo;
33  }
34  */
35  const double pressure = eos.de2p(density, energy);
36  const double sound_speed = eos.dp2c(density, pressure);
37  return Primitive(density,
38  pressure,
39  velocity,
40  energy,
41  sound_speed);
42 }
43 
45 (Primitive const& p,
46  EquationOfState const& eos)
47 {
48  return CalcPrimitive(p.Density,
49  p.Pressure,
50  p.Velocity,
51  eos);
52 }
Set of conserved variables (extensive)
Vector2D Momentum
Momentum.
double Density
Density.
Primitive Conserved2Primitive(Conserved const &c, EquationOfState const &eos)
Calculates the primitive variables from the conserved.
virtual double de2p(double d, double e, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the pressure.
Primitive CalcPrimitive(double density, double pressure, Vector2D const &velocity, EquationOfState const &eos)
Calculates the primitive variables.
Vector2D Velocity
Velocity.
virtual double dp2c(double d, double p, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the speed of sound.
double Energy
Total energy (kinetic + thermal)
Hydrodynamical relations.
Primitive make_eos_consistent(Primitive const &p, EquationOfState const &eos)
Takes a set of primitive variables that do not necessarily satisfy the equation of state...
Base class for equation of state.
double Pressure
Pressure.
virtual double dp2e(double d, double p, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the thermal energy per unit mass.
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
Primitive hydrodynamic variables.
2D Mathematical vector
Definition: geometry.hpp:15