Roe 经典数学公式

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)[源代码]

Select one of three values by integer index; returns 0.0 when the index is outside 0..2.

参数:
  • 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.

返回:

The selected value; 0.0 when the index is out of range.

返回类型:

float

oracq.applications.roe_formulas.conserved_to_primitive(rho, momentum, energy, gamma)[源代码]

Convert one-dimensional Euler conserved variables to primitive variables.

参数:
  • rho -- Density.

  • momentum -- Momentum density.

  • energy -- Total energy density.

  • gamma -- Ratio of specific heats.

返回:

(velocity, pressure, enthalpy), with enthalpy defined as total energy plus pressure divided by density.

返回类型:

tuple

oracq.applications.roe_formulas.euler_entry(velocity, enthalpy, row, col, gamma)[源代码]

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.

参数:
  • 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.

返回:

The element at row row and column col of the Jacobian matrix.

返回类型:

float

oracq.applications.roe_formulas.entropy_absolute(eigenvalue, delta)[源代码]

Absolute value of an eigenvalue with the Harten entropy fix.

When delta is 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.

参数:
  • eigenvalue -- The eigenvalue.

  • delta -- Entropy fix threshold; the fix is disabled when non-positive.

返回:

The entropy-fixed absolute value of the eigenvalue.

返回类型:

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)[源代码]

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, u and u+c are made absolute with the entropy fix, and the elements of |A| are assembled as R*diag(a)*R**-1. Combined with the flux Jacobian elements on both sides given by euler_entry, this returns the values of 0.5*(A_l+|A|) and 0.5*(A_r-|A|) at row and col, as the Roe flux share coefficients applied to the left and right states.

参数:
  • 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.

返回:

(left, right), the elements of the left and right coefficient matrices at the given row and column.

返回类型:

tuple