Roe classical math formulas¶
oracq.applications.roe_formulas
Plain side-effect-free Roe math functions; callable classically or compilable by compile_function.
- oracq.applications.roe_formulas.pick3(index, first, second, third)[source]¶
Select one of three values by integer index; returns
0.0when the index is outside 0..2.- Parameters:
index – Selection index in 0..2; out of range selects no branch.
first – Value selected for index 0.
second – Value selected for index 1.
third – Value selected for index 2.
- Returns:
The selected value;
0.0when the index is out of range.- Return type:
float
- oracq.applications.roe_formulas.conserved_to_primitive(rho, momentum, energy, gamma)[source]¶
Convert one-dimensional Euler conserved variables to primitive variables.
- Parameters:
rho – Density.
momentum – Momentum density.
energy – Total energy density.
gamma – Ratio of specific heats.
- Returns:
(velocity, pressure, enthalpy), with enthalpy defined as total energy plus pressure divided by density.- Return type:
tuple
- oracq.applications.roe_formulas.euler_entry(velocity, enthalpy, row, col, gamma)[source]¶
Return the requested element of the one-dimensional Euler flux Jacobian matrix.
Elements are expressed using only flow velocity and enthalpy; row and column indices follow the ordering of the conserved variables
(rho, momentum, energy), numbered from zero.- Parameters:
velocity – Flow velocity.
enthalpy – Specific enthalpy, defined as in the return value of
conserved_to_primitive.row – Row index, in 0..2.
col – Column index, in 0..2.
gamma – Ratio of specific heats.
- Returns:
The element at row
rowand columncolof the Jacobian matrix.- Return type:
float
- oracq.applications.roe_formulas.entropy_absolute(eigenvalue, delta)[source]¶
Absolute value of an eigenvalue with the Harten entropy fix.
When
deltais positive and the absolute value of the eigenvalue is smaller, the smoothed value(eigenvalue**2+delta**2)/(2*delta)is returned; otherwise the plain absolute value is returned.- Parameters:
eigenvalue – The eigenvalue.
delta – Entropy fix threshold; the fix is disabled when non-positive.
- Returns:
The entropy-fixed absolute value of the eigenvalue.
- Return type:
float
- oracq.applications.roe_formulas.frozen_roe_face(rho_l, m_l, e_l, rho_r, m_r, e_r, row, col, gamma=1.4, entropy_delta=0.125)[source]¶
Compute the element at the given row and column of the frozen-Roe left and right coefficient matrices.
Roe averaging of the left and right conserved states yields the mean flow velocity and enthalpy; the eigenvalues
u-c,uandu+care made absolute with the entropy fix, and the elements of|A|are assembled asR*diag(a)*R**-1. Combined with the flux Jacobian elements on both sides given byeuler_entry, this returns the values of0.5*(A_l+|A|)and0.5*(A_r-|A|)atrowandcol, as the Roe flux share coefficients applied to the left and right states.- Parameters:
rho_l – Left-side density.
m_l – Left-side momentum density.
e_l – Left-side total energy density.
rho_r – Right-side density.
m_r – Right-side momentum density.
e_r – Right-side total energy density.
row – Row index of the matrix element, in 0..2.
col – Column index of the matrix element, in 0..2.
gamma – Ratio of specific heats.
entropy_delta – Harten entropy fix threshold.
- Returns:
(left, right), the elements of the left and right coefficient matrices at the given row and column.- Return type:
tuple