[1D] Fixed singular Jacobian errors after grid modification

Modification of the grid can interfere with the way the fixed temperature point
is handled, leading to solver failures. To fix this, the temperature fixed point
is checked and may be recalculated at the start of the solver.
This commit is contained in:
Ray Speth 2013-03-05 17:02:53 +00:00
parent 246bbfa7fb
commit 68b129eb96

View file

@ -327,6 +327,30 @@ void StFlow::_finalize(const doublereal* x)
if (e) {
solveEnergyEqn();
}
// If the domain contains the temperature fixed point, make sure that it
// is correctly set. This may be necessary when the grid has been modified
// externally.
if (m_tfixed != Undef) {
bool found_zfix = false;
for (size_t j = 0; j < m_points; j++) {
if (z(j) == m_zfixed) {
found_zfix = true;
break;
}
}
if (!found_zfix) {
for (size_t j = 0; j < m_points - 1; j++) {
// Find where the temperature profile crosses the current
// fixed temperature.
if ((T(x, j) - m_tfixed) * (T(x, j+1) - m_tfixed) <= 0.0) {
m_tfixed = T(x, j+1);
m_zfixed = z(j+1);
break;
}
}
}
}
}