6 #include "../../misc/bisection.hpp" 7 #include "../../misc/universal_error.hpp" 12 double phugo(
double v2,
17 return (4*p1 + d1*(1 + g)*pow(v2,2) + sqrt(d1)*v2*
18 sqrt(16*g*p1 + d1*pow(1 + g,2)*pow(v2,2)))/4.;
21 double vhugo(
double p2,
26 return sqrt(2.)*(p2-p1)/sqrt(d1*(p2*(g+1)+p1*(g-1)));
29 double visen(
double p2,
34 return (2*sqrt(g)*pow(p1,1/g/2)*
35 (pow(p2,(g-1)/g/2)-pow(p1,(g-1)/g/2)))/
39 double vhydro(
double p2,
45 return vhugo(p2,d1,p1,g);
47 return visen(p2,d1,p1,g);
50 double left_velocity(
double p,
54 const double d1 = upstream.
Density;
57 return v1 - vhydro(p,d1,p1,g);
60 double right_velocity(
double p,
64 const double d1 = upstream.
Density;
67 return v1 + vhydro(p,d1,p1,g);
70 double eval_trans_eqn(
double p,
75 return right_velocity(p,right,g) - left_velocity(p,left,g);
99 double eval(
double p)
const 101 return eval_trans_eqn(p,left_,right_,g_);
111 double ps_two_rarefactions(
Primitive const& left,
115 const double dl = left.
Density;
118 const double dr = right.
Density;
122 (2*(sqrt(g*dr*pl)+sqrt(g*dl*pr))+
123 sqrt(dl*dr)*(g-1)*(vl-vr))/
124 (2*(sqrt(g*dr)*pow(pl,1/g/2)+
125 sqrt(g*dl)*pow(pr,1/g/2)));
129 const double res = pow(temp,2*g/(g-1));
143 PVContact(
double p,
double v):
144 pressure(p), velocity(v) {}
147 const double pressure;
150 const double velocity;
155 PVContact calc_contact_pv(
Primitive const& left,
161 const double tol = 1e-6;
163 const double vlpr = left_velocity(right.
Pressure, left, g);
164 const double vrpl = right_velocity(left.
Pressure, right, g);
173 const TransEqn eqn(left,right,g);
176 2*
max(plvr,prvl),tol);
179 eo.
AddEntry(
"caught in two shock section of ersig",0);
193 ps = ps_two_rarefactions(left, right, g);
197 const TransEqn eqn(left, right, g);
203 const double vs = 0.5*(left_velocity(ps,left,g)+right_velocity(ps,right,g));
204 return PVContact(ps,vs);
213 double shock_speed(
double p2,
218 return sqrt(g*(p2+p1)+p2-p1)/sqrt(2*d1);
221 double dhugo(
double p2,
226 return (d1*((-1 + g)*p1 + (1 + g)*p2))/((1 + g)*p1 + (-1 + g)*p2);
233 const double ds = dhugo(ps,
247 virtual Primitive getHydroVars(
double v)
const = 0;
249 virtual ~HydroProf(
void) {}
272 upstream.Pressure,g)),
273 upstream_(x_rest_frame(upstream)),
275 (move_on_hugoniot(p2,upstream,g)) {}
325 double disen(
double p2,
330 return d1*pow(p2/p1,1/g);
337 const double dr = disen(pr,
358 upstream_(x_rest_frame(upstream)),
360 (move_on_isentrope(p2, upstream,g)) {}
364 if(v>upstream_.SoundSpeed)
366 else if(v<downstream_.SoundSpeed+downstream_.Velocity.x)
369 const double u = (v-upstream_.SoundSpeed)*2/(1+g_);
370 const double c = upstream_.
SoundSpeed+(g_-1)*u/2;
371 const double p = upstream_.Pressure*
372 pow(c/upstream_.SoundSpeed,2*g_/(g_-1));
373 const double d = disen(p,upstream_.Density,
374 upstream_.Pressure, g_);
434 hugo_(
max(upstream.Pressure,p2),upstream,g),
435 isen_(
min(upstream.Pressure,p2),upstream,g),
436 hugo_flag_(p2>upstream.Pressure) {}
441 return hugo_.getHydroVars(v);
443 return isen_.getHydroVars(v);
448 const ShockProf hugo_;
449 const IsenProf isen_;
450 const bool hugo_flag_;
487 contact_(calc_contact_pv(left,right,g)),
488 left_prof_(contact_.pressure,
490 right_prof_(contact_.pressure,
492 left_(left), right_(right) {}
496 if(v>contact_.velocity){
498 (v-right_.Velocity.x);
504 (left_.Velocity.x - v);
512 const PVContact contact_;
513 const GeneralProf left_prof_;
514 const GeneralProf right_prof_;
560 string const& vacuum_behaviour):
561 g_(g), vacuum_behaviour_(vacuum_behaviour) {}
566 double velocity)
const 570 RiemannProfile(left,right,g_).getHydroVars(velocity);
579 if(vacuum_behaviour_==
"zero flux")
583 eo.
AddEntry(
"ERSIG::Solve data starts here",0);
588 eo.
AddEntry(
"right density",right.Density);
589 eo.
AddEntry(
"right pressure",right.Pressure);
590 eo.
AddEntry(
"right x velocity",right.Velocity.x);
591 eo.
AddEntry(
"right y velocity",right.Velocity.y);
Set of conserved variables (extensive)
Ideal gas equation of state.
Ideal gas equation of state.
double SoundSpeed
Speed of sound.
Container for error reports.
Primitive CalcPrimitive(double density, double pressure, Vector2D const &velocity, EquationOfState const &eos)
Calculates the primitive variables.
ERSIG(double g, string const &vacuum_behaviour="throw exception")
Class constructor.
Vector2D Velocity
Velocity.
double max(vector< double > const &v)
returns the maximal term in a vector
double y
Component in the y direction.
Exact Riemann solver for ideal gas equation of state.
Hydrodynamical relations.
Conserved Primitive2Conserved(Primitive const &p)
Converts primitive variables to conserved intensive.
Conserved Primitive2Flux(Primitive const &p, Vector2D const &n)
Converts primitive variables to flux.
double bisection(Func1Var const &f, double xl, double xr, double tol=1e-6)
Solves a monotonous transcendental equation using the bisection method.
Scalar function of a single variable.
double min(vector< double > const &v)
Returns the minimal term in a vector.
void AddEntry(std::string const &field, double value)
Adds an entry to the list.
Primitive hydrodynamic variables.
double x
Component in the x direction.
std::string const & GetErrorMessage(void) const
Returns the error message.